MDL-11082 Improved groups upgrade performance 1.8x -> 1.9; thanks Eloy for telling...
[moodle-pu.git] / mod / glossary / showentry.php
blob9d4338badb8a7400b9e91ce9b80798631975e257
1 <?php // $Id$
2 require_once("../../config.php");
3 require_once("lib.php");
5 $concept = optional_param('concept', '', PARAM_CLEAN);
6 $courseid = optional_param('courseid', 0, PARAM_INT);
7 $eid = optional_param('eid', 0, PARAM_INT); // glossary entry id
8 $displayformat = optional_param('displayformat',-1, PARAM_SAFEDIR);
10 if ($CFG->forcelogin) {
11 require_login();
14 if ($eid) {
15 $entry = get_record("glossary_entries", "id", $eid);
16 $glossary = get_record('glossary','id',$entry->glossaryid);
17 $entry->glossaryname = format_string($glossary->name,true);
18 if (!$cm = get_coursemodule_from_instance("glossary", $glossary->id)) {
19 error("Could not determine which course module this belonged to!");
21 if (!$cm->visible and !has_capability('moodle/course:viewhiddenactivities', get_context_instance(CONTEXT_MODULE, $cm->id))) {
22 redirect($CFG->wwwroot.'/course/view.php?id='.$cm->course, get_string('activityiscurrentlyhidden'));
24 $entry->cmid = $cm->id;
25 $entry->courseid = $cm->course;
26 $entries[] = $entry;
27 } else if ($concept) {
28 $entries = glossary_get_entries_search($concept, $courseid);
29 } else {
30 error('No valid entry specified');
33 if ($entries) {
34 foreach ($entries as $key => $entry) {
35 //$entries[$key]->footer = "<p align=\"right\">&raquo;&nbsp;<a onClick=\"if (window.opener) {window.opener.location.href='$CFG->wwwroot/mod/glossary/view.php?g=$entry->glossaryid'; return false;} else {openpopup('/mod/glossary/view.php?g=$entry->glossaryid', 'glossary', 'menubar=1,location=1,toolbar=1,scrollbars=1,directories=1,status=1,resizable=1', 0); return false;}\" href=\"$CFG->wwwroot/mod/glossary/view.php?g=$entry->glossaryid\" target=\"_blank\">".format_string($entry->glossaryname,true)."</a></p>"; // Could not get this to work satisfactorily in all cases - Martin
36 $entries[$key]->footer = "<p style=\"text-align:right\">&raquo;&nbsp;<a href=\"$CFG->wwwroot/mod/glossary/view.php?g=$entry->glossaryid\">".format_string($entry->glossaryname,true)."</a></p>";
37 add_to_log($entry->courseid, "glossary", "view entry", "showentry.php?eid=$entry->id", $entry->id, $entry->cmid);
41 if (!empty($courseid)) {
42 $course = get_record("course", "id", $courseid);
43 if ($course->id != SITEID) {
44 require_login($courseid);
47 $strglossaries = get_string("modulenameplural", "glossary");
48 $strsearch = get_string("search");
50 $CFG->framename = "newwindow";
51 $navlinks = array();
52 $navlinks[] = array('name' => $strglossaries, 'link' => '', 'type' => 'activity');
53 $navlinks[] = array('name' => $strsearch, 'link' => '', 'type' => 'title');
55 $navigation = build_navigation($navlinks);
57 print_header(strip_tags("$course->shortname: $strglossaries $strsearch"), $course->fullname, $navigation, "", "", true, "&nbsp;", "&nbsp;");
59 } else {
60 print_header(); // Needs to be something here to allow linking back to the whole glossary
63 if ($entries) {
64 glossary_print_dynaentry($courseid, $entries, $displayformat);
67 close_window_button();
69 /// Show one reduced footer
70 print_footer('none');