MDL-16221
[moodle-linuxchix.git] / mod / glossary / approve.php
blob8f717061e94a03a19f5974dcb69babb2a74b32ba
1 <?php // $Id$
3 require_once("../../config.php");
4 require_once("lib.php");
6 $id = required_param('id', PARAM_INT); // Course Module ID
7 $eid = optional_param('eid', 0, PARAM_INT); // Entry ID
9 $mode = optional_param('mode','approval', PARAM_ALPHA);
10 $hook = optional_param('hook','ALL', PARAM_CLEAN);
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 require_login($course->id, false, $cm);
26 $context = get_context_instance(CONTEXT_MODULE, $cm->id);
27 require_capability('mod/glossary:approve', $context);
29 $newentry->id = $eid;
30 $newentry->approved = 1;
31 $newentry->timemodified = time(); // wee need this date here to speed up recent activity, TODO: use timestamp in approved field instead in 2.0
33 if (! update_record("glossary_entries", $newentry)) {
34 error("Could not update your glossary");
35 } else {
36 add_to_log($course->id, "glossary", "approve entry", "showentry.php?id=$cm->id&amp;eid=$eid", "$eid",$cm->id);
38 redirect("view.php?id=$cm->id&amp;mode=$mode&amp;hook=$hook",get_string("entryapproved","glossary"),1);
39 die;