Merge commit 'catalyst/MOODLE_19_STABLE' into mdl19-linuxchix
[moodle-linuxchix.git] / mod / glossary / comments.php
blobcf13f26c1d57f9374b3deb6ffaea93d1e548b31a
1 <?php // $Id$
3 /// This page prints a particular instance of glossary
4 require_once('../../config.php');
5 require_once('lib.php');
7 $id = required_param('id', PARAM_INT); // Course Module ID
8 $eid = required_param('eid', PARAM_INT); // Entry ID
10 global $USER, $CFG;
12 if (! $cm = get_coursemodule_from_id('glossary', $id)) {
13 error("Course Module ID was incorrect");
16 if (! $course = get_record("course", "id", $cm->course)) {
17 error("Course is misconfigured");
20 if (! $glossary = get_record("glossary", "id", $cm->instance)) {
21 error("Course module is incorrect");
24 if (! $entry = get_record("glossary_entries", "id", $eid)) {
25 error("Entry is incorrect");
28 $context = get_context_instance(CONTEXT_MODULE, $cm->id);
30 require_login($course->id, false, $cm);
32 add_to_log($course->id, "glossary", "view", "view.php?id=$cm->id", "$glossary->id",$cm->id);
34 $strglossaries = get_string("modulenameplural", "glossary");
35 $strglossary = get_string("modulename", "glossary");
36 $strallcategories = get_string("allcategories", "glossary");
37 $straddentry = get_string("addentry", "glossary");
38 $strnoentries = get_string("noentries", "glossary");
39 $strsearchconcept = get_string("searchconcept", "glossary");
40 $strsearchindefinition = get_string("searchindefinition", "glossary");
41 $strsearch = get_string("search");
42 $strcomments = get_string("comments", "glossary");
43 $straddcomment = get_string("addcomment", "glossary");
45 $navigation = build_navigation($strcomments, $cm);
46 print_header_simple(strip_tags("$strcomments: $entry->concept"), "", $navigation,
47 "", "", true, update_module_button($cm->id, $course->id, $strglossary),
48 navmenu($course, $cm));
50 /// original glossary entry
52 echo "<div class=\"boxaligncenter\">";
53 glossary_print_entry($course, $cm, $glossary, $entry, "", "", false);
54 echo "</div>";
56 /// comments
58 print_heading(format_string(get_string('commentson','glossary')." <b>\"$entry->concept\"</b>"));
60 if (has_capability('mod/glossary:comment', $context) and $glossary->allowcomments) {
61 print_heading("<a href=\"comment.php?action=add&amp;eid=$entry->id\">$straddcomment <img title=\"$straddcomment\" src=\"comment.gif\" class=\"iconsmall\" alt=\"$straddcomment\" /></a>");
64 if ($comments = get_records("glossary_comments","entryid",$entry->id,"timemodified ASC")) {
65 foreach ($comments as $comment) {
66 glossary_print_comment($course, $cm, $glossary, $entry, $comment);
67 echo '<br />';
69 } else {
70 print_heading(get_string("nocomments","glossary"));
74 /// Finish the page
76 print_footer($course);