Permalink
Browse files

allow more elaborate regex rules

  • Loading branch information...
1 parent b5671eb commit bfaea78504f321831a0583d631ae524b5884a7bd @0x20h 0x20h committed Jan 13, 2012
Showing with 15 additions and 19 deletions.
  1. +14 −16 lib/Cake/Controller/Component/Acl/PhpAcl.php
  2. +1 −3 lib/Cake/Test/test_app/Config/acl.php
@@ -43,9 +43,9 @@ public function __construct() {
);
}
/**
- * Phptialize method
- *
- * @param AclBase $component
+ * Initialize method
+ *
+ * @param AclComponent $Component Component instance
* @return void
*/
public function initialize($Component) {
@@ -61,12 +61,13 @@ public function initialize($Component) {
$Component->Aro = $this->Aro;
}
-
- public function build($config) {
- if ($config instanceOf ConfigReaderInterface) {
- $config = $config->read(basename($this->options['config']));
- }
-
+/**
+ * build and setup internal ACL representation
+ *
+ * @param array $config configuration array, see docs
+ * @return void
+ */
+ public function build(array $config) {
if (empty($config['roles'])) {
throw new AclException(__d('cake_dev','"roles" section not found in configuration.'));
}
@@ -110,14 +111,15 @@ public function deny($aro, $aco, $action = "*") {
}
/**
- * No op method, inherit cannot be done with PhpAcl
+ * No op method
*
* @param string $aro ARO The requesting object identifier.
* @param string $aco ACO The controlled object identifier.
* @param string $action Action (defaults to *)
* @return boolean Success
*/
public function inherit($aro, $aco, $action = "*") {
+ return false;
}
/**
@@ -192,7 +194,7 @@ public function __construct(array $rules = array()) {
}
/**
- * return path to the requested ACO with allow and deny rules for each level
+ * return path to the requested ACO with allow and deny rules attached on each level
*
* @return array
*/
@@ -202,7 +204,7 @@ public function path($aco) {
$level = 0;
$root = $this->tree;
$stack = array(array($root, 0));
-
+
while (!empty($stack)) {
list($root, $level) = array_pop($stack);
@@ -211,10 +213,6 @@ public function path($aco) {
}
foreach ($root as $node => $elements) {
- if (strpos($node, '*') === false && $node != $aco[$level]) {
- continue;
- }
-
$pattern = '#^'.str_replace(array_keys(self::$modifiers), array_values(self::$modifiers), $node).'$#';
if ($node == $aco[$level] || preg_match($pattern, $aco[$level])) {
@@ -59,9 +59,7 @@
'/controllers/invoices/*' => 'Role/accounting',
'/controllers/invoices/edit'=> 'User/db_manager_2',
'/controllers/db/*' => 'Role/database_manager',
- '/controllers/*/add' => 'User/stan',
- '/controllers/*/edit' => 'User/stan',
- '/controllers/*/publish' => 'User/stan',
+ '/controllers/*/(add|edit|publish)' => 'User/stan',
'/controllers/users/dashboard' => 'Role/default',
// test for case insensitivity
'controllers/Forms/NEW' => 'Role/data_acquirer',

0 comments on commit bfaea78

Please sign in to comment.