Moved the new functions added for Bug #4074 to datalib.php
This commit is contained in:
@@ -2038,24 +2038,4 @@ function move_courses ($courseids, $categoryid) {
|
||||
return true;
|
||||
}
|
||||
|
||||
function course_parent_visible($course = null) {
|
||||
return category_parent_visible($course->category);
|
||||
}
|
||||
|
||||
function category_parent_visible($parent = 0) {
|
||||
if (!$parent) {
|
||||
return true;
|
||||
}
|
||||
$category = get_record('course_categories', 'id', $parent);
|
||||
$list = explode('/', preg_replace('/^\/(.*)$/', '$1', $category->path));
|
||||
$list[] = $parent;
|
||||
$parents = get_records_list('course_categories', 'id', implode(',', $list), 'depth DESC');
|
||||
foreach ($parents as $parent) {
|
||||
if (!$parent->visible) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -3060,5 +3060,25 @@ function check_db_compat() {
|
||||
return true;
|
||||
}
|
||||
|
||||
function course_parent_visible($course = null) {
|
||||
return category_parent_visible($course->category);
|
||||
}
|
||||
|
||||
function category_parent_visible($parent = 0) {
|
||||
if (!$parent) {
|
||||
return true;
|
||||
}
|
||||
$category = get_record('course_categories', 'id', $parent);
|
||||
$list = explode('/', preg_replace('/^\/(.*)$/', '$1', $category->path));
|
||||
$list[] = $parent;
|
||||
$parents = get_records_list('course_categories', 'id', implode(',', $list), 'depth DESC');
|
||||
foreach ($parents as $parent) {
|
||||
if (!$parent->visible) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// vim:autoindent:expandtab:shiftwidth=4:tabstop=4:tw=140:
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user