mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Adding fix for #2753, db_acl.php doesn't respect Dbo alias property
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5399 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
1963c3b501
commit
7e3b4dfd84
1 changed files with 6 additions and 5 deletions
|
@ -70,6 +70,7 @@ class AclNode extends AppModel {
|
||||||
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
$db =& ConnectionManager::getDataSource($this->useDbConfig);
|
||||||
$type = $this->name;
|
$type = $this->name;
|
||||||
$prefix = $this->tablePrefix;
|
$prefix = $this->tablePrefix;
|
||||||
|
$result = null;
|
||||||
|
|
||||||
if (!empty($this->useTable)) {
|
if (!empty($this->useTable)) {
|
||||||
$table = $this->useTable;
|
$table = $this->useTable;
|
||||||
|
@ -84,14 +85,14 @@ class AclNode extends AppModel {
|
||||||
$start = $path[count($path) - 1];
|
$start = $path[count($path) - 1];
|
||||||
unset($path[count($path) - 1]);
|
unset($path[count($path) - 1]);
|
||||||
|
|
||||||
$query = "SELECT {$type}.* From {$prefix}{$table} AS {$type} ";
|
$query = "SELECT {$type}.id, {$type}.parent_id, {$type}.model, {$type}.foreign_key, {$type}.alias FROM {$prefix}{$table} {$db->alias} {$type} ";
|
||||||
$query .= "LEFT JOIN {$prefix}{$table} AS {$type}0 ";
|
$query .= "LEFT JOIN {$prefix}{$table} {$db->alias} {$type}0 ";
|
||||||
$query .= "ON {$type}0.alias = " . $db->value($start) . " ";
|
$query .= "ON {$type}0.alias = " . $db->value($start) . " ";
|
||||||
|
|
||||||
foreach ($path as $i => $alias) {
|
foreach ($path as $i => $alias) {
|
||||||
$j = $i - 1;
|
$j = $i - 1;
|
||||||
$k = $i + 1;
|
$k = $i + 1;
|
||||||
$query .= "LEFT JOIN {$prefix}{$table} AS {$type}{$k} ";
|
$query .= "LEFT JOIN {$prefix}{$table} {$db->alias} {$type}{$k} ";
|
||||||
$query .= "ON {$type}{$k}.lft > {$type}{$i}.lft AND {$type}{$k}.rght < {$type}{$i}.rght ";
|
$query .= "ON {$type}{$k}.lft > {$type}{$i}.lft AND {$type}{$k}.rght < {$type}{$i}.rght ";
|
||||||
$query .= "AND {$type}{$k}.alias = " . $db->value($alias) . " ";
|
$query .= "AND {$type}{$k}.alias = " . $db->value($alias) . " ";
|
||||||
}
|
}
|
||||||
|
@ -129,8 +130,8 @@ class AclNode extends AppModel {
|
||||||
$ref["{$type}0.{$key}"] = $val;
|
$ref["{$type}0.{$key}"] = $val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$query = "SELECT {$type}.* From {$prefix}{$table} AS {$type} ";
|
$query = "SELECT {$type}.id, {$type}.parent_id, {$type}.model, {$type}.foreign_key, {$type}.alias FROM {$prefix}{$table} {$db->alias} {$type} ";
|
||||||
$query .= "LEFT JOIN {$prefix}{$table} AS {$type}0 ";
|
$query .= "LEFT JOIN {$prefix}{$table} {$db->alias} {$type}0 ";
|
||||||
$query .= "ON {$type}.lft <= {$type}0.lft AND {$type}.rght >= {$type}0.rght ";
|
$query .= "ON {$type}.lft <= {$type}0.lft AND {$type}.rght >= {$type}0.rght ";
|
||||||
$result = $this->query("{$query} " . $db->conditions($ref) ." ORDER BY {$type}.lft DESC", $this->cacheQueries);
|
$result = $this->query("{$query} " . $db->conditions($ref) ." ORDER BY {$type}.lft DESC", $this->cacheQueries);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue