From 4389da119de338ab6683d94aa31c603e1aaf41d5 Mon Sep 17 00:00:00 2001 From: gwoo Date: Sun, 9 Mar 2008 22:31:44 +0000 Subject: [PATCH] fixes #4221, AclShell . format git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6544 3807eeeb-6ff5-0310-8944-8be069107fe0 --- cake/console/libs/acl.php | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/cake/console/libs/acl.php b/cake/console/libs/acl.php index b1e6bcfd7..676e2d81e 100644 --- a/cake/console/libs/acl.php +++ b/cake/console/libs/acl.php @@ -26,7 +26,8 @@ * @lastmodified $Date$ * @license http://www.opensource.org/licenses/mit-license.php The MIT License */ -uses ('controller'.DS.'components'.DS.'acl', 'model'.DS.'db_acl'); +App::import('Component', 'Acl'); +App::import('Model', 'DbAcl'); /** * Shell for ACL management. * @@ -211,7 +212,7 @@ class AclShell extends Shell { ) ); $this->Acl->{$class}->create(); - if(!$this->Acl->{$class}->save($data)) { + if (!$this->Acl->{$class}->save($data)) { $this->out(__("Error in setting new parent. Please make sure the parent node exists, and is not a descendant of the node specified.", true), true); } else { $this->out(sprintf(__("Node parent set to %s", true), $this->args[2]) . "\n", true); @@ -410,7 +411,7 @@ class AclShell extends Shell { "\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n", 'initdb' => "\tinitdb\n". - "\t\t" . __("Use this command : cake schema run create DbAcl", true) . "\n", + "\t\t" . __("Uses this command : cake schema run create DbAcl", true) . "\n", 'help' => "\thelp []\n" . "\t\t" . __("Displays this help message, or a message on a specific command.", true) . "\n" @@ -471,8 +472,22 @@ class AclShell extends Shell { $aro = ife(is_numeric($this->args[0]), intval($this->args[0]), $this->args[0]); $aco = ife(is_numeric($this->args[1]), intval($this->args[1]), $this->args[1]); + if (is_string($aro) && preg_match('/^([\w]+)\.(.*)$/', $aro, $matches)) { + $aro = array( + 'model' => $matches[1], + 'foreign_key' => $matches[2], + ); + } + + if (is_string($aco) && preg_match('/^([\w]+)\.(.*)$/', $aco, $matches)) { + $aco = array( + 'model' => $matches[1], + 'foreign_key' => $matches[2], + ); + } + $action = null; - if(isset($this->args[2])) { + if (isset($this->args[2])) { $action = $this->args[2]; if ($action == '' || $action == 'all') { $action = '*'; @@ -501,4 +516,4 @@ class AclShell extends Shell { return $vars; } } -?> +?> \ No newline at end of file