MDL-10689:
[moodle-linuxchix.git] / calendar / set.php
blob0893605a1f33688066aef15e70d8f0bbbf9a54ca
1 <?php // $Id$
3 /////////////////////////////////////////////////////////////////////////////
4 // //
5 // NOTICE OF COPYRIGHT //
6 // //
7 // Moodle - Calendar extension //
8 // //
9 // Copyright (C) 2003-2004 Greek School Network www.sch.gr //
10 // //
11 // Designed by: //
12 // Avgoustos Tsinakos (tsinakos@teikav.edu.gr) //
13 // Jon Papaioannou (pj@moodle.org) //
14 // //
15 // Programming and development: //
16 // Jon Papaioannou (pj@moodle.org) //
17 // //
18 // For bugs, suggestions, etc contact: //
19 // Jon Papaioannou (pj@moodle.org) //
20 // //
21 // The current module was developed at the University of Macedonia //
22 // (www.uom.gr) under the funding of the Greek School Network (www.sch.gr) //
23 // The aim of this project is to provide additional and improved //
24 // functionality to the Asynchronous Distance Education service that the //
25 // Greek School Network deploys. //
26 // //
27 // This program is free software; you can redistribute it and/or modify //
28 // it under the terms of the GNU General Public License as published by //
29 // the Free Software Foundation; either version 2 of the License, or //
30 // (at your option) any later version. //
31 // //
32 // This program is distributed in the hope that it will be useful, //
33 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
34 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
35 // GNU General Public License for more details: //
36 // //
37 // http://www.gnu.org/copyleft/gpl.html //
38 // //
39 /////////////////////////////////////////////////////////////////////////////
41 require_once('../config.php');
42 require_once($CFG->dirroot.'/calendar/lib.php');
44 $from = required_param('from');
45 $var = required_param('var');
46 $value = optional_param('value');
47 $id = optional_param('id');
48 $cal_d = optional_param('cal_d');
49 $cal_m = optional_param('cal_m');
50 $cal_y = optional_param('cal_y');
51 $action = optional_param('action');
52 $type = optional_param('type');
54 // Initialize the session variables
55 calendar_session_vars();
57 // Ensure course id passed if relevant
58 // Required due to changes in view/lib.php mainly (calendar_session_vars())
59 $courseid = '';
60 if (!empty($id)) {
61 $courseid = '&amp;course='.$id;
64 switch($var) {
65 case 'setuser':
66 // Not implemented yet (or possibly at all)
67 break;
68 case 'setcourse':
69 $id = intval($id);
70 if($id == 0) {
71 $SESSION->cal_courses_shown = array();
72 calendar_set_referring_course(0);
74 else if($id == 1) {
75 $SESSION->cal_courses_shown = calendar_get_default_courses(true);
76 calendar_set_referring_course(0);
78 else {
79 if(get_record('course', 'id', $id) === false) {
80 // There is no such course
81 $SESSION->cal_courses_shown = array();
82 calendar_set_referring_course(0);
84 else {
85 calendar_set_referring_course($id);
86 $SESSION->cal_courses_shown = $id;
89 break;
90 case 'showgroups':
91 $SESSION->cal_show_groups = !$SESSION->cal_show_groups;
92 set_user_preference('calendar_savedflt', calendar_get_filters_status());
93 break;
94 case 'showcourses':
95 $SESSION->cal_show_course = !$SESSION->cal_show_course;
96 set_user_preference('calendar_savedflt', calendar_get_filters_status());
97 break;
98 case 'showglobal':
99 $SESSION->cal_show_global = !$SESSION->cal_show_global;
100 set_user_preference('calendar_savedflt', calendar_get_filters_status());
101 break;
102 case 'showuser':
103 $SESSION->cal_show_user = !$SESSION->cal_show_user;
104 set_user_preference('calendar_savedflt', calendar_get_filters_status());
105 break;
108 switch($from) {
109 case 'event':
110 redirect(CALENDAR_URL.'event.php?action='.$action.'&amp;type='.$type.'&amp;id='.intval($id));
111 break;
112 case 'month':
113 redirect(CALENDAR_URL.'view.php?view=month'.$courseid.'&cal_d='.$cal_d.'&cal_m='.$cal_m.'&cal_y='.$cal_y);
114 break;
115 case 'upcoming':
116 redirect(CALENDAR_URL.'view.php?view=upcoming'.$courseid);
117 break;
118 case 'day':
119 redirect(CALENDAR_URL.'view.php?view=day'.$courseid.'&cal_d='.$cal_d.'&cal_m='.$cal_m.'&cal_y='.$cal_y);
120 break;
121 case 'course':
122 redirect($CFG->wwwroot.'/course/view.php?id='.intval($id));
123 break;
124 default: