Merging changes into trunk

git-svn-id: https://svn.cakephp.org/repo/trunk/cake@1565 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2005-12-22 01:07:28 +00:00
parent 94e5730b41
commit 526e1ac450
18 changed files with 1186 additions and 785 deletions

View file

@ -60,6 +60,12 @@ class Dispatcher extends Object
*/
var $admin = false;
/**
* Base URL
* @var string
*/
var $webservices = null;
/**
* Constructor.
*/
@ -146,8 +152,6 @@ class Dispatcher extends Object
$params['controller'] = Inflector::camelize($params['controller']."Controller");
}
$controller->missingController = $params['controller'];
$controller->webroot = $this->webroot;
return $this->_invoke($controller, $params );
}
else
{
@ -181,10 +185,12 @@ class Dispatcher extends Object
$controller->passed_args = empty($params['pass'])? null: $params['pass'];
$controller->autoLayout = !$params['bare'];
$controller->autoRender = !$params['render'];
$controller->webservices = $params['webservices'];
if(!defined('AUTO_SESSION') || AUTO_SESSION == true)
if(!is_null($controller->webservices))
{
array_push($controller->components, 'Session');
array_push($controller->components, $controller->webservices);
array_push($controller->helpers, $controller->webservices);
}
if((in_array('scaffold', array_keys($classVars))) && ($missingAction === true))
@ -261,6 +267,10 @@ class Dispatcher extends Object
}
$params['bare'] = empty($params['ajax'])? (empty($params['bare'])? 0: 1): 1;
if(defined('WEBSERVICES'))
{
$params['webservices'] = empty($params['webservices']) ? null : $params['webservices'];
}
return $params;
}

View file

