]> git.mjollnir.org Git - moodle.git/commitdiff
Now activity names are sorted by name length to avoid Bug 2282
authorstronk7 <stronk7>
Mon, 13 Dec 2004 01:25:23 +0000 (01:25 +0000)
committerstronk7 <stronk7>
Mon, 13 Dec 2004 01:25:23 +0000 (01:25 +0000)
(http://moodle.org/bugs/bug.php?op=show&bugid=2282)

Merged from MOODLE_14_STABLE

filter/activitynames/filter.php

index 5c5e6cc0be2ad92f8c568459b07916f291c79947..8d222901a5c117f81e20bea45a56762c98ad6539 100644 (file)
@@ -1,4 +1,4 @@
-<?PHP // $Id$
+<?php // $Id$
     //This function provides automatic linking to
     //activities when its name (title) is found inside every Moodle text
     //It's based in the glosssary filter by Williams Castillo
@@ -15,6 +15,9 @@
         $course = get_record("course","id",$courseid);
         $modinfo = unserialize($course->modinfo);
 
+        //Sort modinfo by name lenght
+        usort($modinfo,'comparemodulenamesbylenght'); 
+
         if (!empty($modinfo)) {
             $cm = '';
             foreach ($modinfo as $activity) {
         }
         return $text;
     }
+
+    //This function is used to order module names from longer to shorter
+    function comparemodulenamesbylenght($a, $b)  {
+        if (strlen($a->name) == strlen($b->name)) {
+            return 0;
+        }
+        return (strlen($a->name) < strlen($b->name)) ? 1 : -1;
+    }
 ?>