Some small fixes when deleting a category
This commit is contained in:
+7
-1
@@ -103,6 +103,7 @@
|
||||
notify(get_string("categorydeleted", "", $tempcat->name));
|
||||
}
|
||||
if ($children = get_records("course_categories", "parent", $tempcat->id)) {
|
||||
// Send the children to live with their grandparent
|
||||
foreach ($children as $childcat) {
|
||||
if (! set_field("course_categories", "parent", $tempcat->parent, "id", $childcat->id)) {
|
||||
notify("Could not update a child category!");
|
||||
@@ -220,11 +221,16 @@
|
||||
|
||||
/// Find any orphan courses that don't yet have a valid category and set to default
|
||||
if ($courses = get_courses()) {
|
||||
$foundorphans = false;
|
||||
foreach ($courses as $course) {
|
||||
if ($course->category and !isset( $categories[$course->category] )) {
|
||||
if ($course->category and !isset($categories[$course->category])) {
|
||||
set_field("course", "category", $default, "id", $course->id);
|
||||
$foundorphans = true;
|
||||
}
|
||||
}
|
||||
if ($foundorphans) {
|
||||
fix_course_sortorder($default);
|
||||
}
|
||||
}
|
||||
|
||||
/// Print form for creating new categories
|
||||
|
||||
+2
-2
@@ -1115,7 +1115,7 @@ function get_courses($categoryid="all", $sort="c.sortorder ASC", $fields="c.*")
|
||||
|
||||
$categoryselect = "";
|
||||
if ($categoryid != "all") {
|
||||
$categoryselect = "c.category = '$categoryid'";
|
||||
$categoryselect = "WHERE c.category = '$categoryid'";
|
||||
}
|
||||
|
||||
$teachertable = "";
|
||||
@@ -1131,7 +1131,7 @@ function get_courses($categoryid="all", $sort="c.sortorder ASC", $fields="c.*")
|
||||
$visiblecourses = "AND c.visible > 0";
|
||||
}
|
||||
|
||||
$selectsql = "{$CFG->prefix}course c $teachertable WHERE $categoryselect $visiblecourses";
|
||||
$selectsql = "{$CFG->prefix}course c $teachertable $categoryselect $visiblecourses";
|
||||
|
||||
return get_records_sql("SELECT $fields FROM $selectsql $teachergroup ORDER BY $sort");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user