mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge branch '1.3-console' of dev@code.cakephp.org:cakephp into 1.3-console
This commit is contained in:
commit
2dcb661b49
18 changed files with 266 additions and 111 deletions
|
@ -184,6 +184,11 @@
|
||||||
*/
|
*/
|
||||||
Configure::write('Acl.classname', 'DbAcl');
|
Configure::write('Acl.classname', 'DbAcl');
|
||||||
Configure::write('Acl.database', 'default');
|
Configure::write('Acl.database', 'default');
|
||||||
|
/**
|
||||||
|
* If you are on PHP 5.3 uncomment this line and correct your server timezone
|
||||||
|
* to fix the date & time related errors.
|
||||||
|
*/
|
||||||
|
//date_default_timezone_set('UTC');
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Cache Engine Configuration
|
* Cache Engine Configuration
|
||||||
|
|
|
@ -24,7 +24,14 @@
|
||||||
* @lastmodified $Date$
|
* @lastmodified $Date$
|
||||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||||
*/
|
*/
|
||||||
error_reporting(E_ALL);
|
/**
|
||||||
|
* PHP 5.3 raises many notices in bootstrap.
|
||||||
|
*/
|
||||||
|
if (!defined('E_DEPRECATED')) {
|
||||||
|
define('E_DEPRECATED', 8192);
|
||||||
|
}
|
||||||
|
error_reporting(E_ALL & ~E_DEPRECATED);
|
||||||
|
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
ini_set('memory_limit','128M');
|
ini_set('memory_limit','128M');
|
||||||
ini_set('display_errors', 1);
|
ini_set('display_errors', 1);
|
||||||
|
|
|
@ -22,6 +22,11 @@
|
||||||
if (!defined('PHP5')) {
|
if (!defined('PHP5')) {
|
||||||
define('PHP5', (PHP_VERSION >= 5));
|
define('PHP5', (PHP_VERSION >= 5));
|
||||||
}
|
}
|
||||||
|
if (!defined('E_DEPRECATED')) {
|
||||||
|
define('E_DEPRECATED', 8192);
|
||||||
|
}
|
||||||
|
error_reporting(E_ALL & ~E_DEPRECATED);
|
||||||
|
|
||||||
require CORE_PATH . 'cake' . DS . 'basics.php';
|
require CORE_PATH . 'cake' . DS . 'basics.php';
|
||||||
$TIME_START = getMicrotime();
|
$TIME_START = getMicrotime();
|
||||||
require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php';
|
require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php';
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
#!/usr/bin/php -q
|
#!/usr/bin/php -q
|
||||||
<?php
|
<?php
|
||||||
/* SVN FILE: $Id$ */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Command-line code generation utility to automate programmer chores.
|
* Command-line code generation utility to automate programmer chores.
|
||||||
*
|
*
|
||||||
|
@ -26,7 +24,9 @@
|
||||||
* @lastmodified $Date$
|
* @lastmodified $Date$
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||||
*/
|
*/
|
||||||
|
if (!defined('E_DEPRECATED')) {
|
||||||
|
define('E_DEPRECATED', 8192);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* Shell dispatcher
|
* Shell dispatcher
|
||||||
*
|
*
|
||||||
|
|
|
@ -137,52 +137,29 @@ class AclShell extends Shell {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function create() {
|
function create() {
|
||||||
|
|
||||||
$this->_checkArgs(3, 'create');
|
$this->_checkArgs(3, 'create');
|
||||||
$this->checkNodeType();
|
$this->checkNodeType();
|
||||||
extract($this->__dataVars());
|
extract($this->__dataVars());
|
||||||
|
|
||||||
$class = ucfirst($this->args[0]);
|
$class = ucfirst($this->args[0]);
|
||||||
$object = new $class();
|
$parent = $this->parseIdentifier($this->args[1]);
|
||||||
|
|
||||||
if (preg_match('/^([\w]+)\.(.*)$/', $this->args[1], $matches) && count($matches) == 3) {
|
|
||||||
$parent = array(
|
|
||||||
'model' => $matches[1],
|
|
||||||
'foreign_key' => $matches[2],
|
|
||||||
);
|
|
||||||
} else {
|
|
||||||
$parent = $this->args[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!empty($parent) && $parent != '/' && $parent != 'root') {
|
if (!empty($parent) && $parent != '/' && $parent != 'root') {
|
||||||
@$parent = $object->node($parent);
|
$parent = $this->_getNodeId($class, $parent);
|
||||||
if (empty($parent)) {
|
|
||||||
$this->err(sprintf(__('Could not find parent node using reference "%s"', true), $this->args[1]));
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
$parent = Set::extract($parent, "0.{$class}.id");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
$parent = null;
|
$parent = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preg_match('/^([\w]+)\.(.*)$/', $this->args[2], $matches) && count($matches) == 3) {
|
$data = $this->parseIdentifier($this->args[2]);
|
||||||
$data = array(
|
if (is_string($data) && $data != '/') {
|
||||||
'model' => $matches[1],
|
$data = array('alias' => $data);
|
||||||
'foreign_key' => $matches[2],
|
} elseif (is_string($data)) {
|
||||||
);
|
$this->error(__('/ can not be used as an alias!', true), __("\t/ is the root, please supply a sub alias", true));
|
||||||
} else {
|
|
||||||
if (!($this->args[2] == '/')) {
|
|
||||||
$data = array('alias' => $this->args[2]);
|
|
||||||
} else {
|
|
||||||
$this->error(__('/ can not be used as an alias!', true), __('\t/ is the root, please supply a sub alias', true));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['parent_id'] = $parent;
|
$data['parent_id'] = $parent;
|
||||||
$object->create();
|
$this->Acl->{$class}->create();
|
||||||
|
if ($this->Acl->{$class}->save($data)) {
|
||||||
if ($object->save($data)) {
|
|
||||||
$this->out(sprintf(__("New %s '%s' created.\n", true), $class, $this->args[2]), true);
|
$this->out(sprintf(__("New %s '%s' created.\n", true), $class, $this->args[2]), true);
|
||||||
} else {
|
} else {
|
||||||
$this->err(sprintf(__("There was a problem creating a new %s '%s'.", true), $class, $this->args[2]));
|
$this->err(sprintf(__("There was a problem creating a new %s '%s'.", true), $class, $this->args[2]));
|
||||||
|
@ -198,7 +175,11 @@ class AclShell extends Shell {
|
||||||
$this->_checkArgs(2, 'delete');
|
$this->_checkArgs(2, 'delete');
|
||||||
$this->checkNodeType();
|
$this->checkNodeType();
|
||||||
extract($this->__dataVars());
|
extract($this->__dataVars());
|
||||||
if (!$this->Acl->{$class}->delete($this->args[1])) {
|
|
||||||
|
$identifier = $this->parseIdentifier($this->args[1]);
|
||||||
|
$nodeId = $this->_getNodeId($class, $identifier);
|
||||||
|
|
||||||
|
if (!$this->Acl->{$class}->delete($nodeId)) {
|
||||||
$this->error(__("Node Not Deleted", true), sprintf(__("There was an error deleting the %s. Check that the node exists", true), $class) . ".\n");
|
$this->error(__("Node Not Deleted", true), sprintf(__("There was an error deleting the %s. Check that the node exists", true), $class) . ".\n");
|
||||||
}
|
}
|
||||||
$this->out(sprintf(__("%s deleted", true), $class) . ".\n", true);
|
$this->out(sprintf(__("%s deleted", true), $class) . ".\n", true);
|
||||||
|
@ -213,10 +194,13 @@ class AclShell extends Shell {
|
||||||
$this->_checkArgs(3, 'setParent');
|
$this->_checkArgs(3, 'setParent');
|
||||||
$this->checkNodeType();
|
$this->checkNodeType();
|
||||||
extract($this->__dataVars());
|
extract($this->__dataVars());
|
||||||
|
$target = $this->parseIdentifier($this->args[1]);
|
||||||
|
$parent = $this->parseIdentifier($this->args[2]);
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
$class => array(
|
$class => array(
|
||||||
'id' => $this->args[1],
|
'id' => $this->_getNodeId($class, $target),
|
||||||
'parent_id' => $this->args[2]
|
'parent_id' => $this->_getNodeId($class, $parent)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$this->Acl->{$class}->create();
|
$this->Acl->{$class}->create();
|
||||||
|
@ -378,64 +362,81 @@ class AclShell extends Shell {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function help() {
|
function help() {
|
||||||
$head = __("Usage: cake acl <command> <arg1> <arg2>...", true) . "\n";
|
$head = "-----------------------------------------------\n";
|
||||||
|
$head .= __("Usage: cake acl <command> <arg1> <arg2>...", true) . "\n";
|
||||||
$head .= "-----------------------------------------------\n";
|
$head .= "-----------------------------------------------\n";
|
||||||
$head .= __("Commands:", true) . "\n\n";
|
$head .= __("Commands:", true) . "\n";
|
||||||
|
|
||||||
$commands = array(
|
$commands = array(
|
||||||
'create' => "\tcreate aro|aco <parent> <node>\n" .
|
'create' => "create aro|aco <parent> <node>\n" .
|
||||||
"\t\t" . __("Creates a new ACL object <node> under the parent specified by <parent>, an id/alias.", true) . "\n" .
|
"\t" . __("Creates a new ACL object <node> under the parent", true) . "\n" .
|
||||||
"\t\t" . __("The <parent> and <node> references can be in one of the following formats:", true) . "\n" .
|
"\t" . __("specified by <parent>, an id/alias.", true) . "\n" .
|
||||||
"\t\t\t- " . __("<model>.<id> - The node will be bound to a specific record of the given model", true) . "\n" .
|
"\t" . __("The <parent> and <node> references can be", true) . "\n" .
|
||||||
"\t\t\t- " . __("<alias> - The node will be given a string alias (or path, in the case of <parent>),", true) . "\n" .
|
"\t" . __("in one of the following formats:", true) . "\n\n" .
|
||||||
"\t\t\t " . __("i.e. 'John'. When used with <parent>, this takes the form of an alias path,", true) . "\n" .
|
"\t\t- " . __("<model>.<id> - The node will be bound to a", true) . "\n" .
|
||||||
"\t\t\t " . __("i.e. <group>/<subgroup>/<parent>.", true) . "\n" .
|
"\t\t" . __("specific record of the given model.", true) . "\n\n" .
|
||||||
"\t\t" . __("To add a node at the root level, enter 'root' or '/' as the <parent> parameter.", true) . "\n",
|
"\t\t- " . __("<alias> - The node will be given a string alias,", true) . "\n" .
|
||||||
|
"\t\t" . __(" (or path, in the case of <parent>)", true) . "\n" .
|
||||||
|
"\t\t " . __("i.e. 'John'. When used with <parent>,", true) . "\n" .
|
||||||
|
"\t\t" . __("this takes the form of an alias path,", true) . "\n" .
|
||||||
|
"\t\t " . __("i.e. <group>/<subgroup>/<parent>.", true) . "\n\n" .
|
||||||
|
"\t" . __("To add a node at the root level,", true) . "\n" .
|
||||||
|
"\t" . __("enter 'root' or '/' as the <parent> parameter.", true) . "\n",
|
||||||
|
|
||||||
'delete' => "\tdelete aro|aco <node>\n" .
|
'delete' => "delete aro|aco <node>\n" .
|
||||||
"\t\t" . __("Deletes the ACL object with the given <node> reference (see 'create' for info on node references).", true) . "\n",
|
"\t" . __("Deletes the ACL object with the given <node> reference", true) . "\n" .
|
||||||
|
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
|
||||||
|
"\t" . __("see help for the 'create' command.", true),
|
||||||
|
|
||||||
'setparent' => "\tsetParent aro|aco <node> <parent>\n" .
|
'setparent' => "setParent aro|aco <node> <parent>\n" .
|
||||||
"\t\t" . __("Moves the ACL object specified by <node> beneath the parent ACL object specified by <parent>.", true) . "\n" .
|
"\t" . __("Moves the ACL object specified by <node> beneath", true) . "\n" .
|
||||||
"\t\t" . __("To identify the node and parent, use the row id.", true) . "\n",
|
"\t" . __("the parent ACL object specified by <parent>.", true) . "\n" .
|
||||||
|
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
|
||||||
|
"\t" . __("see help for the 'create' command.", true),
|
||||||
|
|
||||||
'getpath' => "\tgetPath aro|aco <node>\n" .
|
'getpath' => "getPath aro|aco <node>\n" .
|
||||||
"\t\t" . __("Returns the path to the ACL object specified by <node>. This command", true) . "\n" .
|
"\t" . __("Returns the path to the ACL object specified by <node>. This command", true) . "\n" .
|
||||||
"\t\t" . __("is useful in determining the inhertiance of permissions for a certain", true) . "\n" .
|
"\t" . __("is useful in determining the inhertiance of permissions for a certain", true) . "\n" .
|
||||||
"\t\t" . __("object in the tree.", true) . "\n" .
|
"\t" . __("object in the tree.", true) . "\n" .
|
||||||
"\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
|
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
|
||||||
|
"\t" . __("see help for the 'create' command.", true),
|
||||||
|
|
||||||
'check' => "\tcheck <aro_id> <aco_id> [<aco_action>] " . __("or", true) . " all\n" .
|
'check' => "check <aro_id> <aco_id> [<aco_action>] " . __("or", true) . " all\n" .
|
||||||
"\t\t" . __("Use this command to check ACL permissions.", true) . "\n" .
|
"\t" . __("Use this command to check ACL permissions.", true) . "\n" .
|
||||||
"\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
|
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
|
||||||
|
"\t" . __("see help for the 'create' command.", true),
|
||||||
|
|
||||||
'grant' => "\tgrant <aro_id> <aco_id> [<aco_action>] " . __("or", true) . " all\n" .
|
'grant' => "grant <aro_id> <aco_id> [<aco_action>] " . __("or", true) . " all\n" .
|
||||||
"\t\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\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\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\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
|
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
|
||||||
|
"\t" . __("see help for the 'create' command.", true),
|
||||||
|
|
||||||
'deny' => "\tdeny <aro_id> <aco_id> [<aco_action>]" . __("or", true) . " all\n" .
|
'deny' => "deny <aro_id> <aco_id> [<aco_action>]" . __("or", true) . " all\n" .
|
||||||
"\t\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\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\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\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
|
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
|
||||||
|
"\t" . __("see help for the 'create' command.", true),
|
||||||
|
|
||||||
'inherit' => "\tinherit <aro_id> <aco_id> [<aco_action>]" . __("or", true) . " all\n" .
|
'inherit' => "inherit <aro_id> <aco_id> [<aco_action>]" . __("or", true) . " all\n" .
|
||||||
"\t\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\t" . __("permissions settings from its parent.", true) . "\n" .
|
"\t" . __("permissions settings from its parent.", true) . "\n" .
|
||||||
"\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
|
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
|
||||||
|
"\t" . __("see help for the 'create' command.", true),
|
||||||
|
|
||||||
'view' => "\tview aro|aco [<node>]\n" .
|
'view' => "view aro|aco [<node>]\n" .
|
||||||
"\t\t" . __("The view command will return the ARO or ACO tree. The optional", true) . "\n" .
|
"\t" . __("The view command will return the ARO or ACO tree.", true) . "\n" .
|
||||||
"\t\t" . __("id/alias parameter allows you to return only a portion of the requested tree.", true) . "\n" .
|
"\t" . __("The optional id/alias parameter allows you to return\n\tonly a portion of the requested tree.", true) . "\n" .
|
||||||
"\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
|
"\t" . __("For more detailed parameter usage info,", true) . "\n" .
|
||||||
|
"\t" . __("see help for the 'create' command.", true),
|
||||||
|
|
||||||
'initdb' => "\tinitdb\n".
|
'initdb' => "initdb\n".
|
||||||
"\t\t" . __("Uses this command : cake schema run create DbAcl", true) . "\n",
|
"\t" . __("Uses this command : cake schema run create DbAcl", true),
|
||||||
|
|
||||||
'help' => "\thelp [<command>]\n" .
|
'help' => "help [<command>]\n" .
|
||||||
"\t\t" . __("Displays this help message, or a message on a specific command.", true) . "\n"
|
"\t" . __("Displays this help message, or a message on a specific command.", true)
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->out($head);
|
$this->out($head);
|
||||||
|
@ -443,8 +444,8 @@ class AclShell extends Shell {
|
||||||
foreach ($commands as $cmd) {
|
foreach ($commands as $cmd) {
|
||||||
$this->out("{$cmd}\n\n");
|
$this->out("{$cmd}\n\n");
|
||||||
}
|
}
|
||||||
} elseif (isset($commands[low($this->args[0])])) {
|
} elseif (isset($commands[strtolower($this->args[0])])) {
|
||||||
$this->out($commands[low($this->args[0])] . "\n\n");
|
$this->out($commands[strtolower($this->args[0])] . "\n\n");
|
||||||
} else {
|
} else {
|
||||||
$this->out(sprintf(__("Command '%s' not found", true), $this->args[0]));
|
$this->out(sprintf(__("Command '%s' not found", true), $this->args[0]));
|
||||||
}
|
}
|
||||||
|
@ -477,7 +478,7 @@ class AclShell extends Shell {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
extract($this->__dataVars($this->args[0]));
|
extract($this->__dataVars($this->args[0]));
|
||||||
$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]);
|
||||||
$possibility = $this->Acl->{$class}->find('all', compact('conditions'));
|
$possibility = $this->Acl->{$class}->find('all', compact('conditions'));
|
||||||
if (empty($possibility)) {
|
if (empty($possibility)) {
|
||||||
|
@ -486,6 +487,42 @@ class AclShell extends Shell {
|
||||||
return $possibility;
|
return $possibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parse an identifier into Model.foriegnKey or an alias.
|
||||||
|
* Takes an identifier determines its type and returns the result as used by other methods.
|
||||||
|
*
|
||||||
|
* @param string $identifier Identifier to parse
|
||||||
|
* @return mixed a string for aliases, and an array for model.foreignKey
|
||||||
|
**/
|
||||||
|
function parseIdentifier($identifier) {
|
||||||
|
if (preg_match('/^([\w]+)\.(.*)$/', $identifier, $matches)) {
|
||||||
|
return array(
|
||||||
|
'model' => $matches[1],
|
||||||
|
'foreign_key' => $matches[2],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return $identifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the node for a given identifier. $identifier can either be a string alias
|
||||||
|
* or an array of properties to use in AcoNode::node()
|
||||||
|
*
|
||||||
|
* @param string $class Class type you want (Aro/Aco)
|
||||||
|
* @param mixed $identifier A mixed identifier for finding the node.
|
||||||
|
* @return int Integer of NodeId. Will trigger an error if nothing is found.
|
||||||
|
**/
|
||||||
|
function _getNodeId($class, $identifier) {
|
||||||
|
$node = $this->Acl->{$class}->node($identifier);
|
||||||
|
if (empty($node)) {
|
||||||
|
if (is_array($identifier)) {
|
||||||
|
$identifier = var_export($identifier, true);
|
||||||
|
}
|
||||||
|
$this->error(sprintf(__('Could not find node using reference "%s"', true), $identifier));
|
||||||
|
}
|
||||||
|
return Set::extract($node, "0.{$class}.id");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get params for standard Acl methods
|
* get params for standard Acl methods
|
||||||
*
|
*
|
||||||
|
@ -533,7 +570,7 @@ class AclShell extends Shell {
|
||||||
}
|
}
|
||||||
$vars = array();
|
$vars = array();
|
||||||
$class = ucwords($type);
|
$class = ucwords($type);
|
||||||
$vars['secondary_id'] = ife(strtolower($class) == 'aro', 'foreign_key', 'object_id');
|
$vars['secondary_id'] = (strtolower($class) == 'aro') ? 'foreign_key' : 'object_id';
|
||||||
$vars['data_name'] = $type;
|
$vars['data_name'] = $type;
|
||||||
$vars['table_name'] = $type . 's';
|
$vars['table_name'] = $type . 's';
|
||||||
$vars['class'] = $class;
|
$vars['class'] = $class;
|
||||||
|
|
|
@ -157,7 +157,7 @@ class BakeShell extends Shell {
|
||||||
$object = new $model();
|
$object = new $model();
|
||||||
$modelExists = true;
|
$modelExists = true;
|
||||||
} else {
|
} else {
|
||||||
App::import('Model');
|
App::import('Model', 'Model', false);
|
||||||
$object = new Model(array('name' => $name, 'ds' => $this->connection));
|
$object = new Model(array('name' => $name, 'ds' => $this->connection));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||||
*/
|
*/
|
||||||
App::import('File');
|
App::import('File');
|
||||||
App::import('Model', 'CakeSchema');
|
App::import('Model', 'CakeSchema', false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Schema is a command-line database management utility for automating programmer chores.
|
* Schema is a command-line database management utility for automating programmer chores.
|
||||||
|
|
|
@ -74,7 +74,7 @@ class FixtureTask extends Shell {
|
||||||
parent::__construct($dispatch);
|
parent::__construct($dispatch);
|
||||||
$this->path = $this->params['working'] . DS . 'tests' . DS . 'fixtures' . DS;
|
$this->path = $this->params['working'] . DS . 'tests' . DS . 'fixtures' . DS;
|
||||||
if (!class_exists('CakeSchema')) {
|
if (!class_exists('CakeSchema')) {
|
||||||
App::import('Model', 'CakeSchema');
|
App::import('Model', 'CakeSchema', false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,7 +384,7 @@ class FixtureTask extends Shell {
|
||||||
while (!$condition) {
|
while (!$condition) {
|
||||||
$condition = $this->in($prompt, null, 'WHERE 1=1 LIMIT 10');
|
$condition = $this->in($prompt, null, 'WHERE 1=1 LIMIT 10');
|
||||||
}
|
}
|
||||||
App::import('Core', 'Model');
|
App::import('Model', 'Model', false);
|
||||||
$modelObject =& new Model(array('name' => $modelName, 'table' => $useTable, 'ds' => $this->connection));
|
$modelObject =& new Model(array('name' => $modelName, 'table' => $useTable, 'ds' => $this->connection));
|
||||||
$records = $modelObject->find('all', array(
|
$records = $modelObject->find('all', array(
|
||||||
'conditions' => $condition,
|
'conditions' => $condition,
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
* @since CakePHP(tm) v 1.2
|
* @since CakePHP(tm) v 1.2
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||||
*/
|
*/
|
||||||
App::import('Model', 'ConnectionManager');
|
App::import('Model', 'Model', false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Task class for creating and updating model files.
|
* Task class for creating and updating model files.
|
||||||
|
@ -82,7 +82,6 @@ class ModelTask extends Shell {
|
||||||
* @return void
|
* @return void
|
||||||
**/
|
**/
|
||||||
function startup() {
|
function startup() {
|
||||||
App::import('Core', 'Model');
|
|
||||||
parent::startup();
|
parent::startup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
* @since CakePHP(tm) v 1.2
|
* @since CakePHP(tm) v 1.2
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||||
*/
|
*/
|
||||||
App::import('Core', 'Controller');
|
App::import('Controller', 'Controller', false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Task class for creating and updating view files.
|
* Task class for creating and updating view files.
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
* @lastmodified $Date$
|
* @lastmodified $Date$
|
||||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||||
*/
|
*/
|
||||||
App::import('Core', 'Helper');
|
App::import('Helper', 'Helper', false);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a placeholder class.
|
* This is a placeholder class.
|
||||||
|
|
|
@ -190,6 +190,11 @@
|
||||||
Configure::write('Acl.classname', 'DbAcl');
|
Configure::write('Acl.classname', 'DbAcl');
|
||||||
Configure::write('Acl.database', 'default');
|
Configure::write('Acl.database', 'default');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If you are on PHP 5.3 uncomment this line and correct your server timezone
|
||||||
|
* to fix the date & time related errors.
|
||||||
|
*/
|
||||||
|
//date_default_timezone_set('UTC');
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Cache Engine Configuration
|
* Cache Engine Configuration
|
||||||
|
|
|
@ -25,7 +25,14 @@
|
||||||
* @lastmodified $Date$
|
* @lastmodified $Date$
|
||||||
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
* @license http://www.opensource.org/licenses/opengroup.php The Open Group Test Suite License
|
||||||
*/
|
*/
|
||||||
error_reporting(E_ALL);
|
/**
|
||||||
|
* PHP 5.3 raises many notices in bootstrap.
|
||||||
|
*/
|
||||||
|
if (!defined('E_DEPRECATED')) {
|
||||||
|
define('E_DEPRECATED', 8192);
|
||||||
|
}
|
||||||
|
error_reporting(E_ALL & ~E_DEPRECATED);
|
||||||
|
|
||||||
set_time_limit(0);
|
set_time_limit(0);
|
||||||
ini_set('memory_limit','128M');
|
ini_set('memory_limit','128M');
|
||||||
ini_set('display_errors', 1);
|
ini_set('display_errors', 1);
|
||||||
|
|
|
@ -226,7 +226,7 @@ class Dispatcher extends Object {
|
||||||
|
|
||||||
if (!isset($methods[strtolower($params['action'])])) {
|
if (!isset($methods[strtolower($params['action'])])) {
|
||||||
if ($controller->scaffold !== false) {
|
if ($controller->scaffold !== false) {
|
||||||
App::import('Core', 'Scaffold');
|
App::import('Controller', 'Scaffold', false);
|
||||||
return new Scaffold($controller, $params);
|
return new Scaffold($controller, $params);
|
||||||
}
|
}
|
||||||
return $this->cakeError('missingAction', array(array(
|
return $this->cakeError('missingAction', array(array(
|
||||||
|
|
|
@ -107,7 +107,7 @@ class Configure extends Object {
|
||||||
|
|
||||||
if (isset($config['debug'])) {
|
if (isset($config['debug'])) {
|
||||||
if ($_this->debug) {
|
if ($_this->debug) {
|
||||||
error_reporting(E_ALL);
|
error_reporting(E_ALL & ~E_DEPRECATED);
|
||||||
|
|
||||||
if (function_exists('ini_set')) {
|
if (function_exists('ini_set')) {
|
||||||
ini_set('display_errors', 1);
|
ini_set('display_errors', 1);
|
||||||
|
@ -844,7 +844,7 @@ class App extends Object {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!App::import($tempType, $plugin . $class)) {
|
if (!App::import($tempType, $plugin . $class, $parent)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -866,7 +866,7 @@ class App extends Object {
|
||||||
if ($name != null && !class_exists($name . $ext['class'])) {
|
if ($name != null && !class_exists($name . $ext['class'])) {
|
||||||
if ($load = $_this->__mapped($name . $ext['class'], $type, $plugin)) {
|
if ($load = $_this->__mapped($name . $ext['class'], $type, $plugin)) {
|
||||||
if ($_this->__load($load)) {
|
if ($_this->__load($load)) {
|
||||||
$_this->__overload($type, $name . $ext['class']);
|
$_this->__overload($type, $name . $ext['class'], $parent);
|
||||||
|
|
||||||
if ($_this->return) {
|
if ($_this->return) {
|
||||||
$value = include $load;
|
$value = include $load;
|
||||||
|
@ -908,7 +908,7 @@ class App extends Object {
|
||||||
if ($directory !== null) {
|
if ($directory !== null) {
|
||||||
$_this->__cache = true;
|
$_this->__cache = true;
|
||||||
$_this->__map($directory . $file, $name . $ext['class'], $type, $plugin);
|
$_this->__map($directory . $file, $name . $ext['class'], $type, $plugin);
|
||||||
$_this->__overload($type, $name . $ext['class']);
|
$_this->__overload($type, $name . $ext['class'], $parent);
|
||||||
|
|
||||||
if ($_this->return) {
|
if ($_this->return) {
|
||||||
$value = include $directory . $file;
|
$value = include $directory . $file;
|
||||||
|
@ -1058,8 +1058,8 @@ class App extends Object {
|
||||||
* @param string $name Class name to overload
|
* @param string $name Class name to overload
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function __overload($type, $name) {
|
function __overload($type, $name, $parent) {
|
||||||
if (($type === 'Model' || $type === 'Helper') && strtolower($name) != 'schema') {
|
if (($type === 'Model' || $type === 'Helper') && $parent !== false) {
|
||||||
Overloadable::overload($name);
|
Overloadable::overload($name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1088,10 +1088,10 @@ class App extends Object {
|
||||||
switch ($load) {
|
switch ($load) {
|
||||||
case 'model':
|
case 'model':
|
||||||
if (!class_exists('Model')) {
|
if (!class_exists('Model')) {
|
||||||
App::import('Model', 'Model', false, App::core('models'));
|
require LIBS . 'model' . DS . 'model.php';
|
||||||
}
|
}
|
||||||
if (!class_exists('AppModel')) {
|
if (!class_exists('AppModel')) {
|
||||||
App::import($type, 'AppModel', false, App::path('models'));
|
App::import($type, 'AppModel', false);
|
||||||
}
|
}
|
||||||
if ($plugin) {
|
if ($plugin) {
|
||||||
if (!class_exists($plugin . 'AppModel')) {
|
if (!class_exists($plugin . 'AppModel')) {
|
||||||
|
|
|
@ -254,7 +254,7 @@ class Debugger extends Object {
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
function handleError($code, $description, $file = null, $line = null, $context = null) {
|
function handleError($code, $description, $file = null, $line = null, $context = null) {
|
||||||
if (error_reporting() == 0 || $code === 2048) {
|
if (error_reporting() == 0 || $code === 2048 || $code === 8192) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,7 +90,7 @@ class CakeSchema extends Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (empty($options['path'])) {
|
if (empty($options['path'])) {
|
||||||
$this->path = CONFIGS . 'sql';
|
$this->path = CONFIGS . 'schema';
|
||||||
}
|
}
|
||||||
|
|
||||||
$options = array_merge(get_object_vars($this), $options);
|
$options = array_merge(get_object_vars($this), $options);
|
||||||
|
@ -161,6 +161,7 @@ class CakeSchema extends Object {
|
||||||
extract(get_object_vars($this));
|
extract(get_object_vars($this));
|
||||||
|
|
||||||
$class = $name .'Schema';
|
$class = $name .'Schema';
|
||||||
|
|
||||||
if (!class_exists($class)) {
|
if (!class_exists($class)) {
|
||||||
if (file_exists($path . DS . $file) && is_file($path . DS . $file)) {
|
if (file_exists($path . DS . $file) && is_file($path . DS . $file)) {
|
||||||
require_once($path . DS . $file);
|
require_once($path . DS . $file);
|
||||||
|
|
|
@ -46,9 +46,11 @@ Mock::generatePartial(
|
||||||
);
|
);
|
||||||
Mock::generatePartial(
|
Mock::generatePartial(
|
||||||
'AclShell', 'MockAclShell',
|
'AclShell', 'MockAclShell',
|
||||||
array('in', 'out', 'hr', 'createFile')
|
array('in', 'out', 'hr', 'createFile', 'error', 'err')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Mock::generate('AclComponent', 'MockAclShellAclComponent');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* AclShellTest class
|
* AclShellTest class
|
||||||
*
|
*
|
||||||
|
@ -82,7 +84,7 @@ class AclShellTest extends CakeTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* setUp method
|
* startTest method
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @access public
|
* @access public
|
||||||
|
@ -92,10 +94,13 @@ class AclShellTest extends CakeTestCase {
|
||||||
$this->Task =& new MockAclShell($this->Dispatcher);
|
$this->Task =& new MockAclShell($this->Dispatcher);
|
||||||
$this->Task->Dispatch = new $this->Dispatcher;
|
$this->Task->Dispatch = new $this->Dispatcher;
|
||||||
$this->Task->params['datasource'] = 'test_suite';
|
$this->Task->params['datasource'] = 'test_suite';
|
||||||
|
$this->Task->Acl =& new AclComponent();
|
||||||
|
$controller = null;
|
||||||
|
$this->Task->Acl->startup($controller);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* tearDown method
|
* endTest method
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
* @access public
|
* @access public
|
||||||
|
@ -128,5 +133,89 @@ class AclShellTest extends CakeTestCase {
|
||||||
|
|
||||||
$this->Task->view();
|
$this->Task->view();
|
||||||
}
|
}
|
||||||
|
/**
|
||||||
|
* test the method that splits model.foreign key. and that it returns an array.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
function testParsingModelAndForeignKey() {
|
||||||
|
$result = $this->Task->parseIdentifier('Model.foreignKey');
|
||||||
|
$expected = array('model' => 'Model', 'foreign_key' => 'foreignKey');
|
||||||
|
|
||||||
|
$result = $this->Task->parseIdentifier('mySuperUser');
|
||||||
|
$this->assertEqual($result, 'mySuperUser');
|
||||||
|
|
||||||
|
$result = $this->Task->parseIdentifier('111234');
|
||||||
|
$this->assertEqual($result, '111234');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test creating aro/aco nodes
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
function testCreate() {
|
||||||
|
$this->Task->args = array('aro', 'root', 'User.1');
|
||||||
|
$this->Task->expectAt(0, 'out', array(new PatternExpectation('/created/'), '*'));
|
||||||
|
$this->Task->create();
|
||||||
|
|
||||||
|
$Aro =& ClassRegistry::init('Aro');
|
||||||
|
$Aro->cacheQueries = false;
|
||||||
|
$result = $Aro->read();
|
||||||
|
$this->assertEqual($result['Aro']['model'], 'User');
|
||||||
|
$this->assertEqual($result['Aro']['foreign_key'], 1);
|
||||||
|
$this->assertEqual($result['Aro']['parent_id'], null);
|
||||||
|
$id = $result['Aro']['id'];
|
||||||
|
|
||||||
|
$this->Task->args = array('aro', 'User.1', 'User.3');
|
||||||
|
$this->Task->expectAt(1, 'out', array(new PatternExpectation('/created/'), '*'));
|
||||||
|
$this->Task->create();
|
||||||
|
|
||||||
|
$Aro =& ClassRegistry::init('Aro');
|
||||||
|
$result = $Aro->read();
|
||||||
|
$this->assertEqual($result['Aro']['model'], 'User');
|
||||||
|
$this->assertEqual($result['Aro']['foreign_key'], 3);
|
||||||
|
$this->assertEqual($result['Aro']['parent_id'], $id);
|
||||||
|
|
||||||
|
$this->Task->args = array('aro', 'root', 'somealias');
|
||||||
|
$this->Task->expectAt(2, 'out', array(new PatternExpectation('/created/'), '*'));
|
||||||
|
$this->Task->create();
|
||||||
|
|
||||||
|
$Aro =& ClassRegistry::init('Aro');
|
||||||
|
$result = $Aro->read();
|
||||||
|
$this->assertEqual($result['Aro']['alias'], 'somealias');
|
||||||
|
$this->assertEqual($result['Aro']['model'], null);
|
||||||
|
$this->assertEqual($result['Aro']['foreign_key'], null);
|
||||||
|
$this->assertEqual($result['Aro']['parent_id'], null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test the delete method with different node types.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
function testDelete() {
|
||||||
|
$this->Task->args = array('aro', 'AuthUser.1');
|
||||||
|
$this->Task->expectAt(0, 'out', array(new NoPatternExpectation('/not/'), true));
|
||||||
|
$this->Task->delete();
|
||||||
|
|
||||||
|
$Aro =& ClassRegistry::init('Aro');
|
||||||
|
$result = $Aro->read(null, 3);
|
||||||
|
$this->assertFalse($result);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test setParent method.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
**/
|
||||||
|
function testSetParent() {
|
||||||
|
$this->Task->args = array('aro', 'AuthUser.2', 'root');
|
||||||
|
$this->Task->setParent();
|
||||||
|
|
||||||
|
$Aro =& ClassRegistry::init('Aro');
|
||||||
|
$result = $Aro->read(null, 4);
|
||||||
|
$this->assertEqual($result['Aro']['parent_id'], null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
Loading…
Reference in a new issue