acl.php

Go to the documentation of this file.
00001 <?php
00002 /* SVN FILE: $Id: libs_2controller_2components_2acl_8php-source.html 675 2008-12-26 00:27:14Z gwoo $ */
00003 /**
00004  * Access Control List factory class.
00005  *
00006  * Permissions system.
00007  *
00008  * PHP versions 4 and 5
00009  *
00010  * CakePHP(tm) :  Rapid Development Framework <http://www.cakephp.org/>
00011  * Copyright 2005-2008, Cake Software Foundation, Inc.
00012  *                              1785 E. Sahara Avenue, Suite 490-204
00013  *                              Las Vegas, Nevada 89104
00014  *
00015  * Licensed under The MIT License
00016  * Redistributions of files must retain the above copyright notice.
00017  *
00018  * @filesource
00019  * @copyright       Copyright 2005-2008, Cake Software Foundation, Inc.
00020  * @link                http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
00021  * @package         cake
00022  * @subpackage      cake.cake.libs.controller.components
00023  * @since           CakePHP(tm) v 0.10.0.1076
00024  * @version         $Revision: 675 $
00025  * @modifiedby      $LastChangedBy: gwoo $
00026  * @lastmodified    $Date: 2008-12-25 16:27:14 -0800 (Thu, 25 Dec 2008) $
00027  * @license         http://www.opensource.org/licenses/mit-license.php The MIT License
00028  */
00029 /**
00030  * Access Control List factory class.
00031  *
00032  * Looks for ACL implementation class in core config, and returns an instance of that class.
00033  *
00034  * @package     cake
00035  * @subpackage  cake.cake.libs.controller.components
00036  */
00037 class AclComponent extends Object {
00038 /**
00039  * Instance of ACL_CLASSNAME set in app/config/core.php
00040  *
00041  * @var object
00042  */
00043     var $_instance = null;
00044 /**
00045  * Enter description here...
00046  *
00047  * @var boolean
00048  */
00049     var $controller = true;
00050 /**
00051  * Constructor.
00052  *
00053  * Will return an instance of the correct ACL class.
00054  */
00055     function __construct() {
00056         $this->getACL();
00057     }
00058 /**
00059  * Static function used to gain an instance of the correct ACL class.
00060  *
00061  * @return object instance of ACL_CLASSNAME set in app/config/core.php
00062  * @access public
00063  */
00064     function &getACL() {
00065         if ($this->_instance == null) {
00066             uses('controller' . DS . 'components' . DS . ACL_FILENAME);
00067             $classname = ACL_CLASSNAME;
00068             $this->_instance = new $classname;
00069         }
00070 
00071         if ($classname == 'DB_ACL') {
00072             $this->Aro = new Aro();
00073             $this->Aco = new Aco();
00074         }
00075         return $this->_instance;
00076     }
00077 /**
00078  * Empty class defintion, to be overridden in subclasses.
00079  *
00080  * @access public
00081  */
00082     function _initACL() {
00083     }
00084 /**
00085  * Pass-thru function for ACL check instance.
00086  *
00087  * @param string $aro
00088  * @param string $aco
00089  * @param string $action : default = *
00090  * @return boolean
00091  * @access public
00092  */
00093     function check($aro, $aco, $action = "*") {
00094         return $this->_instance->check($aro, $aco, $action);
00095     }
00096 /**
00097  * Pass-thru function for ACL allow instance.
00098  *
00099  * @param string $aro
00100  * @param string $aco
00101  * @param string $action : default = *
00102  * @return boolean
00103  * @access public
00104  */
00105     function allow($aro, $aco, $action = "*") {
00106         return $this->_instance->allow($aro, $aco, $action);
00107     }
00108 /**
00109  * Pass-thru function for ACL deny instance.
00110  *
00111  * @param string $aro
00112  * @param string $aco
00113  * @param string $action : default = *
00114  * @return boolean
00115  * @abstract public
00116  */
00117     function deny($aro, $aco, $action = "*") {
00118         return $this->_instance->deny($aro, $aco, $action);
00119     }
00120 /**
00121  * Pass-thru function for ACL inherit instance.
00122  *
00123  * @return boolean
00124  * @abstract public
00125  */
00126     function inherit($aro, $aco, $action = "*") {
00127         return $this->_instance->inherit($aro, $aco, $action);
00128     }
00129 /**
00130  * Pass-thru function for ACL grant instance.
00131  *
00132  * @param string $aro
00133  * @param string $aco
00134  * @param string $action : default = *
00135  * @return boolean
00136  * @access public
00137  */
00138     function grant($aro, $aco, $action = "*") {
00139         return $this->_instance->grant($aro, $aco, $action);
00140     }
00141 /**
00142  * Pass-thru function for ACL grant instance.
00143  *
00144  * @param string $aro
00145  * @param string $aco
00146  * @param string $action : default = *
00147  * @return boolean
00148  * @access public
00149  */
00150     function revoke($aro, $aco, $action = "*") {
00151         return $this->_instance->revoke($aro, $aco, $action);
00152     }
00153 /**
00154  * Sets the current ARO instance to object from getAro
00155  *
00156  * @param string $id
00157  * @return boolean
00158  * @access public
00159  */
00160     function setAro($id) {
00161         return $this->Aro = $this->_instance->getAro($id);
00162     }
00163 /**
00164 * Sets the current ACO instance to object from getAco
00165  *
00166  * @param string $id
00167  * @return boolean
00168  * @access public
00169  */
00170     function setAco($id) {
00171         return $this->Aco = $this->_instance->getAco($id);
00172     }
00173 /**
00174  * Pass-thru function for ACL getAro instance
00175  * that gets an ARO object from the given id or alias
00176  *
00177  * @param string $id
00178  * @return object Aro
00179  * @access public
00180  */
00181     function getAro($id) {
00182         return $this->_instance->getAro($id);
00183     }
00184 /**
00185  * Pass-thru function for ACL getAco instance.
00186  * that gets an ACO object from the given id or alias
00187  *
00188  * @param string $id
00189  * @return object Aco
00190  * @access public
00191  */
00192     function getAco($id) {
00193         return $this->_instance->getAco($id);
00194     }
00195 }
00196 ?>