Automatic installer.php lang files by installer_builder (20070726)
[moodle-linuxchix.git] / grade / edit / action.php
blobf6b4eb2ec4628a67b63f8f146f4d55f4fcaf6090
1 <?php // $Id$
3 require_once '../../config.php';
4 require_once $CFG->dirroot.'/grade/lib.php';
6 $courseid = required_param('id', PARAM_INT);
7 $action = required_param('action', PARAM_ALPHA);
8 $eid = required_param('eid', PARAM_ALPHANUM);
10 /// Make sure they can even access this course
11 if (!$course = get_record('course', 'id', $courseid)) {
12 print_error('nocourseid');
14 require_login($course);
15 $context = get_context_instance(CONTEXT_COURSE, $course->id);
17 // default return url
18 $gpr = new grade_plugin_return();
19 $returnurl = $gpr->get_return_url($CFG->wwwroot.'/grade/edit/tree.php?id='.$course->id);
21 // get the grading tree object
22 $gtree = new grade_tree($courseid, false, false);
24 // what are we working with?
25 if (!$element = $gtree->locate_element($eid)) {
26 error('Incorrect element id!', $returnurl);
28 $object = $element['object'];
31 switch ($action) {
32 case 'hide':
33 if ($eid and confirm_sesskey()) {
34 if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:hide', $context)) {
35 error('No permission to hide!', $returnurl);
37 $object->set_hidden(1);
39 break;
41 case 'show':
42 if ($eid and confirm_sesskey()) {
43 if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:hide', $context)) {
44 error('No permission to show!', $returnurl);
46 $object->set_hidden(0);
48 break;
50 case 'lock':
51 if ($eid and confirm_sesskey()) {
52 if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:lock', $context)) {
53 error('No permission to lock!', $returnurl);
55 $object->set_locked(1);
57 break;
59 case 'unlock':
60 if ($eid and confirm_sesskey()) {
61 if (!has_capability('moodle/grade:manage', $context) and !has_capability('moodle/grade:unlock', $context)) {
62 error('No permission to unlock!', $returnurl);
64 $object->set_locked(0);
66 break;
69 redirect($returnurl);
70 //redirect($returnurl, 'debug delay', 5);