blob: 8da0d09818f87cddc7d2514dd7cf8c5827097a70 (
plain)
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
|
<?php
/**
* cancel_dates.php
*
* 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.
*
* @author André Noack <noack@data-quest.de>
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Stud.IP
* @package admin
*/
class Course_CancelDatesController extends AuthenticatedController
{
/**
* common tasks for all actions
*/
public function before_filter(&$action, &$args)
{
global $perm;
parent::before_filter($action, $args);
if (Request::get('termin_id')) {
$this->dates[0] = new SingleDate(Request::option('termin_id'));
$this->course_id = $this->dates[0]->range_id;
}
if (Request::get('issue_id')) {
$this->issue_id = Request::option('issue_id');
$this->dates = array_values(array_map(function ($data) {
$d = new SingleDate();
$d->fillValuesFromArray($data);
return $d;
}, IssueDB::getDatesforIssue(Request::option('issue_id'))));
$this->course_id = $this->dates[0]->range_id;
}
if (!get_object_type($this->course_id, ['sem']) || !$perm->have_studip_perm("tutor", $this->course_id)) {
throw new Trails\Exception(400);
}
PageLayout::setHelpKeyword('Basis.VeranstaltungenVerwaltenAendernVonZeitenUndTerminen');
PageLayout::setTitle(Course::findCurrent()->getFullName() . " - " . _('Veranstaltungstermine absagen'));
}
public function index_action()
{
}
public function store_action()
{
CSRFProtection::verifyUnsafeRequest();
$sem = Seminar::getInstance($this->course_id);
$msg = '';
foreach ($this->dates as $date) {
$sem->cancelSingleDate($date->getTerminId(), $date->getMetadateId());
$date->setComment(Request::get('cancel_dates_comment'));
$date->setExTermin(true);
$date->store();
}
if (Request::int('cancel_dates_snd_message') && count($this->dates) > 0) {
$snd_messages = raumzeit_send_cancel_message(Request::get('cancel_dates_comment'), $this->dates);
if ($snd_messages > 0) {
$msg = _('Alle Teilnehmenden wurden benachrichtigt.');
}
}
PageLayout::postSuccess(_('Folgende Termine wurden abgesagt') . ($msg ? ' (' . $msg . '):' : ':'), array_map(function ($d) {
return $d->toString();
}, $this->dates));
$this->redirect($this->url_for('course/dates'));
}
public function after_filter($action, $args)
{
if (Request::isXhr()) {
foreach ($this->response->headers as $k => $v) {
if ($k === 'Location') {
$this->response->headers['X-Location'] = $v;
unset($this->response->headers['Location']);
$this->response->set_status(200);
$this->response->body = '';
}
}
}
parent::after_filter($action, $args);
}
}
|