Select Git revision
additional.php
Forked from
Stud.IP / Stud.IP
Source project has a limited visibility.
-
Elmar Ludwig authored
Closes #3368 Merge request studip/studip!2294
Elmar Ludwig authoredCloses #3368 Merge request studip/studip!2294
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
additional.php 2.41 KiB
<?php
/**
* additonal.php - controller class for the additonal data
*
* Admin of a Seminar can chose his required aux data and decide if it is
* forced from the user
*
* 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 Florian Bieringer <florian.bieringer@uni-passau.de>
* @license http://www.gnu.org/licenses/gpl-2.0.html GPL version 2
* @category Stud.IP
* @package admin
* @since 3.0
*/
class Admin_AdditionalController extends AuthenticatedController
{
public function before_filter(&$action, &$args)
{
parent::before_filter($action, $args);
// Load the course
$this->course = Course::findCurrent();
// Check permissions to be on this site
if (!$GLOBALS['perm']->have_studip_perm("tutor", $this->course->id)) {
throw new AccessDeniedException(_("Sie haben keine Berechtigung diese " .
"Veranstaltung zu verändern."));
}
}
/**
* Index displays and updates
*/
public function index_action()
{
/*
* Updaterequest
*/
if (Request::submitted('save')) {
if ($rule = Request::get('aux_data')) {
$this->course->aux_lock_rule = $rule;
$this->course->aux_lock_rule_forced = Request::get('forced') ? : 0;
} else {
// If no rule is set we cant force it
$this->course->aux_lock_rule = null;
$this->course->aux_lock_rule_forced = 0;
}
// purge data
if (Request::submitted('delete')) {
DatafieldEntryModel::deleteBySQL('sec_range_id = ?', [$this->course->id]);
}
if ($this->course->store()) {
if (!is_null($this->course->aux_lock_rule)) {
PageLayout::postSuccess(_('Zusatzangaben wurden erfolgreich zugeordnet'));
} else {
PageLayout::postSuccess(_('Zuweisung der Zusatzangaben wurden aufgehoben'));
}
}
}
// Fetch data
$this->count = DatafieldEntryModel::countBySql('sec_range_id = ?', [$this->course->id]);
$this->list = AuxLockRule::findBySQL('1=1');
}
}