From: poltawski Date: Wed, 26 Dec 2007 17:44:45 +0000 (+0000) Subject: MDL-2013 - stop resource auto-linking from occuring when resources are hidden X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=0bf540bb641d5325b3cb1c982d8ff82cabc3c3ac;p=moodle.git MDL-2013 - stop resource auto-linking from occuring when resources are hidden merged from MOODLE_19_STABLE --- diff --git a/mod/resource/filter.php b/mod/resource/filter.php index f6080ef906..6a76378d96 100644 --- a/mod/resource/filter.php +++ b/mod/resource/filter.php @@ -32,9 +32,23 @@ if (empty($resourcelist)) { - /// The resources are sorted from long to short so longer ones can be linked first. + /* get all non-hidden resources from this course + * sorted from long to short so longer ones can be + * linked first. And order by section so we try to + * link to the top resource first. + */ + $resource_sql = "SELECT r.id, r.name + FROM {$CFG->prefix}resource r, + {$CFG->prefix}course_modules cm, + {$CFG->prefix}modules m + WHERE m.name = 'resource' AND + cm.module = m.id AND + cm.visible = 1 AND + r.id = cm.instance AND + cm.course = {$courseid} + ORDER BY CHAR_LENGTH(r.name) DESC, cm.section ASC;"; - if (!$resources = get_records('resource', 'course', $courseid, 'CHAR_LENGTH(name) DESC', 'id,name')) { + if (!$resources = get_records_sql($resource_sql) ){ $nothingtodo = true; return $text; }