LiveUser
[ class tree: LiveUser ] [ index: LiveUser ] [ all elements ]

Class: LiveUser_Admin

Source Location: /LiveUser-0.11.0/Admin/Admin.php

Class Overview


Attempt at a unified admin class


Author(s):

  • Lukas Smith
  • Arnaud Limbourg

Version:

  • $Id: Admin.php,v 1.23 2004/04/25 17:12:08 dufuz Exp $

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 92]
Attempt at a unified admin class

Simple usage:

  1.  $conf = array(
  2.   'autoInit' => false/true,
  3.   'session'  => array(
  4.       'name'    => 'liveuser session name',
  5.       'varname' => 'liveuser session var name'
  6.   ),
  7.   'login' => array(
  8.       'method'   => 'get or post',
  9.       'username' => 'Form input containing user handle',
  10.       'password' => 'Form input containing password',
  11.       'remember' => '(optional) Form checkbox containing <Remember Me> info',
  12.       'function' => '(optional) Function to be called when accessing a page without logging in first',
  13.       'force'    => 'Should the user be forced to login'
  14.   ),
  15.   'logout' => array(
  16.       'trigger'  => 'GET or POST var that triggers the logout process',
  17.       'redirect' => 'Page path to be redirected to after logout',
  18.       'function' => '(optional) Function to be called when accessing a page without logging in first',
  19.       'destroy'  => 'Whether to destroy the session on logout'
  20.   ),
  21.  // The cookie options are optional. If they are specified, the Remember Me
  22.  // feature is activated.
  23.   'cookie' => array(
  24.       'name'     => 'Name of Remember Me cookie',
  25.       'lifetime' => 'Cookie lifetime in days',
  26.       'path'     => 'Cookie path',
  27.       'domain'   => 'Cookie domain',
  28.       'secret'   => 'Secret key used for cookie value encryption'
  29.   ),
  30.   'authContainers' => array(
  31.       'name' => array(
  32.             'type' => 'DB',
  33.             'connection'    => 'db connection object, use this or dsn',
  34.             'dsn'           => 'database dsn, use this or connection',
  35.             'loginTimeout'  => 0,
  36.             'expireTime'    => 3600,
  37.             'idleTime'      => 1800,
  38.             'allowDuplicateHandles' => 0,
  39.             'authTable'     => 'liveuser_users',
  40.             'authTableCols' => array('user_id'   => 'auth_user_id',
  41.                                      'handle'    => 'handle',
  42.                                      'passwd'    => 'passwd',
  43.                                      'lastlogin' => 'lastlogin'
  44.             )
  45.       )
  46.   ),
  47.   'permContainer' => array(
  48.       'type'       => 'DB_Complex',
  49.       'connection' => 'db connection object, use this or dsn',
  50.       'dsn'        => 'database dsn, use this or connection',
  51.       'prefix'     => 'liveuser_'
  52.   )
  53.  
  54.  $admin = new LiveUser_Admin($conf'FR');
  55.  $found $admin->getUser(3);
  56.  
  57.  if ($found{
  58.   var_dump($admin->perm->getRights());
  59.  }

  • Author: Lukas Smith
  • Author: Arnaud Limbourg
  • Author:
  • Version: $Id: Admin.php,v 1.23 2004/04/25 17:12:08 dufuz Exp $


[ Top ]


Class Variables

$auth =  null

[line 125]

Auth admin object
  • Access: public

Type:   object


[ Top ]

$authContainerName =

[line 101]

Name of the current selected auth container
  • Access: public

Type:   string


[ Top ]

$lang =  ''

[line 141]

Language to be used
  • Access: public

Type:   string


[ Top ]

$perm =  null

[line 117]

Admin perm object
  • Access: public

Type:   object


[ Top ]



Method Detail

LiveUser_Admin (Constructor)   [line 151]

void LiveUser_Admin( array $conf, string $lang)

Constructor
  • Access: protected

Parameters:

array   $conf   —  liveuser conf array
string   $lang   —  two letters language code

[ Top ]

addUser   [line 372]

mixed addUser( string $handle, string $password, [boolean $active = true], [int $id = null], [integer $owner_user_id = null], [integer $owner_group_id = null], [array $customFields = array()])

Tries to add a user to both containers.

If the optional $id parameter is passed it will be used for both containers.

In any case the auth and perm id will be equal when using this method.

If this behaviour doesn't suit your needs please consider using directly the concerned method. This method is just implement to simplify things a bit and should satisfy most user needs.

Note type is optional for DB, thus it's needed for MDB and MDB2, we recommend that you use type even though you use DB, so if you change to MDB[2], it will be no problem for you. usage example for addUser:

  1.         $custom = array(
  2.           array('name' => 'name''value' => 'asdf''type' => 'text'),
  3.            array('name' => 'email''value' => 'fleh@example.com''type' => 'text')
  4.       );
  5.        $user_id $admin->addUser('johndoe''dummypass'truenullnullnull$custom);

Untested: it most likely doesn't work.

  • Return: userid or false
  • Access: public

Parameters:

string   $handle   —  user handle (username)
string   $password   —  user password
boolean   $active   —  is account active ?
int   $id   —  ID
integer   $owner_user_id   —  ID of the owning user.
integer   $owner_group_id   —  ID of the owning group.
array   $customFields   —  Array of custom fields to be added

[ Top ]

getUser   [line 523]

mixed getUser( mixed $userId, [array $customFields = array()])

Finds and gets userinfo by his userID, customFields can also be gotten

Untested: it most likely doesn't work.

  • Return: Array with userinfo if found else error object
  • Access: public

Parameters:

mixed   $userId   —  User ID
array   $customFields   —  custom fields you want to be returned. If not specified the basic set of fields is returned. The keys are the names and the values

[ Top ]

removeUser   [line 455]

mixed removeUser( mixed $authId)

Removes user from both containers

Untested: it most likely doesn't work.

  • Return: error object or true
  • Access: public

Parameters:

mixed   $authId   —  Auth ID

[ Top ]

searchUsers   [line 494]

mixed searchUsers( [array $filters = array()], [array $customFields = array()], [string $order = null], [boolean $rekey = false])

Searches users with given filters and returns all users found with their handle, passwd, auth_user_id lastlogin, is_active and the customFields if they are specified

Untested: it most likely doesn't work.

  • Return: error object or array
  • Access: public

Parameters:

array   $filters   —  filters to apply to fetched data
array   $customFields   —  custom fields you want to be returned. If not specified the basic set of fields is returned. The keys are the names and the values
string   $order   —  if not null 'ORDER BY $order' will be appended to the query
boolean   $rekey   —  will return an associative array with the auth_user_id as the key by using DB::getAssoc() instead of DB::getAll()

[ Top ]

setAdminAuthContainer   [line 244]

boolean setAdminAuthContainer( string $authName)

Sets the current auth container to the one with the given auth container name

Upon success it will return true. You can then access the auth backend container by using the auth property of this class.

e.g.: $admin->auth->addUser();

  • Return: true upon success, false otherwise
  • Access: public

Parameters:

string   $authName   —  auth container name

[ Top ]

setAdminContainers   [line 297]

boolean setAdminContainers( [mixed $authId = null])

Tries to find a user in any of the auth container.

Upon success it will return true. You can then access the backend container by using the auth and perm properties of this class.

e.g.: $admin->perm->updateAuthUserId();

  • Return: true upon success, false otherwise
  • Access: public

Parameters:

mixed   $authId   —  user auth id

[ Top ]

setAdminPermContainer   [line 272]

boolean setAdminPermContainer( )

Sets the perm container

Upon success it will return true. You can then access the perm backend container by using the perm properties of this class.

e.g.: $admin->perm->addUser();

  • Return: true upon success, false otherwise
  • Access: public

[ Top ]

setConfArray   [line 170]

boolean setConfArray( array $conf)

Merges the current configuration array with configuration array pases along with the method call.
  • Return: true upon success, false otherwise

Parameters:

array   $conf   —  configuration array

[ Top ]

updateUser   [line 422]

mixed updateUser( string $authId, string $handle, boolean $password, [int $active = true], [integer $owner_user_id = null], [integer $owner_group_id = null], [array $customFields = array()])

Tried to changes user data for both containers.

Note type is optional for DB, thus it's needed for MDB and MDB2, we recommend that you use type even though you use DB, so if you change to MDB[2], it will be no problem for you. usage example for updateUser:

  1.        $custom = array(
  2.            array('name' => 'name''value' => 'asdfUpdated''type' => 'text'),
  3.            array('name' => 'email''value' => 'fleh@example.comUpdated''type' => 'text')
  4.        );
  5.        $admin->updateUser($user_id'johndoe''dummypass'truenullnull$custom);

Untested: it most likely doesn't work.

  • Return: error object or true
  • Access: public

Parameters:

string   $authId   —  user handle (username)
string   $handle   —  user password
boolean   $password   —  is account active ?
int   $active   —  ID
integer   $owner_user_id   —  ID of the owning user.
integer   $owner_group_id   —  ID of the owning group.
array   $customFields   —  Array of custom fields to be updated

[ Top ]


Documentation generated on Mon, 11 Mar 2019 10:16:01 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.