-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcancelsignup.php
101 lines (81 loc) · 3.57 KB
/
cancelsignup.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
<?php
require_once '../../config.php';
require_once 'lib.php';
require_once 'cancelsignup_form.php';
$s = required_param('s', PARAM_INT); // facetoface session ID
$confirm = optional_param('confirm', false, PARAM_BOOL);
$backtoallsessions = optional_param('backtoallsessions', 0, PARAM_INT);
if (!$session = facetoface_get_session($s)) {
print_error('error:incorrectcoursemodulesession', 'facetoface');
}
if (!$facetoface = get_record('facetoface', 'id', $session->facetoface)) {
print_error('error:incorrectfacetofaceid', 'facetoface');
}
if (!$course = get_record('course', 'id', $facetoface->course)) {
print_error('error:coursemisconfigured', 'facetoface');
}
if (!$cm = get_coursemodule_from_instance("facetoface", $facetoface->id, $course->id)) {
print_error('error:incorrectcoursemoduleid', 'facetoface');
}
require_course_login($course);
$context = get_context_instance(CONTEXT_COURSE, $course->id);
require_capability('mod/facetoface:view', $context);
$returnurl = "$CFG->wwwroot/course/view.php?id=$course->id";
if ($backtoallsessions) {
$returnurl = "$CFG->wwwroot/mod/facetoface/view.php?f=$backtoallsessions";
}
$mform = new mod_facetoface_cancelsignup_form(null, compact('s', 'backtoallsessions'));
if ($mform->is_cancelled()){
redirect($returnurl);
}
if ($fromform = $mform->get_data()) { // Form submitted
if (empty($fromform->submitbutton)) {
print_error('error:unknownbuttonclicked', 'facetoface', $returnurl);
}
$timemessage = 4;
$errorstr = '';
if (facetoface_user_cancel($session, false, false, $errorstr, $fromform->cancelreason)) {
add_to_log($course->id, 'facetoface', 'cancel booking', "cancelsignup.php?s=$session->id", $facetoface->id, $cm->id);
$message = get_string('bookingcancelled', 'facetoface');
if ($session->datetimeknown) {
$error = facetoface_send_cancellation_notice($facetoface, $session, $USER->id);
if (empty($error)) {
if ($session->datetimeknown && $facetoface->cancellationinstrmngr) {
$message .= '<br /><br />'.get_string('cancellationsentmgr', 'facetoface');
}
else {
$message .= '<br /><br />'.get_string('cancellationsent', 'facetoface');
}
}
else {
error($error);
}
}
redirect($returnurl, $message, $timemessage);
}
else {
add_to_log($course->id, 'facetoface', "cancel booking (FAILED)", "cancelsignup.php?s=$session->id", $facetoface->id, $cm->id);
redirect($returnurl, $errorstr, $timemessage);
}
redirect($returnurl);
}
$pagetitle = format_string($facetoface->name);
$navlinks[] = array('name' => get_string('modulenameplural', 'facetoface'), 'link' => "index.php?id=$course->id", 'type' => 'title');
$navlinks[] = array('name' => $pagetitle, 'link' => '', 'type' => 'activityinstance');
$navigation = build_navigation($navlinks);
print_header_simple($pagetitle, '', $navigation, '', '', true,
update_module_button($cm->id, $course->id, get_string('modulename', 'facetoface')));
$heading = get_string('cancelbookingfor', 'facetoface', $facetoface->name);
$viewattendees = has_capability('mod/facetoface:viewattendees', $context);
$signedup = facetoface_check_signup($facetoface->id);
print_box_start();
print_heading($heading, 'center');
if ($signedup) {
facetoface_print_session($session, $viewattendees);
$mform->display();
}
else {
print_error('notsignedup', 'facetoface', $returnurl);
}
print_box_end();
print_footer($course);