modinfo to string prevents one notice when the field is null $modinfo = unserialize((string)$course->modinfo); if (!empty($modinfo)) { $activitylist = array(); /// We will store all the activities here //Sort modinfo by name length usort($modinfo,'comparemodulenamesbylength'); foreach ($modinfo as $activity) { //Exclude labels and hidden items if ($activity->mod != "label" && $activity->visible) { $title = trim(strip_tags(urldecode($activity->name))); /// Avoid empty or unlinkable activity names if (!empty($title)) { $title = str_replace('"', "'", $title); $href_tag_begin = "wwwroot/mod/$activity->mod/view.php?id=$activity->cm\" $CFG->frametarget>"; $currentname = urldecode($activity->name); if ($currentname = trim($currentname)) { $activitylist[] = new filterobject($currentname, $href_tag_begin, '', false, true); } } } } } } return $text = filter_phrases ($text, $activitylist); } //This function is used to order module names from longer to shorter function comparemodulenamesbylength($a, $b) { if (strlen($a->name) == strlen($b->name)) { return 0; } return (strlen($a->name) < strlen($b->name)) ? 1 : -1; } ?>