Patch for postgresql happiness
[moodle.git] / calendar / set.php
blob470bd736396d956ca98e8c8a14690efae3d5f5f6
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@uom.gr) //
13 // Jon Papaioannou (pj@uom.gr) //
14 // //
15 // Programming and development: //
16 // Jon Papaioannou (pj@uom.gr) //
17 // //
18 // For bugs, suggestions, etc contact: //
19 // Jon Papaioannou (pj@uom.gr) //
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 require_variable($_GET['from']);
45 require_variable($_GET['var']);
46 optional_variable($_GET['value']);
47 optional_variable($_GET['id']);
48 optional_variable($_GET['cal_d']);
49 optional_variable($_GET['cal_m']);
50 optional_variable($_GET['cal_y']);
52 switch($_GET['var']) {
53 case 'setuser':
54 // Not implemented yet (or possibly at all)
55 break;
56 case 'setcourse':
57 $id = intval($_GET['id']);
58 if($id == 0) {
59 $SESSION->cal_courses_shown = array();
60 calendar_set_referring_course(0);
62 else if($id == 1) {
63 $SESSION->cal_courses_shown = calendar_get_default_courses(true);
64 calendar_set_referring_course(0);
66 else {
67 // We don't check for membership anymore: if(isstudent($id, $USER->id) || isteacher($id, $USER->id)) {
68 if(get_record('course', 'id', $id) === false) {
69 // There is no such course
70 $SESSION->cal_courses_shown = array();
71 calendar_set_referring_course(0);
73 else {
74 calendar_set_referring_course($id);
75 $SESSION->cal_courses_shown = $id;
78 break;
79 case 'showgroups':
80 $SESSION->cal_show_groups = !$SESSION->cal_show_groups;
81 break;
82 case 'showcourses':
83 $SESSION->cal_show_course = !$SESSION->cal_show_course;
84 break;
85 case 'showglobal':
86 $SESSION->cal_show_global = !$SESSION->cal_show_global;
87 break;
88 case 'showuser':
89 $SESSION->cal_show_user = !$SESSION->cal_show_user;
90 break;
93 switch($_GET['from']) {
94 case 'event':
95 redirect(CALENDAR_URL.'event.php?action='.$_GET['action'].'&type='.$_GET['type'].'&id='.intval($_GET['id']));
96 break;
97 case 'month':
98 redirect(CALENDAR_URL.'view.php?view=month&cal_d='.$_GET['cal_d'].'&cal_m='.$_GET['cal_m'].'&cal_y='.$_GET['cal_y']);
99 break;
100 case 'upcoming':
101 redirect(CALENDAR_URL.'view.php?view=upcoming');
102 break;
103 case 'day':
104 redirect(CALENDAR_URL.'view.php?view=day&cal_d='.$_GET['cal_d'].'&cal_m='.$_GET['cal_m'].'&cal_y='.$_GET['cal_y']);
105 break;
106 case 'course':
107 redirect($CFG->wwwroot.'/course/view.php?id='.intval($_GET['id']));
108 break;
109 default: