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.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
|
||||
|
|
|
@ -24,7 +24,14 @@
|
|||
* @lastmodified $Date$
|
||||
* @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);
|
||||
ini_set('memory_limit','128M');
|
||||
ini_set('display_errors', 1);
|
||||
|
|
|
@ -22,6 +22,11 @@
|
|||
if (!defined('PHP5')) {
|
||||
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';
|
||||
$TIME_START = getMicrotime();
|
||||
require CORE_PATH . 'cake' . DS . 'config' . DS . 'paths.php';
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
#!/usr/bin/php -q
|
||||
<?php
|
||||
/* SVN FILE: $Id$ */
|
||||
|
||||
/**
|
||||
* Command-line code generation utility to automate programmer chores.
|
||||
*
|
||||
|
@ -26,7 +24,9 @@
|
|||
* @lastmodified $Date$
|
||||
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
||||
*/
|
||||
|
||||
if (!defined('E_DEPRECATED')) {
|
||||
define('E_DEPRECATED', 8192);
|
||||
}
|
||||
/**
|
||||
* Shell dispatcher
|
||||
*
|
||||
|
|
|
@ -137,52 +137,29 @@ class AclShell extends Shell {
|
|||
* @access public
|
||||
*/
|
||||
function create() {
|
||||
|
||||
$this->_checkArgs(3, 'create');
|
||||
$this->checkNodeType();
|
||||
extract($this->__dataVars());
|
||||
|
||||
$class = ucfirst($this->args[0]);
|
||||
$object = new $class();
|
||||
|
||||
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];
|
||||
}
|
||||
$parent = $this->parseIdentifier($this->args[1]);
|
||||
|
||||
if (!empty($parent) && $parent != '/' && $parent != 'root') {
|
||||
@$parent = $object->node($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");
|
||||
}
|
||||
$parent = $this->_getNodeId($class, $parent);
|
||||
} else {
|
||||
$parent = null;
|
||||
}
|
||||
|
||||
if (preg_match('/^([\w]+)\.(.*)$/', $this->args[2], $matches) && count($matches) == 3) {
|
||||
$data = array(
|
||||
'model' => $matches[1],
|
||||
'foreign_key' => $matches[2],
|
||||
);
|
||||
} 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 = $this->parseIdentifier($this->args[2]);
|
||||
if (is_string($data) && $data != '/') {
|
||||
$data = array('alias' => $data);
|
||||
} elseif (is_string($data)) {
|
||||
$this->error(__('/ can not be used as an alias!', true), __("\t/ is the root, please supply a sub alias", true));
|
||||
}
|
||||
|
||||
$data['parent_id'] = $parent;
|
||||
$object->create();
|
||||
|
||||
if ($object->save($data)) {
|
||||
$this->Acl->{$class}->create();
|
||||
if ($this->Acl->{$class}->save($data)) {
|
||||
$this->out(sprintf(__("New %s '%s' created.\n", true), $class, $this->args[2]), true);
|
||||
} else {
|
||||
$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->checkNodeType();
|
||||
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->out(sprintf(__("%s deleted", true), $class) . ".\n", true);
|
||||
|
@ -213,10 +194,13 @@ class AclShell extends Shell {
|
|||
$this->_checkArgs(3, 'setParent');
|
||||
$this->checkNodeType();
|
||||
extract($this->__dataVars());
|
||||
$target = $this->parseIdentifier($this->args[1]);
|
||||
$parent = $this->parseIdentifier($this->args[2]);
|
||||
|
||||
$data = array(
|
||||
$class => array(
|
||||
'id' => $this->args[1],
|
||||
'parent_id' => $this->args[2]
|
||||
'id' => $this->_getNodeId($class, $target),
|
||||
'parent_id' => $this->_getNodeId($class, $parent)
|
||||
)
|
||||
);
|
||||
$this->Acl->{$class}->create();
|
||||
|
@ -378,64 +362,81 @@ class AclShell extends Shell {
|
|||
* @access public
|
||||
*/
|
||||
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 .= __("Commands:", true) . "\n\n";
|
||||
$head .= __("Commands:", true) . "\n";
|
||||
|
||||
$commands = array(
|
||||
'create' => "\tcreate 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\t" . __("The <parent> and <node> references can be in one of the following formats:", true) . "\n" .
|
||||
"\t\t\t- " . __("<model>.<id> - The node will be bound to a specific record of the given model", true) . "\n" .
|
||||
"\t\t\t- " . __("<alias> - The node will be given a string alias (or path, in the case of <parent>),", true) . "\n" .
|
||||
"\t\t\t " . __("i.e. 'John'. When used with <parent>, this takes the form of an alias path,", true) . "\n" .
|
||||
"\t\t\t " . __("i.e. <group>/<subgroup>/<parent>.", true) . "\n" .
|
||||
"\t\t" . __("To add a node at the root level, enter 'root' or '/' as the <parent> parameter.", true) . "\n",
|
||||
'create' => "create aro|aco <parent> <node>\n" .
|
||||
"\t" . __("Creates a new ACL object <node> under the parent", true) . "\n" .
|
||||
"\t" . __("specified by <parent>, an id/alias.", true) . "\n" .
|
||||
"\t" . __("The <parent> and <node> references can be", true) . "\n" .
|
||||
"\t" . __("in one of the following formats:", true) . "\n\n" .
|
||||
"\t\t- " . __("<model>.<id> - The node will be bound to a", true) . "\n" .
|
||||
"\t\t" . __("specific record of the given model.", true) . "\n\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" .
|
||||
"\t\t" . __("Deletes the ACL object with the given <node> reference (see 'create' for info on node references).", true) . "\n",
|
||||
'delete' => "delete aro|aco <node>\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" .
|
||||
"\t\t" . __("Moves the ACL object specified by <node> beneath the parent ACL object specified by <parent>.", true) . "\n" .
|
||||
"\t\t" . __("To identify the node and parent, use the row id.", true) . "\n",
|
||||
'setparent' => "setParent aro|aco <node> <parent>\n" .
|
||||
"\t" . __("Moves the ACL object specified by <node> beneath", 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" .
|
||||
"\t\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\t" . __("object in the tree.", true) . "\n" .
|
||||
"\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
|
||||
'getpath' => "getPath aro|aco <node>\n" .
|
||||
"\t" . __("Returns the path to the ACL object specified by <node>. This command", true) . "\n" .
|
||||
"\t" . __("is useful in determining the inhertiance of permissions for a certain", true) . "\n" .
|
||||
"\t" . __("object in the tree.", 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" .
|
||||
"\t\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",
|
||||
'check' => "check <aro_id> <aco_id> [<aco_action>] " . __("or", true) . " all\n" .
|
||||
"\t" . __("Use this command to check ACL permissions.", 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" .
|
||||
"\t\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\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",
|
||||
'grant' => "grant <aro_id> <aco_id> [<aco_action>] " . __("or", true) . " all\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 ACO action (and the ACO's children, if any).", 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" .
|
||||
"\t\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\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",
|
||||
'deny' => "deny <aro_id> <aco_id> [<aco_action>]" . __("or", true) . " all\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 ACO action (and the ACO's children, if any).", 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" .
|
||||
"\t\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\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
|
||||
'inherit' => "inherit <aro_id> <aco_id> [<aco_action>]" . __("or", true) . " all\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" . __("For more detailed parameter usage info,", true) . "\n" .
|
||||
"\t" . __("see help for the 'create' command.", true),
|
||||
|
||||
'view' => "\tview aro|aco [<node>]\n" .
|
||||
"\t\t" . __("The view command will return the ARO or ACO tree. The optional", true) . "\n" .
|
||||
"\t\t" . __("id/alias parameter allows you to return only a portion of the requested tree.", true) . "\n" .
|
||||
"\t\t" . __("For more detailed parameter usage info, see help for the 'create' command.", true) . "\n",
|
||||
'view' => "view aro|aco [<node>]\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" . __("For more detailed parameter usage info,", true) . "\n" .
|
||||
"\t" . __("see help for the 'create' command.", true),
|
||||
|
||||
'initdb' => "\tinitdb\n".
|
||||
"\t\t" . __("Uses this command : cake schema run create DbAcl", true) . "\n",
|
||||
'initdb' => "initdb\n".
|
||||
"\t" . __("Uses this command : cake schema run create DbAcl", true),
|
||||
|
||||
'help' => "\thelp [<command>]\n" .
|
||||
"\t\t" . __("Displays this help message, or a message on a specific command.", true) . "\n"
|
||||
'help' => "help [<command>]\n" .
|
||||
"\t" . __("Displays this help message, or a message on a specific command.", true)
|
||||
);
|
||||
|
||||
$this->out($head);
|
||||
|
@ -443,8 +444,8 @@ class AclShell extends Shell {
|
|||
foreach ($commands as $cmd) {
|
||||
$this->out("{$cmd}\n\n");
|
||||
}
|
||||
} elseif (isset($commands[low($this->args[0])])) {
|
||||
$this->out($commands[low($this->args[0])] . "\n\n");
|
||||
} elseif (isset($commands[strtolower($this->args[0])])) {
|
||||
$this->out($commands[strtolower($this->args[0])] . "\n\n");
|
||||
} else {
|
||||
$this->out(sprintf(__("Command '%s' not found", true), $this->args[0]));
|
||||
}
|
||||
|
@ -477,7 +478,7 @@ class AclShell extends Shell {
|
|||
return false;
|
||||
}
|
||||
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]);
|
||||
$possibility = $this->Acl->{$class}->find('all', compact('conditions'));
|
||||
if (empty($possibility)) {
|
||||
|
@ -486,6 +487,42 @@ class AclShell extends Shell {
|
|||
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
|
||||
*
|
||||
|
@ -533,7 +570,7 @@ class AclShell extends Shell {
|
|||
}
|
||||
$vars = array();
|
||||
$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['table_name'] = $type . 's';
|
||||
$vars['class'] = $class;
|
||||
|
|
|
@ -157,7 +157,7 @@ class BakeShell extends Shell {
|
|||
$object = new $model();
|
||||
$modelExists = true;
|
||||
} else {
|
||||
App::import('Model');
|
||||
App::import('Model', 'Model', false);
|
||||
$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
|
||||
*/
|
||||
App::import('File');
|
||||
App::import('Model', 'CakeSchema');
|
||||
App::import('Model', 'CakeSchema', false);
|
||||
|
||||
/**
|
||||
* Schema is a command-line database management utility for automating programmer chores.
|
||||
|
|
|
@ -74,7 +74,7 @@ class FixtureTask extends Shell {
|
|||
parent::__construct($dispatch);
|
||||
$this->path = $this->params['working'] . DS . 'tests' . DS . 'fixtures' . DS;
|
||||
if (!class_exists('CakeSchema')) {
|
||||
App::import('Model', 'CakeSchema');
|
||||
App::import('Model', 'CakeSchema', false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -384,7 +384,7 @@ class FixtureTask extends Shell {
|
|||
while (!$condition) {
|
||||
$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));
|
||||
$records = $modelObject->find('all', array(
|
||||
'conditions' => $condition,
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
* @since CakePHP(tm) v 1.2
|
||||
* @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.
|
||||
|
@ -82,7 +82,6 @@ class ModelTask extends Shell {
|
|||
* @return void
|
||||
**/
|
||||
function startup() {
|
||||
App::import('Core', 'Model');
|
||||
parent::startup();
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
* @since CakePHP(tm) v 1.2
|
||||
* @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.
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* @lastmodified $Date$
|
||||
* @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.
|
||||
|
|
|
@ -190,6 +190,11 @@
|
|||
Configure::write('Acl.classname', 'DbAcl');
|
||||
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
|
||||
|
|
|
@ -25,7 +25,14 @@
|
|||
* @lastmodified $Date$
|
||||
* @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);
|
||||
ini_set('memory_limit','128M');
|
||||
ini_set('display_errors', 1);
|
||||
|
|
|
@ -226,7 +226,7 @@ class Dispatcher extends Object {
|
|||
|
||||
if (!isset($methods[strtolower($params['action'])])) {
|
||||
if ($controller->scaffold !== false) {
|
||||
App::import('Core', 'Scaffold');
|
||||
App::import('Controller', 'Scaffold', false);
|
||||
return new Scaffold($controller, $params);
|
||||
}
|
||||
return $this->cakeError('missingAction', array(array(
|
||||
|
|
|
@ -107,7 +107,7 @@ class Configure extends Object {
|
|||
|
||||
if (isset($config['debug'])) {
|
||||
if ($_this->debug) {
|
||||
error_reporting(E_ALL);
|
||||
error_reporting(E_ALL & ~E_DEPRECATED);
|
||||
|
||||
if (function_exists('ini_set')) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -866,7 +866,7 @@ class App extends Object {
|
|||
if ($name != null && !class_exists($name . $ext['class'])) {
|
||||
if ($load = $_this->__mapped($name . $ext['class'], $type, $plugin)) {
|
||||
if ($_this->__load($load)) {
|
||||
$_this->__overload($type, $name . $ext['class']);
|
||||
$_this->__overload($type, $name . $ext['class'], $parent);
|
||||
|
||||
if ($_this->return) {
|
||||
$value = include $load;
|
||||
|
@ -908,7 +908,7 @@ class App extends Object {
|
|||
if ($directory !== null) {
|
||||
$_this->__cache = true;
|
||||
$_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) {
|
||||
$value = include $directory . $file;
|
||||
|
@ -1058,8 +1058,8 @@ class App extends Object {
|
|||
* @param string $name Class name to overload
|
||||
* @access private
|
||||
*/
|
||||
function __overload($type, $name) {
|
||||
if (($type === 'Model' || $type === 'Helper') && strtolower($name) != 'schema') {
|
||||
function __overload($type, $name, $parent) {
|
||||
if (($type === 'Model' || $type === 'Helper') && $parent !== false) {
|
||||
Overloadable::overload($name);
|
||||
}
|
||||
}
|
||||
|
@ -1088,10 +1088,10 @@ class App extends Object {
|
|||
switch ($load) {
|
||||
case 'model':
|
||||
if (!class_exists('Model')) {
|
||||
App::import('Model', 'Model', false, App::core('models'));
|
||||
require LIBS . 'model' . DS . 'model.php';
|
||||
}
|
||||
if (!class_exists('AppModel')) {
|
||||
App::import($type, 'AppModel', false, App::path('models'));
|
||||
App::import($type, 'AppModel', false);
|
||||
}
|
||||
if ($plugin) {
|
||||
if (!class_exists($plugin . 'AppModel')) {
|
||||
|
|
|
@ -254,7 +254,7 @@ class Debugger extends Object {
|
|||
* @access public
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ class CakeSchema extends Object {
|
|||
}
|
||||
|
||||
if (empty($options['path'])) {
|
||||
$this->path = CONFIGS . 'sql';
|
||||
$this->path = CONFIGS . 'schema';
|
||||
}
|
||||
|
||||
$options = array_merge(get_object_vars($this), $options);
|
||||
|
@ -161,6 +161,7 @@ class CakeSchema extends Object {
|
|||
extract(get_object_vars($this));
|
||||
|
||||
$class = $name .'Schema';
|
||||
|
||||
if (!class_exists($class)) {
|
||||
if (file_exists($path . DS . $file) && is_file($path . DS . $file)) {
|
||||
require_once($path . DS . $file);
|
||||
|
|
|
@ -46,9 +46,11 @@ Mock::generatePartial(
|
|||
);
|
||||
Mock::generatePartial(
|
||||
'AclShell', 'MockAclShell',
|
||||
array('in', 'out', 'hr', 'createFile')
|
||||
array('in', 'out', 'hr', 'createFile', 'error', 'err')
|
||||
);
|
||||
|
||||
Mock::generate('AclComponent', 'MockAclShellAclComponent');
|
||||
|
||||
/**
|
||||
* AclShellTest class
|
||||
*
|
||||
|
@ -82,7 +84,7 @@ class AclShellTest extends CakeTestCase {
|
|||
}
|
||||
|
||||
/**
|
||||
* setUp method
|
||||
* startTest method
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
|
@ -92,10 +94,13 @@ class AclShellTest extends CakeTestCase {
|
|||
$this->Task =& new MockAclShell($this->Dispatcher);
|
||||
$this->Task->Dispatch = new $this->Dispatcher;
|
||||
$this->Task->params['datasource'] = 'test_suite';
|
||||
$this->Task->Acl =& new AclComponent();
|
||||
$controller = null;
|
||||
$this->Task->Acl->startup($controller);
|
||||
}
|
||||
|
||||
/**
|
||||
* tearDown method
|
||||
* endTest method
|
||||
*
|
||||
* @return void
|
||||
* @access public
|
||||
|
@ -128,5 +133,89 @@ class AclShellTest extends CakeTestCase {
|
|||
|
||||
$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