]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-2013 - stop resource auto-linking from occuring when resources are hidden
authorpoltawski <poltawski>
Wed, 26 Dec 2007 17:44:45 +0000 (17:44 +0000)
committerpoltawski <poltawski>
Wed, 26 Dec 2007 17:44:45 +0000 (17:44 +0000)
merged from MOODLE_19_STABLE

mod/resource/filter.php

index f6080ef9067cf639cd3804f003ed38f818d6966b..6a76378d96123c748897e43dd4684db7cacd657e 100644 (file)
 
         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;
             }