cvs: pear /Perm_LiveUser/Perm Common.php
| From: | Arnaud Limbourg | Date: | Sat, 07 Dec 2002 18:06:02 +0000 |
| Subject: | cvs: pear /Perm_LiveUser/Perm Common.php | ||
| Groups: | php.pear.cvs | ||
| Request: | Send a blank email to pear-cvs+get-7766@lists.php.net to get a copy of this message | ||
arnaud Sat Dec 7 13:06:02 2002 EDT
Modified files:
/pear/Perm_LiveUser/Perm Common.php
Log:
* slight API change on checkRight
* cosmetic
Index: pear/Perm_LiveUser/Perm/Common.php diff -u pear/Perm_LiveUser/Perm/Common.php:1.5 pear/Perm_LiveUser/Perm/Common.php:1.6 --- pear/Perm_LiveUser/Perm/Common.php:1.5 Thu Oct 24 14:43:42 2002 +++ pear/Perm_LiveUser/Perm/Common.php Sat Dec 7 13:06:02 2002 @@ -1,5 +1,4 @@ <?php - // Usertypes // lowest user type id define('LIVEUSER_ANONYMOUS_TYPE_ID', 0); @@ -19,125 +18,132 @@ define('LIVEUSER_ERROR_NOT_CAPABLE', 0); // Include PEAR class definition for creating error objects -include_once('PEAR.php'); +include_once 'PEAR.php'; /** * Class LiveUser_Perm_Common - * + * * Description: * This class provides a set of functions for implementing a user * permission management system on live websites. All authorisation * backends/containers must be extensions of this base class. - * + * * @author Markus Wolff <wolff@21st.de> - * @version $Id: Common.php,v 1.5 2002/10/24 18:43:42 tal Exp $ - **/ -class LiveUser_Perm_Common + * @version $Id: Common.php,v 1.6 2002/12/07 18:06:02 arnaud Exp $ + */ +class LiveUser_Perm_Common extends PEAR { /** - * Unique user ID, used to identify users from the auth container + * Unique user ID, used to identify users from the auth container. + * * @var string - **/ - var $user_id = ""; - + */ + var $user_id = ''; + /** * One-Dimensional array containing current user's AuthAreas * and his rights in each of these areas. This already includes * grouprights and possible overrides by individual right - * settings. - * + * settings. + * * Format: "AreaName" => "RightName" - * + * * @var mixed - **/ - var $rights = FALSE; - + */ + var $rights = false; + /** * Two-dimensional array containing only the individual - * rights for the actual user. - * + * rights for the actual user. + * * Format: "AreaName" => "RightName" => "Value" - * + * * @var array - **/ + */ var $userRights = array(); - + /** * Two-dimensional array containing all groups that * the user belongs to and the grouprights defined for * each area. - * + * * Format: "GroupName" => "AreaName" => "RightName" - * + * * @var array * @see $userRights * @see $rights - **/ - var $groupRights = array(); - + */ + var $groupRights = array(); + /** * Defines the user type. + * * @var integer - **/ + */ var $user_type = LIVEUSER_ANONYMOUS_TYPE_ID; - + /** * Defines if the user is an area admin. * If the user is an area admin this variable will be filled - * with an array of all areas in which the user is area admin + * with an array of all areas in which the user is area admin. + * * @var mixed - **/ - var $area_admin = FALSE; - + */ + var $area_admin = false; + /** * Defines if the user rights should be retrieved ondemand. + * * @var boolean - **/ - var $ondemand = FALSE; - + */ + var $ondemand = false; + /** * Defines the (sub)groups in which the user is a memember + * * @var mixed - **/ - var $group_ids = FALSE; - + */ + var $group_ids = false; + /** * Defines the members of all (sub)groups in which the user is a memember + * * @var mixed - **/ - var $group_user_ids = FALSE; - + */ + var $group_user_ids = false; + /** * Defines the array index number of the LoginManager´s "backends" property. * Only used by the LoginManager for unfreeze()ing the session object * with the right connection data. + * * @var integer - **/ - var $backendArrayIndex = 0; - + */ + var $backendArrayIndex = 0; + /** * LiveUser::LiveUser_Perm() - * + * * Class constructor. Feel free to override in backend subclasses. - **/ + */ function LiveUser_Perm() { // I do nothing here, override me plenty ;-) } - + function unfreeze() { return($this->raiseError('LiveUser permission container: Feature unavailable', LIVEUSER_ERROR_NOT_CAPABLE)); } - + function freeze() { return($this->raiseError('LiveUser permission container: Feature unavailable', LIVEUSER_ERROR_NOT_CAPABLE)); } - + /** * LiveUser::readRights() - * + * * Reads all rights of current user into a * two-dimensional associative array, having the * area names as the key of the 1st dimension. @@ -148,10 +154,10 @@ { return($this->raiseError('LiveUser permission container: Feature unavailable', LIVEUSER_ERROR_NOT_CAPABLE)); } - + /** * LiveUser::checkArea() - * + * * Checks if the current user has a rights in a * given area. If no third parameter is given, this also * checks if the user is logged in and will only return @@ -159,19 +165,19 @@ * logged in. Set the third parameter to FALSE if you * just want to check wheter the user has a certain * right or not while ignoring the login status. - * + * * @param string $area_name The name of the AuthArea to use * @param boolean $checkLogin Flag: Shall the login status also be checked? * @return boolean - **/ + */ function checkArea($area_name, $checkLogin = TRUE) { return($this->raiseError('LiveUser permission container: Feature unavailable', LIVEUSER_ERROR_NOT_CAPABLE)); } - + /** * LiveUser::checkRight() - * + * * Checks if the current user has a certain right in a * given area. If no third parameter is given, this also * checks if the user is logged in and will only return @@ -179,19 +185,19 @@ * logged in. Set the third parameter to FALSE if you * just want to check wheter the user has a certain * right or not while ignoring the login status. - * + * + * @param mixed $right_name The name of the right within the AuthArea to check for * @param string $area_name The name of the AuthArea to use - * @param string $right_name The name of the right within the AuthArea to check for * @return integer level of the right - **/ - function checkRight($area_name, $right_name) + */ + function checkRight($right_name, $area_name = false) { return($this->raiseError('LiveUser permission container: Feature unavailable', LIVEUSER_ERROR_NOT_CAPABLE)); } - + /** * LiveUser::checkRightLevel() - * + * * Checks if the current user has a certain right in a * given area at the necessary level. * If no third parameter is given, this also @@ -200,9 +206,9 @@ * logged in. Set the third parameter to FALSE if you * just want to check wheter the user has a certain * right or not while ignoring the login status. - * + * * Level 1: requires that owner_user_id matches $this->user_id - * Level 2: requires that the $owner_group_id matches the id one of + * Level 2: requires that the $owner_group_id matches the id one of * the (sub)groups that $this->user_id is a memember of * or requires that the $owner_user_id matches a user_id of a memeber of one of $this->user_id's (sub)groups @@ -220,15 +226,15 @@ * which the right is requested * @return boolean TRUE if the level is sufficient to grant access * else FALSE - **/ + */ function checkLevel($level, $owner_user_id, $owner_group_id) { return($this->raiseError('LiveUser permission container: Feature unavailable', LIVEUSER_ERROR_NOT_CAPABLE)); } - + /** * LiveUser::checkRightLevel() - * + * * Checks if the current user has a certain right in a * given area with the sufficient level to gain access * to a specific ressource in that area. @@ -238,7 +244,7 @@ * logged in. Set the third parameter to FALSE if you * just want to check wheter the user has a certain * right or not while ignoring the login status. - * + * * @param string $area_name The name of the AuthArea to use * @param string $right_name The name of the right within the AuthArea to check for * @param mixed $owner_user_id id of the owner of the ressource for @@ -247,57 +253,56 @@ * which the right is requested * @return boolean TRUE if the level is sufficient to grant access * else FALSE - **/ + */ function checkRightLevel($area_name, $right_name, $owner_user_id, $owner_group_id) { return($this->raiseError('LiveUser permission container: Feature unavailable', LIVEUSER_ERROR_NOT_CAPABLE)); } - + /** * LiveUser::readUserRights() - * + * * Reads all individual rights of current user into * a two-dimensional array of this format: * AreaName => RightName -> Value - * + * * Again, this does nothing in the base class. The * described functionality must be implemented in a * subclass overriding this method. - **/ + */ function readUserRights() { return($this->raiseError('LiveUser permission container: Feature unavailable', LIVEUSER_ERROR_NOT_CAPABLE)); } - + /** * LiveUser::readGroupRights() - * + * * Reads all individual rights of current user into * a two-dimensional array of this format: * "GroupName" => "AreaName" -> "RightName" - * + * * Again, this does nothing in the base class. The * described functionality must be implemented in a * subclass overriding this method. - **/ + */ function readGroupRights() { return($this->raiseError('LiveUser permission container: Feature unavailable', LIVEUSER_ERROR_NOT_CAPABLE)); } - + /** * LiveUser::userExists() - * + * * Checks if a user with the given user_id exists in the * permission container and returns TRUE on success. - * + * * @param string $user_id * @return boolean - **/ + */ function userExists($user_id) { return($this->raiseError('LiveUser permission container: Feature unavailable', LIVEUSER_ERROR_NOT_CAPABLE)); } } - -?> +?> \ No newline at end of file
Index: pear/Perm_LiveUser/Perm/Common.php diff -u pear/Perm_LiveUser/Perm/Common.php:1.5 pear/Perm_LiveUser/Perm/Common.php:1.6 --- pear/Perm_LiveUser/Perm/Common.php:1.5 Thu Oct 24 14:43:42 2002 +++ pear/Perm_LiveUser/Perm/Common.php Sat Dec 7 13:06:02 2002 @@ -1,5 +1,4 @@ <?php - // Usertypes // lowest user type id define('LIVEUSER_ANONYMOUS_TYPE_ID', 0); @@ -19,125 +18,132 @@ define('LIVEUSER_ERROR_NOT_CAPABLE', 0); // Include PEAR class definition for creating error objects -include_once('PEAR.php'); +include_once 'PEAR.php'; /** * Class LiveUser_Perm_Common - * + * * Description: * This class provides a set of functions for implementing a user * permission management system on live websites. All authorisation * backends/containers must be extensions of this base class. - * + * * @author Markus Wolff <wolff@21st.de> - * @version $Id: Common.php,v 1.5 2002/10/24 18:43:42 tal Exp $ - **/ -class LiveUser_Perm_Common + * @version $Id: Common.php,v 1.6 2002/12/07 18:06:02 arnaud Exp $ + */ +class LiveUser_Perm_Common extends PEAR { /** - * Unique user ID, used to identify users from the auth container + * Unique user ID, used to identify users from the auth container. + * * @var string - **/ - var $user_id = ""; - + */ + var $user_id = ''; + /** * One-Dimensional array containing current user's AuthAreas * and his rights in each of these areas. This already includes * grouprights and possible overrides by individual right - * settings. - * + * settings. + * * Format: "AreaName" => "RightName" - * + * * @var mixed - **/ - var $rights = FALSE; - + */ + var $rights = false; + /** * Two-dimensional array containing only the individual - * rights for the actual user. - * + * rights for the actual user. + * * Format: "AreaName" => "RightName" => "Value" - * + * * @var array - **/ + */ var $userRights = array(); - + /** * Two-dimensional array containing all groups that * the user belongs to and the grouprights defined for * each area. - * + * * Format: "GroupName" => "AreaName" => "RightName" - * + * * @var array * @see $userRights * @see $rights - **/ - var $groupRights = array(); - + */ + var $groupRights = array(); + /** * Defines the user type. + * * @var integer - **/ + */ var $user_type = LIVEUSER_ANONYMOUS_TYPE_ID; - + /** * Defines if the user is an area admin. * If the user is an area admin this variable will be filled - * with an array of all areas in which the user is area admin + * with an array of all areas in which the user is area admin. + * * @var mixed - **/ - var $area_admin = FALSE; - + */ + var $area_admin = false; + /** * Defines if the user rights should be retrieved ondemand. + * * @var boolean - **/ - var $ondemand = FALSE; - + */ + var $ondemand = false; + /** * Defines the (sub)groups in which the user is a memember + * * @var mixed - **/ - var $group_ids = FALSE; - + */ + var $group_ids = false; + /** * Defines the members of all (sub)groups in which the user is a memember + * * @var mixed - **/ - var $group_user_ids = FALSE; - + */ + var $group_user_ids = false; + /** * Defines the array index number of the LoginManager´s "backends" property. * Only used by the LoginManager for unfreeze()ing the session object * with the right connection data. + * * @var integer - **/ - var $backendArrayIndex = 0; - + */ + var $backendArrayIndex = 0; + /** * LiveUser::LiveUser_Perm() - * + * * Class constructor. Feel free to override in backend subclasses. - **/ + */ function LiveUser_Perm() { // I do nothing here, override me plenty ;-) } - + function unfreeze() { return($this->raiseError('LiveUser permission container: Feature unavailable', LIVEUSER_ERROR_NOT_CAPABLE)); } - + function freeze() { return($this->raiseError('LiveUser permission container: Feature unavailable', LIVEUSER_ERROR_NOT_CAPABLE)); } - + /** * LiveUser::readRights() - * + * * Reads all rights of current user into a * two-dimensional associative array, having the * area names as the key of the 1st dimension. @@ -148,10 +154,10 @@ { return($this->raiseError('LiveUser permission container: Feature unavailable', LIVEUSER_ERROR_NOT_CAPABLE)); } - + /** * LiveUser::checkArea() - * + * * Checks if the current user has a rights in a * given area. If no third parameter is given, this also * checks if the user is logged in and will only return @@ -159,19 +165,19 @@ * logged in. Set the third parameter to FALSE if you * just want to check wheter the user has a certain * right or not while ignoring the login status. - * + * * @param string $area_name The name of the AuthArea to use * @param boolean $checkLogin Flag: Shall the login status also be checked? * @return boolean - **/ + */ function checkArea($area_name, $checkLogin = TRUE) { return($this->raiseError('LiveUser permission container: Feature unavailable', LIVEUSER_ERROR_NOT_CAPABLE)); } - + /** * LiveUser::checkRight() - * + * * Checks if the current user has a certain right in a * given area. If no third parameter is given, this also * checks if the user is logged in and will only return @@ -179,19 +185,19 @@ * logged in. Set the third parameter to FALSE if you * just want to check wheter the user has a certain * right or not while ignoring the login status. - * + * + * @param mixed $right_name The name of the right within the AuthArea to check for * @param string $area_name The name of the AuthArea to use - * @param string $right_name The name of the right within the AuthArea to check for * @return integer level of the right - **/ - function checkRight($area_name, $right_name) + */ + function checkRight($right_name, $area_name = false) { return($this->raiseError('LiveUser permission container: Feature unavailable', LIVEUSER_ERROR_NOT_CAPABLE)); } - + /** * LiveUser::checkRightLevel() - * + * * Checks if the current user has a certain right in a * given area at the necessary level. * If no third parameter is given, this also @@ -200,9 +206,9 @@ * logged in. Set the third parameter to FALSE if you * just want to check wheter the user has a certain * right or not while ignoring the login status. - * + * * Level 1: requires that owner_user_id matches $this->user_id - * Level 2: requires that the $owner_group_id matches the id one of + * Level 2: requires that the $owner_group_id matches the id one of * the (sub)groups that $this->user_id is a memember of * or requires that the $owner_user_id matches a user_id of a memeber of one of $this->user_id's (sub)groups @@ -220,15 +226,15 @@ * which the right is requested * @return boolean TRUE if the level is sufficient to grant access * else FALSE - **/ + */ function checkLevel($level, $owner_user_id, $owner_group_id) { return($this->raiseError('LiveUser permission container: Feature unavailable', LIVEUSER_ERROR_NOT_CAPABLE)); } - + /** * LiveUser::checkRightLevel() - * + * * Checks if the current user has a certain right in a * given area with the sufficient level to gain access * to a specific ressource in that area. @@ -238,7 +244,7 @@ * logged in. Set the third parameter to FALSE if you * just want to check wheter the user has a certain * right or not while ignoring the login status. - * + * * @param string $area_name The name of the AuthArea to use * @param string $right_name The name of the right within the AuthArea to check for * @param mixed $owner_user_id id of the owner of the ressource for @@ -247,57 +253,56 @@ * which the right is requested * @return boolean TRUE if the level is sufficient to grant access * else FALSE - **/ + */ function checkRightLevel($area_name, $right_name, $owner_user_id, $owner_group_id) { return($this->raiseError('LiveUser permission container: Feature unavailable', LIVEUSER_ERROR_NOT_CAPABLE)); } - + /** * LiveUser::readUserRights() - * + * * Reads all individual rights of current user into * a two-dimensional array of this format: * AreaName => RightName -> Value - * + * * Again, this does nothing in the base class. The * described functionality must be implemented in a * subclass overriding this method. - **/ + */ function readUserRights() { return($this->raiseError('LiveUser permission container: Feature unavailable', LIVEUSER_ERROR_NOT_CAPABLE)); } - + /** * LiveUser::readGroupRights() - * + * * Reads all individual rights of current user into * a two-dimensional array of this format: * "GroupName" => "AreaName" -> "RightName" - * + * * Again, this does nothing in the base class. The * described functionality must be implemented in a * subclass overriding this method. - **/ + */ function readGroupRights() { return($this->raiseError('LiveUser permission container: Feature unavailable', LIVEUSER_ERROR_NOT_CAPABLE)); } - + /** * LiveUser::userExists() - * + * * Checks if a user with the given user_id exists in the * permission container and returns TRUE on success. - * + * * @param string $user_id * @return boolean - **/ + */ function userExists($user_id) { return($this->raiseError('LiveUser permission container: Feature unavailable', LIVEUSER_ERROR_NOT_CAPABLE)); } } - -?> +?> \ No newline at end of file