cvs: pear /Perm_LiveUser LoginManager.php

From: Date: Wed, 15 Jan 2003 08:03:19 +0000
Subject: cvs: pear /Perm_LiveUser LoginManager.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-8273@lists.php.net to get a copy of this message
arnaud Wed Jan 15 03:03:19 2003 EDT Modified files: /pear/Perm_LiveUser LoginManager.php Log: * improve user-supplied login function call * doc Index: pear/Perm_LiveUser/LoginManager.php diff -u pear/Perm_LiveUser/LoginManager.php:1.20 pear/Perm_LiveUser/LoginManager.php:1.21 --- pear/Perm_LiveUser/LoginManager.php:1.20 Sat Jan 4 06:56:15 2003 +++ pear/Perm_LiveUser/LoginManager.php Wed Jan 15 03:03:18 2003 @@ -1,7 +1,7 @@ <?php /****************************************************************************** LiveUser: A framework for authentication and authorization in PHP applications -Copyright (c) 2002-2003 Markus Wolff +Copyright (C) 2002-2003 Markus Wolff This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public @@ -21,7 +21,6 @@ $GLOBALS['LIVEUSER_CONFIG_TYPE'] = array('PHP' => '_readConfigFilePHP', 'XML' => '_readConfigFileXML'); -// Include PEAR base class definition require_once 'PEAR.php'; /** @@ -57,70 +56,79 @@ * Thanks to: * Bjoern Schotte, Kristian Koehntopp, Antonio Guerra * - * @author Markus Wolff <wolff@21st.de> - * @version $Id: LoginManager.php,v 1.20 2003/01/04 11:56:15 mj Exp $ - **/ + * @author Markus Wolff <wolff@21st.de> + * @version $Id: LoginManager.php,v 1.21 2003/01/15 08:03:18 arnaud Exp $ + */ class LoginManager extends PEAR { /** * The auth container object + * * @var object - **/ + */ var $user = null; /** * The permission container object + * * @var object - **/ + */ var $_perm = null; /** * The session name to be used for all sessions + * * @var string - **/ + */ var $sessionName; /** * The name of the session variable in which the user object * will be stored + * * @var string - **/ + */ var $sessionVarName; /** * The variable name for the user handle that comes from a * HTML login form + * * @var string - **/ + */ var $handleParamName; /** * The variable name for the password that comes from a * HTML login form + * * @var string - **/ + */ var $passwdParamName; /** * The input channel in which to look for login information. * Can be POST for form input or GET for URL input. + * * @var string [GET|POST] - **/ + */ var $loginInputType; /** * Name of the GET-Parameter that is being monitored for logging * out. If present, the user object in the session will be * destroyed. + * * @var string - **/ + */ var $logoutParamName; /** * The name for the cookie to store user information in (used * for the "remember me" function). + * * @var string - **/ + */ var $cookieName; /** @@ -129,8 +137,9 @@ * information has to be re-entered for every session. * This is the recommended behaviour!!! * Set to 0 for not allowing cookies, set to 1 for allowing them. + * * @var integer [0|1] - **/ + */ var $allowCookies; /** @@ -139,38 +148,43 @@ * and allowCookies has been set to 1, a cookie with user information * will be set so the user won't have to login using his username and * password again as long as the cookie exists. + * * @var string - **/ + */ var $cookieParamName; /** * The lifetime of the "remember me" cookie in days. Note that the * cookie lifetime will be refreshed every time the user logs in. + * * @var integer - **/ + */ var $cookieLifetime; /** * The domain for the "remember me" cookie. Example: "21st.de" + * * @var string - **/ + */ var $cookieDomain; /** * The path for the "remember me" cookie. Example: "/" + * * @var string - **/ + */ var $cookiePath; /** * The URL to redirect to when the user logs out + * * @var string - **/ + */ var $logoutRedirectURL; /** * Nested array with the auth containers that shall be queried for user - * information. Format: array(1 => array("option1" => "value", ...)) + * information. Format: array(1 => array("option1" => "value", ....)) * Typical options are: * - server: The adress of the server being queried (ie. "localhost") * - user: The user name used to login for the server @@ -182,8 +196,9 @@ * contains a reference to an already existing connection resource or object. * - type: The container type. This option must always be present, otherwise * the LoginManager can't include the correct container class definition. + * * @var array - **/ + */ var $authContainers = array(); /** @@ -191,7 +206,7 @@ * backend in which the user data resides. This is needed to include the * correct backend class definition on demand. * @var string - **/ + */ var $authContainerTypeVar; /** @@ -201,7 +216,7 @@ * The array element 'type' must be present for the LoginManager to be able * to include the correct class definition (example: "DB_Complex"). * @var mixed - **/ + */ var $permContainer; /** @@ -294,7 +309,7 @@ * @return boolean * @access public * - * @Author pajoye + * @author pajoye */ function init() { @@ -358,7 +373,7 @@ $passwd = stripslashes($_POST[$this->passwdParamName]); } - if (strlen($handle)>0) { + if (strlen($handle) > 0) { $counter = 0; $userFound = false; $backend_cnt = count($this->authContainers); @@ -400,8 +415,10 @@ } $counter++; } // End loop into backends - } elseif ($this->_callLoginFunction && function_exists($this->_loginFunction)) { - call_user_func($this->_loginFunction); + } + + if ($this->_callLoginFunction && function_exists($this->_loginFunction)) { + call_user_func($this->_loginFunction, $this); } } @@ -622,8 +639,8 @@ * typing, but also allows several applications that use this class to * have the same configuration by using one central XML file. * - * @param string $configFile - * @param boolean $enableCache + * @param string $configFile path to the config file, relative or absolute + * @param boolean $enableCache wether to enable caching for the xml file * @return boolean * @access private */ @@ -840,14 +857,21 @@ } /** - * Use can set a function that - * will be called if the user - * tries to access a page wihout - * logging in first. It will receive - * the user handle as a parameter. + * 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. Be careful to add the & in front of the variable + * name you which to use. With it you will receive a reference to the object + * and not a copy thus making it less ressource-consuming. + * + * Example: + * + * function liveuserLogin(&$liveuser) + * { + * if ($liveuser->isInactive()) { + * } // if + * } // end func liveuserLogin * - * If an empty string or a - * non-existent function is passed + * If an empty string or a non-existent function is passed * it deactivates the call. * * @access public @@ -864,4 +888,5 @@ } // if } // end func setLoginFunction } -?> \ No newline at end of file +?> +

« previous php.pear.cvs (#8273) next »