@ -41,12 +41,16 @@
* @since CakePHP v 0.10.0.1076
*
*/
class AclComponent
class AclComponent extends Object
{
var $_instance = null;
var $controller = true;
/**
* Enter description here...
*
*/
function __construct()
{
$this->getACL();
@ -68,6 +72,10 @@ class AclComponent
return $this->_instance;
}
/**
* Enter description here...
*
*/
function _initACL()
{

View file

@ -1,35 +1,40 @@
<?php
//////////////////////////////////////////////////////////////////////////
// + $Id$
// +------------------------------------------------------------------+ //
// + Cake PHP : Rapid Development Framework <http://www.cakephp.org/> + //
// + Copyright: (c) 2005, CakePHP Authors/Developers + //
// + Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com> + //
// + Larry E. Masters aka PhpNut <nut@phpnut.com> + //
// + Kamil Dzielinski aka Brego <brego.dk@gmail.com> + //
// +------------------------------------------------------------------+ //
// + Licensed under The MIT License + //
// + Redistributions of files must retain the above copyright notice. + //
// + See: http://www.opensource.org/licenses/mit-license.php + //
//////////////////////////////////////////////////////////////////////////
/* SVN FILE: $Id$ */
/**
* Access Control List abstract class.
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @author CakePHP Authors/Developers
* @copyright Copyright (c) 2005, CakePHP Authors/Developers
* @link https://trac.cakephp.org/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.cake.libs.controller.components
* @since CakePHP v 0.10.0.1076
* @since CakePHP v 0.10.0.1232
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*
*/
/**
* Enter description here...
*
* @return AclBase
*/
uses('error_messages');
/**
@ -44,6 +49,11 @@ uses('error_messages');
class AclBase
{
/**
* Enter description here...
*
* @return AclBase
*/
function AclBase()
{
//No instantiations or constructor calls (even statically)
@ -55,6 +65,13 @@ class AclBase
}
/**
* Enter description here...
*
* @param unknown_type $aro
* @param unknown_type $aco
* @param unknown_type $action
*/
function check($aro, $aco, $action = "*") {}
}

View file

@ -11,8 +11,7 @@
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
* Larry E. Masters aka PhpNut <nut@phpnut.com>
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License
@ -23,7 +22,7 @@
* @copyright Copyright (c) 2005, CakePHP Authors/Developers
* @link https://trac.cakephp.org/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.cake.app.controllers.componenets
* @subpackage cake.cake.app.controllers.componenets.dbacl
* @since CakePHP v 0.2.9
* @version $Revision$
* @modifiedby $LastChangedBy$
@ -31,6 +30,7 @@
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
uses('inflector');
uses('controller'.DS.'components'.DS.'acl_base');
uses('controller'.DS.'components'.DS.'dbacl'.DS.'models'.DS.'aclnode');
uses('controller'.DS.'components'.DS.'dbacl'.DS.'models'.DS.'aco');
@ -42,17 +42,29 @@ uses('controller'.DS.'components'.DS.'dbacl'.DS.'models'.DS.'aros_aco');
* In this file you can extend the AclBase.
*
* @package cake
* @subpackage cake.cake.app.controllers.components
* @subpackage cake.cake.app.controllers.components.dbacl
*/
class DB_ACL extends AclBase
{
/**
* Enter description here...
*
*/
function __construct()
{
}
/**
* Enter description here...
*
* @param unknown_type $aro
* @param unknown_type $aco
* @param unknown_type $action
* @return unknown
*/
function check($aro, $aco, $action = "*")
{
@ -96,12 +108,15 @@ class DB_ACL extends AclBase
{
// ARO must be cleared for ALL ACO actions
foreach($permKeys as $key)
{
if(isset($perm['aros_acos']))
{
if($perm['aros_acos'][$key] != 1)
{
return false;
}
}
}
return true;
}
else
@ -234,6 +249,12 @@ class DB_ACL extends AclBase
/**
* Enter description here...
*
* @param unknown_type $id
* @return unknown
*/
function getAro($id = null)
{
if($id == null)
@ -247,6 +268,12 @@ class DB_ACL extends AclBase
}
/**
* Enter description here...
*
* @param unknown_type $id
* @return unknown
*/
function getAco($id = null)
{
if($id == null)
@ -260,6 +287,13 @@ class DB_ACL extends AclBase
}
/**
* Enter description here...
*
* @param unknown_type $aro
* @param unknown_type $aco
* @return unknown
*/
function getAclLink($aro, $aco)
{
$Aro = new Aro();
@ -281,6 +315,12 @@ class DB_ACL extends AclBase
);
}
/**
* Enter description here...
*
* @param unknown_type $keys
* @return unknown
*/
function _getAcoKeys($keys)
{
$newKeys = array();

View file

@ -1,17 +1,77 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @author CakePHP Authors/Developers
* @copyright Copyright (c) 2005, CakePHP Authors/Developers
* @link https://trac.cakephp.org/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.cake.libs.controller.components.dbacl.models
* @since CakePHP v 0.10.0.1232
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Short description.
*/
require_once(CAKE . 'app_model.php');
/**
* Short description for file.
*
* Long description for file
*
* @package cake
* @subpackage cake.cake.libs.controller.components.dbacl.models
* @since CakePHP v 0.10.0.1232
*
*/
class AclNode extends AppModel
{
/**
* Enter description here...
*
* @var unknown_type
*/
var $useTable = false;
/**
* Enter description here...
*
*/
function __construct()
{
parent::__construct();
$this->__setTable();
}
/**
* Enter description here...
*
* @param unknown_type $link_id
* @param unknown_type $parent_id
* @param unknown_type $alias
* @return unknown
*/
function create($link_id = 0, $parent_id = null, $alias = '')
{
parent::create();
@ -58,6 +118,13 @@ class AclNode extends AppModel
}
/**
* Enter description here...
*
* @param unknown_type $parent_id
* @param unknown_type $id
* @return unknown
*/
function setParent($parent_id = null, $id = null)
{
if (strtolower(get_class($this)) == "aclnode")
@ -121,6 +188,12 @@ class AclNode extends AppModel
}
/**
* Enter description here...
*
* @param unknown_type $id
* @return unknown
*/
function getParent($id)
{
$path = $this->getPath($id);
@ -134,6 +207,12 @@ class AclNode extends AppModel
}
}
/**
* Enter description here...
*
* @param unknown_type $id
* @return unknown
*/
function getPath($id)
{
if (strtolower(get_class($this)) == "aclnode")
@ -147,6 +226,12 @@ class AclNode extends AppModel
return $this->findAll("lft <= {$item[$class]['lft']} and rght >= {$item[$class]['rght']}");
}
/**
* Enter description here...
*
* @param unknown_type $id
* @return unknown
*/
function getChildren($id)
{
if (strtolower(get_class($this)) == "aclnode")
@ -160,6 +245,13 @@ class AclNode extends AppModel
return $this->findAll("lft > {$item[$class]['lft']} and rght < {$item[$class]['rght']}");
}
/**
* Enter description here...
*
* @param unknown_type $id
* @param unknown_type $fKey
* @return unknown
*/
function _resolveID($id, $fKey)
{
$key = (is_string($id) ? 'alias' : $fKey);
@ -167,6 +259,14 @@ class AclNode extends AppModel
return "{$key} = {$val}";
}
/**
* Enter description here...
*
* @param unknown_type $table
* @param unknown_type $dir
* @param unknown_type $lft
* @param unknown_type $rght
*/
function _syncTable($table, $dir, $lft, $rght)
{
$shift = ($dir == 2 ? 1 : 2);
@ -174,17 +274,26 @@ class AclNode extends AppModel
$this->db->query("UPDATE $table SET lft = lft " . ($dir > 0 ? "+" : "-") . " {$shift} WHERE lft > " . $lft);
}
/**
* Enter description here...
*
* @return unknown
*/
function __dataVars()
{
$vars = array();
$class = strtolower(get_class($this));
$vars['secondary_id'] = ($class == 'aro' ? 'user_id' : 'object_id');
$class = Inflector::camelize(strtolower(get_class($this)));
$vars['secondary_id'] = (strtolower($class) == 'aro' ? 'user_id' : 'object_id');
$vars['data_name'] = $class;
$vars['table_name'] = $class . 's';
$vars['class'] = ucwords($class);
$vars['class'] = Inflector::camelize($class);
return $vars;
}
/**
* Enter description here...
*
*/
function __setTable()
{
$this->table = strtolower(get_class($this)) . "s";

View file

@ -1,8 +1,53 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @author CakePHP Authors/Developers
* @copyright Copyright (c) 2005, CakePHP Authors/Developers
* @link https://trac.cakephp.org/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.cake.libs.controller.components.dbacl.models
* @since CakePHP v 0.10.0.1232
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Short description for file.
*
* Long description for file
*
* @package cake
* @subpackage cake.cake.libs.controller.components.dbacl.models
* @since CakePHP v 0.10.0.1232
*
*/
class Aco extends AclNode
{
var $name = 'Aco';
/**
* Enter description here...
*
* @var unknown_type
*/
var $hasMany = 'ArosAco,AcoActions';
}

View file

@ -1,9 +1,58 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @author CakePHP Authors/Developers
* @copyright Copyright (c) 2005, CakePHP Authors/Developers
* @link https://trac.cakephp.org/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.cake.libs.controller.components.dbacl.models
* @since CakePHP v 0.10.0.1232
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Short description.
*/
require_once(CAKE.'app_model.php');
/**
* Short description for file.
*
* Long description for file
*
* @package cake
* @subpackage cake.cake.libs.controller.components.dbacl.models
* @since CakePHP v 0.10.0.1232
*
*/
class AcoAction extends AppModel
{
/**
* Enter description here...
*
* @var unknown_type
*/
var $belongsTo = 'Aco';
}

View file

@ -1,7 +1,59 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @author CakePHP Authors/Developers
* @copyright Copyright (c) 2005, CakePHP Authors/Developers
* @link https://trac.cakephp.org/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.cake.libs.controller.components.dbacl.models
* @since CakePHP v 0.10.0.1232
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Short description for file.
*
* Long description for file
*
* @package cake
* @subpackage cake.cake.libs.controller.components.dbacl.models
* @since CakePHP v 0.10.0.1232
*
*/
class Aro extends AclNode
{
/**
* Enter description here...
*
* @var unknown_type
*/
var $name = 'Aro';
/**
* Enter description here...
*
* @var unknown_type
*/
var $hasMany = 'ArosAco';
}

View file

@ -1,8 +1,66 @@
<?php
/* SVN FILE: $Id$ */
/**
* Short description for file.
*
* Long description for file
*
* PHP versions 4 and 5
*
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License
* Redistributions of files must retain the above copyright notice.
*
* @filesource
* @author CakePHP Authors/Developers
* @copyright Copyright (c) 2005, CakePHP Authors/Developers
* @link https://trac.cakephp.org/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.cake.libs.controller.components.dbacl.models
* @since CakePHP v 0.10.0.1232
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
*/
/**
* Short description for file.
*
* Long description for file
*
* @package cake
* @subpackage cake.cake.libs.controller.components.dbacl.models
* @since CakePHP v 0.10.0.1232
*
*/
class ArosAco extends AppModel
{
/**
* Enter description here...
*
* @var unknown_type
*/
var $name = 'ArosAco';
/**
* Enter description here...
*
* @var unknown_type
*/
var $useTable = 'aros_acos';
/**
* Enter description here...
*
* @var unknown_type
*/
var $belongsTo = 'Aro,Aco';
}

View file

@ -121,7 +121,7 @@ class SessionComponent extends Object
/**
* Enter description here...
*
* Use like this. $this->Session->setError();
* Use like this. $this->Session->setFlash('This has been saved');
*
* @return string Last session error
*/
@ -133,7 +133,7 @@ class SessionComponent extends Object
/**
* Enter description here...
*
* Use like this. $this->Session->setError();
* Use like this. $this->Session->flash();
*
* @return
*/

View file

@ -194,6 +194,10 @@ class Controller extends Object
$this->viewPath = Inflector::underscore($this->name);
$this->modelClass = Inflector::singularize($this->name);
$this->modelKey = Inflector::underscore($this->modelClass);
if(!defined('AUTO_SESSION') || AUTO_SESSION == true)
{
array_push($this->components, 'Session');
}
parent::__construct();
}
@ -367,106 +371,6 @@ class Controller extends Object
return $view->render($action, $layout, $file);
}
/**
* Renders the Missing Controller web page.
*
*/
function missingController()
{
$this->autoLayout = true;
$this->pageTitle = 'Missing Controller';
$this->render('../errors/missingController');
exit();
}
/**
* Renders the Missing Action web page.
*
*/
function missingAction()
{
$this->autoLayout = true;
$this->pageTitle = 'Missing Method in Controller';
$this->render('../errors/missingAction');
exit();
}
/**
* Renders the Private Action web page.
*
*/
function privateAction()
{
$this->autoLayout = true;
$this->pageTitle = 'Trying to access private method in class';
$this->render('../errors/privateAction');
exit();
}
/**
* Renders the Missing Database web page.
*
*/
function missingDatabase()
{
$this->autoLayout = true;
$this->pageTitle = 'Scaffold Missing Database Connection';
$this->render('../errors/missingScaffolddb');
exit();
}
/**
* Renders the Missing Table web page.
*
*/
function missingTable($tableName)
{
$this->autoLayout = true;
$this->missingTableName = $tableName;
$this->pageTitle = 'Missing Database Table';
$this->render('../errors/missingTable');
exit();
}
/**
* Renders the Missing Helper file web page.
*
*/
function missingHelperFile($file)
{
$this->missingHelperFile = $file;
$this->missingHelperClass = Inflector::camelize($file) . "Helper";
$this->pageTitle = 'Missing Helper File';
$this->render('../errors/missingHelperFile');
exit();
}
/**
* Renders the Missing Helper class web page.
*
*/
function missingHelperClass($class)
{
$this->missingHelperClass = Inflector::camelize($class) . "Helper";
$this->missingHelperFile = Inflector::underscore($class);
$this->pageTitle = 'Missing Helper Class';
$this->render('../errors/missingHelperClass');
exit();
}
/**
* Renders the Missing Table web page.
*
*/
function missingConnection()
{
$this->autoLayout = true;
$this->pageTitle = 'Missing Database Connection';
$this->render('../errors/missingDatabase');
exit();
}
/**
* Sets data for this view. Will set title if the key "title" is in given $data array.
*

View file

@ -396,6 +396,7 @@ class Scaffold extends Object {
}
else
{
$this->controllerClass->constructClasses();
$this->controllerClass->layout = 'default';
call_user_func_array(array($this->controllerClass, 'missingDatabase'), null);
exit;

View file

@ -11,8 +11,7 @@
* CakePHP : Rapid Development Framework <http://www.cakephp.org/>
* Copyright (c) 2005, CakePHP Authors/Developers
*
* Author(s): Michal Tatarynowicz aka Pies <tatarynowicz@gmail.com>
* Larry E. Masters aka PhpNut <nut@phpnut.com>
* Author(s): Larry E. Masters aka PhpNut <nut@phpnut.com>
* Kamil Dzielinski aka Brego <brego.dk@gmail.com>
*
* Licensed under The MIT License
@ -24,7 +23,7 @@
* @link https://trac.cakephp.org/wiki/Authors Authors/Developers
* @package cake
* @subpackage cake.cake.libs.model
* @since CakePHP v 0.2.9
* @since CakePHP v 0.10.0.0
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
@ -227,7 +226,7 @@ class Model extends Object
$this->db =& $dboFactory;
if(empty($this->db))
{
$this->_throwMissingConnection();
$this->missingConnection();
}
}
@ -302,7 +301,7 @@ class Model extends Object
$association = explode(',', $this->belongsTo);
foreach ($association as $className)
{
$this->_constructAssociatedModels($className , 'Belongs');
$this->_constructAssociatedModels($className, $className , 'Belongs');
$this->linkAssociation('Belongs', $className, $className, $this->id);
}
}
@ -320,7 +319,7 @@ class Model extends Object
foreach ($this->hasOne as $association => $associationValue)
{
$className = $association;
$this->_associationSwitch($className, $className, $associationValue, 'One');
$this->_associationSwitch($association, $className, $associationValue, 'One');
}
}
else
@ -328,7 +327,7 @@ class Model extends Object
$association = explode(',', $this->hasOne);
foreach ($association as $className)
{
$this->_constructAssociatedModels($className , 'One');
$this->_constructAssociatedModels($className, $className , 'One');
$this->linkAssociation('One', $className, $className, $this->id);
}
}
@ -354,7 +353,7 @@ class Model extends Object
$association = explode(',', $this->hasMany);
foreach ($association as $className)
{
$this->_constructAssociatedModels($className , 'Many');
$this->_constructAssociatedModels($className, $className , 'Many');
$this->linkAssociation('Many', $className, $className, $this->id);
}
}
@ -380,7 +379,7 @@ class Model extends Object
$association = explode(',', $this->hasAndBelongsToMany);
foreach ($association as $className)
{
$this->_constructAssociatedModels($className , 'ManyTo');
$this->_constructAssociatedModels($className, $className , 'ManyTo');
$this->linkAssociation('ManyTo', $className, $className, $this->id);
}
}
@ -407,66 +406,66 @@ class Model extends Object
if ($classCreated === false)
{
$this->_constructAssociatedModels($className , $type);
$this->_constructAssociatedModels($association, $className , $type);
$classCreated = true;
}
switch($option)
{
case 'associationForeignKey':
$this->{$className}->{$this->currentModel.'_associationforeignkey'} = $optionValue;
$this->{$association.'_associationforeignkey'} = $optionValue;
break;
case 'conditions':
$this->{$className}->{$this->currentModel.'_conditions'} = $optionValue;
$this->{$association.'_conditions'} = $optionValue;
break;
case 'counterCache':
$this->{$className}->{$this->currentModel.'_countercache'} = $optionValue;
$this->{$association.'_countercache'} = $optionValue;
break;
case 'counterSql':
$this->{$className}->{$this->currentModel.'_countersql'} = $optionValue;
$this->{$association.'_countersql'} = $optionValue;
break;
case 'deleteSql':
$this->{$className}->{$this->currentModel.'_deletesql'} = $optionValue;
$this->{$association.'_deletesql'} = $optionValue;
break;
case 'dependent':
$this->{$className}->{$this->currentModel.'_dependent'} = $optionValue;
$this->{$association.'_dependent'} = $optionValue;
break;
case 'exclusive':
$this->{$className}->{$this->currentModel.'_exclusive'} = $optionValue;
$this->{$association.'_exclusive'} = $optionValue;
break;
case 'finderSql':
$this->{$className}->{$this->currentModel.'_findersql'} = $optionValue;
$this->{$association.'_findersql'} = $optionValue;
break;
case 'foreignKey':
$this->{$className}->{$this->currentModel.'_foreignkey'} = $optionValue;
$this->{$association.'_foreignkey'} = $optionValue;
break;
case 'insertSql':
$this->{$className}->{$this->currentModel.'_insertsql'} = $optionValue;
$this->{$association.'_insertsql'} = $optionValue;
break;
case 'joinTable':
$this->{$className}->{$this->currentModel.'_jointable'} = $optionValue;
$this->{$association.'_jointable'} = $optionValue;
break;
case 'order':
$this->{$className}->{$this->currentModel.'_order'} = $optionValue;
$this->{$association.'_order'} = $optionValue;
break;
case 'uniq':
$this->{$className}->{$this->currentModel.'_uniq'} = $optionValue;
$this->{$association.'_uniq'} = $optionValue;
break;
case 'fields':
$this->{$className}->{$this->currentModel.'_fields'} = $optionValue;
$this->{$association.'_fields'} = $optionValue;
break;
}
}
@ -480,7 +479,7 @@ class Model extends Object
* @param unknown_type $type
* @access private
*/
function _constructAssociatedModels($className, $type)
function _constructAssociatedModels($association, $className, $type)
{
$collectionKey = Inflector::underscore($className);
$classRegistry =& ClassRegistry::getInstance();
@ -497,28 +496,28 @@ class Model extends Object
switch($type)
{
case 'Belongs':
$this->{$className}->{$this->currentModel.'_conditions'} = null;
$this->{$className}->{$this->currentModel.'_order'} = null;
$this->{$className}->{$this->currentModel.'_foreignkey'} = Inflector::singularize($this->{$className}->table).'_id';
$this->{$className}->{$this->currentModel.'_countercache'} = null;
$this->{$association.'_conditions'} = null;
$this->{$association.'_order'} = null;
$this->{$association.'_foreignkey'} = Inflector::singularize($this->{$className}->table).'_id';
$this->{$association.'_countercache'} = null;
break;
case 'One':
$this->{$className}->{$this->currentModel.'_conditions'} = null;
$this->{$className}->{$this->currentModel.'_order'} = null;
$this->{$className}->{$this->currentModel.'_dependent'} = null;
$this->{$className}->{$this->currentModel.'_foreignkey'} = Inflector::singularize($this->table).'_id';
$this->{$association.'_conditions'} = null;
$this->{$association.'_order'} = null;
$this->{$association.'_dependent'} = null;
$this->{$association.'_foreignkey'} = Inflector::singularize($this->table).'_id';
break;
case 'Many':
$this->{$className}->{$this->currentModel.'_conditions'} = null;
$this->{$className}->{$this->currentModel.'_order'} = null;
$this->{$className}->{$this->currentModel.'_foreignkey'} = Inflector::singularize($this->table).'_id';
$this->{$className}->{$this->currentModel.'_fields'} = '*';
$this->{$className}->{$this->currentModel.'_dependent'} = null;
$this->{$className}->{$this->currentModel.'_exclusive'} = null;
$this->{$className}->{$this->currentModel.'_findersql'} = null;
$this->{$className}->{$this->currentModel.'_countersql'} = null;
$this->{$association.'_conditions'} = null;
$this->{$association.'_order'} = null;
$this->{$association.'_foreignkey'} = Inflector::singularize($this->table).'_id';
$this->{$association.'_fields'} = '*';
$this->{$association.'_dependent'} = null;
$this->{$association.'_exclusive'} = null;
$this->{$association.'_findersql'} = null;
$this->{$association.'_countersql'} = null;
break;
case 'ManyTo':
@ -528,16 +527,16 @@ class Model extends Object
$joinTable = $tableSort[0] . '_' . $tableSort[1];
$key1 = Inflector::singularize($this->table) . '_id';
$key2 = Inflector::singularize($this->{$className}->table) . '_id';
$this->{$className}->{$this->currentModel.'_jointable'} = $joinTable;
$this->{$className}->{$this->currentModel.'_fields'} = '*';
$this->{$className}->{$this->currentModel.'_foreignkey'} = $key1;
$this->{$className}->{$this->currentModel.'_associationforeignkey'} = $key2;
$this->{$className}->{$this->currentModel.'_conditions'} = null;
$this->{$className}->{$this->currentModel.'_order'} = null;
$this->{$className}->{$this->currentModel.'_uniq'} = null;
$this->{$className}->{$this->currentModel.'_findersql'} = null;
$this->{$className}->{$this->currentModel.'_deletesql'} = null;
$this->{$className}->{$this->currentModel.'_insertsql'} = null;
$this->{$association.'_jointable'} = $joinTable;
$this->{$association.'_fields'} = '*';
$this->{$association.'_foreignkey'} = $key1;
$this->{$association.'_associationforeignkey'} = $key2;
$this->{$association.'_conditions'} = null;
$this->{$association.'_order'} = null;
$this->{$association.'_uniq'} = null;
$this->{$association.'_findersql'} = null;
$this->{$association.'_deletesql'} = null;
$this->{$association.'_insertsql'} = null;
break;
}
$this->tableToModel[$this->{$className}->table] = $className;
@ -585,7 +584,7 @@ class Model extends Object
{
if (!in_array(strtolower($tableName), $this->db->tables()))
{
$this->_throwMissingTable($tableName);
$this->missingTable($tableName);
exit();
}
else
@ -618,7 +617,7 @@ class Model extends Object
{
foreach ($v as $x => $y)
{
if($x == 'id')
if($x == $this->tableId)
{
$this->id = $y;
}
@ -790,7 +789,7 @@ class Model extends Object
$values[] = (ini_get('magic_quotes_gpc') == 1) ?
$this->db->prepare(stripslashes($y)) : $this->db->prepare($y);
if($x == 'id' && !is_numeric($y))
if($x == $this->tableId && !is_numeric($y))
{
$newID = $y;
}
@ -837,7 +836,7 @@ class Model extends Object
}
else
{
return $this->db->hasAny($this->table, "id = '{$this->id}'");
return $this->db->hasAny($this->table, "$this->tableId = '{$this->id}'");
}
}
else
@ -849,7 +848,7 @@ class Model extends Object
if($this->db->query($sql))
{
$this->id = $this->db->lastInsertId($this->table, 'id');
$this->id = $this->db->lastInsertId($this->table, $this->tableId);
if(!empty($joined))
{
if(!$this->id > 0 && isset($newID))
@ -884,13 +883,12 @@ class Model extends Object
{
foreach ($joined as $x => $y)
{
foreach ($y as $name => $value)
foreach ($y as $association => $value)
{
$name = Inflector::camelize($name);
$joinTable[] = $this->{$name}->{$this->currentModel.'_jointable'};
$mainKey = $this->{$name}->{$this->currentModel.'_foreignkey'};
$joinTable[] = $this->{$association.'_jointable'};
$mainKey = $this->{$association.'_foreignkey'};
$keys[] = $mainKey;
$keys[] = $this->{$name}->{$this->currentModel.'_associationforeignkey'};
$keys[] = $this->{$association.'_associationforeignkey'};
$fields[] = join(',', $keys);
unset($keys);
@ -913,7 +911,8 @@ class Model extends Object
}
}
for ($count = 0; $count < count($joinTable); $count++)
$total = count($joinTable);
for ($count = 0; $count < $total; $count++)
{
$this->db->query("DELETE FROM {$joinTable[$count]} WHERE $mainKey = '{$id}'");
if(!empty($newValue[$count]))
@ -947,7 +946,7 @@ class Model extends Object
{
$this->id = $id;
}
if ($this->id && $this->db->query("DELETE FROM {$this->table} WHERE id = '{$this->id}'"))
if ($this->id && $this->db->query("DELETE FROM {$this->table} WHERE {$this->tableId} = '{$this->id}'"))
{
$this->id = false;
return true;
@ -965,7 +964,7 @@ class Model extends Object
*/
function exists ()
{
return $this->id? $this->db->hasAny($this->table, "id = '{$this->id}'"): false;
return $this->id? $this->db->hasAny($this->table, "$this->tableId = '{$this->id}'"): false;
}
/**
@ -1053,9 +1052,9 @@ class Model extends Object
foreach ($this->_oneToOne as $rule)
{
list($association, $model, $value) = $rule;
if(!empty($this->{$model}->{$this->currentModel.'_foreignkey'}))
if(!empty($this->{$association.'_foreignkey'}))
{
if($this->name == $this->{$model}->name)
if($this->name == $this->{$model}->name and $this->name == $association)
{
$alias = 'Child_'.$association;
}
@ -1063,11 +1062,11 @@ class Model extends Object
{
$alias = $association;
}
$oneToOneConditions = $this->parseConditions($this->{$model}->{$this->currentModel.'_conditions'});
$oneToOneOrder = $this->{$model}->{$this->currentModel.'_order'};
$oneToOneConditions = $this->parseConditions($this->{$association.'_conditions'});
$oneToOneOrder = $this->{$association.'_order'};
$joins[] = "LEFT JOIN {$this->{$model}->table} AS `$alias` ON
`$alias`.{$this->{$model}->{$this->currentModel.'_foreignkey'}} = {$this->name}.id"
`$alias`.{$this->{$association.'_foreignkey'}} = {$this->name}.id"
.($oneToOneConditions? " WHERE {$oneToOneConditions}":null)
.($oneToOneOrder? " ORDER BY {$oneToOneOrder}": null);
}
@ -1079,9 +1078,9 @@ class Model extends Object
foreach ($this->_belongsToOther as $rule)
{
list($association, $model, $value) = $rule;
if(!empty($this->{$model}->{$this->currentModel.'_foreignkey'}))
if(!empty($this->{$association.'_foreignkey'}))
{
if($this->name == $this->{$model}->name)
if($this->name == $this->{$model}->name and $this->name == $association)
{
$alias = 'Child_'.$association;
}
@ -1089,10 +1088,10 @@ class Model extends Object
{
$alias = $association;
}
$belongsToOtherConditions = $this->parseConditions($this->{$model}->{$this->currentModel.'_conditions'});
$belongsToOtherOrder = $this->{$model}->{$this->currentModel.'_order'};
$belongsToOtherConditions = $this->parseConditions($this->{$association.'_conditions'});
$belongsToOtherOrder = $this->{$association.'_order'};
$joins[] = "LEFT JOIN {$this->{$model}->table} AS `$alias` ON {$this->name}.{$this->{$model}->{$this->currentModel.'_foreignkey'}} = `$alias`.id"
$joins[] = "LEFT JOIN {$this->{$model}->table} AS `$alias` ON {$this->name}.{$this->{$association.'_foreignkey'}} = `$alias`.id"
.($belongsToOtherConditions? " WHERE {$belongsToOtherConditions}":null)
.($belongsToOtherOrder? " ORDER BY {$belongsToOtherOrder}": null);
}
@ -1158,18 +1157,18 @@ class Model extends Object
{
if($key2 === $this->name)
{
if($this->{$model}->{$this->currentModel.'_findersql'})
if($this->{$association.'_findersql'})
{
$tmpSQL = $this->{$model}->{$this->currentModel.'_findersql'};
$tmpSQL = $this->{$association.'_findersql'};
}
else
{
$oneToManyConditions = $this->parseConditions($this->{$model}->{$this->currentModel.'_conditions'});
$oneToManyOrder = $this->{$model}->{$this->currentModel.'_order'};
$oneToManyConditions = $this->parseConditions($this->{$association.'_conditions'});
$oneToManyOrder = $this->{$association.'_order'};
$tmpSQL = "SELECT {$this->{$model}->{$this->currentModel.'_fields'}} FROM {$this->{$model}->table} AS `{$association}`
WHERE ({$this->{$model}->{$this->currentModel.'_foreignkey'}}) = '{$value2['id']}'"
.($oneToManyConditions? " WHERE {$oneToManyConditions}":null)
$tmpSQL = "SELECT {$this->{$association.'_fields'}} FROM {$this->{$model}->table} AS `{$association}`
WHERE ({$this->{$association.'_foreignkey'}}) = '{$value2['id']}'"
.($oneToManyConditions? " {$oneToManyConditions}":null)
.($oneToManyOrder? " ORDER BY {$oneToManyOrder}": null);
}
@ -1235,25 +1234,25 @@ class Model extends Object
{
if($key2 === $this->name)
{
if( 0 == strncmp($key2, $this->{$model}->{$this->currentModel.'_foreignkey'}, $key2) )
if( 0 == strncmp($key2, $this->{$association.'_foreignkey'}, $key2) )
{
if(!empty ($value2['id']))
{
if($this->{$model}->{$this->currentModel.'_findersql'})
if($this->{$association.'_findersql'})
{
$tmpSQL = $this->{$model}->{$this->currentModel.'_findersql'};
$tmpSQL = $this->{$association.'_findersql'};
}
else
{
$manyToManyConditions = $this->parseConditions($this->{$model}->{$this->currentModel.'_conditions'});
$manyToManyOrder = $this->{$model}->{$this->currentModel.'_order'};
$manyToManyConditions = $this->parseConditions($this->{$association.'_conditions'});
$manyToManyOrder = $this->{$association.'_order'};
$tmpSQL = "SELECT {$this->{$model}->{$this->currentModel.'_fields'}} FROM {$this->{$model}->table} AS `{$association}`
JOIN {$this->{$model}->{$this->currentModel.'_jointable'}}
ON {$this->{$model}->{$this->currentModel.'_jointable'}}.
{$this->{$model}->{$this->currentModel.'_foreignkey'}} = '$value2[id]'
AND {$this->{$model}->{$this->currentModel.'_jointable'}}.
{$this->{$model}->{$this->currentModel.'_associationforeignkey'}} = `{$association}` .id"
$tmpSQL = "SELECT {$this->{$association.'_fields'}} FROM {$this->{$model}->table} AS `{$association}`
JOIN {$this->{$association.'_jointable'}}
ON {$this->{$association.'_jointable'}}.
{$this->{$association.'_foreignkey'}} = '$value2[id]'
AND {$this->{$association.'_jointable'}}.
{$this->{$association.'_associationforeignkey'}} = `{$association}` .id"
.($manyToManyConditions? " WHERE {$manyToManyConditions}":null)
.($manyToManyOrder? " ORDER BY {$manyToManyOrder}": null);
@ -1488,7 +1487,7 @@ class Model extends Object
foreach ($this->_belongsToOther as $rule)
{
list($association, $model, $value) = $rule;
$foreignKeys[$this->{$model}->{$this->currentModel.'_foreignkey'}] = $this->{$model}->{$this->currentModel.'_foreignkey'};
$foreignKeys[$this->{$association.'_foreignkey'}] = $this->{$association.'_foreignkey'};
}
}
@ -1516,7 +1515,7 @@ class Model extends Object
// And if the display field does not exist in the table info structure, use the ID field.
if( false == $this->hasField( $dispField ) )
$dispField = 'id';
$dispField = $this->tableId;
return $dispField;
}
@ -1528,32 +1527,7 @@ class Model extends Object
*/
function getLastInsertID()
{
return $this->db->lastInsertId($this->table, 'id');
}
/**
* Enter description here...
*
* @param unknown_type $tableName
*/
function _throwMissingTable($tableName)
{
$error =& new Controller();
$error->missingTable = $this->table;
call_user_func_array(array(&$error, 'missingTable'), $tableName);
exit;
}
/**
* Enter description here...
*
*/
function _throwMissingConnection()
{
$error =& new Controller();
$error->missingConnection = $this->name;
call_user_func_array(array(&$error, 'missingConnection'), null);
exit;
return $this->db->lastInsertId($this->table, $this->tableId);
}
}

View file

@ -139,6 +139,123 @@ class Object
return $this->_log->write('error', $msg);
}
}
/**
* Renders the Missing Controller web page.
*
*/
function missingController()
{
$this->autoLayout = true;
$this->pageTitle = 'Missing Controller';
$this->render('../errors/missingController');
exit();
}
/**
* Renders the Missing Action web page.
*
*/
function missingAction()
{
$this->autoLayout = true;
$this->pageTitle = 'Missing Method in Controller';
$this->render('../errors/missingAction');
exit();
}
/**
* Renders the Private Action web page.
*
*/
function privateAction()
{
$this->autoLayout = true;
$this->pageTitle = 'Trying to access private method in class';
$this->render('../errors/privateAction');
exit();
}
/**
* Renders the Missing View web page.
*
*/
function missingView()
{
//We are simulating action call below, this is not a filename!
$this->autoLayout = true;
$this->missingView = $this->name;
$this->pageTitle = 'Missing View';
$this->render('../errors/missingView');
}
/**
* Renders the Missing Database web page.
*
*/
function missingDatabase()
{
$this->autoLayout = true;
$this->pageTitle = 'Scaffold Missing Database Connection';
$this->render('../errors/missingScaffolddb');
exit();
}
/**
* Renders the Missing Table web page.
*
*/
function missingTable($tableName)
{
$error =& new Controller();
$error->constructClasses();
$error->missingTable = $this->table;
$error->missingTableName = $tableName;
$error->pageTitle = 'Missing Database Table';
$error->render('../errors/missingTable');
exit();
}
/**
* Renders the Missing Table web page.
*
*/
function missingConnection()
{
$error =& new Controller();
$error->constructClasses();
$error->missingConnection = $this->name;
$error->autoLayout = true;
$error->pageTitle = 'Missing Database Connection';
$error->render('../errors/missingDatabase');
exit();
}
/**
* Renders the Missing Helper file web page.
*
*/
function missingHelperFile($file)
{
$this->missingHelperFile = $file;
$this->missingHelperClass = Inflector::camelize($file) . "Helper";
$this->pageTitle = 'Missing Helper File';
$this->render('../errors/missingHelperFile');
exit();
}
/**
* Renders the Missing Helper class web page.
*
*/
function missingHelperClass($class)
{
$this->missingHelperClass = Inflector::camelize($class) . "Helper";
$this->missingHelperFile = Inflector::underscore($class);
$this->pageTitle = 'Missing Helper Class';
$this->render('../errors/missingHelperClass');
exit();
}
}
?>

View file

@ -149,6 +149,16 @@ class Router extends Object {
$this->connect('/bare/:controller/:action/*', array('bare'=>'1'));
$this->connect('/ajax/:controller/:action/*', array('bare'=>'1'));
if(defined('WEBSERVICES') && WEBSERVICES == 'on' )
{
$this->connect('/rest/:controller/:action/*', array('webservices'=>'Rest'));
$this->connect('/rss/:controller/:action/*', array('webservices'=>'Rss'));
$this->connect('/soap/:controller/:action/*', array('webservices'=>'Soap'));
$this->connect('/xml/:controller/:action/*', array('webservices'=>'Xml'));
$this->connect('/xmlrpc/:controller/:action/*', array('webservices'=>'XmlRpc'));
}
$this->routes[] = $default_route;
foreach ($this->routes as $route)

View file

@ -111,7 +111,7 @@ class CakeSession extends Object
$this->path = '/';
}
$this->ip = $_SERVER['REMOTE_ADDR'];
$this->ip = !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
$this->userAgent = !empty($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : "";
$this->_initSession();
$this->_begin();
@ -371,7 +371,7 @@ class CakeSession extends Object
ini_set('session.gc_maxlifetime', Security::inactiveMins() * 60);
break;
default :
$config = CONFIGS.CAKE_SESSION_SAVE.'.php.';
$config = CONFIGS.CAKE_SESSION_SAVE.'.php';
if(is_file($config))
{
require_once($config);

View file

@ -44,7 +44,7 @@ define('VALID_NUMBER', '/^[0-9]+$/');
/**
* A valid email address.
*/
define('VALID_EMAIL', '/^([a-z0-9][a-z0-9_\-\.\+]*)@([a-z0-9][a-z0-9\.\-]{0,63}\.([a-z][a-z]|com|org|net|biz|info|name|net|pro|aero|coop|museum))$/i');
define('VALID_EMAIL', '/\\A(?:^([a-z0-9][a-z0-9_\\-\\.\\+]*)@([a-z0-9][a-z0-9\\.\\-]{0,63}\\.(com|org|net|biz|info|name|net|pro|aero|coop|museum|[a-z]{2,4}))$)\\z/i');
/**
* A valid year (1000-2999).

View file

@ -200,6 +200,7 @@ class View extends Object
$this->params =& $this->controller->params;
$this->data =& $this->controller->data;
$this->displayFields =& $this->controller->displayFields;
$this->webservices =& $this->controller->webservices;
}
/**
@ -429,18 +430,6 @@ class View extends Object
print ($this->_render(VIEWS.'layouts/error.thtml', array('code'=>$code,'name'=>$name,'message'=>$message)));
}
/**
* Renders the Missing View web page.
*
*/
function missingView()
{
//We are simulating action call below, this is not a filename!
$this->autoLayout = true;
$this->missingView = $this->name;
$this->render('../errors/missingView');
}
/**************************************************************************
* Private methods.
@ -458,19 +447,27 @@ class View extends Object
{
$action = Inflector::underscore($action);
$viewFileName = VIEWS.$this->viewPath.DS.$action.'.thtml';
if(!is_null($this->webservices))
{
$type = strtolower($this->webservices).DS;
}
else
{
$type = null;
}
$viewFileName = VIEWS.$this->viewPath.DS.$type.$action.'.thtml';
if(file_exists(VIEWS.$this->viewPath.DS.$action.'.thtml'))
if(file_exists(VIEWS.$this->viewPath.DS.$type.$action.'.thtml'))
{
$viewFileName = VIEWS.$this->viewPath.DS.$action.'.thtml';
$viewFileName = VIEWS.$this->viewPath.DS.$type.$action.'.thtml';
}
elseif(file_exists(LIBS.'view'.DS.'templates'.DS.'errors'.DS.$action.'.thtml'))
elseif(file_exists(LIBS.'view'.DS.'templates'.DS.'errors'.DS.$type.$action.'.thtml'))
{
$viewFileName = LIBS.'view'.DS.'templates'.DS.'errors'.DS.$action.'.thtml';
$viewFileName = LIBS.'view'.DS.'templates'.DS.'errors'.DS.$type.$action.'.thtml';
}
elseif(file_exists(LIBS.'view'.DS.'templates'.DS.$this->viewPath.DS.$action.'.thtml'))
elseif(file_exists(LIBS.'view'.DS.'templates'.DS.$this->viewPath.DS.$type.$action.'.thtml'))
{
$viewFileName = LIBS.'view'.DS.'templates'.DS.$this->viewPath.DS.$action.'.thtml';
$viewFileName = LIBS.'view'.DS.'templates'.DS.$this->viewPath.DS.$type.$action.'.thtml';
}
@ -491,13 +488,23 @@ class View extends Object
*/
function _getLayoutFileName()
{
if(file_exists(LAYOUTS."{$this->layout}.thtml"))
if(!is_null($this->webservices))
{
$layoutFileName = LAYOUTS."{$this->layout}.thtml";
$type = strtolower($this->webservices).DS;
}
else if(file_exists(LIBS.'view'.DS.'templates'.DS."layouts".DS."{$this->layout}.thtml"))
else
{
$layoutFileName = LIBS.'view'.DS.'templates'.DS."layouts".DS."{$this->layout}.thtml";
$type = null;
}
$layoutFileName = LAYOUTS.$type."{$this->layout}.thtml";
if(file_exists(LAYOUTS.$type."{$this->layout}.thtml"))
{
$layoutFileName = LAYOUTS.$type."{$this->layout}.thtml";
}
else if(file_exists(LIBS.'view'.DS.'templates'.DS."layouts".DS.$type."{$this->layout}.thtml"))
{
$layoutFileName = LIBS.'view'.DS.'templates'.DS."layouts".DS.$type."{$this->layout}.thtml";
}
return $layoutFileName;
}