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

Class: LiveUser

Source Location: /LiveUser-0.16.5/LiveUser.php

Class Overview


This is a manager class for a user login system using the LiveUser class. It creates a LiveUser object, takes care of the whole login process and stores the LiveUser object in a session.


Author(s):

Version:

  • Release: @package_version@

Copyright:

  • 2002-2005 Markus Wolff

Variables

Methods


Inherited Variables

Inherited Methods


Class Details

[line 191]
This is a manager class for a user login system using the LiveUser class. It creates a LiveUser object, takes care of the whole login process and stores the LiveUser object in a session.

You can also configure this class to try to connect to more than one server that can store user information - each server requiring a different backend class.

An example would be to create a login system for a live website that first queries the local database and if the requested user is not found, it tries to find it in your company's LDAP server. It means you don't have to create several user accounts for your employees so that they can access closed sections of your website - everyone can use one account.

NOTE: No browser output may be made before using this class, because it will try to send HTTP headers such as cookies and redirects.

Requirements:

  • Should run on PHP version 4.2.0 (required for PEAR_Errorstack or higher, tested only from 4.2.1 onwards
Thanks to: Bjoern Schotte, Kristian Koehntopp, Antonio Guerra



[ Top ]


Class Variables

$dispatcher =  null

[line 329]

Stores the event dispatcher which handles notifications
  • Access: protected

Type:   array


[ Top ]



Method Detail

LiveUser (Constructor)   [line 337]

void LiveUser( )

Constructor
  • Access: protected

[ Top ]

addErrorLog   [line 791]

boolean addErrorLog( Log &$log)

Adds an error logger to Errorstack.

Be aware that if you need add a log at the beginning of your code if you want it to be effective. A log will only be taken into account after it's added.

Sample usage:

  1.  $lu_object &LiveUser::singleton($conf);
  2.  $logger &Log::factory('mail''bug@example.com',
  3.       'myapp_debug_mail_log'array('from' => 'application_bug@example.com'));
  4.  $lu_object->addErrorLog($logger);

  • Return: true on success or false on failure
  • Access: public

Parameters:

Log   &$log   —  logger instance

[ Top ]

arrayMergeClobber   [line 663]

array|false arrayMergeClobber( array $a1, array $a2)

Clobbers two arrays together.

Function taken from the user notes of array_merge_recursive used in LiveUser::readConfig() may be called statically

  • Return: array on success and false on error
  • Author: kc@hireability.com
  • Access: public

Parameters:

array   $a1   —  array that should be clobbered
array   $a2   —  array that should be clobbered

[ Top ]

authFactory   [line 571]

object|false &authFactory( array|file &$conf, string $containerName, [string $classprefix = 'LiveUser_'])

Creates an instance of an auth object.
  • Return: Returns an instance of an auth container class or false on error
  • Access: public

Parameters:

array|file   &$conf   —  Name of array containing the configuration.
string   $containerName   —  Name of the container we'll be using.
string   $classprefix   —  Prefix of the class that will be used.

[ Top ]

checkGroup   [line 1487]

boolean checkGroup( array|int $groups)

Wrapper method for the permission object's own checkGroup method.
  • Return: true on success or false on failure
  • Access: public

Parameters:

array|int   $groups   —  A group id or an array of groups.

[ Top ]

checkRight   [line 1431]

int|false checkRight( array|int $rights)

Wrapper method for the permission object's own checkRight method.
  • Return: level if the user has the right/rights false if not
  • Access: public

Parameters:

array|int   $rights   —  A right id or an array of rights.

[ Top ]

checkRightLevel   [line 1469]

boolean checkRightLevel( array|int $rights, array|int $owner_user_id, array|int $owner_group_id)

Wrapper method for the permission object's own checkRightLevel method.
  • Return: true on success or false on failure
  • Access: public

Parameters:

array|int   $rights   —  A right id or an array of rights.
array|int   $owner_user_id   —  Id or array of Ids of the owner of the
array|int   $owner_group_id   —  Id or array of Ids of the group of the ressource for which the right is requested.

[ Top ]

cryptRC4Factory   [line 807]

object returns &cryptRC4Factory( string $secret)

Creates an instance of the PEAR::Crypt_Rc4 class.
  • Return: an instance of the Crypt_RC4 class
  • Access: public

Parameters:

string   $secret   —  token to use to encrypt data

[ Top ]

disconnect   [line 1178]

boolean disconnect( )

Properly disconnect resources in the active container
  • Return: true on success or false on failure
  • Access: public

[ Top ]

factory   [line 458]

LiveUser|false &factory( mixed $conf, [string $handle = ''], [string $passwd = ''], [boolean $logout = false], [boolean $remember = false], [mixed $confName = 'liveuserConfig'])

Returns an instance of the login manager class.

This array contains private options defined by the following associative keys:

  1.  array(
  2.   'autoInit' => false/true,
  3.   'session'  => array(
  4.       'name'    => 'liveuser session name',
  5.       'varname' => 'liveuser session var name'
  6.   ),
  7.  // The session_save_handler options are optional. If they are specified,
  8.  // session_set_save_handler() will be called with the parameters
  9.   'session_save_handler' => array(
  10.       'open'    => 'name of the open function/method',
  11.       'close'   => 'name of the close function/method',
  12.       'read'    => 'name of the read function/method',
  13.       'write'   => 'name of the write function/method',
  14.       'destroy' => 'name of the destroy function/method',
  15.       'gc'      => 'name of the gc function/method',
  16.   ),
  17.  // The session_cookie_params options are optional. If they are specified,
  18.  // session_set_cookie_params() will be called with the parameters
  19.   'session_cookie_params' => array(
  20.       'lifetime' => 'Cookie lifetime in days',
  21.       'path'     => 'Cookie path',
  22.       'domain'   => 'Cookie domain',
  23.       'secure'   => 'Cookie send only over secure connections',
  24.   ),
  25.  'cache_perm' => if the permission data should be cached inside the session
  26.   'login' => array(
  27.       'force'    => 'Should the user be forced to login'
  28.       'regenid'  => 'Should the session be regenerated on login'
  29.   ),
  30.   'logout' => array(
  31.       'destroy'  => 'Whether to destroy the session on logout' false or true
  32.   ),
  33.  // The cookie options are optional. If they are specified, the Remember Me
  34.  // feature is activated.
  35.   'cookie' => array(
  36.       'name'     => 'Name of Remember Me cookie',
  37.       'lifetime' => 'Cookie lifetime in days',
  38.       'path'     => 'Cookie path',
  39.       'domain'   => 'Cookie domain',
  40.       'secret'   => 'Secret key used for cookie value encryption',
  41.       'savedir'  => '/absolute/path/to/writeable/directory' // No / at the end !
  42.       'secure'   => 'Cookie send only over secure connections',
  43.   ),
  44.   'authContainers' => array(
  45.       'name' => array(
  46.             'type'            => 'DB',
  47.             'loginTimeout'    => 0,
  48.             'expireTime'      => 3600,
  49.             'idleTime'        => 1800,
  50.             'updateLastLogin' => true,
  51.             'allowDuplicateHandles' => false,
  52.             'allowEmptyPasswords'   => false,
  53.             'storage' => array(
  54.                 'connection'      => 'db connection object, use this or dsn',
  55.                 'dsn'             => 'database dsn, use this or connection',
  56.            ),
  57.            'externalValues' => array(
  58.                   'values'      => &$_SERVER,
  59.                   'keysToCheck' => array('HTTP_USER_AGENT')
  60.            ),
  61.       ),
  62.   ),
  63.   'permContainer' => array(
  64.       'type'     => 'Complex',
  65.       'storage'  => array(
  66.           'MDB2' => array(
  67.               'dsn'       => $dsn,
  68.               'prefix'    => 'liveuser_'
  69.               'tables'    => array(),
  70.               'fields'    => array(),
  71.               'alias'     => array(),
  72.               'force_seq' => true,
  73.           ),
  74.       ),
  75.   ),

Other options in the configuration file relative to the Auth and Perm containers depend on what the containers expect. Refer to the Containers documentation. The examples for containers provided are just general do not reflect all the options for all containers.

  • Return: Returns an object of either LiveUser or false on error if so use LiveUser::getErrors() to get the errors
  • See: LiveUser::getErrors
  • Access: public

Parameters:

mixed   $conf   —  The config file or the config array to configure.
string   $handle   —  Handle of the user trying to authenticate
string   $passwd   —  Password of the user trying to authenticate
boolean   $logout   —  set to true if user wants to logout
boolean   $remember   —  set if you want to use the rememberMe feature
mixed   $confName   —  Name of array containing the configuration.

[ Top ]

fileExists   [line 686]

boolean fileExists( string $file)

Checks if a file exists in the include path.
  • Return: true success and false on error
  • Access: public

Parameters:

string   $file   —  filename

[ Top ]

freeze   [line 1151]

boolean freeze( )

Stores all properties in the session.
  • Return: true on sucess or false on failure
  • Access: public

[ Top ]

getErrors   [line 529]

array getErrors( )

Wrapper method to get the Error Stack
  • Return: an array of the errors or false if there are no errors
  • Access: public

[ Top ]

getOption   [line 888]

mixed getOption( string $option)

Returns the value of an option
  • Return: the option value or false on failure
  • Access: public

Parameters:

string   $option   —  option name

[ Top ]

getProperty   [line 1554]

mixed getProperty( string $what, [string $container = 'auth'])

Wrapper method to access properties from the auth and permission containers.
  • Return: a value or an array.
  • Access: public

Parameters:

string   $what   —  Name of the property to be returned.
string   $container   —  'auth' or 'perm'

[ Top ]

getStatus   [line 1612]

integer getStatus( )

Get the current status.
  • See: LIVEUSER_STATUS_* constants
  • Access: public

[ Top ]

init   [line 945]

boolean init( [string $handle = ''], [string $passwd = ''], [boolean $logout = false], [boolean $remember = false])

Tries to retrieve auth object from session.

If this fails, the method attempts a login based on the parameters or cookie data

  • Return: true if init process well, false if something went wrong.
  • Access: public

Parameters:

string   $handle   —  handle of the user trying to authenticate
string   $passwd   —  password of the user trying to authenticate
boolean   $logout   —  set to true if user wants to logout
boolean   $remember   —  set if remember me is set

[ Top ]

isInactive   [line 1539]

boolean isInactive( )

Function that determines if the user exists but hasn't yet been declared "active" by an administrator.

Use this to check if this was the reason why a user was not able to login. true == user account is NOT active false == user account is active

  • Return: true if the user account is *not* active false if the user account *is* active
  • Access: public

[ Top ]

isLoggedIn   [line 1516]

boolean isLoggedIn( )

Checks if a user is logged in.
  • Return: true if user is logged in, false if not
  • Access: public

[ Top ]

loadClass   [line 545]

boolean loadClass( string $classname)

Loads a PEAR class
  • Return: true success or false on failure
  • Access: public

Parameters:

string   $classname   —  classname

[ Top ]

loadPEARLog   [line 763]

void loadPEARLog( )

This method lazy loads PEAR::Log.
  • Access: protected

[ Top ]

permFactory   [line 594]

object|false &permFactory( array|file &$conf, [string $classprefix = 'LiveUser_'])

Creates an instance of an perm object.
  • Return: Returns an instance of a perm container class or false on error
  • Access: public

Parameters:

array|file   &$conf   —  Name of array containing the configuration.
string   $classprefix   —  Prefix of the class that will be used.

[ Top ]

readConfig   [line 706]

boolean readConfig( array|file $conf, string $confName)

Reads the configuration.
  • Return: true on success or false on failure
  • Access: public

Parameters:

array|file   $conf   —  Conf array or file path to configuration
string   $confName   —  Name of array containing the configuration

[ Top ]

setOption   [line 869]

boolean setOption( string $option, mixed $value)

Sets an option.
  • Return: true on success or false on failure
  • See: LiveUser::_options
  • Access: public

Parameters:

string   $option   —  option name
mixed   $value   —  value for the option

[ Top ]

singleton   [line 495]

LiveUser|false &singleton( [array|file $conf = array()], [string $handle = ''], [string $passwd = ''], [boolean $logout = false], [boolean $remember = false], [string $confName = 'liveuserConfig'])

This uses the singleton pattern, making sure you have one and only instance of the class.

In PHP4 you MUST call this method with the $var = &LiveUser::singleton() syntax. Without the ampersand (&) in front of the method name, you will not get a reference, you will get a copy.

  • Return: Returns an object of either LiveUser or false on failure
  • See: LiveUser::getErrors
  • See: LiveUser::factory
  • Access: public

Parameters:

array|file   $conf   —  The config file or the config array to configure.
string   $handle   —  Handle of the user trying to authenticate
string   $passwd   —  Password of the user trying to authenticate
boolean   $logout   —  set to true if user wants to logout
boolean   $remember   —  set if remember me is set
string   $confName   —  Name of array containing the configuration.

[ Top ]

statusMessage   [line 1637]

string statusMessage( int $value)

Return a textual status message for a LiveUser status code.
  • Return: error message
  • Access: public

Parameters:

int   $value   —  status code

[ Top ]

storageFactory   [line 617]

object|false &storageFactory( array &$confArray, [string $classprefix = 'LiveUser_Perm_'])

Returns an instance of a storage Container.
  • Return: will return an instance of a Storage container or false upon error
  • Access: protected

Parameters:

array   &$confArray   —  configuration array to pass to the storage container
string   $classprefix   —  Prefix of the class that will be used.

[ Top ]

updateProperty   [line 1578]

boolean updateProperty( boolean $auth, [boolean $perm = null])

updates the properties of the containers from the original source
  • Access: public

Parameters:

boolean   $auth   —  if the auth container should be updated
boolean   $perm   —  if the perm container should be updated

[ Top ]

__toString   [line 1624]

string __toString( )

Make a string representation of the object.
  • Return: returns a string representation of the class
  • Access: public

[ Top ]


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