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