aboutsummaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+studip@gmail.com>2022-11-24 10:29:24 +0000
committerJan-Hendrik Willms <tleilax+studip@gmail.com>2022-11-24 10:29:24 +0000
commit7dddea8ccca601bf2da28960f2e27a223fe60ea6 (patch)
treeb34ee92f9a4e0e4c1f7e4dcf5f15b396f9097d6f /app
parent1231022837beceedef376e4bb8084ff38fbc7d93 (diff)
rework aux lock rules, use sorm model, deprecate old class and let name and description be translatable, fixes #1791
Closes #1791 Merge request studip/studip!1177
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin/courses.php8
-rw-r--r--app/controllers/admin/specification.php106
-rw-r--r--app/controllers/authenticated_controller.php21
-rw-r--r--app/controllers/consultation/consultation_controller.php12
-rw-r--r--app/controllers/course/members.php3
-rw-r--r--app/controllers/course/overview.php26
-rw-r--r--app/views/admin/courses/aux-select.php12
-rw-r--r--app/views/admin/courses/aux_preselect.php21
-rw-r--r--app/views/admin/specification/_field.php28
-rw-r--r--app/views/admin/specification/edit.php129
-rw-r--r--app/views/admin/specification/index.php75
-rw-r--r--app/views/course/members/additional_input.php54
12 files changed, 257 insertions, 238 deletions
diff --git a/app/controllers/admin/courses.php b/app/controllers/admin/courses.php
index e832628..7e78aae 100644
--- a/app/controllers/admin/courses.php
+++ b/app/controllers/admin/courses.php
@@ -372,13 +372,7 @@ class Admin_CoursesController extends AuthenticatedController
]],
LockRule::findAllByType('sem')
));
- $this->aux_lock_rules = array_merge(
- [[
- 'name' => '--' . _("keine Zusatzangaben") . '--',
- 'lock_id' => 'none'
- ]],
- AuxLockRules::getAllLockRules()
- );
+ $this->aux_lock_rules = AuxLockRule::findBySQL('1 ORDER BY name');
//build the sidebar:
diff --git a/app/controllers/admin/specification.php b/app/controllers/admin/specification.php
index 977ec18..819d59b 100644
--- a/app/controllers/admin/specification.php
+++ b/app/controllers/admin/specification.php
@@ -17,6 +17,8 @@
*/
class Admin_SpecificationController extends AuthenticatedController
{
+ protected $_autobind = true;
+
/**
* Common tasks for all actions.
*/
@@ -41,25 +43,39 @@ class Admin_SpecificationController extends AuthenticatedController
*/
public function index_action()
{
- $this->allrules = AuxLockRules::getAllLockRules();
+ $this->rules = AuxLockRule::findBySQL('1 ORDER BY name');
+
+ Sidebar::Get()->addWidget(new ActionsWidget())->addLink(
+ _('Neue Regel anlegen'),
+ $this->editURL(),
+ Icon::create('add')
+ );
}
/**
* Edit or create a rule
- *
- * @param string $edit_id
+ * @property AuxLockRule $rule
*/
- public function edit_action($id = null)
+ public function edit_action(AuxLockRule $rule = null)
{
- //get data
- $user_field = 'user';
- $semdata_field = 'usersemdata';
- $this->semFields = AuxLockRules::getSemFields();
- $this->entries_user = DataField::getDataFields($user_field);
- $this->entries_semdata = DataField::getDataFields($semdata_field);
- $this->rule = is_null($id) ? false : AuxLockRules::getLockRuleByID($id);
-
- if ($GLOBALS['perm']->have_perm('root') && count($this->entries_semdata) == 0) {
+ $rule->name = Request::i18n('name', $rule->name);
+ $rule->description = Request::i18n('description', $rule->description);
+ $rule->attributes = Request::optionArray('fields') ?: $rule->attributes;
+ $rule->sorting = Request::getArray('order') ?: $rule->sorting;
+
+ if ($GLOBALS['perm']->have_perm('root')) {
+ Sidebar::Get()->addWidget(new ActionsWidget())->addLink(
+ _('Datenfelder bearbeiten'),
+ URLHelper::getURL('dispatch.php/admin/datafields'),
+ Icon::create('edit')
+ );
+ }
+
+ $this->semFields = $this->getSemFields();
+ $this->entries_user = DataField::getDataFields('user');
+ $this->entries_semdata = DataField::getDataFields('usersemdata');
+
+ if ($GLOBALS['perm']->have_perm('root') && count($this->entries_semdata) === 0) {
PageLayout::postWarning(sprintf(
_('Sie müssen zuerst im Bereich %sDatenfelder%s in der Kategorie '
. '<em>Datenfelder für Personenzusatzangaben in Veranstaltungen</em> '
@@ -74,51 +90,63 @@ class Admin_SpecificationController extends AuthenticatedController
* Store or edit Rule
* @param string $id
*/
- public function store_action($id = '')
+ public function store_action(AuxLockRule $rule = null)
{
- CSRFProtection::verifyRequest();
+ CSRFProtection::verifyUnsafeRequest();
$errors = [];
- if (!Request::get('rulename')) {
+ if (!trim(Request::get('name'))) {
$errors[] = _('Bitte geben Sie der Regel mindestens einen Namen!');
}
- if (!AuxLockRules::checkLockRule(Request::getArray('fields'))) {
+
+ if (!AuxLockRule::validateFields(Request::optionArray('fields'))) {
$errors[] = _('Bitte wählen Sie mindestens ein Feld aus der Kategorie "Zusatzinformationen" aus!');
}
- if (empty($errors)) {
- if (!$id) {
- //new
- AuxLockRules::createLockRule(Request::get('rulename'), Request::get('description'), Request::getArray('fields'), Request::getArray('order'));
- } else {
- //edit
- AuxLockRules::updateLockRule($id, Request::get('rulename'), Request::get('description'), Request::getArray('fields'), Request::getArray('order'));
- }
- PageLayout::postSuccess(sprintf(
- _('Die Regel "%s" wurde erfolgreich gespeichert!'),
- htmlReady(Request::get('rulename'))
- ));
- } else {
+ if ($errors) {
PageLayout::postError(_('Ihre Eingaben sind ungültig.'), $errors);
- }
+ $this->keepRequest();
+ $this->redirect($this->editURL($rule));
+ } else {
+ $rule->name = Request::i18n('name');
+ $rule->description = Studip\Markup::purifyHtml(Request::i18n('description'));
+ $rule->attributes = Request::optionArray('fields') ?? [];
+ $rule->sorting = Request::getArray('order') ?? [];
- $this->redirect('admin/specification');
+ if ($rule->store()) {
+ PageLayout::postSuccess(sprintf(
+ _('Die Regel "%s" wurde erfolgreich gespeichert!'),
+ htmlReady($rule->name)
+ ));
+ }
+ $this->redirect('admin/specification');
+ }
}
/**
* Delete a rule, using a modal dialog
- *
- * @param string $rule_id
*/
- public function delete_action($rule_id)
+ public function delete_action(AuxLockRule $rule)
{
CSRFProtection::verifyUnsafeRequest();
- if (AuxLockRules::deleteLockRule($rule_id)) {
- PageLayout::postSuccess(_('Die Regel wurde erfolgreich gelöscht!'));
- } else {
+
+ $result = $rule->delete();
+ if ($result === false) {
PageLayout::postError(_('Es können nur nicht verwendete Regeln gelöscht werden!'));
+ } elseif ($result > 0) {
+ PageLayout::postSuccess(_('Die Regel wurde erfolgreich gelöscht!'));
}
- $this->redirect('admin/specification');
+ $this->redirect($this->indexURL());
+ }
+
+ private function getSemFields(): array
+ {
+ return [
+ 'vasemester' => _('Semester'),
+ 'vanr' => _('Veranstaltungsnummer'),
+ 'vatitle' => _('Veranstaltungstitel'),
+ 'vadozent' => _('Dozent'),
+ ];
}
}
diff --git a/app/controllers/authenticated_controller.php b/app/controllers/authenticated_controller.php
index f50d478..e051ffa 100644
--- a/app/controllers/authenticated_controller.php
+++ b/app/controllers/authenticated_controller.php
@@ -1,8 +1,4 @@
<?php
-# Lifter007: TODO
-# Lifter003: TODO
-# Lifter010: TODO
-
/*
* Copyright (C) 2009 - Marcus Lunzenauer <mlunzena@uos.de>
*
@@ -16,4 +12,21 @@ class AuthenticatedController extends StudipController
{
protected $with_session = true; //we do need to have a session for this controller
protected $allow_nobody = false; //nobody is not allowed and always gets a login-screen
+
+ public function before_filter(&$action, &$args)
+ {
+ parent::before_filter($action, $args);
+
+ // Restore request if present
+ if (isset($this->flash['request'])) {
+ foreach ($this->flash['request'] as $key => $value) {
+ Request::set($key, $value);
+ }
+ }
+ }
+
+ protected function keepRequest()
+ {
+ $this->flash['request'] = Request::getInstance()->getIterator()->getArrayCopy();
+ }
}
diff --git a/app/controllers/consultation/consultation_controller.php b/app/controllers/consultation/consultation_controller.php
index eba81ff..dc7fd6e 100644
--- a/app/controllers/consultation/consultation_controller.php
+++ b/app/controllers/consultation/consultation_controller.php
@@ -26,13 +26,6 @@ abstract class ConsultationController extends AuthenticatedController
URLHelper::addLinkParam('cid', $this->range->id);
}
- // Restore request if present
- if (isset($this->flash['request'])) {
- foreach ($this->flash['request'] as $key => $value) {
- Request::set($key, $value);
- }
- }
-
// This defines the function to display a note. Not really a partial,
// not a controller method. This has no real place...
$this->displayNote = function ($what, $length = 40, $position = 'above') {
@@ -72,11 +65,6 @@ abstract class ConsultationController extends AuthenticatedController
return $this->range->getConfiguration()->CONSULTATION_TAB_TITLE;
}
- protected function keepRequest()
- {
- $this->flash['request'] = Request::getInstance()->getIterator()->getArrayCopy();
- }
-
/**
* @param $block_id
*
diff --git a/app/controllers/course/members.php b/app/controllers/course/members.php
index 16c59a3..ad7d6da 100644
--- a/app/controllers/course/members.php
+++ b/app/controllers/course/members.php
@@ -1330,6 +1330,9 @@ class Course_MembersController extends AuthenticatedController
$course = Course::findCurrent();
$member = $course->members->findOneBy('user_id', $GLOBALS['user']->id);
$this->datafields = $member ? $course->aux->getMemberData($member) : [];
+
+ $this->editable = false;
+
// We need aux data in the view
$this->aux = $course->aux;
diff --git a/app/controllers/course/overview.php b/app/controllers/course/overview.php
index 0994d54..96e7f5a 100644
--- a/app/controllers/course/overview.php
+++ b/app/controllers/course/overview.php
@@ -87,24 +87,14 @@ class Course_OverviewController extends AuthenticatedController
$this->show_dozenten = $show_dozenten;
// Check lock rules
- if (!$GLOBALS["perm"]->have_studip_perm('dozent', $this->course_id)) {
- $rule = AuxLockRules::getLockRuleBySemId($this->course_id);
- if (isset($rule)) {
- $show = false;
- foreach ((array) $rule['attributes'] as $val) {
- if ($val == 1) {
- // Es gibt also Zusatzangaben. Nun noch überprüfen ob der Nutzer diese Angaben schon gemacht hat...
- $count = DataField::countBySql("LEFT JOIN datafields_entries USING (datafield_id) WHERE object_type = ? AND sec_range_id = ? AND range_id = ?",
- ['usersemdata', $this->course_id, $GLOBALS['user']->id]
- );
- if (!$count) {
- $show = true;
- }
- break;
- }
- }
-
- if ($show) {
+ if (!$GLOBALS['perm']->have_studip_perm('dozent', $this->course_id)) {
+ $rule = AuxLockRule::findOneByCourse($this->course);
+ if ($rule && count($rule->attributes) > 0) {
+ $count = DataField::countBySql("LEFT JOIN datafields_entries USING (datafield_id) WHERE object_type = ? AND sec_range_id = ? AND range_id = ?",
+ ['usersemdata', $this->course_id, $GLOBALS['user']->id]
+ );
+
+ if ($count === 0) {
PageLayout::postInfo(
_("Sie haben noch nicht die für diese Veranstaltung benötigten Zusatzinformationen eingetragen."),
[
diff --git a/app/views/admin/courses/aux-select.php b/app/views/admin/courses/aux-select.php
index 1786598..950120e 100644
--- a/app/views/admin/courses/aux-select.php
+++ b/app/views/admin/courses/aux-select.php
@@ -1,13 +1,17 @@
<?php
/**
* @var Course $course
- * @var array $aux_lock_rules
+ * @var AuxLockRule[] $aux_lock_rules
+ * @var array $values
*/
?>
<select name="lock_sem[<?= htmlReady($course->id) ?>]" style="max-width: 200px">
-<? foreach ($aux_lock_rules as $id => $rule) : ?>
- <option value="<?= $id ?>" <?= $values['aux_lock_rule'] == $id ? 'selected' : '' ?>>
- <?= htmlReady($rule['name']) ?>
+ <option value="none">
+ --<?= _('keine Zusatzangaben') ?>--
+ </option>
+<? foreach ($aux_lock_rules as $rule) : ?>
+ <option value="<?= htmlReady($rule->id) ?>" <? if ($values['aux_lock_rule'] === $rule->id) echo 'selected'; ?>>
+ <?= htmlReady($rule->name) ?>
</option>
<? endforeach ?>
</select>
diff --git a/app/views/admin/courses/aux_preselect.php b/app/views/admin/courses/aux_preselect.php
index e44e378..73a2036 100644
--- a/app/views/admin/courses/aux_preselect.php
+++ b/app/views/admin/courses/aux_preselect.php
@@ -1,21 +1,24 @@
<?php
/**
* @var array $values
- * @var array $aux_lock_rules
+ * @var AuxLockRule[] $aux_lock_rules
*/
?>
<label><?= _('Für alle Veranstaltungen') ?>
<select name="lock_sem_all" style="max-width: 200px">
- <? foreach ($aux_lock_rules as $id => $rule) : ?>
- <option value="<?= $id ?>"
- <?= ($values['aux_lock_rule'] == $id) ? 'selected' : '' ?>>
- <?= htmlReady($rule["name"]) ?>
- </option>
- <? endforeach ?>
+ <option value="none">
+ --<?= _('keine Zusatzangaben') ?>--
+ </option>
+ <? foreach ($aux_lock_rules as $rule) : ?>
+ <option value="<?= htmlReady($rule->id) ?>"
+ <? if ($values['aux_lock_rule'] === $rule->id) echo 'selected'; ?>>
+ <?= htmlReady($rule->name) ?>
+ </option>
+ <? endforeach ?>
</select>
</label>
<label>
-<input type="checkbox" value="1" name="aux_all_forced">
-<?=_("Erzwungen")?>
+ <input type="checkbox" value="1" name="aux_all_forced">
+ <?=_('Erzwungen')?>
</label>
<?= \Studip\Button::createAccept(_('Speichern'), 'all'); ?>
diff --git a/app/views/admin/specification/_field.php b/app/views/admin/specification/_field.php
index 05ea09f..3d2703b 100644
--- a/app/views/admin/specification/_field.php
+++ b/app/views/admin/specification/_field.php
@@ -2,40 +2,36 @@
/**
* @var string $name
* @var string $id
- * @var array $rule
+ * @var AuxLockRule $rule
*/
-$fields = Request::getArray('fields');
-$order = Request::getArray('order');
?>
<section>
- <? if (!empty($required)) : ?>
+<? if (!empty($required)) : ?>
<span class="required">
<?= htmlReady($name) ?>
</span>
- <? else : ?>
+<? else: ?>
<?= htmlReady($name) ?>
- <? endif ?>
-
+<? endif ?>
<div class="hgroup">
<label class="col-2">
<?= _('Sortierung') ?>
- <input id="order_<?= $id ?>" min="0" type="number" size="3" name="order[<?= $id ?>]"
- value="<?= (int)(($order && isset($order[$id])) ? $order[$id] : @$rule['order'][$id]) ?>">
- <input type="hidden" name="fields[<?= $id ?>]" value="0">
+ <input id="order_<?= htmlReady($id) ?>" min="0" type="number" size="3" name="order[<?= htmlReady($id) ?>]"
+ value="<?= ($rule->sorting[$id] ?? 0) ?>">
</label>
<label class="col-2">
<input type="checkbox"
- name="fields[<?= $id ?>]"
- value="1"
- <?= (($fields && isset($fields[$id])) ? $fields[$id] : @$rule['attributes'][$id]) ? 'checked="checked"' : '' ?>>
+ name="fields[]"
+ value="<?= htmlReady($id) ?>"
+ <? if ($rule->attributes->contains($id)) echo 'checked'; ?>>
<?= _('Aktivieren') ?>
</label>
+ <? if (!empty($institution)) : ?>
<label class="col-1">
- <? if (!empty($institution)) : ?>
- <?= htmlReady($institution->name)?>
- <? endif; ?>
+ <?= htmlReady($institution->name )?>
</label>
+ <? endif; ?>
</div>
</section>
diff --git a/app/views/admin/specification/edit.php b/app/views/admin/specification/edit.php
index 30bee49..452c39b 100644
--- a/app/views/admin/specification/edit.php
+++ b/app/views/admin/specification/edit.php
@@ -3,95 +3,86 @@
/**
* @var Admin_SpecificationController $controller
- * @var AuxLockRules $rule
+ * @var AuxLockRule $rule
* @var array $semFields
* @var DataField[] $entries_semdata
* @var DataField[] $entries_user
*/
use Studip\Button, Studip\LinkButton;
?>
-<? if (isset($flash['error'])) : ?>
- <?= MessageBox::error($flash['error'], $flash['error_detail']) ?>
-<? elseif (isset($flash['info'])): ?>
- <?= MessageBox::info($flash['info']) ?>
-<? endif ?>
-
-<form action="<?= $controller->url_for('admin/specification/store' . ($rule ? '/' . $rule['lock_id'] : '')) ?>"
- method="post" class="default">
+<form action="<?= $controller->store($rule) ?>" method="post" class="default">
<?= CSRFProtection::tokenTag() ?>
<fieldset>
<legend>
- <? if ($rule) : ?>
- <?= sprintf(_('Regel "%s" editieren'), htmlReady($rule['name'])) ?>
- <? else : ?>
- <?= _('Eine neue Regel definieren') ?>
- <? endif ?>
+ <? if ($rule->isNew()) : ?>
+ <?= _('Eine neue Regel definieren') ?>
+ <? else : ?>
+ <?= sprintf(_('Regel "%s" editieren'), htmlReady($rule['name'])) ?>
+ <? endif ?>
</legend>
<label>
<span class="required">
- <?= _('Name der Regel:') ?>
+ <?= _('Name der Regel') ?>
</span>
- <input type="text" name="rulename" value="<?= htmlReady(Request::get('rulename', $rule ? $rule['name'] : '')) ?>"
- required="required">
+ <?= I18N::input('name', $rule->name, [
+ 'required' => '',
+ ]) ?>
</label>
<label>
<?= _('Beschreibung') ?>
- <textarea cols="60" rows="5"
- name="description"><?= htmlReady(Request::get('description', $rule ? $rule['description'] : '')) ?></textarea>
+ <?= I18N::textarea('description', $rule->description, [
+ 'class' => 'wysiwyg',
+ ]) ?>
</label>
</fieldset>
- <? if (count($entries_semdata) > 0) : ?>
- <fieldset>
- <legend>
- <?= _('Zusatzinformationen') ?>
- </legend>
- <? foreach ($entries_semdata as $id => $entry) : ?>
- <?= $this->render_partial('admin/specification/_field', array_merge(
- compact('rule'),
- ['id' => $entry->datafield_id, 'name' => $entry->name],
- ['required' => true, 'institution' => $entry->institution]
- )) ?>
- <? endforeach ?>
- </fieldset>
- <? endif ?>
- <? if (count($semFields) > 0) : ?>
- <fieldset>
- <legend>
- <?= _('Veranstaltungsinformationen') ?>
- </legend>
- <? foreach ($semFields as $id => $name) : ?>
- <?= $this->render_partial('admin/specification/_field', compact('rule', 'id', 'name')) ?>
- <? endforeach ?>
- </fieldset>
- <? endif ?>
+<? if (count($entries_semdata) > 0) : ?>
+ <fieldset>
+ <legend>
+ <?= _('Zusatzinformationen') ?>
+ </legend>
+ <? foreach ($entries_semdata as $id => $entry) : ?>
+ <?= $this->render_partial('admin/specification/_field', [
+ 'rule' => $rule,
+ 'id' => $entry->datafield_id,
+ 'name' => $entry->name,
+ 'required' => true,
+ 'institution' => $entry->institution,
+ ]) ?>
+ <? endforeach ?>
+ </fieldset>
+<? endif ?>
+
+ <fieldset>
+ <legend>
+ <?= _('Veranstaltungsinformationen') ?>
+ </legend>
+ <? foreach ($semFields as $id => $name) : ?>
+ <?= $this->render_partial('admin/specification/_field', compact('rule', 'id', 'name')) ?>
+ <? endforeach ?>
+ </fieldset>
+
+<? if (count($entries_user) > 0) : ?>
+ <fieldset>
+ <legend>
+ <?= _('Personenbezogene Informationen') ?>
+ </legend>
+ <? foreach ($entries_user as $id => $entry) : ?>
+ <?= $this->render_partial('admin/specification/_field', [
+ 'rule' => $rule,
+ 'id' => $entry->datafield_id,
+ 'name' => $entry->name,
+ ]) ?>
+ <? endforeach ?>
+ </fieldset>
+<? endif ?>
- <? if (count($entries_user) > 0) : ?>
- <fieldset>
- <legend>
- <?= _('Personenbezogene Informationen') ?>
- </legend>
- <? foreach ($entries_user as $id => $entry) : ?>
- <?= $this->render_partial('admin/specification/_field',
- array_merge(compact('rule'), ['id' => $entry->datafield_id, 'name' => $entry->name])) ?>
- <? endforeach ?>
- </fieldset>
- <? endif ?>
<footer>
- <? if ($rule) : ?>
- <?= Button::createAccept(_('Übernehmen'), 'uebernehmen', ['title' => _('Änderungen übernehmen')]) ?>
- <? else : ?>
- <?= Button::createAccept(_('Erstellen'), 'erstellen', ['title' => _('Neue Regel erstellen')]) ?>
- <? endif ?>
- <?= LinkButton::createCancel(_('Abbrechen'), $controller->url_for('admin/specification'), ['title' => _('Zurück zur Übersicht')]) ?>
+ <? if ($rule->isNew()) : ?>
+ <?= Button::createAccept(_('Erstellen'), 'erstellen', ['title' => _('Neue Regel erstellen')]) ?>
+ <? else : ?>
+ <?= Button::createAccept(_('Übernehmen'), 'uebernehmen', ['title' => _('Änderungen übernehmen')]) ?>
+ <? endif ?>
+ <?= LinkButton::createCancel(_('Abbrechen'), $controller->indexURL(), ['title' => _('Zurück zur Übersicht')]) ?>
</footer>
</form>
-
-<?
-$sidebar = Sidebar::Get();
-if ($GLOBALS['perm']->have_perm('root')) {
- $actions = new ActionsWidget();
- $actions->addLink(_('Datenfelder bearbeiten'), URLHelper::getLink('dispatch.php/admin/datafields'), Icon::create('add', 'clickable'));
- $sidebar->addWidget($actions);
-}
-?>
diff --git a/app/views/admin/specification/index.php b/app/views/admin/specification/index.php
index b2b42ea..4538b6a 100644
--- a/app/views/admin/specification/index.php
+++ b/app/views/admin/specification/index.php
@@ -1,62 +1,63 @@
<?php
/**
* @var Admin_SpecificationController $controller
- * @var AuxLockRules[] $allrules
+ * @var AuxLockRule[] $rules
*/
?>
<form method="post" class="default">
<?= CSRFProtection::tokenTag() ?>
- <table class="default">
+ <table class="default <? if (count($rules) > 0) echo 'sortable-table'; ?>" data-sortlist="[[0, 0]]">
<caption>
<?= _('Verwaltung von Zusatzangaben') ?>
</caption>
<colgroup>
- <col style="width: 45%">
- <col style="width: 45%">
- <col style="width: 10%">
+ <col style="width: 40%">
+ <col>
+ <col style="width: 10ex">
+ <col style="width: 8ex">
</colgroup>
<thead>
<tr>
- <th><?= _('Name') ?></th>
- <th><?= _('Beschreibung') ?></th>
- <th><?= _('Aktionen') ?></th>
+ <th data-sort="text"><?= _('Name') ?></th>
+ <th data-sort="text"><?= _('Beschreibung') ?></th>
+ <th data-sort="htmldata">
+ <abbr title="<?= _('Anzahl der zugeordneten Veranstaltungen') ?>">#</abbr>
+ </th>
+ <th class="actions" data-sort="false"><?= _('Aktionen') ?></th>
</tr>
</thead>
<tbody>
- <? if (!empty($allrules)): ?>
- <? foreach ($allrules as $index => $rule) : ?>
- <tr>
- <td>
- <?= htmlReady($rule['name']) ?>
- </td>
- <td>
- <?= htmlReady($rule['description']) ?>
- </td>
- <td class="actions">
- <a href="<?=$controller->url_for('admin/specification/edit/'.$rule['lock_id']) ?>" style="vertical-align: bottom">
- <?= Icon::create('edit', 'clickable', ['title' => _('Regel bearbeiten')])->asImg() ?>
- </a>
- <?=Icon::create('trash', 'clickable', tooltip2(_('Regel löschen')))->asInput([
- 'formaction' => $controller->url_for('admin/specification/delete/' . $rule['lock_id']),
- 'data-confirm' => sprintf(_('Wollen Sie die Regel "%s" wirklich löschen?'), $rule['name']),
- 'style' => 'vertical-align: bottom'
- ])?>
- </td>
- </tr>
- <? endforeach ?>
- <? else : ?>
+ <? if (count($rules) === 0): ?>
<tr>
- <td colspan="3" style="text-align: center">
+ <td colspan="4" style="text-align: center">
<?= _('Es wurden noch keine Zusatzangaben definiert.') ?>
</td>
</tr>
<? endif ?>
+ <? foreach ($rules as $index => $rule) : ?>
+ <tr>
+ <td><?= htmlReady($rule->name) ?></td>
+ <td><?= htmlReady(Studip\Markup::removeHtml($rule->description)) ?></td>
+ <td data-sort-value="<?= count($rule->courses) ?>">
+ <?= number_format(count($rule->courses), 0, ',', '.') ?>
+ </td>
+ <td class="actions">
+ <a href="<?= $controller->edit($rule) ?>">
+ <?= Icon::create('edit')->asImg(['title' => _('Regel bearbeiten')]) ?>
+ </a>
+ <? if (count($rule->courses) > 0): ?>
+ <?= Icon::create('trash', Icon::ROLE_INACTIVE)->asImg(
+ tooltip2(_('Die Regel kann nicht gelöscht werden, da sie noch verwendet wird.'))
+ ) ?>
+ <? else: ?>
+ <?= Icon::create('trash')->asInput(tooltip2(_('Regel löschen')) + [
+ 'formaction' => $controller->deleteURL($rule),
+ 'data-confirm' => sprintf(_('Wollen Sie die Regel "%s" wirklich löschen?'), $rule->name),
+ ]) ?>
+ <? endif; ?>
+ </td>
+ </tr>
+ <? endforeach ?>
</tbody>
</table>
</form>
-<?
-
-$sidebar = Sidebar::Get();
-$actions = new ActionsWidget();
-$actions->addLink(_('Neue Regel anlegen'), $controller->url_for('admin/specification/edit'), Icon::create('add', 'clickable'));
-$sidebar->addWidget($actions);
diff --git a/app/views/course/members/additional_input.php b/app/views/course/members/additional_input.php
index 89df041..50fd3b0 100644
--- a/app/views/course/members/additional_input.php
+++ b/app/views/course/members/additional_input.php
@@ -1,30 +1,38 @@
+<?php
+/**
+ * @var DataFieldEntryModel[] $datafields
+ * @var AuxLockRule $aux
+ * @var bool $editable
+ */
+$editable = false;
+?>
<form class="default" method="post">
- <? if ($datafields) : ?>
- <fieldset>
- <legend>
- <?= htmlReady($aux->name) ?>
- </legend>
+<? if ($datafields) : ?>
+ <fieldset>
+ <legend>
+ <?= htmlReady($aux->name) ?>
+ </legend>
- <p><?= formatReady($aux->description) ?></p>
+ <p><?= formatReady($aux->description) ?></p>
- <? foreach ($datafields as $field): ?>
- <? if ($field->getTypedDatafield()->isVisible()): ?>
- <? if ($field->getTypedDatafield()->isEditable()) : ?>
- <? $editable = true; ?>
- <? endif ?>
- <?= $field->getTypedDatafield()->getHTML('aux'); ?>
- <? endif; ?>
- <? endforeach; ?>
- </fieldset>
+ <? foreach ($datafields as $field): ?>
+ <? if ($field->getTypedDatafield()->isVisible()): ?>
+ <? if ($field->getTypedDatafield()->isEditable()) : ?>
+ <? $editable = true; ?>
+ <? endif ?>
+ <?= $field->getTypedDatafield()->getHTML('aux'); ?>
+ <? endif; ?>
+ <? endforeach; ?>
+ </fieldset>
- <? if ($editable): ?>
- <footer>
- <?= \Studip\Button::create(_('Speichern'), 'save') ?>
- </footer>
- <? else: ?>
- <?= MessageBox::info(_('Keine einstellbaren Zusatzdaten vorhanden')) ?>
- <? endif; ?>
- <? else : ?>
+ <? if ($editable): ?>
+ <footer>
+ <?= Studip\Button::create(_('Speichern'), 'save') ?>
+ </footer>
+ <? else: ?>
<?= MessageBox::info(_('Keine einstellbaren Zusatzdaten vorhanden')) ?>
<? endif; ?>
+<? else : ?>
+ <?= MessageBox::info(_('Keine einstellbaren Zusatzdaten vorhanden')) ?>
+<? endif; ?>
</form>