Skip to content

Commit

Permalink
Merge branch 'w51_MDL-37105_m25_catlimit' of git://github.com/skodak/…
Browse files Browse the repository at this point in the history
…moodle
  • Loading branch information
Sam Hemelryk committed Jan 6, 2013
2 parents b33f3d7 + bb900d1 commit 9fa3979
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions lib/navigationlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -1663,19 +1663,21 @@ protected function load_all_categories($categoryid = self::LOAD_ROOT_CATEGORIES,
$categoryids[] = $category->key;
}
}
list($categoriessql, $params) = $DB->get_in_or_equal($categoryids, SQL_PARAMS_NAMED);
$params['limit'] = (!empty($CFG->navcourselimit))?$CFG->navcourselimit:20;
$sql = "SELECT cc.id, COUNT(c.id) AS coursecount
FROM {course_categories} cc
JOIN {course} c ON c.category = cc.id
WHERE cc.id {$categoriessql}
GROUP BY cc.id
HAVING COUNT(c.id) > :limit";
$excessivecategories = $DB->get_records_sql($sql, $params);
foreach ($categories as &$category) {
if (array_key_exists($category->key, $excessivecategories) && !$this->can_add_more_courses_to_category($category)) {
$url = new moodle_url('/course/category.php', array('id'=>$category->key));
$category->add(get_string('viewallcourses'), $url, self::TYPE_SETTING);
if ($categoryids) {
list($categoriessql, $params) = $DB->get_in_or_equal($categoryids, SQL_PARAMS_NAMED);
$params['limit'] = (!empty($CFG->navcourselimit))?$CFG->navcourselimit:20;
$sql = "SELECT cc.id, COUNT(c.id) AS coursecount
FROM {course_categories} cc
JOIN {course} c ON c.category = cc.id
WHERE cc.id {$categoriessql}
GROUP BY cc.id
HAVING COUNT(c.id) > :limit";
$excessivecategories = $DB->get_records_sql($sql, $params);
foreach ($categories as &$category) {
if (array_key_exists($category->key, $excessivecategories) && !$this->can_add_more_courses_to_category($category)) {
$url = new moodle_url('/course/category.php', array('id'=>$category->key));
$category->add(get_string('viewallcourses'), $url, self::TYPE_SETTING);
}
}
}
}
Expand Down

0 comments on commit 9fa3979

Please sign in to comment.