mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Fix most coding standard issues in Controller.
This commit is contained in:
parent
db8c6b5c78
commit
61aba0f0f8
22 changed files with 111 additions and 91 deletions
|
@ -75,4 +75,5 @@ class CakeErrorController extends AppController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,8 @@ class Component extends Object {
|
||||||
* @return void
|
* @return void
|
||||||
* @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::initialize
|
* @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::initialize
|
||||||
*/
|
*/
|
||||||
public function initialize(Controller $controller) { }
|
public function initialize(Controller $controller) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called after the Controller::beforeFilter() and before the controller action
|
* Called after the Controller::beforeFilter() and before the controller action
|
||||||
|
@ -115,7 +116,8 @@ class Component extends Object {
|
||||||
* @return void
|
* @return void
|
||||||
* @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::startup
|
* @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::startup
|
||||||
*/
|
*/
|
||||||
public function startup(Controller $controller) { }
|
public function startup(Controller $controller) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called after the Controller::beforeRender(), after the view class is loaded, and before the
|
* Called after the Controller::beforeRender(), after the view class is loaded, and before the
|
||||||
|
@ -125,7 +127,8 @@ class Component extends Object {
|
||||||
* @return void
|
* @return void
|
||||||
* @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::beforeRender
|
* @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::beforeRender
|
||||||
*/
|
*/
|
||||||
public function beforeRender(Controller $controller) { }
|
public function beforeRender(Controller $controller) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called after Controller::render() and before the output is printed to the browser.
|
* Called after Controller::render() and before the output is printed to the browser.
|
||||||
|
@ -134,7 +137,8 @@ class Component extends Object {
|
||||||
* @return void
|
* @return void
|
||||||
* @link @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::shutdown
|
* @link @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::shutdown
|
||||||
*/
|
*/
|
||||||
public function shutdown(Controller $controller) { }
|
public function shutdown(Controller $controller) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called before Controller::redirect(). Allows you to replace the url that will
|
* Called before Controller::redirect(). Allows you to replace the url that will
|
||||||
|
@ -155,6 +159,7 @@ class Component extends Object {
|
||||||
* @return array|null Either an array or null.
|
* @return array|null Either an array or null.
|
||||||
* @link @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::beforeRedirect
|
* @link @link http://book.cakephp.org/2.0/en/controllers/components.html#Component::beforeRedirect
|
||||||
*/
|
*/
|
||||||
public function beforeRedirect(Controller $controller, $url, $status = null, $exit = true) {}
|
public function beforeRedirect(Controller $controller, $url, $status = null, $exit = true) {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,4 +66,5 @@ interface AclInterface {
|
||||||
* @param AclComponent $component
|
* @param AclComponent $component
|
||||||
*/
|
*/
|
||||||
public function initialize(Component $component);
|
public function initialize(Component $component);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -94,7 +94,7 @@ class DbAcl extends Object implements AclInterface {
|
||||||
$acoIDs = Set::extract($acoPath, '{n}.' . $this->Aco->alias . '.id');
|
$acoIDs = Set::extract($acoPath, '{n}.' . $this->Aco->alias . '.id');
|
||||||
|
|
||||||
$count = count($aroPath);
|
$count = count($aroPath);
|
||||||
for ($i = 0 ; $i < $count; $i++) {
|
for ($i = 0; $i < $count; $i++) {
|
||||||
$permAlias = $this->Aro->Permission->alias;
|
$permAlias = $this->Aro->Permission->alias;
|
||||||
|
|
||||||
$perms = $this->Aro->Permission->find('all', array(
|
$perms = $this->Aro->Permission->find('all', array(
|
||||||
|
@ -289,5 +289,5 @@ class DbAcl extends Object implements AclInterface {
|
||||||
}
|
}
|
||||||
return $newKeys;
|
return $newKeys;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -45,7 +45,6 @@ class IniAcl extends Object implements AclInterface {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function initialize(Component $component) {
|
public function initialize(Component $component) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -57,7 +56,6 @@ class IniAcl extends Object implements AclInterface {
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
*/
|
*/
|
||||||
public function allow($aro, $aco, $action = "*") {
|
public function allow($aro, $aco, $action = "*") {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -69,7 +67,6 @@ class IniAcl extends Object implements AclInterface {
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
*/
|
*/
|
||||||
public function deny($aro, $aco, $action = "*") {
|
public function deny($aro, $aco, $action = "*") {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -81,7 +78,6 @@ class IniAcl extends Object implements AclInterface {
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
*/
|
*/
|
||||||
public function inherit($aro, $aco, $action = "*") {
|
public function inherit($aro, $aco, $action = "*") {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -91,10 +87,10 @@ class IniAcl extends Object implements AclInterface {
|
||||||
*
|
*
|
||||||
* @param string $aro ARO
|
* @param string $aro ARO
|
||||||
* @param string $aco ACO
|
* @param string $aco ACO
|
||||||
* @param string $aco_action Action
|
* @param string $action Action
|
||||||
* @return boolean Success
|
* @return boolean Success
|
||||||
*/
|
*/
|
||||||
public function check($aro, $aco, $aco_action = null) {
|
public function check($aro, $aco, $action = null) {
|
||||||
if ($this->config == null) {
|
if ($this->config == null) {
|
||||||
$this->config = $this->readConfigFile(APP . 'Config' . DS . 'acl.ini.php');
|
$this->config = $this->readConfigFile(APP . 'Config' . DS . 'acl.ini.php');
|
||||||
}
|
}
|
||||||
|
@ -147,7 +143,8 @@ class IniAcl extends Object implements AclInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses an INI file and returns an array that reflects the INI file's section structure. Double-quote friendly.
|
* Parses an INI file and returns an array that reflects the
|
||||||
|
* INI file's section structure. Double-quote friendly.
|
||||||
*
|
*
|
||||||
* @param string $filename File
|
* @param string $filename File
|
||||||
* @return array INI section structure
|
* @return array INI section structure
|
||||||
|
@ -171,4 +168,5 @@ class IniAcl extends Object implements AclInterface {
|
||||||
array_unshift($array, "");
|
array_unshift($array, "");
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,6 @@ class PhpAcl extends Object implements AclInterface {
|
||||||
*/
|
*/
|
||||||
public $options = array();
|
public $options = array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Aro Object
|
* Aro Object
|
||||||
*
|
*
|
||||||
|
@ -52,13 +51,18 @@ class PhpAcl extends Object implements AclInterface {
|
||||||
*/
|
*/
|
||||||
public $Aco = null;
|
public $Aco = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* Sets a few default settings up.
|
||||||
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->options = array(
|
$this->options = array(
|
||||||
'policy' => self::DENY,
|
'policy' => self::DENY,
|
||||||
'config' => APP . 'Config' . DS . 'acl.php',
|
'config' => APP . 'Config' . DS . 'acl.php',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize method
|
* Initialize method
|
||||||
*
|
*
|
||||||
|
@ -83,6 +87,7 @@ class PhpAcl extends Object implements AclInterface {
|
||||||
*
|
*
|
||||||
* @param array $config configuration array, see docs
|
* @param array $config configuration array, see docs
|
||||||
* @return void
|
* @return void
|
||||||
|
* @throws AclException When required keys are missing.
|
||||||
*/
|
*/
|
||||||
public function build(array $config) {
|
public function build(array $config) {
|
||||||
if (empty($config['roles'])) {
|
if (empty($config['roles'])) {
|
||||||
|
@ -145,15 +150,15 @@ class PhpAcl extends Object implements AclInterface {
|
||||||
*
|
*
|
||||||
* @param string $aro ARO
|
* @param string $aro ARO
|
||||||
* @param string $aco ACO
|
* @param string $aco ACO
|
||||||
* @param string $aco_action Action
|
* @param string $action Action
|
||||||
* @return boolean true if access is granted, false otherwise
|
* @return boolean true if access is granted, false otherwise
|
||||||
*/
|
*/
|
||||||
public function check($aro, $aco, $aco_action = "*") {
|
public function check($aro, $aco, $action = "*") {
|
||||||
$allow = $this->options['policy'];
|
$allow = $this->options['policy'];
|
||||||
$prioritizedAros = $this->Aro->roles($aro);
|
$prioritizedAros = $this->Aro->roles($aro);
|
||||||
|
|
||||||
if ($aco_action && $aco_action != "*") {
|
if ($action && $action != "*") {
|
||||||
$aco .= '/' . $aco_action;
|
$aco .= '/' . $action;
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = $this->Aco->path($aco);
|
$path = $this->Aco->path($aco);
|
||||||
|
@ -176,6 +181,7 @@ class PhpAcl extends Object implements AclInterface {
|
||||||
|
|
||||||
return $allow;
|
return $allow;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -189,7 +195,7 @@ class PhpAco {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $tree = array();
|
protected $_tree = array();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* map modifiers for ACO paths to their respective PCRE pattern
|
* map modifiers for ACO paths to their respective PCRE pattern
|
||||||
|
@ -219,7 +225,7 @@ class PhpAco {
|
||||||
$aco = $this->resolve($aco);
|
$aco = $this->resolve($aco);
|
||||||
$path = array();
|
$path = array();
|
||||||
$level = 0;
|
$level = 0;
|
||||||
$root = $this->tree;
|
$root = $this->_tree;
|
||||||
$stack = array(array($root, 0));
|
$stack = array(array($root, 0));
|
||||||
|
|
||||||
while (!empty($stack)) {
|
while (!empty($stack)) {
|
||||||
|
@ -230,7 +236,7 @@ class PhpAco {
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($root as $node => $elements) {
|
foreach ($root as $node => $elements) {
|
||||||
$pattern = '/^'.str_replace(array_keys(self::$modifiers), array_values(self::$modifiers), $node).'$/';
|
$pattern = '/^' . str_replace(array_keys(self::$modifiers), array_values(self::$modifiers), $node) . '$/';
|
||||||
|
|
||||||
if ($node == $aco[$level] || preg_match($pattern, $aco[$level])) {
|
if ($node == $aco[$level] || preg_match($pattern, $aco[$level])) {
|
||||||
// merge allow/denies with $path of current level
|
// merge allow/denies with $path of current level
|
||||||
|
@ -239,7 +245,6 @@ class PhpAco {
|
||||||
if (empty($path[$level][$policy])) {
|
if (empty($path[$level][$policy])) {
|
||||||
$path[$level][$policy] = array();
|
$path[$level][$policy] = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$path[$level][$policy] = array_merge($path[$level][$policy], $elements[$policy]);
|
$path[$level][$policy] = array_merge($path[$level][$policy], $elements[$policy]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -255,7 +260,6 @@ class PhpAco {
|
||||||
return $path;
|
return $path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* allow/deny ARO access to ARO
|
* allow/deny ARO access to ARO
|
||||||
*
|
*
|
||||||
|
@ -264,7 +268,7 @@ class PhpAco {
|
||||||
public function access($aro, $aco, $action, $type = 'deny') {
|
public function access($aro, $aco, $action, $type = 'deny') {
|
||||||
$aco = $this->resolve($aco);
|
$aco = $this->resolve($aco);
|
||||||
$depth = count($aco);
|
$depth = count($aco);
|
||||||
$root = $this->tree;
|
$root = $this->_tree;
|
||||||
$tree = &$root;
|
$tree = &$root;
|
||||||
|
|
||||||
foreach ($aco as $i => $node) {
|
foreach ($aco as $i => $node) {
|
||||||
|
@ -285,7 +289,7 @@ class PhpAco {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->tree = &$root;
|
$this->_tree = &$root;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -315,7 +319,7 @@ class PhpAco {
|
||||||
*/
|
*/
|
||||||
public function build(array $allow, array $deny = array()) {
|
public function build(array $allow, array $deny = array()) {
|
||||||
$stack = array();
|
$stack = array();
|
||||||
$this->tree = array();
|
$this->_tree = array();
|
||||||
$tree = array();
|
$tree = array();
|
||||||
$root = &$tree;
|
$root = &$tree;
|
||||||
|
|
||||||
|
@ -336,7 +340,6 @@ class PhpAco {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -382,7 +385,7 @@ class PhpAro {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
protected $tree = array();
|
protected $_tree = array();
|
||||||
|
|
||||||
public function __construct(array $aro = array(), array $map = array(), array $aliases = array()) {
|
public function __construct(array $aro = array(), array $map = array(), array $aliases = array()) {
|
||||||
if (!empty($map)) {
|
if (!empty($map)) {
|
||||||
|
@ -393,7 +396,6 @@ class PhpAro {
|
||||||
$this->build($aro);
|
$this->build($aro);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* From the perspective of the given ARO, walk down the tree and
|
* From the perspective of the given ARO, walk down the tree and
|
||||||
* collect all inherited AROs levelwise such that AROs from different
|
* collect all inherited AROs levelwise such that AROs from different
|
||||||
|
@ -413,7 +415,7 @@ class PhpAro {
|
||||||
list($element, $depth) = array_pop($stack);
|
list($element, $depth) = array_pop($stack);
|
||||||
$aros[$depth][] = $element;
|
$aros[$depth][] = $element;
|
||||||
|
|
||||||
foreach ($this->tree as $node => $children) {
|
foreach ($this->_tree as $node => $children) {
|
||||||
if (in_array($element, $children)) {
|
if (in_array($element, $children)) {
|
||||||
array_push($stack, array($node, $depth + 1));
|
array_push($stack, array($node, $depth + 1));
|
||||||
}
|
}
|
||||||
|
@ -423,7 +425,6 @@ class PhpAro {
|
||||||
return array_reverse($aros);
|
return array_reverse($aros);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* resolve an ARO identifier to an internal ARO string using
|
* resolve an ARO identifier to an internal ARO string using
|
||||||
* the internal mapping information.
|
* the internal mapping information.
|
||||||
|
@ -460,7 +461,7 @@ class PhpAro {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->tree[$mapped])) {
|
if (isset($this->_tree[$mapped])) {
|
||||||
return $mapped;
|
return $mapped;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,13 +469,10 @@ class PhpAro {
|
||||||
if (!empty($this->aliases[$mapped])) {
|
if (!empty($this->aliases[$mapped])) {
|
||||||
return $this->aliases[$mapped];
|
return $this->aliases[$mapped];
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::DEFAULT_ROLE;
|
return self::DEFAULT_ROLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* adds a new ARO to the tree
|
* adds a new ARO to the tree
|
||||||
*
|
*
|
||||||
|
@ -483,8 +481,8 @@ class PhpAro {
|
||||||
*/
|
*/
|
||||||
public function addRole(array $aro) {
|
public function addRole(array $aro) {
|
||||||
foreach ($aro as $role => $inheritedRoles) {
|
foreach ($aro as $role => $inheritedRoles) {
|
||||||
if (!isset($this->tree[$role])) {
|
if (!isset($this->_tree[$role])) {
|
||||||
$this->tree[$role] = array();
|
$this->_tree[$role] = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($inheritedRoles)) {
|
if (!empty($inheritedRoles)) {
|
||||||
|
@ -503,15 +501,15 @@ class PhpAro {
|
||||||
$path .= implode('|', (array)$roleDependencies) . ' -> ';
|
$path .= implode('|', (array)$roleDependencies) . ' -> ';
|
||||||
}
|
}
|
||||||
|
|
||||||
trigger_error(__d('cake_dev', 'cycle detected when inheriting %s from %s. Path: %s', $role, $dependency, $path.$role));
|
trigger_error(__d('cake_dev', 'cycle detected when inheriting %s from %s. Path: %s', $role, $dependency, $path . $role));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($this->tree[$dependency])) {
|
if (!isset($this->_tree[$dependency])) {
|
||||||
$this->tree[$dependency] = array();
|
$this->_tree[$dependency] = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->tree[$dependency][] = $role;
|
$this->_tree[$dependency][] = $role;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -534,7 +532,8 @@ class PhpAro {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function build(array $aros) {
|
public function build(array $aros) {
|
||||||
$this->tree = array();
|
$this->_tree = array();
|
||||||
$this->addRole($aros);
|
$this->addRole($aros);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,6 +177,5 @@ class AclComponent extends Component {
|
||||||
trigger_error(__d('cake_dev', 'AclComponent::revoke() is deprecated, use deny() instead'), E_USER_WARNING);
|
trigger_error(__d('cake_dev', 'AclComponent::revoke() is deprecated, use deny() instead'), E_USER_WARNING);
|
||||||
return $this->_Instance->deny($aro, $aco, $action);
|
return $this->_Instance->deny($aro, $aco, $action);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -38,4 +38,5 @@ class ActionsAuthorize extends BaseAuthorize {
|
||||||
$user = array($this->settings['userModel'] => $user);
|
$user = array($this->settings['userModel'] => $user);
|
||||||
return $Acl->check($user, $this->action($request));
|
return $Acl->check($user, $this->action($request));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,8 @@ abstract class BaseAuthenticate {
|
||||||
* @param array $user The user about to be logged out.
|
* @param array $user The user about to be logged out.
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function logout($user) { }
|
public function logout($user) {
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a user based on information in the request. Primarily used by stateless authentication
|
* Get a user based on information in the request. Primarily used by stateless authentication
|
||||||
|
@ -133,4 +134,5 @@ abstract class BaseAuthenticate {
|
||||||
public function getUser($request) {
|
public function getUser($request) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
* @see AuthComponent::$authenticate
|
* @see AuthComponent::$authenticate
|
||||||
*/
|
*/
|
||||||
abstract class BaseAuthorize {
|
abstract class BaseAuthorize {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Controller for the request.
|
* Controller for the request.
|
||||||
*
|
*
|
||||||
|
@ -156,4 +157,5 @@ abstract class BaseAuthorize {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,7 @@ App::uses('BaseAuthenticate', 'Controller/Component/Auth');
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
class BasicAuthenticate extends BaseAuthenticate {
|
class BasicAuthenticate extends BaseAuthenticate {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Settings for this object.
|
* Settings for this object.
|
||||||
*
|
*
|
||||||
|
@ -121,4 +122,5 @@ class BasicAuthenticate extends BaseAuthenticate {
|
||||||
public function loginHeaders() {
|
public function loginHeaders() {
|
||||||
return sprintf('WWW-Authenticate: Basic realm="%s"', $this->settings['realm']);
|
return sprintf('WWW-Authenticate: Basic realm="%s"', $this->settings['realm']);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -61,7 +61,7 @@ class ControllerAuthorize extends BaseAuthorize {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function authorize($user, CakeRequest $request) {
|
public function authorize($user, CakeRequest $request) {
|
||||||
return (bool) $this->_Controller->isAuthorized($user);
|
return (bool)$this->_Controller->isAuthorized($user);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -98,4 +98,5 @@ class CrudAuthorize extends BaseAuthorize {
|
||||||
$this->settings['actionMap'][$request->params['action']]
|
$this->settings['actionMap'][$request->params['action']]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,6 +55,7 @@ App::uses('BaseAuthenticate', 'Controller/Component/Auth');
|
||||||
* @since 2.0
|
* @since 2.0
|
||||||
*/
|
*/
|
||||||
class DigestAuthenticate extends BaseAuthenticate {
|
class DigestAuthenticate extends BaseAuthenticate {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Settings for this object.
|
* Settings for this object.
|
||||||
*
|
*
|
||||||
|
@ -65,7 +66,8 @@ class DigestAuthenticate extends BaseAuthenticate {
|
||||||
* - `realm` The realm authentication is for, Defaults to the servername.
|
* - `realm` The realm authentication is for, Defaults to the servername.
|
||||||
* - `nonce` A nonce used for authentication. Defaults to `uniqid()`.
|
* - `nonce` A nonce used for authentication. Defaults to `uniqid()`.
|
||||||
* - `qop` Defaults to auth, no other values are supported at this time.
|
* - `qop` Defaults to auth, no other values are supported at this time.
|
||||||
* - `opaque` A string that must be returned unchanged by clients. Defaults to `md5($settings['realm'])`
|
* - `opaque` A string that must be returned unchanged by clients.
|
||||||
|
* Defaults to `md5($settings['realm'])`
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
|
@ -261,4 +263,5 @@ class DigestAuthenticate extends BaseAuthenticate {
|
||||||
}
|
}
|
||||||
return 'WWW-Authenticate: Digest ' . implode(',', $opts);
|
return 'WWW-Authenticate: Digest ' . implode(',', $opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -718,4 +718,5 @@ class AuthComponent extends Component {
|
||||||
public function flash($message) {
|
public function flash($message) {
|
||||||
$this->Session->setFlash($message, $this->flash['element'], $this->flash['params'], $this->flash['key']);
|
$this->Session->setFlash($message, $this->flash['element'], $this->flash['params'], $this->flash['key']);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -431,7 +431,7 @@ class CookieComponent extends Component {
|
||||||
|
|
||||||
if ($this->_encrypted === true) {
|
if ($this->_encrypted === true) {
|
||||||
$type = $this->_type;
|
$type = $this->_type;
|
||||||
$value = "Q2FrZQ==." .base64_encode(Security::$type($value, $this->key));
|
$value = "Q2FrZQ==." . base64_encode(Security::$type($value, $this->key));
|
||||||
}
|
}
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
@ -503,4 +503,5 @@ class CookieComponent extends Component {
|
||||||
}
|
}
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -370,11 +370,12 @@ class PaginatorComponent extends Component {
|
||||||
* @return array An array of options for pagination
|
* @return array An array of options for pagination
|
||||||
*/
|
*/
|
||||||
public function checkLimit($options) {
|
public function checkLimit($options) {
|
||||||
$options['limit'] = (int) $options['limit'];
|
$options['limit'] = (int)$options['limit'];
|
||||||
if (empty($options['limit']) || $options['limit'] < 1) {
|
if (empty($options['limit']) || $options['limit'] < 1) {
|
||||||
$options['limit'] = 1;
|
$options['limit'] = 1;
|
||||||
}
|
}
|
||||||
$options['limit'] = min((int)$options['limit'], $options['maxLimit']);
|
$options['limit'] = min((int)$options['limit'], $options['maxLimit']);
|
||||||
return $options;
|
return $options;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -592,4 +592,5 @@ class SecurityComponent extends Component {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,4 +124,5 @@ class ComponentCollection extends ObjectCollection implements CakeEventListener
|
||||||
'Controller.shutdown' => array('callable' => 'trigger'),
|
'Controller.shutdown' => array('callable' => 'trigger'),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
|
@ -1,9 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* Base controller class.
|
|
||||||
*
|
|
||||||
* PHP 5
|
|
||||||
*
|
|
||||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||||
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
* Copyright 2005-2011, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||||
*
|
*
|
||||||
|
@ -145,7 +141,6 @@ class Controller extends Object implements CakeEventListener {
|
||||||
*/
|
*/
|
||||||
public $viewVars = array();
|
public $viewVars = array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The name of the view file to render. The name specified
|
* The name of the view file to render. The name specified
|
||||||
* is the filename in /app/View/<SubFolder> without the .ctp extension.
|
* is the filename in /app/View/<SubFolder> without the .ctp extension.
|
||||||
|
@ -321,7 +316,7 @@ class Controller extends Object implements CakeEventListener {
|
||||||
*/
|
*/
|
||||||
public function __construct($request = null, $response = null) {
|
public function __construct($request = null, $response = null) {
|
||||||
if ($this->name === null) {
|
if ($this->name === null) {
|
||||||
$this->name = substr(get_class($this), 0, strlen(get_class($this)) -10);
|
$this->name = substr(get_class($this), 0, strlen(get_class($this)) - 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->viewPath == null) {
|
if ($this->viewPath == null) {
|
||||||
|
@ -476,7 +471,9 @@ class Controller extends Object implements CakeEventListener {
|
||||||
*
|
*
|
||||||
* @param CakeRequest $request
|
* @param CakeRequest $request
|
||||||
* @return mixed The resulting response.
|
* @return mixed The resulting response.
|
||||||
* @throws PrivateActionException, MissingActionException
|
* @throws PrivateActionException When actions are not public or prefixed by _
|
||||||
|
* @throws MissingActionException When actions are not defined and scaffolding is
|
||||||
|
* not enabled.
|
||||||
*/
|
*/
|
||||||
public function invokeAction(CakeRequest $request) {
|
public function invokeAction(CakeRequest $request) {
|
||||||
try {
|
try {
|
||||||
|
@ -640,7 +637,7 @@ class Controller extends Object implements CakeEventListener {
|
||||||
$this->_mergeControllerVars();
|
$this->_mergeControllerVars();
|
||||||
$this->Components->init($this);
|
$this->Components->init($this);
|
||||||
if ($this->uses) {
|
if ($this->uses) {
|
||||||
$this->uses = (array) $this->uses;
|
$this->uses = (array)$this->uses;
|
||||||
list(, $this->modelClass) = pluginSplit(current($this->uses));
|
list(, $this->modelClass) = pluginSplit(current($this->uses));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -1062,10 +1059,10 @@ class Controller extends Object implements CakeEventListener {
|
||||||
}
|
}
|
||||||
$fieldOp = strtoupper(trim($fieldOp));
|
$fieldOp = strtoupper(trim($fieldOp));
|
||||||
if ($fieldOp === 'LIKE') {
|
if ($fieldOp === 'LIKE') {
|
||||||
$key = $key.' LIKE';
|
$key = $key . ' LIKE';
|
||||||
$value = '%' . $value . '%';
|
$value = '%' . $value . '%';
|
||||||
} elseif ($fieldOp && $fieldOp != '=') {
|
} elseif ($fieldOp && $fieldOp != '=') {
|
||||||
$key = $key.' ' . $fieldOp;
|
$key = $key . ' ' . $fieldOp;
|
||||||
}
|
}
|
||||||
$cond[$key] = $value;
|
$cond[$key] = $value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,7 @@ class Scaffold {
|
||||||
$this->ScaffoldModel = $this->controller->{$this->modelClass};
|
$this->ScaffoldModel = $this->controller->{$this->modelClass};
|
||||||
$this->scaffoldTitle = Inflector::humanize(Inflector::underscore($this->viewPath));
|
$this->scaffoldTitle = Inflector::humanize(Inflector::underscore($this->viewPath));
|
||||||
$this->scaffoldActions = $controller->scaffold;
|
$this->scaffoldActions = $controller->scaffold;
|
||||||
$title_for_layout = __d('cake', 'Scaffold :: ') . Inflector::humanize($request->action) . ' :: ' . $this->scaffoldTitle;
|
$title = __d('cake', 'Scaffold :: ') . Inflector::humanize($request->action) . ' :: ' . $this->scaffoldTitle;
|
||||||
$modelClass = $this->controller->modelClass;
|
$modelClass = $this->controller->modelClass;
|
||||||
$primaryKey = $this->ScaffoldModel->primaryKey;
|
$primaryKey = $this->ScaffoldModel->primaryKey;
|
||||||
$displayField = $this->ScaffoldModel->displayField;
|
$displayField = $this->ScaffoldModel->displayField;
|
||||||
|
@ -140,6 +140,7 @@ class Scaffold {
|
||||||
'title_for_layout', 'modelClass', 'primaryKey', 'displayField', 'singularVar', 'pluralVar',
|
'title_for_layout', 'modelClass', 'primaryKey', 'displayField', 'singularVar', 'pluralVar',
|
||||||
'singularHumanName', 'pluralHumanName', 'scaffoldFields', 'associations'
|
'singularHumanName', 'pluralHumanName', 'scaffoldFields', 'associations'
|
||||||
));
|
));
|
||||||
|
$this->set('title_for_layout', $title);
|
||||||
|
|
||||||
if ($this->controller->viewClass) {
|
if ($this->controller->viewClass) {
|
||||||
$this->controller->viewClass = 'Scaffold';
|
$this->controller->viewClass = 'Scaffold';
|
||||||
|
@ -287,7 +288,8 @@ class Scaffold {
|
||||||
*
|
*
|
||||||
* @param CakeRequest $request Request for scaffolding
|
* @param CakeRequest $request Request for scaffolding
|
||||||
* @return mixed Success on delete, error if delete fails
|
* @return mixed Success on delete, error if delete fails
|
||||||
* @throws MethodNotAllowedException, NotFoundException
|
* @throws MethodNotAllowedException When HTTP method is not a DELETE
|
||||||
|
* @throws NotFoundException When id being deleted does not exist.
|
||||||
*/
|
*/
|
||||||
protected function _scaffoldDelete(CakeRequest $request) {
|
protected function _scaffoldDelete(CakeRequest $request) {
|
||||||
if ($this->controller->beforeScaffold('delete')) {
|
if ($this->controller->beforeScaffold('delete')) {
|
||||||
|
@ -350,7 +352,8 @@ class Scaffold {
|
||||||
*
|
*
|
||||||
* @param CakeRequest $request Request object for scaffolding
|
* @param CakeRequest $request Request object for scaffolding
|
||||||
* @return mixed A rendered view of scaffold action, or showing the error
|
* @return mixed A rendered view of scaffold action, or showing the error
|
||||||
* @throws MissingActionException, MissingDatabaseException
|
* @throws MissingActionException When methods are not scaffolded.
|
||||||
|
* @throws MissingDatabaseException When the database connection is undefined.
|
||||||
*/
|
*/
|
||||||
protected function _scaffold(CakeRequest $request) {
|
protected function _scaffold(CakeRequest $request) {
|
||||||
$db = ConnectionManager::getDataSource($this->ScaffoldModel->useDbConfig);
|
$db = ConnectionManager::getDataSource($this->ScaffoldModel->useDbConfig);
|
||||||
|
@ -440,4 +443,5 @@ class Scaffold {
|
||||||
}
|
}
|
||||||
return $associations;
|
return $associations;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue