3 /// This page lists all the instances of glossary in a particular course
4 /// Replace glossary with the name of your module
6 require_once("../../config.php");
7 require_once("lib.php");
8 require_once("$CFG->libdir/rsslib.php");
10 $id = required_param('id', PARAM_INT
); // course
12 if (! $course = get_record("course", "id", $id)) {
13 error("Course ID is incorrect");
16 require_course_login($course);
17 $context = get_context_instance(CONTEXT_COURSE
, $course->id
);
19 add_to_log($course->id
, "glossary", "view all", "index.php?id=$course->id", "");
22 /// Get all required strings
24 $strglossarys = get_string("modulenameplural", "glossary");
25 $strglossary = get_string("modulename", "glossary");
26 $strrss = get_string("rss");
31 $navlinks[] = array('name' => $strglossarys, 'link' => "index.php?id=$course->id", 'type' => 'activity');
32 $navigation = build_navigation($navlinks);
34 print_header_simple("$strglossarys", "", $navigation, "", "", true, "", navmenu($course));
36 /// Get all the appropriate data
38 if (! $glossarys = get_all_instances_in_course("glossary", $course)) {
39 notice("There are no glossaries", "../../course/view.php?id=$course->id");
43 /// Print the list of instances (your module will probably extend this)
46 $strname = get_string("name");
47 $strweek = get_string("week");
48 $strtopic = get_string("topic");
49 $strentries = get_string("entries", "glossary");
51 if ($course->format
== "weeks") {
52 $table->head
= array ($strweek, $strname, $strentries);
53 $table->align
= array ("CENTER", "LEFT", "CENTER");
54 } else if ($course->format
== "topics") {
55 $table->head
= array ($strtopic, $strname, $strentries);
56 $table->align
= array ("CENTER", "LEFT", "CENTER");
58 $table->head
= array ($strname, $strentries);
59 $table->align
= array ("LEFT", "CENTER");
62 if ($show_rss = (isset($CFG->enablerssfeeds
) && isset($CFG->glossary_enablerssfeeds
) &&
63 $CFG->enablerssfeeds
&& $CFG->glossary_enablerssfeeds
)) {
64 $table->head
[] = $strrss;
65 $table->align
[] = "CENTER";
70 foreach ($glossarys as $glossary) {
71 if (!$glossary->visible
&& has_capability('moodle/course:viewhiddenactivities', $context)) {
72 // Show dimmed if the mod is hidden.
73 $link = "<a class=\"dimmed\" href=\"view.php?id=$glossary->coursemodule\">".format_string($glossary->name
,true)."</a>";
74 } else if ($glossary->visible
) {
75 // Show normal if the mod is visible.
76 $link = "<a href=\"view.php?id=$glossary->coursemodule\">".format_string($glossary->name
,true)."</a>";
78 // Don't show the glossary.
82 if ($glossary->section
!== $currentsection) {
83 if ($glossary->section
) {
84 $printsection = $glossary->section
;
86 if ($currentsection !== "") {
87 $table->data
[] = 'hr';
89 $currentsection = $glossary->section
;
92 $count = count_records_sql("SELECT COUNT(*) FROM {$CFG->prefix}glossary_entries where (glossaryid = $glossary->id or sourceglossaryid = $glossary->id)");
94 //If this glossary has RSS activated, calculate it
97 if ($glossary->rsstype
and $glossary->rssarticles
) {
98 //Calculate the tolltip text
99 $tooltiptext = get_string("rsssubscriberss","glossary",format_string($glossary->name
));
100 if (empty($USER->id
)) {
105 //Get html code for RSS link
106 $rsslink = rss_get_link($course->id
, $userid, "glossary", $glossary->id
, $tooltiptext);
110 if ($course->format
== "weeks" or $course->format
== "topics") {
111 $linedata = array ($printsection, $link, $count);
113 $linedata = array ($link, $count);
117 $linedata[] = $rsslink;
120 $table->data
[] = $linedata;
129 print_footer($course);