Skip to content

Commit

Permalink
Fixing notice error when non-existant node type is used.
Browse files Browse the repository at this point in the history
Fixing view() so you can view a slice of the tree.
  • Loading branch information
markstory committed Aug 7, 2009
1 parent ae89e70 commit 2cc8ae6
Showing 1 changed file with 20 additions and 10 deletions.
30 changes: 20 additions & 10 deletions cake/console/libs/acl.php
@@ -1,6 +1,6 @@
<?php
/**
* Acl Shell provides Acl access in the CLI environment
* Acl Shell provides Acl access in the CLI environment
*
* PHP versions 4 and 5
*
Expand Down Expand Up @@ -218,7 +218,7 @@ function getPath() {

if (empty($nodes)) {
$this->error(
sprintf(__("Supplied Node '%s' not found", true), $this->args[1]),
sprintf(__("Supplied Node '%s' not found", true), $this->args[1]),
__("No tree returned.", true)
);
}
Expand Down Expand Up @@ -322,14 +322,24 @@ function view() {
$this->checkNodeType();
extract($this->__dataVars());

if (isset($this->args[1]) && !is_null($this->args[1])) {
$key = is_numeric($this->args[1]) ? $secondary_id : 'alias';
$conditions = array($class . '.' . $key => $this->args[1]);
if (isset($this->args[1])) {
$identity = $this->parseIdentifier($this->args[1]);

$topNode = $this->Acl->{$class}->find('first', array(
'conditions' => array($class . '.id' => $this->_getNodeId($class, $identity))
));

$nodes = $this->Acl->{$class}->find('all', array(
'conditions' => array(
$class . '.lft >=' => $topNode[$class]['lft'],
$class . '.lft <=' => $topNode[$class]['rght']
),
'order' => $class . '.lft ASC'
));
} else {
$conditions = null;
$nodes = $this->Acl->{$class}->find('all', array('order' => $class . '.lft ASC'));
}

$nodes = $this->Acl->{$class}->find('all', array('conditions' => $conditions, 'order' => 'lft ASC'));
if (empty($nodes)) {
if (isset($this->args[1])) {
$this->error(sprintf(__("%s not found", true), $this->args[1]), __("No tree returned.", true));
Expand Down Expand Up @@ -447,7 +457,7 @@ function help() {
'view' => "view aro|aco [<node>]\n" .
"\t" . __("The view command will return the ARO or ACO 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" . __("only a portion of the requested tree.", true) . "\n" .
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
"\t" . __("see help for the 'create' command.", true),

Expand Down Expand Up @@ -480,7 +490,7 @@ function checkNodeType() {
return false;
}
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. Either "aro" or "aco"', true));
$this->error(sprintf(__("Missing/Unknown node type: '%s'", true), $this->args[0]), __('Please specify which ACL object type you wish to create. Either "aro" or "aco"', true));
}
}

Expand Down Expand Up @@ -551,7 +561,7 @@ function _getNodeId($class, $identifier) {
function __getParams() {
$aro = is_numeric($this->args[0]) ? intval($this->args[0]) : $this->args[0];
$aco = is_numeric($this->args[1]) ? intval($this->args[1]) : $this->args[1];

if (is_string($aro)) {
$aro = $this->parseIdentifier($aro);
}
Expand Down

0 comments on commit 2cc8ae6

Please sign in to comment.