Source for file Simple.php
Documentation is available at Simple.php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
* A framework for authentication and authorization in PHP applications
* LiveUser is an authentication/permission framework designed
* to be flexible and easily extendable.
* Since it is impossible to have a
* "one size fits all" it takes a container
* approach which should enable it to
* be versatile enough to meet most needs.
* LICENSE: This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* @category authentication
* @author Markus Wolff <wolff@21st.de>
* @author Helgi Þormar Þorbjörnsson <dufuz@php.net>
* @author Lukas Smith <smith@pooteeweet.org>
* @author Arnaud Limbourg <arnaud@php.net>
* @author Pierre-Alain Joye <pajoye@php.net>
* @author Bjoern Kraus <krausbn@php.net>
* @copyright 2002-2006 Markus Wolff
* @license http://www.gnu.org/licenses/lgpl.txt
* @version CVS: $Id: Simple.php,v 1.41 2006/04/10 14:41:44 lsmith Exp $
* @link http://pear.php.net/LiveUser
* Base class for permission handling. Provides the simplest
* set of permission handling features.
* This class provides a set of functions for implementing a user
* permission management system on live websites. All authorisation
* backends/containers must extend this base class.
* @category authentication
* @author Markus Wolff <wolff@21st.de>
* @author Bjoern Kraus <krausbn@php.net>
* @copyright 2002-2006 Markus Wolff
* @license http://www.gnu.org/licenses/lgpl.txt
* @version Release: @package_version@
* @link http://pear.php.net/LiveUser
* Unique user ID, used to identify users from the auth container.
* One-dimensional array containing current user's rights (direct and (sub)group).
* This already includes grouprights and possible overrides by
* individual right settings.
* Format: "RightId" => "Level"
* One-dimensional array containing only the individual
* rights directly assigned to the user.
* Format: "RightId" => "Level"
* Defines the user type. Depending on the value the user can gain certain
* Class constructor. Feel free to override in backend subclasses.
$this->stack = &PEAR_ErrorStack ::singleton ('LiveUser');
* Load and initialize the storage container.
* @param array Array with the configuration
* @return bool true on success or false on failure
array ('msg' => 'Missing storage configuration array'));
foreach ($keys as $key) {
if (isset ($this->$key)) {
$this->$key = & $conf[$key];
if ($this->_storage === false ) {
$key = key($conf['storage']);
array ('msg' => 'Could not instanciate perm storage container: '. $key));
* Tries to find the user with the given user ID in the permissions
* container. Will read all permission data and return true on success.
* @param string user identifier
* @param string name of the auth container
* @return bool true on success or false on failure
function mapUser($auth_user_id = null , $containerName = null )
$result = $this->_storage->mapUser ($auth_user_id, $containerName);
* Reads all rights of current user into a
* two-dimensional associative array, having the
* area names as the key of the 1st dimension.
* @return array requested data or false on failure
* Read all the user rights from the storage and puts them in a class
* member for later retrieval.
* @param int perm user id
* @return array requested data or false on failure
function readUserRights ($perm_user_id)
$result = $this->_storage->readUserRights ($perm_user_id);
* Checks if the current user has a certain right.
* If the user is has an "area admin" type he will automatically be
* @param int Id of the right to check for.
* @return int level at which the user has the given right or
* false if the user does not have the right.
// check if the user is above areaadmin
// If he does, look for the right in question.
// We know the user has the right so the right level will be returned.
* Function returns the inquired value if it exists in the class.
* @param string name of the property to be returned.
* @return mixed null, a scalar or an array.
if (isset ($this->$what)) {
* Stores all properties in an array.
* @param string name of the session in use.
* @return array containing the property values
'group_right_ids' => $this->group_right_ids,
'group_ids' => $this->group_ids,
return $this->_storage->freeze ($sessionName, $propertyValues);
* Reinitializes properties from the storage container.
* @param string name of the key to use inside the session
* @param bool always returns true
$propertyValues = $this->_storage->unfreeze ($sessionName);
foreach ($propertyValues as $key => $value) {
* Properly disconnect from resources.
* @return bool true on success and false on failure
Documentation generated on Mon, 28 Jan 2008 03:30:32 -0500 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.
|