Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/glossary/showentry.php
Go to the documentation of this file.
00001 <?php
00002 
00003 require_once('../../config.php');
00004 require_once('lib.php');
00005 
00006 $concept  = optional_param('concept', '', PARAM_CLEAN);
00007 $courseid = optional_param('courseid', 0, PARAM_INT);
00008 $eid      = optional_param('eid', 0, PARAM_INT); // glossary entry id
00009 $displayformat = optional_param('displayformat',-1, PARAM_SAFEDIR);
00010 
00011 $url = new moodle_url('/mod/glossary/showentry.php');
00012 $url->param('concept', $concept);
00013 $url->param('courseid', $courseid);
00014 $url->param('eid', $eid);
00015 $url->param('displayformat', $displayformat);
00016 $PAGE->set_url($url);
00017 
00018 if ($CFG->forcelogin) {
00019     require_login();
00020 }
00021 
00022 if ($eid) {
00023     $entry = $DB->get_record('glossary_entries', array('id'=>$eid), '*', MUST_EXIST);
00024     $glossary = $DB->get_record('glossary', array('id'=>$entry->glossaryid), '*', MUST_EXIST);
00025     $cm = get_coursemodule_from_instance('glossary', $glossary->id, 0, false, MUST_EXIST);
00026     $course = $DB->get_record('course', array('id'=>$cm->course), '*', MUST_EXIST);
00027     require_course_login($course, true, $cm);
00028     $entry->glossaryname = $glossary->name;
00029     $entry->cmid = $cm->id;
00030     $entry->courseid = $cm->course;
00031     $entries = array($entry);
00032 
00033 } else if ($concept) {
00034     $course = $DB->get_record('course', array('id'=>$courseid), '*', MUST_EXIST);
00035     require_course_login($course);
00036     $entries = glossary_get_entries_search($concept, $courseid);
00037 
00038 } else {
00039     print_error('invalidelementid');
00040 }
00041 
00042 $PAGE->set_pagelayout('course');
00043 
00044 if ($entries) {
00045     foreach ($entries as $key => $entry) {
00046         // Need to get the course where the entry is,
00047         // in order to check for visibility/approve permissions there
00048         $entrycourse = $DB->get_record('course', array('id' => $entry->courseid), '*', MUST_EXIST);
00049         $modinfo = get_fast_modinfo($entrycourse);
00050         // make sure the entry is visible
00051         if (empty($modinfo->cms[$entry->cmid]->uservisible)) {
00052             unset($entries[$key]);
00053             continue;
00054         }
00055         // make sure the entry is approved (or approvable by current user)
00056         if (!$entry->approved and ($USER->id != $entry->userid)) {
00057             $context = get_context_instance(CONTEXT_MODULE, $entry->cmid);
00058             if (!has_capability('mod/glossary:approve', $context)) {
00059                 unset($entries[$key]);
00060                 continue;
00061             }
00062         }
00063         $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>";
00064         add_to_log($entry->courseid, 'glossary', 'view entry', "showentry.php?eid=$entry->id", $entry->id, $entry->cmid);
00065     }
00066 }
00067 
00068 if (!empty($courseid)) {
00069     $strglossaries = get_string('modulenameplural', 'glossary');
00070     $strsearch = get_string('search');
00071 
00072     $PAGE->navbar->add($strglossaries);
00073     $PAGE->navbar->add($strsearch);
00074     $PAGE->set_title(strip_tags("$course->shortname: $strglossaries $strsearch"));
00075     $PAGE->set_heading($course->fullname);
00076     echo $OUTPUT->header();
00077 } else {
00078     echo $OUTPUT->header();    // Needs to be something here to allow linking back to the whole glossary
00079 }
00080 
00081 if ($entries) {
00082     glossary_print_dynaentry($courseid, $entries, $displayformat);
00083 }
00084 
00086 echo $OUTPUT->footer();
 All Data Structures Namespaces Files Functions Variables Enumerations