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

Source for file Storage.php

Documentation is available at Storage.php

  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
  3.  
  4. /**
  5.  * A framework for authentication and authorization in PHP applications
  6.  *
  7.  * LiveUser is an authentication/permission framework designed
  8.  * to be flexible and easily extendable.
  9.  *
  10.  * Since it is impossible to have a
  11.  * "one size fits all" it takes a container
  12.  * approach which should enable it to
  13.  * be versatile enough to meet most needs.
  14.  *
  15.  * PHP version 4 and 5
  16.  *
  17.  * LICENSE: This library is free software; you can redistribute it and/or
  18.  * modify it under the terms of the GNU Lesser General Public
  19.  * License as published by the Free Software Foundation; either
  20.  * version 2.1 of the License, or (at your option) any later version.
  21.  *
  22.  * This library is distributed in the hope that it will be useful,
  23.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  25.  * Lesser General Public License for more details.
  26.  *
  27.  * You should have received a copy of the GNU Lesser General Public
  28.  * License along with this library; if not, write to the Free Software
  29.  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  30.  * MA  02111-1307  USA
  31.  *
  32.  *
  33.  * @category authentication
  34.  * @package LiveUser
  35.  * @author  Markus Wolff <wolff@21st.de>
  36.  * @author  Helgi Þormar Þorbjörnsson <dufuz@php.net>
  37.  * @author  Lukas Smith <smith@pooteeweet.org>
  38.  * @author  Arnaud Limbourg <arnaud@php.net>
  39.  * @author  Pierre-Alain Joye <pajoye@php.net>
  40.  * @author  Bjoern Kraus <krausbn@php.net>
  41.  * @copyright 2002-2006 Markus Wolff
  42.  * @license http://www.gnu.org/licenses/lgpl.txt
  43.  * @version CVS: $Id: Storage.php,v 1.18 2006/03/14 13:10:04 lsmith Exp $
  44.  * @link http://pear.php.net/LiveUser
  45.  */
  46.  
  47. /**
  48.  * Abstraction class for all the storage containers
  49.  *
  50.  * @category authentication
  51.  * @package LiveUser
  52.  * @author  Lukas Smith <smith@pooteeweet.org>
  53.  * @author  Bjoern Kraus <krausbn@php.net>
  54.  * @copyright 2002-2006 Markus Wolff
  55.  * @license http://www.gnu.org/licenses/lgpl.txt
  56.  * @version Release: @package_version@
  57.  * @link http://pear.php.net/LiveUser
  58.  */
  59. {
  60.     /**
  61.      * Table configuration
  62.      *
  63.      * @var    array 
  64.      * @access public
  65.      */
  66.     var $tables = array();
  67.  
  68.     /**
  69.      * All fields with their types
  70.      *
  71.      * @var    array 
  72.      * @access public
  73.      */
  74.     var $fields = array();
  75.  
  76.     /**
  77.      * All fields with their alias
  78.      *
  79.      * @var    array 
  80.      * @access public
  81.      */
  82.     var $alias = array();
  83.  
  84.     /**
  85.      * Constructor
  86.      *
  87.      * @access protected
  88.      * @param  mixed      configuration array
  89.      * @return void 
  90.      */
  91.     function LiveUser_Perm_Storage()
  92.     {
  93.         $this->stack &PEAR_ErrorStack::singleton('LiveUser');
  94.     }
  95.  
  96.     /**
  97.      * Initialize the storage container
  98.      *
  99.      * @param array Array with the storage configuration
  100.      * @return bool true on success, false on failure.
  101.      *
  102.      * @access public
  103.      */
  104.     function init(&$storageConf)
  105.     {
  106.         if (is_array($storageConf)) {
  107.             $keys array_keys($storageConf);
  108.             foreach ($keys as $key{
  109.                 if (isset($this->$key)) {
  110.                     $this->$key =$storageConf[$key];
  111.                 }
  112.             }
  113.         }
  114.  
  115.         require_once 'LiveUser/Perm/Storage/Globals.php';
  116.         if (empty($this->tables)) {
  117.             $this->tables = $GLOBALS['_LiveUser']['perm']['tables'];
  118.         else {
  119.             $this->tables = LiveUser::arrayMergeClobber($GLOBALS['_LiveUser']['perm']['tables']$this->tables);
  120.         }
  121.         if (empty($this->fields)) {
  122.             $this->fields = $GLOBALS['_LiveUser']['perm']['fields'];
  123.         else {
  124.             $this->fields = LiveUser::arrayMergeClobber($GLOBALS['_LiveUser']['perm']['fields']$this->fields);
  125.         }
  126.         if (empty($this->alias)) {
  127.             $this->alias = $GLOBALS['_LiveUser']['perm']['alias'];
  128.         else {
  129.             $this->alias = LiveUser::arrayMergeClobber($GLOBALS['_LiveUser']['perm']['alias']$this->alias);
  130.         }
  131.  
  132.         return true;
  133.     }
  134.  
  135.     /**
  136.      * map an auth user to a perm user
  137.      *
  138.      * @param int $auth_user_id 
  139.      * @param string $containerName 
  140.      * @return array requested data or false on failure
  141.      *
  142.      * @access public
  143.      */
  144.     function mapUser($auth_user_id$containerName)
  145.     {
  146.         $this->stack->push(LIVEUSER_ERROR'error'array(),
  147.             __METHOD__.' is not implemented');
  148.         return false;
  149.     }
  150.  
  151.     /**
  152.      * Reads all rights of current user into a
  153.      * two-dimensional associative array, having the
  154.      * area names as the key of the 1st dimension.
  155.      * Group rights and invididual rights are being merged
  156.      * in the process.
  157.      *
  158.      * @param int perm user id
  159.      * @return array requested data or false on failure
  160.      *
  161.      * @access public
  162.      */
  163.     function readUserRights($perm_user_id)
  164.     {
  165.         $this->stack->push(LIVEUSER_ERROR'error'array(),
  166.             __METHOD__.' is not implemented');
  167.         return false;
  168.     }
  169.  
  170.     /**
  171.      * read the areas in which a user is an area admin
  172.      *
  173.      * @param int perm user id
  174.      * @return array requested data or false on failure
  175.      *
  176.      * @access public
  177.      */
  178.     function readAreaAdminAreas($perm_user_id)
  179.     {
  180.         $this->stack->push(LIVEUSER_ERROR'error'array(),
  181.             __METHOD__.' is not implemented');
  182.         return false;
  183.     }
  184.  
  185.     /**
  186.      * Reads all the group ids in that the user is also a member of
  187.      * (all groups that are subgroups of these are also added recursively)
  188.      *
  189.      * @param int perm user id
  190.      * @return array requested data or false on failure
  191.      *
  192.      * @see    readRights()
  193.      * @access public
  194.      */
  195.     function readGroups($perm_user_id)
  196.     {
  197.         $this->stack->push(LIVEUSER_ERROR'error'array(),
  198.             __METHOD__.' is not implemented');
  199.         return false;
  200.     }
  201.  
  202.     /**
  203.      * Reads the group rights
  204.      * and put them in the array
  205.      *
  206.      * right => 1
  207.      *
  208.      * @param int group ids
  209.      * @return array requested data or false on failure
  210.      *
  211.      * @access public
  212.      */
  213.     function readGroupRights($group_ids)
  214.     {
  215.         $this->stack->push(LIVEUSER_ERROR'error'array(),
  216.             __METHOD__.' is not implemented');
  217.         return false;
  218.     }
  219.  
  220.     /**
  221.      * Read the sub groups of the new groups that are not part of the group ids
  222.      *
  223.      * @param array group ids
  224.      * @param array new group ids
  225.      * @return array requested data or false on failure
  226.      *
  227.      * @access public
  228.      */
  229.     function readSubGroups($group_ids$newGroupIds)
  230.     {
  231.         $this->stack->push(LIVEUSER_ERROR'error'array(),
  232.             __METHOD__.' is not implemented');
  233.         return false;
  234.     }
  235.  
  236.     /**
  237.      * Read out the rights from the userrights or grouprights table
  238.      * that imply other rights along with their level
  239.      *
  240.      * @param array right ids
  241.      * @param string name of the table
  242.      * @return array requested data or false on failure
  243.      *
  244.      * @access public
  245.      */
  246.     function readImplyingRights($rightIds$table)
  247.     {
  248.         $this->stack->push(LIVEUSER_ERROR'error'array(),
  249.             __METHOD__.' is not implemented');
  250.         return false;
  251.     }
  252.  
  253.     /**
  254.     * Read out the implied rights with a given level from the implied_rights table
  255.     *
  256.     * @param array current right ids
  257.     * @param string current level
  258.      * @return array requested data or false on failure
  259.     *
  260.     * @access public
  261.     */
  262.     function readImpliedRights($currentRights$currentLevel)
  263.     {
  264.         $this->stack->push(LIVEUSER_ERROR'error'array(),
  265.             __METHOD__.' is not implemented');
  266.         return false;
  267.     }
  268.  
  269.     /**
  270.      * store all properties in the session and return them as an array
  271.      *
  272.      * @param string name of the key to use inside the session
  273.      * @param array property values
  274.      * @return array containing the property values
  275.      *
  276.      * @access public
  277.      */
  278.     function freeze($sessionName$propertyValues)
  279.     {
  280.         $_SESSION[$sessionName]['perm'$propertyValues;
  281.         return $propertyValues;
  282.     }
  283.  
  284.     /**
  285.      * Reinitializes properties
  286.      *
  287.      * @param string name of the key to use inside the session
  288.      * @return array 
  289.      *
  290.      * @access public
  291.      */
  292.     function unfreeze($sessionName)
  293.     {
  294.         return (array_key_exists('perm'$_SESSION[$sessionName])
  295.             && is_array($_SESSION[$sessionName]['perm']))
  296.                 ? $_SESSION[$sessionName]['perm': array();
  297.     }
  298.  
  299.     /**
  300.      * properly disconnect from resources
  301.      *
  302.      * @return bool true on success and false on failure
  303.      *
  304.      * @access public
  305.      */
  306.     function disconnect()
  307.     {
  308.     }
  309. }
  310. ?>

Documentation generated on Mon, 28 Jan 2008 03:30:33 -0500 by phpDocumentor 1.4.0. PEAR Logo Copyright © PHP Group 2004.