mirror of
https://github.com/brmlab/brmsklad.git
synced 2025-08-03 06:33:38 +02:00
Upgrade CakePHP from 2.2.5 to 2.9.5
This commit is contained in:
parent
5a580df460
commit
235a541597
793 changed files with 60746 additions and 23753 deletions
|
@ -1,19 +1,17 @@
|
|||
<?php
|
||||
/**
|
||||
*
|
||||
* PHP 5
|
||||
*
|
||||
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
|
||||
* Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
*
|
||||
* Licensed under The MIT License
|
||||
* For full copyright and license information, please see the LICENSE.txt
|
||||
* Redistributions of files must retain the above copyright notice.
|
||||
*
|
||||
* @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
|
||||
* @link http://cakephp.org CakePHP(tm) Project
|
||||
* @package Cake.Model
|
||||
* @since CakePHP(tm) v 0.2.9
|
||||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
App::uses('Model', 'Model');
|
||||
|
@ -28,7 +26,7 @@ class AclNode extends Model {
|
|||
/**
|
||||
* Explicitly disable in-memory query caching for ACL models
|
||||
*
|
||||
* @var boolean
|
||||
* @var bool
|
||||
*/
|
||||
public $cacheQueries = false;
|
||||
|
||||
|
@ -42,13 +40,17 @@ class AclNode extends Model {
|
|||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param bool|int|string|array $id Set this ID for this model on startup,
|
||||
* can also be an array of options, see above.
|
||||
* @param string $table Name of database table to use.
|
||||
* @param string $ds DataSource connection name.
|
||||
*/
|
||||
public function __construct() {
|
||||
public function __construct($id = false, $table = null, $ds = null) {
|
||||
$config = Configure::read('Acl.database');
|
||||
if (isset($config)) {
|
||||
$this->useDbConfig = $config;
|
||||
}
|
||||
parent::__construct();
|
||||
parent::__construct($id, $table, $ds);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -84,47 +86,51 @@ class AclNode extends Model {
|
|||
'joins' => array(array(
|
||||
'table' => $table,
|
||||
'alias' => "{$type}0",
|
||||
'type' => 'LEFT',
|
||||
'type' => 'INNER',
|
||||
'conditions' => array("{$type}0.alias" => $start)
|
||||
)),
|
||||
'order' => $db->name("{$type}.lft") . ' DESC'
|
||||
);
|
||||
|
||||
$conditionsAfterJoin = array();
|
||||
|
||||
foreach ($path as $i => $alias) {
|
||||
$j = $i - 1;
|
||||
|
||||
$queryData['joins'][] = array(
|
||||
'table' => $table,
|
||||
'alias' => "{$type}{$i}",
|
||||
'type' => 'LEFT',
|
||||
'type' => 'INNER',
|
||||
'conditions' => array(
|
||||
$db->name("{$type}{$i}.lft") . ' > ' . $db->name("{$type}{$j}.lft"),
|
||||
$db->name("{$type}{$i}.rght") . ' < ' . $db->name("{$type}{$j}.rght"),
|
||||
$db->name("{$type}{$i}.alias") . ' = ' . $db->value($alias, 'string'),
|
||||
$db->name("{$type}{$j}.id") . ' = ' . $db->name("{$type}{$i}.parent_id")
|
||||
"{$type}{$i}.alias" => $alias
|
||||
)
|
||||
);
|
||||
|
||||
// it will be better if this conditions will performs after join operation
|
||||
$conditionsAfterJoin[] = $db->name("{$type}{$j}.id") . ' = ' . $db->name("{$type}{$i}.parent_id");
|
||||
$conditionsAfterJoin[] = $db->name("{$type}{$i}.rght") . ' < ' . $db->name("{$type}{$j}.rght");
|
||||
$conditionsAfterJoin[] = $db->name("{$type}{$i}.lft") . ' > ' . $db->name("{$type}{$j}.lft");
|
||||
|
||||
$queryData['conditions'] = array('or' => array(
|
||||
$db->name("{$type}.lft") . ' <= ' . $db->name("{$type}0.lft") . ' AND ' . $db->name("{$type}.rght") . ' >= ' . $db->name("{$type}0.rght"),
|
||||
$db->name("{$type}.lft") . ' <= ' . $db->name("{$type}{$i}.lft") . ' AND ' . $db->name("{$type}.rght") . ' >= ' . $db->name("{$type}{$i}.rght"))
|
||||
);
|
||||
}
|
||||
$queryData['conditions'] = array_merge($queryData['conditions'], $conditionsAfterJoin);
|
||||
$result = $db->read($this, $queryData, -1);
|
||||
$path = array_values($path);
|
||||
|
||||
if (
|
||||
!isset($result[0][$type]) ||
|
||||
if (!isset($result[0][$type]) ||
|
||||
(!empty($path) && $result[0][$type]['alias'] != $path[count($path) - 1]) ||
|
||||
(empty($path) && $result[0][$type]['alias'] != $start)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
} elseif (is_object($ref) && is_a($ref, 'Model')) {
|
||||
} elseif (is_object($ref) && $ref instanceof Model) {
|
||||
$ref = array('model' => $ref->name, 'foreign_key' => $ref->id);
|
||||
} elseif (is_array($ref) && !(isset($ref['model']) && isset($ref['foreign_key']))) {
|
||||
$name = key($ref);
|
||||
list($plugin, $alias) = pluginSplit($name);
|
||||
list(, $alias) = pluginSplit($name);
|
||||
|
||||
$model = ClassRegistry::init(array('class' => $name, 'alias' => $alias));
|
||||
|
||||
|
@ -162,7 +168,7 @@ class AclNode extends Model {
|
|||
'joins' => array(array(
|
||||
'table' => $table,
|
||||
'alias' => "{$type}0",
|
||||
'type' => 'LEFT',
|
||||
'type' => 'INNER',
|
||||
'conditions' => array(
|
||||
$db->name("{$type}.lft") . ' <= ' . $db->name("{$type}0.lft"),
|
||||
$db->name("{$type}.rght") . ' >= ' . $db->name("{$type}0.rght")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue