Merge branch 'MDL-62181-33-enfix' of git://github.com/mudrd8mz/moodle into MOODLE_33_...
[moodle.git] / calendar / set.php
blobc69de934a1a03997981ea5b8a567edf85261181c
1 <?php
2 // This file is part of Moodle - http://moodle.org/
3 //
4 // Moodle is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // Moodle is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
14 // You should have received a copy of the GNU General Public License
15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
17 /**
18 * Sets the events filter for the calendar view.
20 * @package core_calendar
21 * @copyright 2003 Jon Papaioannou (pj@moodle.org)
22 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 require_once('../config.php');
25 require_once($CFG->dirroot.'/calendar/lib.php');
27 $var = required_param('var', PARAM_ALPHA);
28 $return = clean_param(base64_decode(required_param('return', PARAM_RAW)), PARAM_LOCALURL);
29 $courseid = optional_param('id', -1, PARAM_INT);
30 if ($courseid != -1) {
31 $return = new moodle_url($return, array('course' => $courseid));
32 } else {
33 $return = new moodle_url($return);
36 if (!confirm_sesskey()) {
37 // Do not call require_sesskey() since this page may be accessed without session (for example by bots).
38 redirect($return);
41 $url = new moodle_url('/calendar/set.php', array('return'=>base64_encode($return->out_as_local_url(false)), 'course' => $courseid, 'var'=>$var, 'sesskey'=>sesskey()));
42 $PAGE->set_url($url);
43 $PAGE->set_context(context_system::instance());
45 switch($var) {
46 case 'showgroups':
47 calendar_set_event_type_display(CALENDAR_EVENT_GROUP);
48 break;
49 case 'showcourses':
50 calendar_set_event_type_display(CALENDAR_EVENT_COURSE);
51 break;
52 case 'showglobal':
53 calendar_set_event_type_display(CALENDAR_EVENT_GLOBAL);
54 break;
55 case 'showuser':
56 calendar_set_event_type_display(CALENDAR_EVENT_USER);
57 break;
60 redirect($return);