blog (development code)
[moodle.git] / blog / set_session_vars.php
1 <?php
2 /// inspired/taken from moodle calendar module's set.php file
4     require_once('../config.php');
5     require_once('lib.php');
7     require_variable($_GET['referrer']);
8     require_variable($_GET['var']);
9     optional_variable($_GET['value']);
10     optional_variable($_GET['userid']);
11     optional_variable($_GET['courseid']);
12     optional_variable($_GET['categoryid']);
13     optional_variable($_GET['d']);
14     optional_variable($_GET['m']);
15     optional_variable($_GET['y']);
17     switch($_GET['var']) {
18         case 'setcourse':
19             $id = intval($_GET['id']);
20             if($id == 0) {
21                 $SESSION->cal_courses_shown = array();
22                 calendar_set_referring_course(0);
23             }
24             else if($id == 1) {
25                 $SESSION->cal_courses_shown = calendar_get_default_courses(true);
26                 calendar_set_referring_course(0);
27             }
28             else {
29                 // We don't check for membership anymore: if(isstudent($id, $USER->id) || isteacher($id, $USER->id)) {
30                 if(get_record('course', 'id', $id) === false) {
31                     // There is no such course
32                     $SESSION->cal_courses_shown = array();
33                     calendar_set_referring_course(0);
34                 }
35                 else {
36                     calendar_set_referring_course($id);
37                     $SESSION->cal_courses_shown = $id;
38                 }
39             }
40         break;
41         case 'setcategory':
42         break;
43         case 'setblog':
44         break;
45         case 'showediting':
46             $SESSION->blog_editing_enabled = !$SESSION->blog_editing_enabled;
47         break;
48     }
49     redirect($referrer);
50 ?>