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

Class: LiveUser

Source Location: /LiveUser-0.11.1/LiveUser.php

Class Overview

PEAR
   |
   --LiveUser

Class LiveUser - Login handling class


Author(s):

Version:

  • $Id: LiveUser.php,v 1.91 2004/04/24 17:23:12 lsmith Exp $

Methods


Inherited Variables

Inherited Methods


Class Details

[line 100]
Class LiveUser - Login handling class

Description: 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. This way you can for example 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 im in your company's LDAP server. That way you don't have to create lots of user accounts for your employees so that they can access closed sections of your website - everyone can use his existing 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.1.0 or higher, tested only from 4.2.1 onwards
Thanks to: Bjoern Schotte, Kristian Koehntopp, Antonio Guerra



[ Top ]


Method Detail

LiveUser (Constructor)   [line 212]

LiveUser LiveUser( )

Constructor

[ Top ]

arrayMergeClobber   [line 452]

mixed arrayMergeClobber( array $a1, array $a2)

Clobbers two arrays together

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 402]

object Returns &authFactory( mixed $conf)

creates an instance of an auth object
  • Return: an object of an auth container
  • Access: public

Parameters:

mixed   $conf   —  Name of array containing the configuration.

[ Top ]

checkRight   [line 1189]

mixed checkRight( mixed $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:

mixed   $rights   —  A right id or an array of rights.

[ Top ]

checkRightLevel   [line 1228]

boolean checkRightLevel( mixed $rights, mixed $owner_user_id, mixed $owner_group_id)

Wrapper method for the permission object's own checkRightLevel method.
  • Access: public

Parameters:

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

[ Top ]

disconnect   [line 963]

void disconnect( )

properly disconnect resources in the active container
  • Access: public

[ Top ]

errorMessage   [line 1519]

string errorMessage( int $value)

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

Parameters:

int   $value   —  error code

[ Top ]

factory   [line 341]

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

Checks the given file and returns an object of the LoginManager.

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.   'login' => array(
  8.       'method'   => 'request, 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.       'method'   => 'request, get or post',
  17.       'trigger'  => 'REQUEST, GET or POST var that triggers the logout process',
  18.       'redirect' => 'Page path to be redirected to after logout',
  19.       'function' => '(optional) Function to be called when accessing a page without logging in first',
  20.       'destroy'  => 'Whether to destroy the session on logout' falsetrue or regenid
  21.   ),
  22.  // The cookie options are optional. If they are specified, the Remember Me
  23.  // feature is activated.
  24.   'cookie' => array(
  25.       'name'     => 'Name of Remember Me cookie',
  26.       'lifetime' => 'Cookie lifetime in days',
  27.       'path'     => 'Cookie path',
  28.       'domain'   => 'Cookie domain',
  29.       'secret'   => 'Secret key used for cookie value encryption'
  30.   ),
  31.   'authContainers' => array(
  32.       'name' => array(
  33.             'type' => 'DB',
  34.             'connection'    => 'db connection object, use this or dsn',
  35.             'dsn'           => 'database dsn, use this or connection',
  36.             'loginTimeout'  => 0,
  37.             'expireTime'    => 3600,
  38.             'idleTime'      => 1800,
  39.             'allowDuplicateHandles' => 0,
  40.             'authTable'     => 'liveuser_users',
  41.             'authTableCols' => array('user_id'            => 'auth_user_id',
  42.                                      'handle'             => 'handle',
  43.                                      'passwd'             => 'passwd',
  44.                                      'lastlogin'          => 'lastlogin'
  45.                                      'owner_user_id'      => 'owner_user_id'
  46.                                      'owner_group_id'     => 'owner_group_id'
  47.             )
  48.       )
  49.   ),
  50.   'permContainer' => array(
  51.       'type'       => 'DB_Complex',
  52.       'connection' => 'db connection object, use this or dsn',
  53.       'dsn'        => 'database dsn, use this or connection',
  54.       'prefix'     => 'liveuser_'
  55.   )

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: an object of either LiveUser or PEAR_Error type
  • 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 remember me is set
mixed   $confName   —  Name of array containing the configuration.

[ Top ]

freeze   [line 940]

void freeze( )

store all properties in an array
  • Access: public

[ Top ]

getAuthContainer   [line 634]

mixed &getAuthContainer( )

Get the Auth Container class instance of it exists
  • Return: object or PEAR Error
  • Access: public

[ Top ]

getOption   [line 619]

mixed getOption( string $option)

Returns the value of an option
  • Return: the option value
  • Access: public

Parameters:

string   $option   —  option name

[ Top ]

getPermContainer   [line 650]

mixed &getPermContainer( )

Get the Perm Container class instance if it exists
  • Return: object or PEAR Error
  • Access: public

[ Top ]

getProperty   [line 1362]

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 ]

