* @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] = CourseDate::find(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 = CourseDate::findBySQL( "JOIN `themen_termine` USING (`termin_id`) WHERE `issue_id` = :issue_id ORDER BY `date`", ['issue_id' => 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(); $msg = ''; foreach ($this->dates as $date) { $ex_date = $date->cancelDate(); if ($ex_date) { $ex_date->content = Request::get('cancel_dates_comment'); $ex_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->getFullName(); }, $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); } }