Merging changes into trunk

git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1565 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2005-12-22 01:07:28 +00:00
parent 94e5730b41
commit 526e1ac450
18 changed files with 1186 additions and 785 deletions

View file

@ -41,22 +41,26 @@
* @since CakePHP v 0.10.0.1076
*
*/
class AclComponent
class AclComponent extends Object
{
var $_instance = null;
var $controller = true;
/**
* Enter description here...
*
*/
function __construct()
{
$this->getACL();
}
/**
* Static function used to gain an instance of the correct ACL class.
*
* @return MyACL
*/
/**
* Static function used to gain an instance of the correct ACL class.
*
* @return MyACL
*/
function &getACL()
{
if($this->_instance == null)
@ -68,89 +72,93 @@ class AclComponent
return $this->_instance;
}
/**
* Enter description here...
*
*/
function _initACL()
{
}
/**
* Pass-thru function for ACL check instance.
*
* @return boolean
*/
/**
* Pass-thru function for ACL check instance.
*
* @return boolean
*/
function check($aro, $aco, $action = "*")
{
return $this->_instance->check($aro, $aco, $action);
}
/**
* Pass-thru function for ACL allow instance.
*
* @return boolean
*/
/**
* Pass-thru function for ACL allow instance.
*
* @return boolean
*/
function allow($aro, $aco, $action = "*")
{
return $this->_instance->allow($aro, $aco, $action);
}
/**
* Pass-thru function for ACL deny instance.
*
* @return boolean
*/
/**
* Pass-thru function for ACL deny instance.
*
* @return boolean
*/
function deny($aro, $aco, $action = "*")
{
return $this->_instance->deny($aro, $aco, $action);
}
/**
* Pass-thru function for ACL inherit instance.
*
* @return boolean
*/
/**
* Pass-thru function for ACL inherit instance.
*
* @return boolean
*/
function inherit($aro, $aco, $action = "*")
{
return $this->_instance->inherit($aro, $aco, $action);
}
/**
* Pass-thru function for ACL grant instance.
*
* @return boolean
*/
/**
* Pass-thru function for ACL grant instance.
*
* @return boolean
*/
function grant($aro, $aco, $action = "*")
{
return $this->_instance->grant($aro, $aco, $action);
}
/**
* Pass-thru function for ACL grant instance.
*
* @return boolean
*/
/**
* Pass-thru function for ACL grant instance.
*
* @return boolean
*/
function revoke($aro, $aco, $action = "*")
{
return $this->_instance->revoke($aro, $aco, $action);
}
/**
* Pass-thru function for ACL getAro instance.
*
* @return Aro
*/
/**
* Pass-thru function for ACL getAro instance.
*
* @return Aro
*/
function getAro($id)
{
return $this->_instance->getAro($id);
}
/**
* Pass-thru function for ACL getAco instance.
*
* @return Aco
*/
/**
* Pass-thru function for ACL getAco instance.
*
* @return Aco
*/
function getAco($id)
{
return $this->_instance->getAco($id);

View file

@ -1,35 +1,40 @@
<?php
//////////////////////////////////////////////////////////////////////////
// + $Id$
// +------------------------------------------------------------------+ //
// + Cake PHP : Rapid Development Framework <http://www.cakephp.org/> + //
// + Copyright: (c) 2005, CakePHP Authors/Developers + //
// + Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com> + //
// + Larry E. Masters aka PhpNut <nut@phpnut.com> + //
// + Kamil Dzielinski aka Brego <brego.dk@gmail.com> + //
// +------------------------------------------------------------------+ //
// + Licensed under The MIT License + //
// + Redistributions of files must retain the above copyright notice. + //
// + See: http://www.opensource.org/licenses/mit-license.php + //
//////////////////////////////////////////////////////////////////////////
/* SVN FILE: $Id$ */
/**
* Access Control List abstract class.
*
* @filesource
* @author CakePHP Authors/Developers
* @copyright Copyright (c) 2005, CakePHP Authors/Developers
* @link https://trac.cakephp.org/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.cake.libs.controller.components
* @since CakePHP v 0.10.0.1076
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @author CakePHP Authors/Developers
* @copyright Copyright (c) 2005, CakePHP Authors/Developers
* @link https://trac.cakephp.org/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.cake.libs.controller.components
* @since CakePHP v 0.10.0.1232
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Enter description here...
*
* @return AclBase
*/
uses('error_messages');
/**
@ -44,6 +49,11 @@ uses('error_messages');
class AclBase
{
/**
* Enter description here...
*
* @return AclBase
*/
function AclBase()
{
//No instantiations or constructor calls (even statically)
@ -55,6 +65,13 @@ class AclBase
}
/**
* Enter description here...
*
* @param unknown_type $aro
* @param unknown_type $aco
* @param unknown_type $action
*/
function check($aro, $aco, $action = "*") {}
}

View file

@ -11,8 +11,7 @@
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
* Larry E. Masters aka PhpNut <nut@phpnut.com>
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License
@ -23,7 +22,7 @@
* @copyright Copyright (c) 2005, CakePHP Authors/Developers
* @link https://trac.cakephp.org/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.cake.app.controllers.componenets
* @subpackage cake.cake.app.controllers.componenets.dbacl
* @since CakePHP v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
@ -31,6 +30,7 @@
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
uses('inflector');
uses('controller'.DS.'components'.DS.'acl_base');
uses('controller'.DS.'components'.DS.'dbacl'.DS.'models'.DS.'aclnode');
uses('controller'.DS.'components'.DS.'dbacl'.DS.'models'.DS.'aco');
@ -42,17 +42,29 @@ uses('controller'.DS.'components'.DS.'dbacl'.DS.'models'.DS.'aros_aco');
* In this file you can extend the AclBase.
*
* @package cake
* @subpackage cake.cake.app.controllers.components
* @subpackage cake.cake.app.controllers.components.dbacl
*/
class DB_ACL extends AclBase
{
/**
* Enter description here...
*
*/
function __construct()
{
}
/**
* Enter description here...
*
* @param unknown_type $aro
* @param unknown_type $aco
* @param unknown_type $action
* @return unknown
*/
function check($aro, $aco, $action = "*")
{
@ -97,9 +109,12 @@ class DB_ACL extends AclBase
// ARO must be cleared for ALL ACO actions
foreach($permKeys as $key)
{
if($perm['aros_acos'][$key] != 1)
if(isset($perm['aros_acos']))
{
return false;
if($perm['aros_acos'][$key] != 1)
{
return false;
}
}
}
return true;
@ -124,11 +139,11 @@ class DB_ACL extends AclBase
return false;
}
/**
* Allow
*
* @return boolean
*/
/**
* Allow
*
* @return boolean
*/
function allow($aro, $aco, $action = "*", $value = 1)
{
$Perms = new ArosAco();
@ -192,41 +207,41 @@ class DB_ACL extends AclBase
return true;
}
/**
* Deny
*
* @return boolean
*/
/**
* Deny
*
* @return boolean
*/
function deny($aro, $aco, $action = "*")
{
return $this->allow($aro, $aco, $action, -1);
}
/**
* Inherit
*
* @return boolean
*/
/**
* Inherit
*
* @return boolean
*/
function inherit($aro, $aco, $action = "*")
{
return $this->allow($aro, $aco, $action, 0);
}
/**
* Allow alias
*
* @return boolean
*/
/**
* Allow alias
*
* @return boolean
*/
function grant($aro, $aco, $action = "*")
{
return $this->allow($aro, $aco, $action);
}
/**
* Deny alias
*
* @return boolean
*/
/**
* Deny alias
*
* @return boolean
*/
function revoke($aro, $aco, $action = "*")
{
return $this->deny($aro, $aco, $action);
@ -234,6 +249,12 @@ class DB_ACL extends AclBase
/**
* Enter description here...
*
* @param unknown_type $id
* @return unknown
*/
function getAro($id = null)
{
if($id == null)
@ -247,6 +268,12 @@ class DB_ACL extends AclBase
}
/**
* Enter description here...
*
* @param unknown_type $id
* @return unknown
*/
function getAco($id = null)
{
if($id == null)
@ -260,6 +287,13 @@ class DB_ACL extends AclBase
}
/**
* Enter description here...
*
* @param unknown_type $aro
* @param unknown_type $aco
* @return unknown
*/
function getAclLink($aro, $aco)
{
$Aro = new Aro();
@ -281,6 +315,12 @@ class DB_ACL extends AclBase
);
}
/**
* Enter description here...
*
* @param unknown_type $keys
* @return unknown
*/
function _getAcoKeys($keys)
{
$newKeys = array();

View file

@ -1,17 +1,77 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @author CakePHP Authors/Developers
* @copyright Copyright (c) 2005, CakePHP Authors/Developers
* @link https://trac.cakephp.org/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.cake.libs.controller.components.dbacl.models
* @since CakePHP v 0.10.0.1232
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Short description.
*/
require_once(CAKE . 'app_model.php');
/**
* Short description for file.
*
* Long description for file
*
* @package cake
* @subpackage cake.cake.libs.controller.components.dbacl.models
* @since CakePHP v 0.10.0.1232
*
*/
class AclNode extends AppModel
{
/**
* Enter description here...
*
* @var unknown_type
*/
var $useTable = false;
/**
* Enter description here...
*
*/
function __construct()
{
parent::__construct();
$this->__setTable();
}
/**
* Enter description here...
*
* @param unknown_type $link_id
* @param unknown_type $parent_id
* @param unknown_type $alias
* @return unknown
*/
function create($link_id = 0, $parent_id = null, $alias = '')
{
parent::create();
@ -58,6 +118,13 @@ class AclNode extends AppModel
}
/**
* Enter description here...
*
* @param unknown_type $parent_id
* @param unknown_type $id
* @return unknown
*/
function setParent($parent_id = null, $id = null)
{
if (strtolower(get_class($this)) == "aclnode")
@ -121,6 +188,12 @@ class AclNode extends AppModel
}
/**
* Enter description here...
*
* @param unknown_type $id
* @return unknown
*/
function getParent($id)
{
$path = $this->getPath($id);
@ -134,6 +207,12 @@ class AclNode extends AppModel
}
}
/**
* Enter description here...
*
* @param unknown_type $id
* @return unknown
*/
function getPath($id)
{
if (strtolower(get_class($this)) == "aclnode")
@ -147,6 +226,12 @@ class AclNode extends AppModel
return $this->findAll("lft <= {$item[$class]['lft']} and rght >= {$item[$class]['rght']}");
}
/**
* Enter description here...
*
* @param unknown_type $id
* @return unknown
*/
function getChildren($id)
{
if (strtolower(get_class($this)) == "aclnode")
@ -160,6 +245,13 @@ class AclNode extends AppModel
return $this->findAll("lft > {$item[$class]['lft']} and rght < {$item[$class]['rght']}");
}
/**
* Enter description here...
*
* @param unknown_type $id
* @param unknown_type $fKey
* @return unknown
*/
function _resolveID($id, $fKey)
{
$key = (is_string($id) ? 'alias' : $fKey);
@ -167,6 +259,14 @@ class AclNode extends AppModel
return "{$key} = {$val}";
}
/**
* Enter description here...
*
* @param unknown_type $table
* @param unknown_type $dir
* @param unknown_type $lft
* @param unknown_type $rght
*/
function _syncTable($table, $dir, $lft, $rght)
{
$shift = ($dir == 2 ? 1 : 2);
@ -174,17 +274,26 @@ class AclNode extends AppModel
$this->db->query("UPDATE $table SET lft = lft " . ($dir > 0 ? "+" : "-") . " {$shift} WHERE lft > " . $lft);
}
/**
* Enter description here...
*
* @return unknown
*/
function __dataVars()
{
$vars = array();
$class = strtolower(get_class($this));
$vars['secondary_id'] = ($class == 'aro' ? 'user_id' : 'object_id');
$class = Inflector::camelize(strtolower(get_class($this)));
$vars['secondary_id'] = (strtolower($class) == 'aro' ? 'user_id' : 'object_id');
$vars['data_name'] = $class;
$vars['table_name'] = $class . 's';
$vars['class'] = ucwords($class);
$vars['class'] = Inflector::camelize($class);
return $vars;
}
/**
* Enter description here...
*
*/
function __setTable()
{
$this->table = strtolower(get_class($this)) . "s";

View file

@ -1,8 +1,53 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @author CakePHP Authors/Developers
* @copyright Copyright (c) 2005, CakePHP Authors/Developers
* @link https://trac.cakephp.org/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.cake.libs.controller.components.dbacl.models
* @since CakePHP v 0.10.0.1232
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Short description for file.
*
* Long description for file
*
* @package cake
* @subpackage cake.cake.libs.controller.components.dbacl.models
* @since CakePHP v 0.10.0.1232
*
*/
class Aco extends AclNode
{
var $name = 'Aco';
/**
* Enter description here...
*
* @var unknown_type
*/
var $hasMany = 'ArosAco,AcoActions';
}

View file

@ -1,9 +1,58 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @author CakePHP Authors/Developers
* @copyright Copyright (c) 2005, CakePHP Authors/Developers
* @link https://trac.cakephp.org/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.cake.libs.controller.components.dbacl.models
* @since CakePHP v 0.10.0.1232
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Short description.
*/
require_once(CAKE.'app_model.php');
/**
* Short description for file.
*
* Long description for file
*
* @package cake
* @subpackage cake.cake.libs.controller.components.dbacl.models
* @since CakePHP v 0.10.0.1232
*
*/
class AcoAction extends AppModel
{
/**
* Enter description here...
*
* @var unknown_type
*/
var $belongsTo = 'Aco';
}

View file

@ -1,8 +1,60 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @author CakePHP Authors/Developers
* @copyright Copyright (c) 2005, CakePHP Authors/Developers
* @link https://trac.cakephp.org/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.cake.libs.controller.components.dbacl.models
* @since CakePHP v 0.10.0.1232
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Short description for file.
*
* Long description for file
*
* @package cake
* @subpackage cake.cake.libs.controller.components.dbacl.models
* @since CakePHP v 0.10.0.1232
*
*/
class Aro extends AclNode
{
var $hasMany = 'ArosAco';
/**
* Enter description here...
*
* @var unknown_type
*/
var $name = 'Aro';
/**
* Enter description here...
*
* @var unknown_type
*/
var $hasMany = 'ArosAco';
}

View file

@ -1,8 +1,66 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @author CakePHP Authors/Developers
* @copyright Copyright (c) 2005, CakePHP Authors/Developers
* @link https://trac.cakephp.org/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.cake.libs.controller.components.dbacl.models
* @since CakePHP v 0.10.0.1232
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Short description for file.
*
* Long description for file
*
* @package cake
* @subpackage cake.cake.libs.controller.components.dbacl.models
* @since CakePHP v 0.10.0.1232
*
*/
class ArosAco extends AppModel
{
/**
* Enter description here...
*
* @var unknown_type
*/
var $name = 'ArosAco';
/**
* Enter description here...
*
* @var unknown_type
*/
var $useTable = 'aros_acos';
/**
* Enter description here...
*
* @var unknown_type
*/
var $belongsTo = 'Aro,Aco';
}

View file

@ -31,7 +31,7 @@
/**
* Short description for file.
*
*
* Long description for file
*
* @package cake
@ -39,19 +39,19 @@
* @since CakePHP v 0.10.0.1232
*
*/
class SessionComponent extends Object
{
class SessionComponent extends Object
{
/**
* Enter description here...
*
*/
function __construct ()
function __construct ()
{
$this->CakeSession = New CakeSession();
parent::__construct();
}
/**
* Enter description here...
*
@ -65,7 +65,7 @@ class SessionComponent extends Object
{
return $this->CakeSession->writeSessionVar($name, $value);
}
/**
* Enter description here...
*
@ -79,7 +79,7 @@ class SessionComponent extends Object
{
return $this->CakeSession->readSessionVar($name);
}
/**
* Enter description here...
*
@ -92,7 +92,7 @@ class SessionComponent extends Object
{
return $this->CakeSession->delSessionVar($name);
}
/**
* Enter description here...
*
@ -105,7 +105,7 @@ class SessionComponent extends Object
{
return $this->CakeSession->checkSessionVar($name);
}
/**
* Enter description here...
*
@ -117,11 +117,11 @@ class SessionComponent extends Object
{
return $this->CakeSession->getLastError();
}
/**
* Enter description here...
*
* Use like this. $this->Session->setError();
* Use like this. $this->Session->setFlash('This has been saved');
*
* @return string Last session error
*/
@ -133,7 +133,7 @@ class SessionComponent extends Object
/**
* Enter description here...
*
* Use like this. $this->Session->setError();
* Use like this. $this->Session->flash();
*
* @return
*/
@ -148,9 +148,9 @@ class SessionComponent extends Object
{
return false;
}
}
/**
* Enter description here...
*
@ -164,6 +164,6 @@ class SessionComponent extends Object
{
return $this->CakeSession->isValid();
}
}
?>