[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/inc/auth/ -> mysql.class.php (summary)

(no description)

File Size: 947 lines (34 kb)
Included or required: 1 time
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

auth_mysql:: (29 methods):
  __construct()
  _chkcnf()
  checkPass()
  getUserData()
  createUser()
  modifyUser()
  deleteUsers()
  getUserCount()
  retrieveUsers()
  joinGroup()
  leaveGroup()
  isCaseSensitive()
  _addUserToGroup()
  _delUserFromGroup()
  _getGroups()
  _getUserID()
  _addUser()
  _delUser()
  _getUserInfo()
  _updateUserInfo()
  _getGroupID()
  _openDB()
  _closeDB()
  _queryDB()
  _modifyDB()
  _lockTables()
  _unlockTables()
  _createSQLFilter()
  _escape()


Class: auth_mysql  - X-Ref

MySQLP authentication backend

__construct()   X-Ref
Constructor

checks if the mysql interface is available, otherwise it will
set the variable $success of the basis class to false

author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>

_chkcnf($keys, $wop=false)   X-Ref
Check if the given config strings are set

author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>
return: bool

checkPass($user,$pass)   X-Ref
Checks if the given user exists and the given plaintext password
is correct. Furtheron it might be checked wether the user is
member of the right group

Depending on which SQL string is defined in the config, password
checking is done here (getpass) or by the database (passcheck)

author: Andreas Gohr <andi@splitbrain.org>
author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>
param: $user  user who would like access
param: $pass  user's clear text password to check
return: bool

getUserData($user)   X-Ref
[public function]

Returns info about the given user needs to contain
at least these fields:
name  string  full name of the user
mail  string  email addres of the user
grps  array   list of groups the user is in

author: Andreas Gohr <andi@splitbrain.org>
author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>
param: $user   user's nick to get data for

createUser($user,$pwd,$name,$mail,$grps=null)   X-Ref
[public function]

Create a new User. Returns false if the user already exists,
null when an error occurred and true if everything went well.

The new user will be added to the default group by this
function if grps are not specified (default behaviour).

author: Andreas Gohr <andi@splitbrain.org>
author: Chris Smith <chris@jalakai.co.uk>
author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>
param: $user  nick of the user
param: $pwd   clear text password
param: $name  full name of the user
param: $mail  email address
param: $grps  array of groups the user should become member of

modifyUser($user, $changes)   X-Ref
Modify user data [public function]

An existing user dataset will be modified. Changes are given in an array.

The dataset update will be rejected if the user name should be changed
to an already existing one.

The password must be provides unencrypted. Pasword cryption is done
automatically if configured.

If one or more groups could't be updated, an error would be set. In
this case the dataset might already be changed and we can't rollback
the changes. Transactions would be really usefull here.

modifyUser() may be called without SQL statements defined that are
needed to change group membership (for example if only the user profile
should be modified). In this case we asure that we don't touch groups
even $changes['grps'] is set by mistake.

author: Chris Smith <chris@jalakai.co.uk>
author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>
param: $user     nick of the user to be changed
param: $changes  array of field/value pairs to be changed (password
return: bool      true on success, false on error

deleteUsers($users)   X-Ref
[public function]

Remove one or more users from the list of registered users

author: Christopher Smith <chris@jalakai.co.uk>
author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>
param: array  $users   array of users to be deleted
return: int             the number of users deleted

getUserCount($filter=array()   X-Ref
[public function]

Counts users which meet certain $filter criteria.

author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>
param: array  $filter  filter criteria in item/pattern pairs
return: count of found users.

retrieveUsers($first=0,$limit=10,$filter=array()   X-Ref
Bulk retrieval of user data. [public function]

author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>
param: first     index of first user to be returned
param: limit     max number of users to be returned
param: filter    array of field/pattern pairs
return: array of userinfo (refer getUserData for internal userinfo details)

joinGroup($user, $group)   X-Ref
Give user membership of a group [public function]

author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>
param: $user
param: $group
return: bool    true on success, false on error

leaveGroup($user, $group)   X-Ref
Remove user from a group [public function]

author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>
param: $user    user that leaves a group
param: $group   group to leave
return: bool

isCaseSensitive()   X-Ref
MySQL is case-insensitive


_addUserToGroup($user, $group, $force=0)   X-Ref
Adds a user to a group.

If $force is set to '1' non existing groups would be created.

The database connection must already be established. Otherwise
this function does nothing and returns 'false'. It is strongly
recommended to call this function only after all participating
tables (group and usergroup) have been locked.

author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>
param: $user    user to add to a group
param: $group   name of the group
param: $force   '1' create missing groups
return: bool     'true' on success, 'false' on error

_delUserFromGroup($user, $group)   X-Ref
Remove user from a group

author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>
param: $user    user that leaves a group
param: $group   group to leave
return: bool     true on success, false on error

_getGroups($user)   X-Ref
Retrieves a list of groups the user is a member off.

The database connection must already be established
for this function to work. Otherwise it will return
'false'.

author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>
param: $user  user whose groups should be listed
return: bool   false on error
return: array  array containing all groups on success

_getUserID($user)   X-Ref
Retrieves the user id of a given user name

The database connection must already be established
for this function to work. Otherwise it will return
'false'.

author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>
param: $user   user whose id is desired
return: user id

_addUser($user,$pwd,$name,$mail,$grps)   X-Ref
Adds a new User to the database.

The database connection must already be established
for this function to work. Otherwise it will return
'false'.

author: Andreas Gohr <andi@splitbrain.org>
author: Chris Smith <chris@jalakai.co.uk>
author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>
param: $user  login of the user
param: $pwd   encrypted password
param: $name  full name of the user
param: $mail  email address
param: $grps  array of groups the user should become member of
return: bool

_delUser($user)   X-Ref
Deletes a given user and all his group references.

The database connection must already be established
for this function to work. Otherwise it will return
'false'.

author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>
param: $user   user whose id is desired
return: bool

_getUserInfo($user)   X-Ref
getUserInfo

Gets the data for a specific user The database connection
must already be established for this function to work.
Otherwise it will return 'false'.

author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>
param: $user  user's nick to get data for
return: bool   false on error
return: array  user info on success

_updateUserInfo($changes, $uid)   X-Ref
Updates the user info in the database

Update a user data structure in the database according changes
given in an array. The user name can only be changes if it didn't
exists already. If the new user name exists the update procedure
will be aborted. The database keeps unchanged.

The database connection has already to be established for this
function to work. Otherwise it will return 'false'.

The password will be crypted if necessary.

author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>
param: $changes  array of items to change as pairs of item and value
param: $uid      user id of dataset to change, must be unique in DB
return: true on success or false on error

_getGroupID($group)   X-Ref
Retrieves the group id of a given group name

The database connection must already be established
for this function to work. Otherwise it will return
'false'.

author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>
param: $group   group name which id is desired
return: group id

_openDB()   X-Ref
Opens a connection to a database and saves the handle for further
usage in the object. The successful call to this functions is
essential for most functions in this object.

author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>
return: bool

_closeDB()   X-Ref
Closes a database connection.

author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>

_queryDB($query)   X-Ref
Sends a SQL query to the database and transforms the result into
an associative array.

This function is only able to handle queries that returns a
table such as SELECT.

author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>
param: $query  SQL string that contains the query
return: array with the result table

_modifyDB($query)   X-Ref
Sends a SQL query to the database

This function is only able to handle queries that returns
either nothing or an id value such as INPUT, DELETE, UPDATE, etc.

author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>
param: $query  SQL string that contains the query
return: insert id or 0, false on error

_lockTables($mode)   X-Ref
Locked a list of tables for exclusive access so that modifications
to the database can't be disturbed by other threads. The list
could be set with $conf['auth']['mysql']['TablesToLock'] = array()

If aliases for tables are used in SQL statements, also this aliases
must be locked. For eg. you use a table 'user' and the alias 'u' in
some sql queries, the array must looks like this (order is important):
array("user", "user AS u");

MySQL V3 is not able to handle transactions with COMMIT/ROLLBACK
so that this functionality is simulated by this function. Nevertheless
it is not as powerful as transactions, it is a good compromise in safty.

author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>
param: $mode  could be 'READ' or 'WRITE'

_unlockTables()   X-Ref
Unlock locked tables. All existing locks of this thread will be
abrogated.

author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>

_createSQLFilter($sql, $filter)   X-Ref
Transforms the filter settings in an filter string for a SQL database
The database connection must already be established, otherwise the
original SQL string without filter criteria will be returned.

author: Matthias Grimm <matthiasgrimm@users.sourceforge.net>
param: $sql     SQL string to which the $filter criteria should be added
param: $filter  array of filter criteria as pairs of item and pattern
return: SQL string with attached $filter criteria on success
return: the original SQL string on error.

_escape($string,$like=false)   X-Ref
Escape a string for insertion into the database

author: Andreas Gohr <andi@splitbrain.org>
param: string  $string The string to escape
param: boolean $like   Escape wildcard chars as well?



Generated: Sun Feb 3 03:00:06 2013 Cross-referenced by PHPXref 0.7
WikiForumIRCBugsGitXRefTranslate