mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +00:00
Updating view() to use node references.
updating test cases to use new formating.
This commit is contained in:
parent
e6b32e21ad
commit
eda74d08b4
2 changed files with 28 additions and 27 deletions
|
@ -54,7 +54,7 @@ class AclShell extends Shell {
|
||||||
* @var string
|
* @var string
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $dataSource = 'default';
|
var $connection = 'default';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains tasks to load and instantiate
|
* Contains tasks to load and instantiate
|
||||||
|
@ -70,10 +70,8 @@ class AclShell extends Shell {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function startup() {
|
function startup() {
|
||||||
$this->dataSource = 'default';
|
if (isset($this->params['connection'])) {
|
||||||
|
$this->connection = $this->params['connection'];
|
||||||
if (isset($this->params['datasource'])) {
|
|
||||||
$this->dataSource = $this->params['datasource'];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!in_array(Configure::read('Acl.classname'), array('DbAcl', 'DB_ACL'))) {
|
if (!in_array(Configure::read('Acl.classname'), array('DbAcl', 'DB_ACL'))) {
|
||||||
|
@ -227,6 +225,8 @@ class AclShell extends Shell {
|
||||||
__("No tree returned.", true)
|
__("No tree returned.", true)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
$this->out(__('Path:', true));
|
||||||
|
$this->hr();
|
||||||
for ($i = 0; $i < count($nodes); $i++) {
|
for ($i = 0; $i < count($nodes); $i++) {
|
||||||
$this->_outputNode($class, $nodes[$i], $i);
|
$this->_outputNode($class, $nodes[$i], $i);
|
||||||
}
|
}
|
||||||
|
@ -324,12 +324,14 @@ class AclShell extends Shell {
|
||||||
$this->_checkArgs(1, 'view');
|
$this->_checkArgs(1, 'view');
|
||||||
$this->checkNodeType();
|
$this->checkNodeType();
|
||||||
extract($this->__dataVars());
|
extract($this->__dataVars());
|
||||||
|
|
||||||
if (isset($this->args[1]) && !is_null($this->args[1])) {
|
if (isset($this->args[1]) && !is_null($this->args[1])) {
|
||||||
$key = ife(is_numeric($this->args[1]), $secondary_id, 'alias');
|
$key = is_numeric($this->args[1]) ? $secondary_id : 'alias';
|
||||||
$conditions = array($class . '.' . $key => $this->args[1]);
|
$conditions = array($class . '.' . $key => $this->args[1]);
|
||||||
} else {
|
} else {
|
||||||
$conditions = null;
|
$conditions = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$nodes = $this->Acl->{$class}->find('all', array('conditions' => $conditions, 'order' => 'lft ASC'));
|
$nodes = $this->Acl->{$class}->find('all', array('conditions' => $conditions, 'order' => 'lft ASC'));
|
||||||
if (empty($nodes)) {
|
if (empty($nodes)) {
|
||||||
if (isset($this->args[1])) {
|
if (isset($this->args[1])) {
|
||||||
|
@ -340,8 +342,10 @@ class AclShell extends Shell {
|
||||||
}
|
}
|
||||||
$this->out($class . " tree:");
|
$this->out($class . " tree:");
|
||||||
$this->hr();
|
$this->hr();
|
||||||
|
|
||||||
$stack = array();
|
$stack = array();
|
||||||
$last = null;
|
$last = null;
|
||||||
|
|
||||||
foreach ($nodes as $n) {
|
foreach ($nodes as $n) {
|
||||||
$stack[] = $n;
|
$stack[] = $n;
|
||||||
if (!empty($last)) {
|
if (!empty($last)) {
|
||||||
|
@ -357,12 +361,8 @@ class AclShell extends Shell {
|
||||||
}
|
}
|
||||||
$last = $n[$class]['rght'];
|
$last = $n[$class]['rght'];
|
||||||
$count = count($stack);
|
$count = count($stack);
|
||||||
$indent = str_repeat(' ', $count);
|
|
||||||
if ($n[$class]['alias']) {
|
$this->_outputNode($class, $n, $count);
|
||||||
$this->out($indent . "[" . $n[$class]['id'] . "]" . $n[$class]['alias']."\n");
|
|
||||||
} else {
|
|
||||||
$this->out($indent . "[" . $n[$class]['id'] . "]" . $n[$class]['model'] . '.' . $n[$class]['foreign_key'] . "\n");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$this->hr();
|
$this->hr();
|
||||||
}
|
}
|
||||||
|
@ -409,7 +409,7 @@ class AclShell extends Shell {
|
||||||
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
|
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
|
||||||
"\t" . __("see help for the 'create' command.", true),
|
"\t" . __("see help for the 'create' command.", true),
|
||||||
|
|
||||||
'setparent' => "setParent aro|aco <node> <parent>\n" .
|
'setparent' => "setParent aro|aco <node> <parent node>\n" .
|
||||||
"\t" . __("Moves the ACL object specified by <node> beneath", true) . "\n" .
|
"\t" . __("Moves the ACL object specified by <node> beneath", true) . "\n" .
|
||||||
"\t" . __("the parent ACL object specified by <parent>.", true) . "\n" .
|
"\t" . __("the parent ACL object specified by <parent>.", true) . "\n" .
|
||||||
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
|
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
|
||||||
|
@ -422,26 +422,26 @@ class AclShell extends Shell {
|
||||||
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
|
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
|
||||||
"\t" . __("see help for the 'create' command.", true),
|
"\t" . __("see help for the 'create' command.", true),
|
||||||
|
|
||||||
'check' => "check <aro_id> <aco_id> [<aco_action>] " . __("or", true) . " all\n" .
|
'check' => "check <node> <node> [<aco_action>] " . __("or", true) . " all\n" .
|
||||||
"\t" . __("Use this command to check ACL permissions.", true) . "\n" .
|
"\t" . __("Use this command to check ACL permissions.", true) . "\n" .
|
||||||
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
|
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
|
||||||
"\t" . __("see help for the 'create' command.", true),
|
"\t" . __("see help for the 'create' command.", true),
|
||||||
|
|
||||||
'grant' => "grant <aro_id> <aco_id> [<aco_action>] " . __("or", true) . " all\n" .
|
'grant' => "grant <node> <node> [<aco_action>] " . __("or", true) . " all\n" .
|
||||||
"\t" . __("Use this command to grant ACL permissions. Once executed, the ARO", true) . "\n" .
|
"\t" . __("Use this command to grant ACL permissions. Once executed, the ARO", true) . "\n" .
|
||||||
"\t" . __("specified (and its children, if any) will have ALLOW access to the", true) . "\n" .
|
"\t" . __("specified (and its children, if any) will have ALLOW access to the", true) . "\n" .
|
||||||
"\t" . __("specified ACO action (and the ACO's children, if any).", true) . "\n" .
|
"\t" . __("specified ACO action (and the ACO's children, if any).", true) . "\n" .
|
||||||
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
|
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
|
||||||
"\t" . __("see help for the 'create' command.", true),
|
"\t" . __("see help for the 'create' command.", true),
|
||||||
|
|
||||||
'deny' => "deny <aro_id> <aco_id> [<aco_action>]" . __("or", true) . " all\n" .
|
'deny' => "deny <node> <node> [<aco_action>]" . __("or", true) . " all\n" .
|
||||||
"\t" . __("Use this command to deny ACL permissions. Once executed, the ARO", true) . "\n" .
|
"\t" . __("Use this command to deny ACL permissions. Once executed, the ARO", true) . "\n" .
|
||||||
"\t" . __("specified (and its children, if any) will have DENY access to the", true) . "\n" .
|
"\t" . __("specified (and its children, if any) will have DENY access to the", true) . "\n" .
|
||||||
"\t" . __("specified ACO action (and the ACO's children, if any).", true) . "\n" .
|
"\t" . __("specified ACO action (and the ACO's children, if any).", true) . "\n" .
|
||||||
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
|
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
|
||||||
"\t" . __("see help for the 'create' command.", true),
|
"\t" . __("see help for the 'create' command.", true),
|
||||||
|
|
||||||
'inherit' => "inherit <aro_id> <aco_id> [<aco_action>]" . __("or", true) . " all\n" .
|
'inherit' => "inherit <node> <node> [<aco_action>]" . __("or", true) . " all\n" .
|
||||||
"\t" . __("Use this command to force a child ARO object to inherit its", true) . "\n" .
|
"\t" . __("Use this command to force a child ARO object to inherit its", true) . "\n" .
|
||||||
"\t" . __("permissions settings from its parent.", true) . "\n" .
|
"\t" . __("permissions settings from its parent.", true) . "\n" .
|
||||||
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
|
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
|
||||||
|
@ -449,7 +449,8 @@ class AclShell extends Shell {
|
||||||
|
|
||||||
'view' => "view aro|aco [<node>]\n" .
|
'view' => "view aro|aco [<node>]\n" .
|
||||||
"\t" . __("The view command will return the ARO or ACO tree.", true) . "\n" .
|
"\t" . __("The view command will return the ARO or ACO tree.", true) . "\n" .
|
||||||
"\t" . __("The optional id/alias parameter allows you to return\n\tonly a portion of the requested tree.", true) . "\n" .
|
"\t" . __("The optional node parameter allows you to return", true) . "\n" .
|
||||||
|
"\t" . __("only a portion of the requested tree.", true) . "\n" .
|
||||||
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
|
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
|
||||||
"\t" . __("see help for the 'create' command.", true),
|
"\t" . __("see help for the 'create' command.", true),
|
||||||
|
|
||||||
|
@ -482,7 +483,7 @@ class AclShell extends Shell {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ($this->args[0] != 'aco' && $this->args[0] != 'aro') {
|
if ($this->args[0] != 'aco' && $this->args[0] != 'aro') {
|
||||||
$this->error(sprintf(__("Missing/Unknown node type: '%s'", true), $this->args[1]), __('Please specify which ACL object type you wish to create.', true));
|
$this->error(sprintf(__("Missing/Unknown node type: '%s'", true), $this->args[1]), __('Please specify which ACL object type you wish to create. Either "aro" or "aco"', true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -125,9 +125,9 @@ class AclShellTest extends CakeTestCase {
|
||||||
$this->Task->args[0] = 'aro';
|
$this->Task->args[0] = 'aro';
|
||||||
|
|
||||||
$this->Task->expectAt(0, 'out', array('Aro tree:'));
|
$this->Task->expectAt(0, 'out', array('Aro tree:'));
|
||||||
$this->Task->expectAt(1, 'out', array(new PatternExpectation('/\[1\]ROOT/')));
|
$this->Task->expectAt(1, 'out', array(new PatternExpectation('/\[1\] ROOT/')));
|
||||||
$this->Task->expectAt(3, 'out', array(new PatternExpectation('/\[3\]Gandalf/')));
|
$this->Task->expectAt(3, 'out', array(new PatternExpectation('/\[3\] Gandalf/')));
|
||||||
$this->Task->expectAt(5, 'out', array(new PatternExpectation('/\[5\]MyModel.2/')));
|
$this->Task->expectAt(5, 'out', array(new PatternExpectation('/\[5\] MyModel.2/')));
|
||||||
|
|
||||||
$this->Task->view();
|
$this->Task->view();
|
||||||
}
|
}
|
||||||
|
@ -295,9 +295,9 @@ class AclShellTest extends CakeTestCase {
|
||||||
**/
|
**/
|
||||||
function testGetPath() {
|
function testGetPath() {
|
||||||
$this->Task->args = array('aro', 'AuthUser.2');
|
$this->Task->args = array('aro', 'AuthUser.2');
|
||||||
$this->Task->expectAt(0, 'out', array('[1] ROOT'));
|
$this->Task->expectAt(1, 'out', array('[1] ROOT'));
|
||||||
$this->Task->expectAt(1, 'out', array(' [2] admins'));
|
$this->Task->expectAt(2, 'out', array(' [2] admins'));
|
||||||
$this->Task->expectAt(2, 'out', array(' [4] Elrond'));
|
$this->Task->expectAt(3, 'out', array(' [4] Elrond'));
|
||||||
$this->Task->getPath();
|
$this->Task->getPath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue