mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-12 06:56:24 +00:00
converted bake script to use console. refactored some other script code
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5009 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
c9dcd61801
commit
9e6677030b
4 changed files with 250 additions and 510 deletions
|
@ -82,7 +82,7 @@ class AclScript extends CakeScript {
|
||||||
$this->out('');
|
$this->out('');
|
||||||
$this->out('Your database configuration was not found.');
|
$this->out('Your database configuration was not found.');
|
||||||
$this->out('Take a moment to create one:');
|
$this->out('Take a moment to create one:');
|
||||||
$this->doDbConfig();
|
$this->__doDbConfig();
|
||||||
}
|
}
|
||||||
require_once (CONFIGS.'database.php');
|
require_once (CONFIGS.'database.php');
|
||||||
|
|
||||||
|
@ -109,11 +109,12 @@ class AclScript extends CakeScript {
|
||||||
$parent = $this->args[2];
|
$parent = $this->args[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($parent)) {
|
/*if (!empty($parent)) {
|
||||||
$parent = $this->{$class}->node($model, $parent);
|
$parent = $this->{$class}->node($model, $parent);
|
||||||
} else {
|
} else {
|
||||||
$parent = null;
|
$parent = null;
|
||||||
}
|
}*/
|
||||||
|
|
||||||
$this->Acl->{$class}->create();
|
$this->Acl->{$class}->create();
|
||||||
if($this->Acl->{$class}->save(array(
|
if($this->Acl->{$class}->save(array(
|
||||||
'parent_id' => Set::extract($parent, "0.{$class}.id"),
|
'parent_id' => Set::extract($parent, "0.{$class}.id"),
|
||||||
|
@ -251,7 +252,9 @@ class AclScript extends CakeScript {
|
||||||
$this->out("Creating access control objects table (acos)...\n");
|
$this->out("Creating access control objects table (acos)...\n");
|
||||||
$sql = " CREATE TABLE ".$db->fullTableName('acos')." (
|
$sql = " CREATE TABLE ".$db->fullTableName('acos')." (
|
||||||
".$db->name('id')." ".$db->column($db->columns['primary_key']).",
|
".$db->name('id')." ".$db->column($db->columns['primary_key']).",
|
||||||
".$db->name('object_id')." ".$db->column($db->columns['integer'])." default NULL,
|
".$db->name('parent_id')." ".$db->column($db->columns['integer'])." default NULL,
|
||||||
|
".$db->name('model')." ".$db->column($db->columns['string'])." NOT NULL default '',
|
||||||
|
".$db->name('foreign_key')." ".$db->column($db->columns['integer'])." default NULL,
|
||||||
".$db->name('alias')." ".$db->column($db->columns['string'])." NOT NULL default '',
|
".$db->name('alias')." ".$db->column($db->columns['string'])." NOT NULL default '',
|
||||||
".$db->name('lft')." ".$db->column($db->columns['integer'])." default NULL,
|
".$db->name('lft')." ".$db->column($db->columns['integer'])." default NULL,
|
||||||
".$db->name('rght')." ".$db->column($db->columns['integer'])." default NULL,
|
".$db->name('rght')." ".$db->column($db->columns['integer'])." default NULL,
|
||||||
|
@ -264,6 +267,8 @@ class AclScript extends CakeScript {
|
||||||
$this->out("Creating access request objects table (aros)...\n");
|
$this->out("Creating access request objects table (aros)...\n");
|
||||||
$sql2 = "CREATE TABLE ".$db->fullTableName('aros')." (
|
$sql2 = "CREATE TABLE ".$db->fullTableName('aros')." (
|
||||||
".$db->name('id')." ".$db->column($db->columns['primary_key']).",
|
".$db->name('id')." ".$db->column($db->columns['primary_key']).",
|
||||||
|
".$db->name('parent_id')." ".$db->column($db->columns['integer'])." default NULL,
|
||||||
|
".$db->name('model')." ".$db->column($db->columns['string'])." NOT NULL default '',
|
||||||
".$db->name('foreign_key')." ".$db->column($db->columns['integer'])." default NULL,
|
".$db->name('foreign_key')." ".$db->column($db->columns['integer'])." default NULL,
|
||||||
".$db->name('alias')." ".$db->column($db->columns['string'])." NOT NULL default '',
|
".$db->name('alias')." ".$db->column($db->columns['string'])." NOT NULL default '',
|
||||||
".$db->name('lft')." ".$db->column($db->columns['integer'])." default NULL,
|
".$db->name('lft')." ".$db->column($db->columns['integer'])." default NULL,
|
||||||
|
@ -292,32 +297,6 @@ class AclScript extends CakeScript {
|
||||||
$this->out("\nDone.\n");
|
$this->out("\nDone.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Enter description here...
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function upgradedb() {
|
|
||||||
$db =& ConnectionManager::getDataSource($this->dataSource);
|
|
||||||
$this->out("Initializing Database...\n");
|
|
||||||
$this->out("Upgrading table (aros)...\n");
|
|
||||||
$sql = "ALTER TABLE ".$db->fullTableName('aros')."
|
|
||||||
CHANGE ".$db->name('user_id')."
|
|
||||||
".$db->name('foreign_key')."
|
|
||||||
INT( 10 ) UNSIGNED NULL DEFAULT NULL;";
|
|
||||||
$sql .= "ALTER TABLE " . $db->name('aros_acos') . " CHANGE " . $db->name('_create')
|
|
||||||
. " " . $db->name('_create') . " CHAR(2) NOT NULL DEFAULT '0';";
|
|
||||||
$sql .= "ALTER TABLE " . $db->name('aros_acos') . " CHANGE " . $db->name('_update')
|
|
||||||
. " " . $db->name('_update') . " CHAR(2) NOT NULL DEFAULT '0';";
|
|
||||||
$sql .= "ALTER TABLE " . $db->name('aros_acos') . " CHANGE " . $db->name('_read')
|
|
||||||
. " " . $db->name('_read') . " CHAR(2) NOT NULL DEFAULT '0';";
|
|
||||||
$sql .= "ALTER TABLE " . $db->name('aros_acos') . " CHANGE " . $db->name('_delete')
|
|
||||||
. " " . $db->name('_delete') . " CHAR(2) NOT NULL DEFAULT '0';";
|
|
||||||
if ($db->query($sql) === false) {
|
|
||||||
die("Error: " . $db->lastError() . "\n\n");
|
|
||||||
}
|
|
||||||
$this->out("\nDatabase upgrade is complete.\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter description here...
|
* Enter description here...
|
||||||
*
|
*
|
||||||
|
@ -331,7 +310,7 @@ class AclScript extends CakeScript {
|
||||||
$out .= "\t\tCreates a new ACL object under the parent specified by <parent_id>, an id/alias (see\n";
|
$out .= "\t\tCreates a new ACL object under the parent specified by <parent_id>, an id/alias (see\n";
|
||||||
$out .= "\t\t'view'). The link_id allows you to link a user object to Cake's\n";
|
$out .= "\t\t'view'). The link_id allows you to link a user object to Cake's\n";
|
||||||
$out .= "\t\tACL structures. The alias parameter allows you to address your object\n";
|
$out .= "\t\tACL structures. The alias parameter allows you to address your object\n";
|
||||||
$out .= "\t\tusing a non-integer ID. Example: \"\$php acl.php create aro 57 0 John\"\n";
|
$out .= "\t\tusing a non-integer ID. Example: \"\$cake acl create aro 57 0 John\"\n";
|
||||||
$out .= "\t\twould create a new ARO object at the root of the tree, linked to 57\n";
|
$out .= "\t\twould create a new ARO object at the root of the tree, linked to 57\n";
|
||||||
$out .= "\t\tin your users table, with an internal alias 'John'.";
|
$out .= "\t\tin your users table, with an internal alias 'John'.";
|
||||||
$out .= "\n";
|
$out .= "\n";
|
||||||
|
@ -431,7 +410,7 @@ class AclScript extends CakeScript {
|
||||||
* Database configuration setup.
|
* Database configuration setup.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function doDbConfig() {
|
function __doDbConfig() {
|
||||||
$this->hr(true);
|
$this->hr(true);
|
||||||
$this->out('Database Configuration:');
|
$this->out('Database Configuration:');
|
||||||
$this->hr(true);
|
$this->hr(true);
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -127,7 +127,7 @@ class CakeScript extends Object {
|
||||||
* Main-loop method.
|
* Main-loop method.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function main() {
|
function bake() {
|
||||||
|
|
||||||
$this->out('');
|
$this->out('');
|
||||||
$this->out('');
|
$this->out('');
|
||||||
|
@ -139,7 +139,8 @@ class CakeScript extends Object {
|
||||||
|
|
||||||
if(empty($this->dbConfig)) {
|
if(empty($this->dbConfig)) {
|
||||||
$this->out('');
|
$this->out('');
|
||||||
$this->out('Your database configuration was not found. Take a moment to create one:');
|
$this->err('Your database configuration was not found. Take a moment to create one:');
|
||||||
|
exit();
|
||||||
}
|
}
|
||||||
require_once (CONFIGS . 'database.php');
|
require_once (CONFIGS . 'database.php');
|
||||||
|
|
||||||
|
@ -195,7 +196,7 @@ class CakeScript extends Object {
|
||||||
* @param string $string Error text to output.
|
* @param string $string Error text to output.
|
||||||
*/
|
*/
|
||||||
function err($string) {
|
function err($string) {
|
||||||
return $this->Dispatch->stderr($string);
|
return $this->Dispatch->stderr($string."\n");
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Outputs a series of minus characters to the standard output, acts as a visual separator.
|
* Outputs a series of minus characters to the standard output, acts as a visual separator.
|
||||||
|
|
|
@ -342,6 +342,7 @@ class ConsoleDispatcher {
|
||||||
$this->args[] = $params[$i];
|
$this->args[] = $params[$i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$this->params = array_merge(array('working'=> dirname(dirname(dirname(__FILE__)))), $this->params);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* Removes first argument and shifts other arguments up
|
* Removes first argument and shifts other arguments up
|
||||||
|
|
Loading…
Add table
Reference in a new issue