MDL-48421 navigation: accounting for potential regression

This commit is contained in:
Tim Price 2014-12-16 11:45:10 +11:00
parent 85e59ac2f3
commit 6eb3da841d

View File

@ -1632,13 +1632,15 @@ class global_navigation extends navigation_node {
// have been loaded
$addedcategories = $this->addedcategories;
unset($addedcategories[$categoryid]);
list($sql, $params) = $DB->get_in_or_equal(array_keys($addedcategories), SQL_PARAMS_NAMED, 'parent', false);
if ($showbasecategories) {
// We need to include categories with parent = 0 as well
$sqlwhere .= " AND (cc.parent = :categoryid OR cc.parent = 0) AND cc.parent {$sql}";
} else {
// All we need is categories that match the parent
$sqlwhere .= " AND cc.parent = :categoryid AND cc.parent {$sql}";
if (count($addedcategories) > 0) {
list($sql, $params) = $DB->get_in_or_equal(array_keys($addedcategories), SQL_PARAMS_NAMED, 'parent', false);
if ($showbasecategories) {
// We need to include categories with parent = 0 as well
$sqlwhere .= " AND (cc.parent = :categoryid OR cc.parent = 0) AND cc.parent {$sql}";
} else {
// All we need is categories that match the parent
$sqlwhere .= " AND cc.parent = :categoryid AND cc.parent {$sql}";
}
}
$params['categoryid'] = $categoryid;
} else {