This repository has been archived by the owner on Nov 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
view.php
139 lines (114 loc) · 4.7 KB
/
view.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
<?PHP // $Id: view.php,v 1.19.10.8 2011/03/15 21:46:18 diml Exp $
/**
* This page prints a particular instance of scheduler and handles
* top level interactions
*
* @package mod-scheduler
* @category mod
* @author Gustav Delius, Valery Fremaux > 1.8
*
*/
/**
* Requires and includes
*/
require_once('../../config.php');
require_once($CFG->dirroot.'/mod/scheduler/lib.php');
require_once($CFG->dirroot.'/mod/scheduler/locallib.php');
// common parameters
$id = optional_param('id', '', PARAM_INT); // Course Module ID, or
$a = optional_param('a', '', PARAM_INT); // scheduler ID
$action = optional_param('what', 'view', PARAM_CLEAN);
$subaction = optional_param('subaction', '', PARAM_CLEAN);
$page = optional_param('page', 'allappointments', PARAM_CLEAN);
$offset = optional_param('offset', '');
$usehtmleditor = false;
$editorfields = '';
if ($id) {
if (! $cm = get_record('course_modules', 'id', $id)) {
error('Course Module ID was incorrect');
}
if (! $course = get_record('course', 'id', $cm->course)) {
error('Course is misconfigured');
}
if (! $scheduler = get_record('scheduler', 'id', $cm->instance)) {
error('Course module is incorrect');
}
} else {
if (! $scheduler = get_record('scheduler', 'id', $a)) {
error('Course module is incorrect');
}
if (! $course = get_record('course', 'id', $scheduler->course)) {
error('Course is misconfigured');
}
if (! $cm = get_coursemodule_from_instance('scheduler', $scheduler->id, $course->id)) {
error('Course Module ID was incorrect');
}
}
require_login($course->id);
// echo " [$action:$subaction] "; //$$DEBUG$$
add_to_log($course->id, 'scheduler', "$action:$subaction", "view.php?id={$cm->id}", $scheduler->id, $cm->id);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
$groupmode = groupmode($COURSE, $cm);
/// Security trap if module is not visible
if (!has_capability('moodle/course:viewhiddenactivities', $context) && !$cm->visible){
error("The module was set to not visible. You cannot access this URL at the moment.");
}
/// This is a pre-header selector for downloded documents generation
if (has_capability('mod/scheduler:manage', $context) || isteacher($course->id, $USER->id)) {
if (preg_match("/downloadexcel|downloadcsv|downloadods|dodownloadcsv/", $action)){
include_once 'downloads.php';
}
}
/// Print the page header
$strschedulers = get_string('modulenameplural', 'scheduler');
$strscheduler = get_string('modulename', 'scheduler');
$strtime = get_string('time');
$strdate = get_string('date', 'scheduler');
$strstart = get_string('start', 'scheduler');
$strend = get_string('end', 'scheduler');
$strname = get_string('name');
$strseen = get_string('seen', 'scheduler');
$strnote = get_string('comments', 'scheduler');
$strgrade = get_string('note', 'scheduler');
$straction = get_string('action', 'scheduler');
$strduration = get_string('duration', 'scheduler');
$stremail = get_string('email');
// @see forum/view.php for source sample.
$navigation = build_navigation('', $cm);
print_header_simple($scheduler->name, '', $navigation, '', '', true, update_module_button($cm->id, $course->id, $strscheduler), navmenu($course, $cm));
/// integrate module specific stylesheets overrides by theme
echo '<link rel="stylesheet" href="'.$CFG->themewww.'/'.current_theme().'/scheduler.css" type="text/css" />';
/// route to screen
// teacher side
if (has_capability('mod/scheduler:manage', $context)) {
if ($action == 'viewstatistics'){
include_once 'viewstatistics.php';
}
elseif ($action == 'viewstudent'){
include_once "viewstudent.php";
}
elseif ($action == 'downloads'){
include_once "downloads.php";
}
elseif ($action == 'datelist'){
include_once 'datelist.php';
}
else{
include_once 'teacherview.php';
}
}
// student side
elseif (isstudent($course->id) || has_capability('mod/scheduler:appoint', $context)) {
include_once 'studentview.php';
}
// for guests
else {
echo "<br/>";
print_simple_box(get_string('guestscantdoanything', 'scheduler'), 'center', '70%');
}
/// Finish the page
if (empty($nohtmleditorneeded) and $usehtmleditor) {
use_html_editor($editorfields);
}
print_footer($course);
?>