getRights   [line 1388]

mixed getRights( [boolean $withLevels = false])

Returns a one-dimensional array with all rights assigned to this user.

Array format depends on the optional parameter: true:

  1. array(intRight_ID => intRightLevel...)
false
  1. array(intRight_ID...[Default]
If no rights are available, false is returned.

  • Return: an array of rights or false
  • Access: public

Parameters:

boolean   $withLevels   —  Return array with right_id's as key and level as value

[ Top ]

getStatus   [line 1402]

integer getStatus( )

Get the current status.
  • Access: public

[ Top ]

init   [line 675]

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

Tries to retrieve auth object from session.

If this fails, the class attempts a login based on cookie or form information (depends on class settings). Returns true if a auth object was successfully retrieved or created. Otherwise, false is returned.

  • Return: true if init process well, false if something went wrong or an error object.
  • 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 ]

isError   [line 1506]

bool isError( mixed $value)

Tell whether a result from a LiveUser method is an error.
  • Return: whether value is an error
  • Access: public

Parameters:

mixed   $value   —  result code

[ Top ]

isInactive   [line 1287]

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 == Not active false == active

  • Access: public

[ Top ]

isLoggedIn   [line 1263]

boolean isLoggedIn( )

Checks if a user is logged in.
  • Access: public

[ Top ]

logout   [line 1112]

void logout( )

This destroys the session object.
  • Access: public

[ Top ]

permFactory   [line 424]

object Returns &permFactory( mixed $conf)

Creates an instance of an perm object
  • Return: an object of an perm container
  • Access: public

Parameters:

mixed   $conf   —  Name of array containing the configuration.

[ Top ]

raiseError   [line 245]

object a &raiseError( [mixed $code = null], [int $mode = null], [mixed $options = null], [string $userinfo = null])

This method is used to communicate an error and invoke error callbacks etc. Basically a wrapper for PEAR::raiseError without the message string.
  • Return: PEAR error object
  • See: PEAR_Error

Parameters:

mixed   $code   —  integer error code, or a PEAR error object (all other parameters are ignored if this parameter is an object
int   $mode   —  error mode, see PEAR_Error docs
mixed   $options   —  If error mode is PEAR_ERROR_TRIGGER, this is the error level (E_USER_NOTICE etc). If error mode is PEAR_ERROR_CALLBACK, this is the callback function, either as a function name, or as an array of an object and method name. For other error modes this parameter is ignored.
string   $userinfo   —  Extra debug information. Defaults to the last query and native error code.

[ Top ]

setLoginFunction   [line 1308]

mixed setLoginFunction( string $functionName)

Sets a callback login function.

The user can set a function that will be called if the user tries to access a page wihout logging in first. It will receive the liveuser object. If an empty string or a non-existent function is passed it deactivates the call.

  • Return: void or PEAR_Error
  • Access: public

Parameters:

string   $functionName   —  The name of the function to be called.

[ Top ]

setLogoutFunction   [line 1338]

mixed setLogoutFunction( string $functionName)

Sets a callback logout function.

The user can set a function that will be called if the user wants to logout (by providing the appropriate GET-parameter). If an empty string or a non-existent function is passed it deactivates the call. Attention: Don't use a die() or exit() statement in your logout function. Otherwise the user can't be logged out properly.

  • Return: void or a PEAR_Error
  • See: LiveUser::_options
  • Access: public

Parameters:

string   $functionName   —  The name of the function to be called.

[ Top ]

setOption   [line 602]

mixed setOption( string $option, mixed $value)

Sets an option.
  • Return: true or PEAR Error
  • See: LiveUser::_options
  • Access: public

Parameters:

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

[ Top ]

singleton   [line 382]

object Returns &singleton( mixed $conf, [string $handle = ''], [string $passwd = ''], [boolean $logout = false], [boolean $remember = false], [mixed $confName = 'liveuserConfig'])

Makes your instance global.

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: an object of either LiveUser or PEAR_Error type
  • See: LiveUser::factory
  • 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 remember me is set
mixed   $confName   —  Name of array containing the configuration.

[ Top ]


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