-
Notifications
You must be signed in to change notification settings - Fork 16
/
slots_delete.php
executable file
·95 lines (82 loc) · 3.57 KB
/
slots_delete.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
<?php
// This file is part of mod_organizer for Moodle - http://moodle.org/
//
// It 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 3 of the License, or
// (at your option) any later version.
//
// It 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.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* view_action.php
*
* @package mod_organizer
* @author Andreas Hruska (andreas.hruska@tuwien.ac.at)
* @author Katarzyna Potocka (katarzyna.potocka@tuwien.ac.at)
* @author Thomas Niedermaier (thomas.niedermaier@meduniwien.ac.at)
* @author Andreas Windbichler
* @author Ivan Šakić
* @copyright 2014 Academic Moodle Cooperation {@link http://www.academic-moodle-cooperation.org}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once(dirname(dirname(dirname(__FILE__))) . '/config.php');
require_once(dirname(__FILE__) . '/locallib.php');
require_once(dirname(__FILE__) . '/view_action_form_delete.php');
require_once(dirname(__FILE__) . '/view_lib.php');
require_once(dirname(__FILE__) . '/messaging.php');
$mode = optional_param('mode', null, PARAM_INT);
$action = optional_param('action', null, PARAM_ALPHANUMEXT);
$slot = optional_param('slot', null, PARAM_INT);
$slots = organizer_get_param_slots();
list($cm, $course, $organizer, $context, $redirecturl) = organizer_slotpages_header();
require_login($course, false, $cm);
$logurl = 'view_action.php?id=' . $cm->id . '&mode=' . $mode . '&action=' . $action;
require_capability('mod/organizer:deleteslots', $context);
$infoboxmessage = "";
if (!$slots) {
$infoboxmessage .= $OUTPUT->notification(get_string('message_warning_no_slots_selected', 'organizer'),
'error');
redirect($redirecturl);
}
$mform = new organizer_delete_slots_form(null, array('id' => $cm->id, 'mode' => $mode, 'slots' => $slots));
if ($data = $mform->get_data()) {
$a = new stdClass();
if (isset($slots)) {
$notified = 0;
foreach ($slots as $slotid) {
if ($organizer->isgrouporganizer == ORGANIZER_GROUPMODE_NEWGROUPSLOT ||
$organizer->isgrouporganizer == ORGANIZER_GROUPMODE_NEWGROUPBOOKING) {
organizer_delete_coursegroup(null, $slotid);
}
$notified += organizer_delete_appointment_slot($slotid);
}
$a->notified = $notified;
$a->deleted = count($slots);
$event = \mod_organizer\event\slot_deleted::create(array('objectid' => $PAGE->cm->id,
'context' => $PAGE->context));
$event->trigger();
if ($a->deleted == 1) {
$infoboxmessage .= $OUTPUT->notification(get_string('message_info_slots_deleted_sg', 'organizer', $a),
'success');
} else {
$infoboxmessage .= $OUTPUT->notification(get_string('message_info_slots_deleted_pl', 'organizer', $a),
'success');
}
}
if ($infoboxmessage) {
$_SESSION["infoboxmessage"] = $infoboxmessage;
}
redirect($redirecturl);
} else if ($mform->is_cancelled()) {
redirect($redirecturl);
} else {
organizer_display_form($mform, get_string('title_delete', 'organizer'));
}
print_error('If you see this, something went wrong with delete action!');
die;