2009-09-24 07:29:14 +00:00
|
|
|
<?php
|
2003-09-29 17:45:42 +00:00
|
|
|
|
2009-11-22 10:35:20 +00:00
|
|
|
require_once('../../config.php');
|
|
|
|
require_once('lib.php');
|
2003-09-29 17:45:42 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
$concept = optional_param('concept', '', PARAM_CLEAN);
|
|
|
|
$courseid = optional_param('courseid', 0, PARAM_INT);
|
|
|
|
$eid = optional_param('eid', 0, PARAM_INT); // glossary entry id
|
|
|
|
$displayformat = optional_param('displayformat',-1, PARAM_SAFEDIR);
|
|
|
|
|
|
|
|
$url = new moodle_url($CFG->wwwroot.'/mod/glossary/showentry.php');
|
2009-11-22 10:35:20 +00:00
|
|
|
$url->param('concept', $concept);
|
|
|
|
$url->param('courseid', $courseid);
|
|
|
|
$url->param('eid', $eid);
|
|
|
|
$url->param('displayformat', $displayformat);
|
2009-09-24 07:29:14 +00:00
|
|
|
$PAGE->set_url($url);
|
2004-05-15 17:27:50 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
if ($CFG->forcelogin) {
|
|
|
|
require_login();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($eid) {
|
2009-11-22 10:35:20 +00:00
|
|
|
$entry = $DB->get_record('glossary_entries', array('id'=>$eid), '*', MUST_EXIST);
|
|
|
|
$glossary = $DB->get_record('glossary', 'id', array($entry->glossaryid), '*', MUST_EXIST);
|
|
|
|
$cm = get_coursemodule_from_instance('glossary', $glossary->id, 0, false, MUST_EXIST);
|
|
|
|
$course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
|
|
|
|
require_course_login($course, true, $cm);
|
|
|
|
$entry->glossaryname = $glossary->name;
|
2009-09-24 07:29:14 +00:00
|
|
|
$entry->cmid = $cm->id;
|
|
|
|
$entry->courseid = $cm->course;
|
2009-11-22 10:35:20 +00:00
|
|
|
$entries = array($entry);
|
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
} else if ($concept) {
|
2009-11-22 10:35:20 +00:00
|
|
|
$course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);
|
|
|
|
require_course_login($course);
|
2009-09-24 07:29:14 +00:00
|
|
|
$entries = glossary_get_entries_search($concept, $courseid);
|
2009-11-22 10:35:20 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
} else {
|
2009-11-22 10:35:20 +00:00
|
|
|
error('No valid entry specified');
|
2009-09-24 07:29:14 +00:00
|
|
|
}
|
2004-07-27 17:19:47 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
if ($entries) {
|
|
|
|
foreach ($entries as $key => $entry) {
|
2009-12-05 17:46:58 +00:00
|
|
|
// Need to get the course where the entry is,
|
|
|
|
// in order to check for visibility/approve permissions there
|
|
|
|
$entrycourse = $DB->get_record('course', array('id', $entry->courseid), '*', MUST_EXIST);
|
|
|
|
$modinfo = get_fast_modinfo($entrycourse);
|
2009-11-22 10:35:20 +00:00
|
|
|
// make sure the entry is visible
|
|
|
|
if (empty($modinfo->cms[$entry->cmid]->uservisible)) {
|
|
|
|
unset($entries[$key]);
|
|
|
|
continue;
|
|
|
|
}
|
2009-12-05 17:46:58 +00:00
|
|
|
// make sure the entry is approved (or approvable by current user)
|
2009-11-22 10:35:20 +00:00
|
|
|
if (!$entry->approved and ($USER->id != $entry->userid)) {
|
|
|
|
$context = get_context_instance(CONTEXT_MODULE, $entry->cmid);
|
|
|
|
if (!has_capability('mod/glossary:approve', $context)) {
|
|
|
|
unset($entries[$key]);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2009-09-24 07:29:14 +00:00
|
|
|
$entries[$key]->footer = "<p style=\"text-align:right\">» <a href=\"$CFG->wwwroot/mod/glossary/view.php?g=$entry->glossaryid\">".format_string($entry->glossaryname,true)."</a></p>";
|
2009-11-22 10:35:20 +00:00
|
|
|
add_to_log($entry->courseid, 'glossary', 'view entry', "showentry.php?eid=$entry->id", $entry->id, $entry->cmid);
|
2004-07-27 17:19:47 +00:00
|
|
|
}
|
2009-09-24 07:29:14 +00:00
|
|
|
}
|
2004-07-27 17:19:47 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
if (!empty($courseid)) {
|
2009-11-22 10:35:20 +00:00
|
|
|
$strglossaries = get_string('modulenameplural', 'glossary');
|
|
|
|
$strsearch = get_string('search');
|
2004-01-17 10:18:12 +00:00
|
|
|
|
2009-11-22 10:35:20 +00:00
|
|
|
$CFG->framename = 'newwindow';
|
2004-05-02 02:25:04 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
$PAGE->navbar->add($strglossaries);
|
|
|
|
$PAGE->navbar->add($strsearch);
|
|
|
|
$PAGE->set_title(strip_tags("$course->shortname: $strglossaries $strsearch"));
|
|
|
|
$PAGE->set_heading($course->fullname);
|
|
|
|
echo $OUTPUT->header();
|
|
|
|
} else {
|
|
|
|
echo $OUTPUT->header(); // Needs to be something here to allow linking back to the whole glossary
|
|
|
|
}
|
2004-01-16 11:39:40 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
if ($entries) {
|
|
|
|
glossary_print_dynaentry($courseid, $entries, $displayformat);
|
|
|
|
}
|
2005-02-16 10:40:48 +00:00
|
|
|
|
2009-09-24 07:29:14 +00:00
|
|
|
echo $OUTPUT->close_window_button();
|
2003-09-29 17:45:42 +00:00
|
|
|
|
2006-07-16 09:01:03 +00:00
|
|
|
/// Show one reduced footer
|
2009-09-24 07:29:14 +00:00
|
|
|
echo $OUTPUT->footer();
|
2006-07-16 09:01:03 +00:00
|
|
|
|