diff options
| author | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2023-03-22 12:43:48 +0000 |
|---|---|---|
| committer | Jan-Hendrik Willms <tleilax+studip@gmail.com> | 2023-03-22 12:43:48 +0000 |
| commit | 953de28bb8cdbb8edbf14c7f0ce81d0f5abbd8a8 (patch) | |
| tree | a01617f3f105d3bafbc2c248b595137af9f61eb2 /app | |
| parent | 7e94d278c685d68fa464f2b7c0f136165e30cc86 (diff) | |
rework admission user list overview, fixes #2393
Closes #2393
Merge request studip/studip!1583
Diffstat (limited to 'app')
| -rw-r--r-- | app/controllers/admission/userlist.php | 36 | ||||
| -rw-r--r-- | app/views/admission/user_list/delete.php | 15 | ||||
| -rw-r--r-- | app/views/admission/user_list/index.php | 48 | ||||
| -rw-r--r-- | app/views/admission/userlist/configure.php (renamed from app/views/admission/user_list/configure.php) | 4 | ||||
| -rw-r--r-- | app/views/admission/userlist/index.php | 62 |
5 files changed, 83 insertions, 82 deletions
diff --git a/app/controllers/admission/userlist.php b/app/controllers/admission/userlist.php index 4c86185..683f1e2 100644 --- a/app/controllers/admission/userlist.php +++ b/app/controllers/admission/userlist.php @@ -15,7 +15,7 @@ * @category Stud.IP */ -class Admission_UserListController extends AuthenticatedController +class Admission_UserlistController extends AuthenticatedController { /** * @see AuthenticatedController::before_filter @@ -28,16 +28,18 @@ class Admission_UserListController extends AuthenticatedController Navigation::activateItem('/browse/coursesets/userlists'); PageLayout::addScript('studip-admission.js'); - $views = new ViewsWidget(); - $views->setTitle(_('Aktionen')); - $views->addLink(_('Personenliste anlegen'),$this->url_for('admission/userlist/configure'))->setActive($action == 'configure'); - Sidebar::Get()->addWidget($views); + Sidebar::get()->addWidget(new ActionsWidget())->addLink( + _('Personenliste anlegen'), + $this->configureURL(), + Icon::create('add') + ); } /** * Show the user lists the current user has access to. */ - public function index_action() { + public function index_action() + { $this->userlists = []; foreach (AdmissionUserList::getUserLists($GLOBALS['user']->id) as $list) { $this->userlists[$list->getId()] = $list; @@ -50,7 +52,8 @@ class Admission_UserListController extends AuthenticatedController * @param String $userlistId user list to load settings from (or empty * if it is a new user list) */ - public function configure_action($userlistId='') { + public function configure_action($userlistId = '') + { if ($userlistId) { $this->userlist = new AdmissionUserList($userlistId); $this->userlist_id = $userlistId; @@ -100,7 +103,8 @@ class Admission_UserListController extends AuthenticatedController * * @param String $userlistId user list to save */ - public function save_action($userlistId='') { + public function save_action($userlistId = '') + { CSRFProtection::verifyUnsafeRequest(); $userlist = new AdmissionUserList($userlistId); $userlist->setName(Request::get('name')) @@ -120,15 +124,13 @@ class Admission_UserListController extends AuthenticatedController * * @param String $userlistId the user list to delete */ - public function delete_action($userlistId) { - $this->userlist = new AdmissionUserList($userlistId); - if (Request::int('really')) { - $this->userlist->delete(); - $this->redirect($this->url_for('admission/userlist')); - } - if (Request::int('cancel')) { - $this->redirect($this->url_for('admission/userlist')); - } + public function delete_action($userlistId) + { + CSRFProtection::verifyUnsafeRequest(); + + $userlist = new AdmissionUserList($userlistId); + $userlist->delete(); + $this->redirect($this->indexURL()); } /** diff --git a/app/views/admission/user_list/delete.php b/app/views/admission/user_list/delete.php deleted file mode 100644 index b921e9e..0000000 --- a/app/views/admission/user_list/delete.php +++ /dev/null @@ -1,15 +0,0 @@ -<?php -/** - * @var AdmissionUserList $userlist - * @var Admission_UserListController $controller - */ -?> -<?= QuestionBox::create( - sprintf( - _('Soll die Nutzerliste %s wirklich gelöscht werden?'), - htmlReady($list->getName()) - ), - $controller->deleteURL($userlist->getId(), ['really' => true]), - $controller->deleteURL($userlist->getId(), ['cancel' => true]) -) -?> diff --git a/app/views/admission/user_list/index.php b/app/views/admission/user_list/index.php deleted file mode 100644 index 645ad19..0000000 --- a/app/views/admission/user_list/index.php +++ /dev/null @@ -1,48 +0,0 @@ -<?php -/** - * @var AdmissionUserList[] $userlists - * @var Admission_UserListController $controller - */ -Helpbar::get()->addPlainText(_('Info'),"Personenlisten erfassen eine Menge von Personen, die ". - "mit modifizierten Chancen in die Platzverteilung bei ". - "Anmeldeverfahren eingehen. Dies können z.B. ". - "Härtefälle sein, die bevorzugt einen Platz in ". - "Veranstaltungen erhalten sollen."); -Helpbar::get()->addPlainText(_('Info'), "Hier sehen Sie alle Personenlisten, auf die Sie Zugriff ". - "haben."); -?> - -<?php -if ($userlists) { -?> -<div id="userlists"> - <?php foreach ($userlists as $list) { ?> - <div id="userlist_<?= $list->getId() ?>"> - <a href="#" onclick="return STUDIP.Admission.toggleDetails('userlist_arrow_<?= $list->getId() ?>', 'userlist_details_<?= $list->getId() ?>')"> - <?= Icon::create('arr_1right', 'clickable')->asImg(20, ["id" => 'userlist_arrow_'.$list->getId(), "align" => 'top', "rel" => Icon::create('arr_1down', 'clickable')->asImagePath(20)]) ?> - <?= htmlReady($list->getName()) ?> - </a> - <a class="userlist-action" - href="<?= URLHelper::getURL('dispatch.php/admission/userlist/configure/'.$list->getId()); ?>"> - <?= Icon::create('edit', 'clickable', ['title' => _('Nutzerliste bearbeiten')])->asImg(20, ["alt" => _('Nutzerliste bearbeiten')]); ?> - </a> - <a class="userlist-action" href="<?= $controller->link_for('admission/userlist/delete', $list->getId(), ['really' => true]) ?>" - data-confirm="<?= htmlReady(sprintf(_('Soll die Nutzerliste %s wirklich gelöscht werden?'), $list->getName())) ?>"> - <?= Icon::create('trash', 'clickable', ['title' => _('Personenliste löschen')])->asImg(20) ?> - </a> - </div> - <div id="userlist_details_<?= $list->getId() ?>" style="display: none; margin-left: 20px;"> - <?= $list->toString() ?> - </div> - <?php } ?> -</div> -<?php -} else { -?> -<?= MessageBox::info(sprintf(_('Es wurden keine Personenlisten gefunden. Sie können eine '. - 'neue %sPersonenliste anlegen%s.'), '<a href="'. - $controller->url_for('admission/userlist/configure').'">', - '</a>')); ?> -<?php -} -?> diff --git a/app/views/admission/user_list/configure.php b/app/views/admission/userlist/configure.php index a35fd51..4e5df25 100644 --- a/app/views/admission/user_list/configure.php +++ b/app/views/admission/userlist/configure.php @@ -19,12 +19,12 @@ Helpbar::get()->addPlainText(_('Info'), "Stellen Sie hier ein, wie die Chancen b "bevorzugt."); ?> <?= $error ?? '' ?> -<form class="default" action="<?= $controller->url_for('admission/userlist/save', $userlist_id) ?>" method="post"> +<form class="default" action="<?= $controller->link_for('admission/userlist/save', $userlist_id) ?>" method="post"> <?= CSRFProtection::tokenTag() ?> <fieldset> <legend> - <?= ($userlist_id) ? _('Personenliste bearbeiten') : _('Personenliste anlegen') ?> + <?= $userlist_id ? _('Personenliste bearbeiten') : _('Personenliste anlegen') ?> </legend> <label> <span class="required"> diff --git a/app/views/admission/userlist/index.php b/app/views/admission/userlist/index.php new file mode 100644 index 0000000..4c87fdf --- /dev/null +++ b/app/views/admission/userlist/index.php @@ -0,0 +1,62 @@ +<?php +/** + * @var AdmissionUserList[] $userlists + * @var Admission_UserListController $controller + */ +Helpbar::get()->addPlainText(_('Info'),"Personenlisten erfassen eine Menge von Personen, die ". + "mit modifizierten Chancen in die Platzverteilung bei ". + "Anmeldeverfahren eingehen. Dies können z.B. ". + "Härtefälle sein, die bevorzugt einen Platz in ". + "Veranstaltungen erhalten sollen."); +Helpbar::get()->addPlainText(_('Info'), "Hier sehen Sie alle Personenlisten, auf die Sie Zugriff ". + "haben."); +?> +<form action="#" method="post"> + <?= CSRFProtection::tokenTag() ?> + + <table class="default"> + <colgroup> + <col> + <col> + <col> + <col style="width: 48px"> + </colgroup> + <thead> + <tr> + <th><?= _('Name') ?></th> + <th><?= _('Beschreibung') ?></th> + <th><?= _('Personen') ?></th> + <th></th> + </tr> + </thead> + <tbody> + <? if (empty($userlists)): ?> + <tr> + <td colspan="4" style="text-align: center;"> + <?= _('Es sind noch keine Personenlisten vorhanden.') ?><br> + <?= Studip\LinkButton::create( + _('Neue Personenliste anlegen'), + $controller->configureURL() + ) ?> + </td> + </tr> + <? endif; ?> + <? foreach ($userlists as $list): ?> + <tr id="userlist_<?= htmlReady($list->getId()) ?>"> + <td><?= htmlReady($list->getName()) ?></td> + <td><?= htmlReady($list->describe()) ?></td> + <td><?= count($list->getUsers()) ?></td> + <td class="actions"> + <a href="<?= $controller->configure($list->getId()) ?>"> + <?= Icon::create('edit')->asImg(tooltip2(_('Nutzerliste bearbeiten'))) ?> + </a> + <?= Icon::create('trash')->asInput(tooltip2(_('Personenliste löschen')) + [ + 'formaction' => $controller->deleteURL($list->getId()), + 'data-confirm' => sprintf(_('Soll die Nutzerliste %s wirklich gelöscht werden?'), $list->getName()), + ]) ?> + </td> + </tr> + <? endforeach; ?> + </tbody> + </table> +</form> |
