From d1f9ad57d5c9e7feff291c24513aed7db51a3dd7 Mon Sep 17 00:00:00 2001 From: stronk7 Date: Mon, 13 Dec 2004 01:23:22 +0000 Subject: [PATCH] Now activity names are sorted by name length to avoid Bug 2282 (http://moodle.org/bugs/bug.php?op=show&bugid=2282) --- filter/activitynames/filter.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/filter/activitynames/filter.php b/filter/activitynames/filter.php index 9e52f155c1cfa..8f80dabeda747 100644 --- a/filter/activitynames/filter.php +++ b/filter/activitynames/filter.php @@ -17,6 +17,9 @@ function activitynames_filter($courseid, $text) { $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) { @@ -113,4 +116,12 @@ function activity_link_names($text,$name,$href_tag_begin,$href_tag_end = "") } 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; + } ?>