MDL-29108 Orphaned areas are excluded from search results
authorDavid Mudrak <david@moodle.com>
Fri, 11 Nov 2011 13:16:17 +0000 (14:16 +0100)
committerDavid Mudrak <david@moodle.com>
Fri, 11 Nov 2011 13:16:17 +0000 (14:16 +0100)
If for any reason the referenced context does not exist any more, the
forms defined in relevant areas are considered removed (even if their
records still exist in the database).

grade/grading/pick.php

index 5b0175b..fd4d6ef 100644 (file)
@@ -147,7 +147,8 @@ if ($searchdata = $searchform->get_data()) {
 $sql = "SELECT DISTINCT gd.id, gd.areaid, gd.name, gd.description, gd.descriptionformat, gd.timecreated,
                         gd.usercreated, gd.timemodified, gd.usermodified
           FROM {grading_definitions} gd
-          JOIN {grading_areas} ga ON (gd.areaid = ga.id)";
+          JOIN {grading_areas} ga ON (gd.areaid = ga.id)
+          JOIN {context} cx ON (ga.contextid = cx.id)";
 // join method-specific tables from the plugin scope
 $sql .= $targetcontrollerclass::sql_search_from_tables('gd.id');