Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/glossary/approve.php
Go to the documentation of this file.
00001 <?php
00002 
00003 require_once("../../config.php");
00004 require_once("lib.php");
00005 
00006 $eid = required_param('eid', PARAM_INT);    // Entry ID
00007 
00008 $mode = optional_param('mode', 'approval', PARAM_ALPHA);
00009 $hook = optional_param('hook', 'ALL', PARAM_CLEAN);
00010 
00011 $url = new moodle_url('/mod/glossary/approve.php', array('eid'=>$eid,'mode'=>$mode, 'hook'=>$hook));
00012 $PAGE->set_url($url);
00013 
00014 $entry = $DB->get_record('glossary_entries', array('id'=> $eid), '*', MUST_EXIST);
00015 $glossary = $DB->get_record('glossary', array('id'=> $entry->glossaryid), '*', MUST_EXIST);
00016 $cm = get_coursemodule_from_instance('glossary', $glossary->id, 0, false, MUST_EXIST);
00017 $course = $DB->get_record('course', array('id'=> $cm->course), '*', MUST_EXIST);
00018 
00019 require_login($course, false, $cm);
00020 
00021 $context = get_context_instance(CONTEXT_MODULE, $cm->id);
00022 require_capability('mod/glossary:approve', $context);
00023 
00024 if (!$entry->approved and confirm_sesskey()) {
00025     $newentry = new stdClass();
00026     $newentry->id           = $entry->id;
00027     $newentry->approved     = 1;
00028     $newentry->timemodified = time(); // wee need this date here to speed up recent activity, TODO: use timestamp in approved field instead in 2.0
00029     $DB->update_record("glossary_entries", $newentry);
00030 
00031     // Update completion state
00032     $completion = new completion_info($course);
00033     if ($completion->is_enabled($cm) == COMPLETION_TRACKING_AUTOMATIC && $glossary->completionentries) {
00034         $completion->update_state($cm, COMPLETION_COMPLETE, $entry->userid);
00035     }
00036 
00037     add_to_log($course->id, "glossary", "approve entry", "showentry.php?id=$cm->id&amp;eid=$eid", "$eid", $cm->id);
00038 }
00039 
00040 redirect("view.php?id=$cm->id&amp;mode=$mode&amp;hook=$hook");
 All Data Structures Namespaces Files Functions Variables Enumerations