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

@ -39,7 +39,7 @@ uses('error_messages', 'object', 'router', DS.'controller'.DS.'controller', DS.'
/**
* Dispatcher translates URLs to controller-action-paramter triads.
*
*
* Dispatches the request, creating appropriate models and controllers.
*
* @package cake
@ -53,13 +53,19 @@ class Dispatcher extends Object
* @var string
*/
var $base = false;
/**
* Base URL
* @var string
*/
var $admin = false;
/**
* Base URL
* @var string
*/
var $webservices = null;
/**
* Constructor.
*/
@ -71,8 +77,8 @@ class Dispatcher extends Object
/**
* Dispatches and invokes given URL, handing over control to the involved controllers, and then renders the results (if autoRender is set).
*
* If no controller of given name can be found, invoke() shows error messages in
* the form of Missing Controllers information. It does the same with Actions (methods of Controllers are called
* If no controller of given name can be found, invoke() shows error messages in
* the form of Missing Controllers information. It does the same with Actions (methods of Controllers are called
* Actions).
*
* @param string $url URL information to work on.
@ -85,7 +91,7 @@ class Dispatcher extends Object
$missingAction = false;
$missingView = false;
$privateAction = false;
if(defined('CAKE_ADMIN'))
{
if(isset($params[CAKE_ADMIN]))
@ -102,14 +108,14 @@ class Dispatcher extends Object
}
}
}
$this->base = $this->baseUrl();
if(!in_array('render', array_keys($params)))
{
$params['render'] = 0;
}
if (empty($params['controller']))
{
$missingController = true;
@ -146,32 +152,30 @@ 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
{
$controller =& new $ctrlClass($this);
}
$classMethods = get_class_methods($controller);
$classVars = get_object_vars($controller);
if (empty($params['action']))
{
$params['action'] = 'index';
}
if(in_array($params['action'], $classMethods) && strpos($params['action'], '_', 0) === 0)
{
$privateAction = true;
}
if(!in_array($params['action'], $classMethods))
{
$missingAction = true;
}
$controller->base = $this->base;
$controller->here = $this->base.'/'.$url;
$controller->webroot = $this->webroot;
@ -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))
@ -194,22 +200,22 @@ class Dispatcher extends Object
}
$controller->constructClasses();
if ($missingAction)
{
$controller->missingAction = $params['action'];
$params['action'] = 'missingAction';
}
if ($privateAction)
{
$controller->privateAction = $params['action'];
$params['action'] = 'privateAction';
}
return $this->_invoke($controller, $params );
}
/**
* Invokes given controller's render action if autoRender option is set. Otherwise the contents of the operation are returned as a string.
*
@ -240,7 +246,7 @@ class Dispatcher extends Object
$Route = new Router();
include CONFIGS.'routes.php';
$params = $Route->parse ($from_url);
// add submitted form data
$params['form'] = $_POST;
if (isset($_POST['data']))
@ -254,13 +260,17 @@ class Dispatcher extends Object
$params['url'] = (ini_get('magic_quotes_gpc') == 1)?
$this->stripslashes_deep($params['url']) : $params['url'];
}
foreach ($_FILES as $name => $data)
{
$params['form'][$name] = $data;
}
$params['bare'] = empty($params['ajax'])? (empty($params['bare'])? 0: 1): 1;
if(defined('WEBSERVICES'))
{
$params['webservices'] = empty($params['webservices']) ? null : $params['webservices'];
}
return $params;
}
@ -270,7 +280,7 @@ class Dispatcher extends Object
*/
function stripslashes_deep($val)
{
return (is_array($val)) ?
return (is_array($val)) ?
array_map(array('Dispatcher','stripslashes_deep'), $val) : stripslashes($val);
}
@ -280,7 +290,7 @@ class Dispatcher extends Object
*/
function urldecode_deep($val)
{
return (is_array($val)) ?
return (is_array($val)) ?
array_map(array('Dispatcher','urldecode_deep'), $val) : urldecode($val);
}
@ -298,10 +308,10 @@ class Dispatcher extends Object
{
$base = BASE_URL.$this->admin;
}
$docRoot = $_SERVER['DOCUMENT_ROOT'];
$scriptName = $_SERVER['PHP_SELF'];
// If document root ends with 'webroot', it's probably correctly set
$r = null;
if (preg_match('/'.APP_DIR.'\\'.DS.WEBROOT_DIR.'/', $docRoot))
@ -351,7 +361,7 @@ class Dispatcher extends Object
}
return $base;
}
/**
* Displays an error page (e.g. 404 Not found).
*

View file

@ -41,22 +41,26 @@
* @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();
}
/**
* Static function used to gain an instance of the correct ACL class.
*
* @return MyACL
*/
/**
* Static function used to gain an instance of the correct ACL class.
*
* @return MyACL
*/
function &getACL()
{
if($this->_instance == null)
@ -68,89 +72,93 @@ class AclComponent
return $this->_instance;
}
/**
* Enter description here...
*
*/
function _initACL()
{
}
/**
* Pass-thru function for ACL check instance.
*
* @return boolean
*/
/**
* Pass-thru function for ACL check instance.
*
* @return boolean
*/
function check($aro, $aco, $action = "*")
{
return $this->_instance->check($aro, $aco, $action);
}
/**
* Pass-thru function for ACL allow instance.
*
* @return boolean
*/
/**
* Pass-thru function for ACL allow instance.
*
* @return boolean
*/
function allow($aro, $aco, $action = "*")
{
return $this->_instance->allow($aro, $aco, $action);
}
/**
* Pass-thru function for ACL deny instance.
*
* @return boolean
*/
/**
* Pass-thru function for ACL deny instance.
*
* @return boolean
*/
function deny($aro, $aco, $action = "*")
{
return $this->_instance->deny($aro, $aco, $action);
}
/**
* Pass-thru function for ACL inherit instance.
*
* @return boolean
*/
/**
* Pass-thru function for ACL inherit instance.
*
* @return boolean
*/
function inherit($aro, $aco, $action = "*")
{
return $this->_instance->inherit($aro, $aco, $action);
}
/**
* Pass-thru function for ACL grant instance.
*
* @return boolean
*/
/**
* Pass-thru function for ACL grant instance.
*
* @return boolean
*/
function grant($aro, $aco, $action = "*")
{
return $this->_instance->grant($aro, $aco, $action);
}
/**
* Pass-thru function for ACL grant instance.
*
* @return boolean
*/
/**
* Pass-thru function for ACL grant instance.
*
* @return boolean
*/
function revoke($aro, $aco, $action = "*")
{
return $this->_instance->revoke($aro, $aco, $action);
}
/**
* Pass-thru function for ACL getAro instance.
*
* @return Aro
*/
/**
* Pass-thru function for ACL getAro instance.
*
* @return Aro
*/
function getAro($id)
{
return $this->_instance->getAro($id);
}
/**
* Pass-thru function for ACL getAco instance.
*
* @return Aco
*/
/**
* Pass-thru function for ACL getAco instance.
*
* @return Aco
*/
function getAco($id)
{
return $this->_instance->getAco($id);

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.
*
* @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
* @version $Revision$
* @modifiedby $LastChangedBy$
* @lastmodified $Date$
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
* 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.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 = "*")
{
@ -97,9 +109,12 @@ class DB_ACL extends AclBase
// ARO must be cleared for ALL ACO actions
foreach($permKeys as $key)
{
if($perm['aros_acos'][$key] != 1)
if(isset($perm['aros_acos']))
{
return false;
if($perm['aros_acos'][$key] != 1)
{
return false;
}
}
}
return true;
@ -124,11 +139,11 @@ class DB_ACL extends AclBase
return false;
}
/**
* Allow
*
* @return boolean
*/
/**
* Allow
*
* @return boolean
*/
function allow($aro, $aco, $action = "*", $value = 1)
{
$Perms = new ArosAco();
@ -192,41 +207,41 @@ class DB_ACL extends AclBase
return true;
}
/**
* Deny
*
* @return boolean
*/
/**
* Deny
*
* @return boolean
*/
function deny($aro, $aco, $action = "*")
{
return $this->allow($aro, $aco, $action, -1);
}
/**
* Inherit
*
* @return boolean
*/
/**
* Inherit
*
* @return boolean
*/
function inherit($aro, $aco, $action = "*")
{
return $this->allow($aro, $aco, $action, 0);
}
/**
* Allow alias
*
* @return boolean
*/
/**
* Allow alias
*
* @return boolean
*/
function grant($aro, $aco, $action = "*")
{
return $this->allow($aro, $aco, $action);
}
/**
* Deny alias
*
* @return boolean
*/
/**
* Deny alias
*
* @return boolean
*/
function revoke($aro, $aco, $action = "*")
{
return $this->deny($aro, $aco, $action);
@ -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,8 +1,60 @@
<?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
{
var $hasMany = 'ArosAco';
/**
* 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

@ -31,7 +31,7 @@
/**
* Short description for file.
*
*
* Long description for file
*
* @package cake
@ -39,19 +39,19 @@
* @since CakePHP v 0.10.0.1232
*
*/
class SessionComponent extends Object
{
class SessionComponent extends Object
{
/**
* Enter description here...
*
*/
function __construct ()
function __construct ()
{
$this->CakeSession = New CakeSession();
parent::__construct();
}
/**
* Enter description here...
*
@ -65,7 +65,7 @@ class SessionComponent extends Object
{
return $this->CakeSession->writeSessionVar($name, $value);
}
/**
* Enter description here...
*
@ -79,7 +79,7 @@ class SessionComponent extends Object
{
return $this->CakeSession->readSessionVar($name);
}
/**
* Enter description here...
*
@ -92,7 +92,7 @@ class SessionComponent extends Object
{
return $this->CakeSession->delSessionVar($name);
}
/**
* Enter description here...
*
@ -105,7 +105,7 @@ class SessionComponent extends Object
{
return $this->CakeSession->checkSessionVar($name);
}
/**
* Enter description here...
*
@ -117,11 +117,11 @@ class SessionComponent extends Object
{
return $this->CakeSession->getLastError();
}
/**
* 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
*/
@ -148,9 +148,9 @@ class SessionComponent extends Object
{
return false;
}
}
/**
* Enter description here...
*
@ -164,6 +164,6 @@ class SessionComponent extends Object
{
return $this->CakeSession->isValid();
}
}
?>

View file

@ -167,7 +167,7 @@ class Controller extends Object
* @access public
*/
var $beforeFilter = null;
/**
* Enter description here...
*
@ -190,10 +190,14 @@ class Controller extends Object
}
$this->name = $r[1];
}
$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();
}
@ -205,12 +209,12 @@ class Controller extends Object
{
$dboFactory = DboFactory::getInstance($this->useDbConfig);
$this->db =& $dboFactory;
if (!empty($this->components))
{
$component =& new Component($this);
}
if (!empty($this->beforeFilter))
{
if(is_array($this->beforeFilter))
@ -231,7 +235,7 @@ class Controller extends Object
}
}
}
if(empty($this->params['pass']))
{
$id = false;
@ -272,34 +276,34 @@ class Controller extends Object
}
}
/**
* Redirects to given $url, after turning off $this->autoRender.
*
* @param unknown_type $url
*/
/**
* Redirects to given $url, after turning off $this->autoRender.
*
* @param unknown_type $url
*/
function redirect ($url)
{
$this->autoRender = false;
header ('Location: '.$this->base.$url);
}
/**
* Saves a variable to use inside a template.
*
* @param mixed $one A string or an array of data.
* @param string $two Value in case $one is a string (which then works as the key), otherwise unused.
* @return unknown
*/
/**
* Saves a variable to use inside a template.
*
* @param mixed $one A string or an array of data.
* @param string $two Value in case $one is a string (which then works as the key), otherwise unused.
* @return unknown
*/
function set($one, $two=null)
{
return $this->_setArray(is_array($one)? $one: array($one=>$two));
}
/**
* Enter description here...
*
* @param unknown_type $action
*/
/**
* Enter description here...
*
* @param unknown_type $action
*/
function setAction ($action)
{
$this->action = $action;
@ -308,11 +312,11 @@ class Controller extends Object
call_user_func_array(array(&$this, $action), $args);
}
/**
* Returns number of errors in a submitted FORM.
*
* @return int Number of errors
*/
/**
* Returns number of errors in a submitted FORM.
*
* @return int Number of errors
*/
function validate ()
{
$args = func_get_args();
@ -321,11 +325,11 @@ class Controller extends Object
return count($errors);
}
/**
* Validates a FORM according to the rules set up in the Model.
*
* @return int Number of errors
*/
/**
* Validates a FORM according to the rules set up in the Model.
*
* @return int Number of errors
*/
function validateErrors ()
{
$objects = func_get_args();
@ -340,15 +344,15 @@ class Controller extends Object
return $this->validationErrors = (count($errors)? $errors: false);
}
/**
* Gets an instance of the view object & prepares it for rendering the output, then
* asks the view to actualy do the job.
*
* @param unknown_type $action
* @param unknown_type $layout
* @param unknown_type $file
* @return unknown
*/
/**
* Gets an instance of the view object & prepares it for rendering the output, then
* asks the view to actualy do the job.
*
* @param unknown_type $action
* @param unknown_type $layout
* @param unknown_type $file
* @return unknown
*/
function render($action=null, $layout=null, $file=null)
{
$view =& new View($this);
@ -368,111 +372,11 @@ class Controller extends Object
}
/**
* Renders the Missing Controller web page.
* Sets data for this view. Will set title if the key "title" is in given $data array.
*
* @param array $data Array of
* @access private
*/
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.
*
* @param array $data Array of
* @access private
*/
function _setArray($data)
{
foreach ($data as $name => $value)
@ -484,25 +388,25 @@ class Controller extends Object
}
}
/**
* Set the title element of the page.
*
* @param string $pageTitle Text for the title
* @access private
*/
/**
* Set the title element of the page.
*
* @param string $pageTitle Text for the title
* @access private
*/
function _setTitle($pageTitle)
{
$this->pageTitle = $pageTitle;
}
/**
* Shows a message to the user $time seconds, then redirects to $url
* Uses flash.thtml as a layout for the messages
*
* @param string $message Message to display to the user
* @param string $url Relative URL to redirect to after the time expires
* @param int $time Time to show the message
*/
/**
* Shows a message to the user $time seconds, then redirects to $url
* Uses flash.thtml as a layout for the messages
*
* @param string $message Message to display to the user
* @param string $url Relative URL to redirect to after the time expires
* @param int $time Time to show the message
*/
function flash($message, $url, $pause=1)
{
$this->autoRender = false;
@ -521,24 +425,24 @@ class Controller extends Object
{
$flash = LIBS.'view'.DS.'templates'.DS."layouts".DS.'flash.thtml';
}
$this->render(null,false,$flash);
}
/**
* Shows a message to the user $time seconds, then redirects to $url
* Uses flash.thtml as a layout for the messages
*
* @param string $message Message to display to the user
* @param string $url URL to redirect to after the time expires
* @param int $time Time to show the message
*
* @param unknown_type $message
* @param unknown_type $url
* @param unknown_type $time
*/
/**
* Shows a message to the user $time seconds, then redirects to $url
* Uses flash.thtml as a layout for the messages
*
* @param string $message Message to display to the user
* @param string $url URL to redirect to after the time expires
* @param int $time Time to show the message
*
* @param unknown_type $message
* @param unknown_type $url
* @param unknown_type $time
*/
function flashOut($message, $url, $time=1)
{
$this->autoRender = false;
@ -551,24 +455,24 @@ class Controller extends Object
$this->render(null,false,VIEWS.'layouts'.DS.'flash.thtml');
}
/**
* This function creates a $fieldNames array for the view to use.
* @todo Map more database field types to html form fields.
* @todo View the database field types from all the supported databases.
*
*/
/**
* This function creates a $fieldNames array for the view to use.
* @todo Map more database field types to html form fields.
* @todo View the database field types from all the supported databases.
*
*/
function generateFieldNames( $data = null, $doCreateOptions = true )
{
$fieldNames = array();
$model = $this->modelClass;
$modelKey = $this->modelKey;
$table = $this->{$model}->table;
$association = array_search($table,$this->{$model}->alias);
$classRegistry =& ClassRegistry::getInstance();
$objRegistryModel = $classRegistry->getObject($modelKey);
foreach ($objRegistryModel->_tableInfo as $tables)
{
foreach ($tables as $tabl)
@ -638,7 +542,7 @@ class Controller extends Object
}
switch( $type )
{
case "text":
case "mediumtext":
{
@ -658,7 +562,7 @@ class Controller extends Object
// get the list of options from the other model.
$registry = ClassRegistry::getInstance();
$otherModel = $registry->getObject(Inflector::underscore($fieldNames[$tabl['name']]['modelKey']));
if( is_object($otherModel) )
{
if( $doCreateOptions )
@ -668,7 +572,7 @@ class Controller extends Object
{
foreach( $pass as $key=>$value )
{
if( $alias.$key == $this->{$model}->tableToModel[$fieldNames[ $tabl['name'] ]['table']] && isset( $value['id'] ) && isset( $value[$otherDisplayField] ) )
{
$fieldNames[ $tabl['name']]['options'][$value['id']] = $value[$otherDisplayField];
@ -691,7 +595,7 @@ class Controller extends Object
{
$fieldNames[ $tabl['name']]['type'] = 'input';
}
else
else
{
$fieldNames[ $tabl['name']]['type'] = 'checkbox';
}
@ -721,7 +625,7 @@ class Controller extends Object
// get the list of options from the other model.
$registry = ClassRegistry::getInstance();
$otherModel = $registry->getObject(Inflector::underscore($fieldNames[$tabl['name']]['modelKey']));
if( is_object($otherModel) )
{
if( $doCreateOptions )
@ -783,7 +687,7 @@ class Controller extends Object
foreach( $objRegistryModel->_manyToMany as $relation )
{
//list($modelName) = $relation;
list($manyAssociation, $modelName, $value) = $relation;
list($manyAssociation, $modelName, $value) = $relation;
$modelKeyM = Inflector::underscore($modelName);
$modelObject = new $modelName();
@ -815,7 +719,7 @@ class Controller extends Object
}
} // end loop through manytomany relations.
}
return $fieldNames;
}
}

View file

@ -38,7 +38,7 @@ uses(DS.'model'.DS.'model', 'inflector', 'object');
/**
* Scaffolding is a set of automatic views, forms and controllers for starting web development work faster.
*
* Scaffold inspects your database tables, and making educated guesses, sets up a
* Scaffold inspects your database tables, and making educated guesses, sets up a
* number of pages for each of your Models. These pages have data forms that work,
* and afford the web developer an early look at the data, and the possibility to over-ride
* scaffolded actions with custom-made ones.
@ -48,7 +48,7 @@ uses(DS.'model'.DS.'model', 'inflector', 'object');
* @since Cake v 0.10.0.1076
*/
class Scaffold extends Object {
/**
* Enter description here...
*
@ -106,8 +106,8 @@ class Scaffold extends Object {
$this->controllerClass->pageTitle = $this->scaffoldTitle;
$this->_renderScaffold($params);
}
/**
* Enter description here...
*
@ -118,7 +118,7 @@ class Scaffold extends Object {
{
$this->_scaffoldView($params);
}
/**
* Renders the List view as the default action (index).
*
@ -173,7 +173,7 @@ class Scaffold extends Object {
$this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames() );
return $this->controllerClass->render($this->actionView, '', LIBS.'controller'.DS.'templates'.DS.'scaffolds'.DS.'new.thtml');
}
/**
* Renders an Edit view for scaffolded Model.
*
@ -194,26 +194,26 @@ class Scaffold extends Object {
* Renders a "create new" view for scaffolded Model.
*
* @param array $params
* @return success on save new form if data is empty or if data does not validate
* @return success on save new form if data is empty or if data does not validate
* @access private
*/
function _scaffoldCreate($params)
{
if(empty($this->controllerClass->params['data']))
if(empty($this->controllerClass->params['data']))
{
return $this->_scaffoldNew($params);
}
$this->controllerClass->set('fieldNames', $this->controllerClass->generateFieldNames() );
$this->_cleanUpFields();
if ($this->controllerClass->{$this->modelKey}->save($this->controllerClass->params['data']))
{
if(is_object($this->controllerClass->Session))
{
$this->controllerClass->Session->setFlash('Your '.Inflector::humanize($this->modelKey).' has been saved.');
$this->controllerClass->redirect('/'.Inflector::underscore($this->controllerClass->viewPath));
}
else
{
@ -225,7 +225,7 @@ class Scaffold extends Object {
{
if(is_object($this->controllerClass->Session))
{
$this->controllerClass->Session->setFlash('Please correct errors below');
$this->controllerClass->Session->setFlash('Please correct errors below');
}
$this->controllerClass->set('data', $this->controllerClass->params['data']);
$this->controllerClass->validateErrors($this->controllerClass->{$this->modelKey});
@ -242,21 +242,21 @@ class Scaffold extends Object {
*/
function _scaffoldUpdate($params=array())
{
if(empty($this->controllerClass->params['data']))
if(empty($this->controllerClass->params['data']))
{
return $this->_scaffoldNew($params);
}
$this->_cleanUpFields();
$this->controllerClass->{$this->modelKey}->set($this->controllerClass->params['data']);
if ( $this->controllerClass->{$this->modelKey}->save())
{
if(is_object($this->controllerClass->Session))
{
$this->controllerClass->Session->setFlash('Your '.Inflector::humanize($this->modelKey).' has been saved.', '/');
$this->controllerClass->redirect('/'.Inflector::underscore($this->controllerClass->viewPath));
}
else
{
@ -270,7 +270,7 @@ class Scaffold extends Object {
{
$this->controllerClass->Session->setFlash('The '.Inflector::humanize($this->modelKey).' has been updated.','/');
$this->controllerClass->redirect('/'.Inflector::underscore($this->controllerClass->viewPath));
}
else
{
@ -296,7 +296,7 @@ class Scaffold extends Object {
{
$this->controllerClass->Session->setFlash('The '.Inflector::humanize($this->modelKey).' with id: '.$id.' has been deleted.', '/');
$this->controllerClass->redirect('/'.Inflector::underscore($this->controllerClass->viewPath));
}
else
{
@ -310,7 +310,7 @@ class Scaffold extends Object {
{
$this->controllerClass->Session->setFlash('There was an error deleting the '.Inflector::humanize($this->modelKey).' with the id '.$id, '/');
$this->controllerClass->redirect('/'.Inflector::underscore($this->controllerClass->viewPath));
}
else
{
@ -319,7 +319,7 @@ class Scaffold extends Object {
}
}
}
/**
* When methods are now present in a controller
* scaffoldView is used to call default Scaffold methods if:
@ -340,15 +340,15 @@ class Scaffold extends Object {
{
$this->controllerClass->helpers[] = 'Form';
}
$isDataBaseSet = DboFactory::getInstance($this->controllerClass->useDbConfig);
if(!empty($isDataBaseSet))
{
$this->controllerClass->constructClasses();
if($params['action'] === 'index' || $params['action'] === 'list' ||
$params['action'] === 'show' || $params['action'] === 'add' ||
$params['action'] === 'create' || $params['action'] === 'edit' ||
$params['action'] === 'show' || $params['action'] === 'add' ||
$params['action'] === 'create' || $params['action'] === 'edit' ||
$params['action'] === 'update' || $params['action'] === 'destroy')
{
switch ($params['action'])
@ -356,36 +356,36 @@ class Scaffold extends Object {
case 'index':
$this->_scaffoldIndex($params);
break;
case 'show':
$this->_scaffoldShow($params);
break;
case 'list':
$this->_scaffoldList($params);
break;
case 'add':
$this->_scaffoldNew($params);
break;
case 'edit':
$this->_scaffoldEdit($params);
break;
case 'create':
$this->_scaffoldCreate($params);
break;
case 'update':
$this->_scaffoldUpdate($params);
break;
case 'destroy':
$this->_scaffoldDestroy($params);
break;
}
}
}
else
{
$this->controllerClass->layout = 'default';
@ -396,20 +396,21 @@ class Scaffold extends Object {
}
else
{
$this->controllerClass->constructClasses();
$this->controllerClass->layout = 'default';
call_user_func_array(array($this->controllerClass, 'missingDatabase'), null);
exit;
}
}
/**
* Cleans up the date fields of current Model.
*
*
* @access private
*/
function _cleanUpFields()
{
foreach( $this->controllerClass->{$this->modelKey}->_tableInfo as $table )
{
foreach ($table as $field)

File diff suppressed because it is too large Load diff

View file

@ -4,7 +4,7 @@
/**
* Object class, allowing __construct and __destruct in PHP4.
*
* Also includes methods for logging and the special method RequestAction,
* Also includes methods for logging and the special method RequestAction,
* to call other Controllers' Actions from anywhere.
*
* PHP versions 4 and 5
@ -40,7 +40,7 @@ uses('log');
/**
* Object class, allowing __construct and __destruct in PHP4.
*
* Also includes methods for logging and the special method RequestAction,
* Also includes methods for logging and the special method RequestAction,
* to call other Controllers' Actions from anywhere.
*
* @package cake
@ -98,7 +98,7 @@ class Object
}
/**
* Calls a controller's method from any location.
* Calls a controller's method from any location.
*
* @param string $url URL in the form of Cake URL ("/controller/method/parameter")
* @param array $extra If array includes the key "render" it sets the AutoRender to true.
@ -112,12 +112,12 @@ class Object
}
else
{
$extra['render'] = 1;
$extra['render'] = 1;
}
$dispatcher =& new Dispatcher();
return $dispatcher->dispatch($url, $extra);
}
/**
* API for logging events.
*
@ -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

@ -31,7 +31,7 @@
/**
* Short description for file.
*
*
* Long description for file
*
* @package cake
@ -82,7 +82,7 @@ class CakeSession extends Object
* @var unknown_type
*/
var $sessionId = null;
/**
* Enter description here...
*
@ -96,7 +96,7 @@ class CakeSession extends Object
{
$this->host = substr($this->host,0, strpos($this->host, ':'));
}
if (empty($this->path))
{
$dispatcher =& new Dispatcher();
@ -110,8 +110,8 @@ 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();
@ -129,7 +129,7 @@ class CakeSession extends Object
$expression = "return isset(".$this->_sessionVarNames($name).");";
return eval($expression);
}
/**
* Enter description here...
*
@ -147,7 +147,7 @@ class CakeSession extends Object
$this->_setError(2, "$name doesn't exist");
return false;
}
/**
* Enter description here...
*
@ -165,7 +165,7 @@ class CakeSession extends Object
return $this->error[$errorNumber];
}
}
/**
* Enter description here...
*
@ -173,7 +173,7 @@ class CakeSession extends Object
*/
function getLastError()
{
if($this->lastError)
{
return $this->getError($this->lastError);
@ -183,7 +183,7 @@ class CakeSession extends Object
return false;
}
}
/**
* Enter description here...
*
@ -191,10 +191,10 @@ class CakeSession extends Object
*/
function isValid()
{
return $this->valid;
}
/**
* Enter description here...
*
@ -207,7 +207,7 @@ class CakeSession extends Object
{
return $this->returnSessionVars();
}
if($this->checkSessionVar($name))
{
$result = eval("return ".$this->_sessionVarNames($name).";");
@ -216,7 +216,7 @@ class CakeSession extends Object
$this->_setError(2, "$name doesn't exist");
return false;
}
/**
* Enter description here...
*
@ -225,7 +225,7 @@ class CakeSession extends Object
*/
function returnSessionVars()
{
if(!empty($_SESSION))
{
$result = eval("return ".$_SESSION.";");
@ -234,20 +234,20 @@ class CakeSession extends Object
$this->_setError(2, "No Session vars set");
return false;
}
/**
* Enter description here...
* Enter description here...
*
* @param unknown_type $name
* @param unknown_type $value
*/
function writeSessionVar($name, $value)
{
$expression = $this->_sessionVarNames($name);
$expression .= " = \$value;";
eval($expression);
}
}
/**
* Enter description here...
@ -256,17 +256,17 @@ class CakeSession extends Object
*/
function _begin()
{
if (function_exists('session_write_close'))
{
session_write_close();
}
session_cache_limiter("must-revalidate");
session_cache_limiter("must-revalidate");
session_start();
$this->_new();
}
/**
* Enter description here...
*
@ -279,7 +279,7 @@ class CakeSession extends Object
echo "</pre>";
die();
}
/**
* Enter description here...
*
@ -292,7 +292,7 @@ class CakeSession extends Object
echo "</pre>";
die();
}
/**
* Enter description here...
*
@ -305,7 +305,7 @@ class CakeSession extends Object
echo "</pre>";
die();
}
/**
* Enter description here...
*
@ -313,7 +313,7 @@ class CakeSession extends Object
*/
function _initSession()
{
switch (CAKE_SECURITY)
{
case 'high':
@ -328,7 +328,7 @@ class CakeSession extends Object
$this->cookieLifeTime = 788940000;
break;
}
switch (CAKE_SESSION_SAVE)
{
case 'cake':
@ -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);
@ -382,22 +382,22 @@ class CakeSession extends Object
ini_set('session.cookie_lifetime', $this->cookieLifeTime);
ini_set('session.cookie_path', $this->path);
ini_set('session.gc_probability', 1);
ini_set('session.gc_maxlifetime', Security::inactiveMins() * 60);
}
ini_set('session.gc_maxlifetime', Security::inactiveMins() * 60);
}
break;
}
}
/**
* Enter description here...
*
* @access private
*
*
*/
function _new()
{
if(!ereg("proxy\.aol\.com$", gethostbyaddr($this->ip)))
{
if($this->readSessionVar("Config"))
@ -415,7 +415,7 @@ class CakeSession extends Object
else
{
srand((double)microtime() * 1000000);
$this->writeSessionVar('Config.rand', rand());
$this->writeSessionVar('Config.rand', rand());
$this->writeSessionVar("Config.ip", $this->ip);
$this->writeSessionVar("Config.userAgent", $this->userAgent);
$this->valid = true;
@ -426,25 +426,25 @@ class CakeSession extends Object
if(!$this->readSessionVar("Config"))
{
srand((double)microtime() * 1000000);
$this->writeSessionVar('Config.rand', rand());
$this->writeSessionVar('Config.rand', rand());
$this->writeSessionVar("Config.ip", $this->ip);
$this->writeSessionVar("Config.userAgent", $this->userAgent);
}
$this->valid = true;
}
if(CAKE_SECURITY == 'high')
{
$this->_regenerateId();
}
header('P3P: CP="NOI ADM DEV PSAi COM NAV OUR OTRo STP IND DEM"');
}
/**
* Enter description here...
*
* @access private
*
*
*/
function _open()
{
@ -453,12 +453,12 @@ class CakeSession extends Object
echo "</pre>";
die();
}
/**
* Enter description here...
*
* @access private
*
*
*/
function _read()
{
@ -467,18 +467,18 @@ class CakeSession extends Object
echo "</pre>";
die();
}
/**
* Enter description here...
*
*
* @access private
*
*
*/
function _regenerateId()
{
$oldSessionId = session_id();
session_regenerate_id();
$newSessid = session_id();
@ -504,13 +504,13 @@ class CakeSession extends Object
* Enter description here...
*
* @access private
*
*
*/
function _renew()
{
$this->_regenerateId();
}
/**
* Enter description here...
*
@ -520,7 +520,7 @@ class CakeSession extends Object
*/
function _sessionVarNames($name)
{
if(is_string($name))
{
if(strpos($name, "."))
@ -532,7 +532,7 @@ class CakeSession extends Object
$names = array($name);
}
$expression = $expression = "\$_SESSION";
foreach($names as $item)
{
$expression .= is_numeric($item) ? "[$item]" : "['$item']";
@ -542,7 +542,7 @@ class CakeSession extends Object
$this->setError(3, "$name is not a string");
return false;
}
/**
* Enter description here...
*
@ -552,16 +552,16 @@ class CakeSession extends Object
*/
function _setError($errorNumber, $errorMessage)
{
if($this->error === false)
{
$this->error = array();
}
$this->error[$errorNumber] = $errorMessage;
$this->lastError = $errorNumber;
}
/**
* Enter description here...
*
@ -574,5 +574,5 @@ class CakeSession extends Object
echo "</pre>";
die();
}
}
}
?>

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

@ -35,7 +35,7 @@
uses('object', DS.'view'.DS.'helper');
/**
* View, the V in the MVC triad.
* View, the V in the MVC triad.
*
* Class holding methods for displaying presentation data.
*
@ -167,7 +167,7 @@ class View extends Object
* @var boolean
*/
var $hasRendered = null;
/**
* Enter description here...
*
@ -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;
}
/**
@ -219,7 +220,7 @@ class View extends Object
/**
* Renders view for given action and layout. If $file is given, that is used
* Renders view for given action and layout. If $file is given, that is used
* for a view filename (e.g. customFunkyView.thtml).
*
* @param string $action Name of action to render for
@ -352,7 +353,7 @@ class View extends Object
* Renders a piece of PHP with provided parameters and returns HTML, XML, or any other string.
*
* This realizes the concept of Elements, (or "partial layouts")
* and the $params array is used to send data to be used in the
* and the $params array is used to send data to be used in the
* Element.
*
* @param string $name Name of template file in the /app/views/elements/ folder
@ -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.
@ -457,28 +446,36 @@ class View extends Object
function _getViewFileName($action)
{
$action = Inflector::underscore($action);
$viewFileName = VIEWS.$this->viewPath.DS.$action.'.thtml';
if(file_exists(VIEWS.$this->viewPath.DS.$action.'.thtml'))
if(!is_null($this->webservices))
{
$viewFileName = VIEWS.$this->viewPath.DS.$action.'.thtml';
$type = strtolower($this->webservices).DS;
}
elseif(file_exists(LIBS.'view'.DS.'templates'.DS.'errors'.DS.$action.'.thtml'))
else
{
$viewFileName = LIBS.'view'.DS.'templates'.DS.'errors'.DS.$action.'.thtml';
$type = null;
}
elseif(file_exists(LIBS.'view'.DS.'templates'.DS.$this->viewPath.DS.$action.'.thtml'))
$viewFileName = VIEWS.$this->viewPath.DS.$type.$action.'.thtml';
if(file_exists(VIEWS.$this->viewPath.DS.$type.$action.'.thtml'))
{
$viewFileName = LIBS.'view'.DS.'templates'.DS.$this->viewPath.DS.$action.'.thtml';
$viewFileName = VIEWS.$this->viewPath.DS.$type.$action.'.thtml';
}
elseif(file_exists(LIBS.'view'.DS.'templates'.DS.'errors'.DS.$type.$action.'.thtml'))
{
$viewFileName = LIBS.'view'.DS.'templates'.DS.'errors'.DS.$type.$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.$type.$action.'.thtml';
}
$viewPath = explode(DS, $viewFileName);
$i = array_search('..', $viewPath);
unset($viewPath[$i-1]);
unset($viewPath[$i]);
$return = '/'.implode('/', $viewPath);
return $return;
}
@ -489,21 +486,31 @@ class View extends Object
* @return string Filename for layout file (.thtml).
* @access private
*/
function _getLayoutFileName()
{
if(file_exists(LAYOUTS."{$this->layout}.thtml"))
function _getLayoutFileName()
{
if(!is_null($this->webservices))
{
$type = strtolower($this->webservices).DS;
}
else
{
$type = null;
}
$layoutFileName = LAYOUTS.$type."{$this->layout}.thtml";
if(file_exists(LAYOUTS.$type."{$this->layout}.thtml"))
{
$layoutFileName = LAYOUTS."{$this->layout}.thtml";
$layoutFileName = LAYOUTS.$type."{$this->layout}.thtml";
}
else if(file_exists(LIBS.'view'.DS.'templates'.DS."layouts".DS."{$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."{$this->layout}.thtml";
$layoutFileName = LIBS.'view'.DS.'templates'.DS."layouts".DS.$type."{$this->layout}.thtml";
}
return $layoutFileName;
}
/**
* Renders and returns output for given view filename with its
* Renders and returns output for given view filename with its
* array of data.
*
* @param string $___viewFn Filename of the view
@ -521,12 +528,12 @@ class View extends Object
{
$loadedHelpers = array();
$loadedHelpers = $this->_loadHelpers($loadedHelpers, $this->helpers);
foreach(array_keys($loadedHelpers) as $helper)
{
$replace = strtolower(substr($helper, 0, 1));
$camelBackedHelper = preg_replace('/\\w/', $replace, $helper, 1);
${$camelBackedHelper} =& $loadedHelpers[$helper];
if(isset(${$camelBackedHelper}->helpers) && is_array(${$camelBackedHelper}->helpers))
{
@ -560,13 +567,13 @@ class View extends Object
return $out;
}
/**
* Loads helpers, with their dependencies.
*
* @param array $loaded List of helpers that are already loaded.
* @param array $helpers List of helpers to load.
* @return array
* @return array
*/
function &_loadHelpers(&$loaded, $helpers) {
@ -575,7 +582,7 @@ class View extends Object
if(in_array($helper, array_keys($loaded)) !== true)
{
$helperFn = Inflector::underscore($helper).'.php';
if(file_exists(HELPERS.$helperFn))
{
$helperFn = HELPERS.$helperFn;
@ -584,7 +591,7 @@ class View extends Object
{
$helperFn = LIBS.'view'.DS.'helpers'.DS.$helperFn;
}
$helperCn = $helper.'Helper';
$replace = strtolower(substr($helper, 0, 1));
$camelBackedHelper = preg_replace('/\\w/', $replace, $helper, 1);
@ -601,7 +608,7 @@ class View extends Object
${$camelBackedHelper}->params = $this->params;
${$camelBackedHelper}->action = $this->action;
${$camelBackedHelper}->data = $this->data;
if(!empty($this->validationErrors))
{
${$camelBackedHelper}->validationErrors = $this->validationErrors;
@ -633,7 +640,7 @@ class View extends Object
}
}
}
return $loaded;
}
}