From bbb0d83322ccd88cdb9f9501f06b9518dbafa7a2 Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms Date: Tue, 14 Oct 2025 16:43:26 +0200 Subject: sort admin user table via js and not via php, fixes #5945 Closes #5945 Merge request studip/studip!4543 --- app/controllers/admin/user.php | 11 +- app/views/admin/user/_results.php | 371 ++++++++++++++++++-------------------- 2 files changed, 177 insertions(+), 205 deletions(-) diff --git a/app/controllers/admin/user.php b/app/controllers/admin/user.php index f461f8b..2a29ea7 100644 --- a/app/controllers/admin/user.php +++ b/app/controllers/admin/user.php @@ -116,16 +116,7 @@ class Admin_UserController extends AuthenticatedController //wenn suche durchgeführt if (!empty($request)) { //Suchparameter - $this->sortby = Request::option('sortby', 'username'); - $this->order = Request::option('order', 'asc'); - if (Request::int('toggle')) { - $this->order = $this->order == 'desc' ? 'asc' : 'desc'; - } - - $request['sortby'] = $this->sortby; - $request['order'] = $this->order; - - $empty_search = $request['perm'] === 'alle'; + $empty_search = $request['perm'] === 'alle'; $values = [ 'username', diff --git a/app/views/admin/user/_results.php b/app/views/admin/user/_results.php index 6fe0ad0..3ea545b 100644 --- a/app/views/admin/user/_results.php +++ b/app/views/admin/user/_results.php @@ -1,7 +1,7 @@ link_for('admin/user/bulk') ?>" method="post" data-dialog="size=auto" class="default"> - +
- - + - - - - - - - - + - - - - - - - - - - - - - - - + + + + + + + + + + + + - - + if (Privacy::isVisible($user->id)) { + $actionMenu->addLink( + $controller->url_for("privacy/landing/{$user->id}"), + _('Anzeige Personendaten'), + Icon::create('log'), + ['data-dialog' => 'size=medium'] + ); + $actionMenu->addLink( + $controller->url_for("privacy/print/{$user->id}"), + _('Personendaten drucken'), + Icon::create('print'), + ['class' => 'print_action', 'target' => '_blank'] + ); + $actionMenu->addLink( + $controller->url_for("privacy/export/{$user->id}"), + _('Export Personendaten als CSV'), + Icon::create('file-text') + ); + $actionMenu->addLink( + $controller->url_for("privacy/xml/{$user->id}"), + _('Export Personendaten als XML'), + Icon::create('file-text') + ); + $actionMenu->addLink( + $controller->url_for("privacy/filesexport/{$user->id}"), + _('Export persönlicher Dateien als ZIP'), + Icon::create('file-archive') + ); + } + echo $actionMenu; + ?> + + + -- cgit v1.0
> - - - +
+  > - - - + + > - - - + + > - - - + + > - - - + + > - - - + + > - - - + + > - - - + + > - - - + +
- - id}") ?>" - title=""> - id)->getImageTag(Avatar::SMALL) ?> - - - id}") ?>" - title=""> - username) ?> - - locked) : ?> - asSvg(tooltip2(sprintf(_('%s ist gesperrt'), htmlReady($user->getFullName())))) ?> - - - user_id); - $tooltxt = _('Sichtbarkeit:') . ' ' . $user->visible; - if (!empty($userdomains)) { - $domains = []; - array_walk($userdomains, function ($a) use (&$domains) { - if (!in_array($a->name, $domains)) { - $domains[] = $a->name; - } - }); - $tooltxt .= "\n" . _('Domänen:') . ' ' . implode(', ', $domains); - } - if ($user->locked == '1') { - $tooltxt .= "\n" . _("Nutzer ist gesperrt!"); - } - ?> - - matriculation_number) ?>Vorname) ?>nachname) ?>email) ?> - online->last_lifesign)) : - $inactive = time() - $user->online->last_lifesign; - if ($inactive < 3600 * 24) { - $inactive = gmdate('H:i:s', $inactive); - } else { - $inactive = floor($inactive / (3600 * 24)) . ' ' . _('Tage'); - } - else : - $inactive = _('nie benutzt'); - endif ?> - - - mkdate ? strftime('%x', $user->mkdate) : _('unbekannt') ?> - auth_plugin) ?> + +
+ + id}") ?>" + title=""> + id)->getImageTag(Avatar::SMALL) ?> + + + id}") ?>" + title=""> + username) ?> + + locked) : ?> + asSvg(tooltip2(sprintf(_('%s ist gesperrt'), htmlReady($user->getFullName())))) ?> + + setContext($user); + $userdomains = UserDomain::getUserDomainsForUser($user->user_id); + $tooltxt = _('Sichtbarkeit:') . ' ' . $user->visible; + if (!empty($userdomains)) { + $domains = []; + array_walk($userdomains, function ($a) use (&$domains) { + if (!in_array($a->name, $domains)) { + $domains[] = $a->name; + } + }); + $tooltxt .= "\n" . _('Domänen:') . ' ' . implode(', ', $domains); + } + if ($user->locked == '1') { + $tooltxt .= "\n" . _("Nutzer ist gesperrt!"); + } + ?> + + matriculation_number) ?>perms) ?>vorname) ?>nachname) ?>email) ?> + online->last_lifesign)) : + $inactive = time() - $user->online->last_lifesign; + if ($inactive < 3600 * 24) { + $inactive = gmdate('H:i:s', $inactive); + } else { + $inactive = floor($inactive / (3600 * 24)) . ' ' . _('Tage'); + } + else : + $inactive = _('nie benutzt'); + endif ?> + + + mkdate ? strftime('%x', $user->mkdate) : _('unbekannt') ?> + auth_plugin) ?> + setContext($user); + $actionMenu->addLink( + $controller->url_for("admin/user/edit/{$user->id}"), + _('Nutzer bearbeiten'), + Icon::create('edit') + ); + + $actionMenu->addLink( + $controller->url_for('profile',['username' => $user->username]), + _('Zum Profil'), + Icon::create('person') + ); + if ($GLOBALS['perm']->have_perm('root')) { $actionMenu->addLink( - $controller->url_for("admin/user/edit/{$user->id}"), - _('Nutzer bearbeiten'), - Icon::create('edit') + $controller->url_for('admin/user/activities/' . $user->user_id, ['from_index' => 1]), + _('Datei- und Aktivitätsübersicht'), + Icon::create('vcard'), + ['data-dialog' => 'size=auto'] ); - $actionMenu->addLink( - $controller->url_for('profile',['username' => $user->username]), - _('Zum Profil'), - Icon::create('person') + $controller->show_user_coursesURL($user, ['from_index' => 1]), + _('Veranstaltungsübersicht'), + Icon::create('seminar'), + ['data-dialog' => 'size=auto'] ); - if ($GLOBALS['perm']->have_perm('root')) { - $actionMenu->addLink( - $controller->url_for('admin/user/activities/' . $user->user_id, ['from_index' => 1]), - _('Datei- und Aktivitätsübersicht'), - Icon::create('vcard'), - ['data-dialog' => 'size=auto'] - ); + if (Config::get()->LOG_ENABLE) { $actionMenu->addLink( - $controller->show_user_coursesURL($user, ['from_index' => 1]), - _('Veranstaltungsübersicht'), - Icon::create('seminar'), - ['data-dialog' => 'size=auto'] + $controller->url_for('event_log/show', ['search' => $user->username, 'type' => 'user', 'object_id' => $user->id]), + _('Personeneinträge im Log'), + Icon::create('log') ); - if (Config::get()->LOG_ENABLE) { - $actionMenu->addLink( - $controller->url_for('event_log/show', ['search' => $user->username, 'type' => 'user', 'object_id' => $user->id]), - _('Personeneinträge im Log'), - Icon::create('log') - ); - } } + } + $actionMenu->addLink( + $controller->url_for('messages/write', ['rec_uname' => $user->username]), + _('Nachricht an Nutzer verschicken'), + Icon::create('mail'), + ['data-dialog' => 'size=auto'] + ); + + if ($user->locked) { + $actionMenu->addButton( + 'unlock', + _('Nutzeraccount entsperren'), + Icon::create('lock-unlocked'), + [ + 'formaction' => $controller->url_for("admin/user/unlock/{$user->id}", ['from_index' => 1]) + ] + ); + } else { $actionMenu->addLink( - $controller->url_for('messages/write', ['rec_uname' => $user->username]), - _('Nachricht an Nutzer verschicken'), - Icon::create('mail'), + $controller->url_for("admin/user/lock_comment/{$user->id}", ['from_index' => 1]), + _('Nutzeraccount sperren'), + Icon::create('lock-locked'), ['data-dialog' => 'size=auto'] ); + } - if ($user->locked) { + if ($user->auth_plugin !== 'preliminary' && ($GLOBALS['perm']->have_perm('root') || $GLOBALS['perm']->is_fak_admin() || !in_array($user->perms, words('root admin')))) { + if (!StudipAuthAbstract::CheckField('auth_user_md5.password', $user->auth_plugin)) { $actionMenu->addButton( - 'unlock', - _('Nutzeraccount entsperren'), - Icon::create('lock-unlocked'), + 'change_password', + _('Passwortlink zusenden'), + Icon::create('key'), [ - 'formaction' => $controller->url_for("admin/user/unlock/{$user->id}", ['from_index' => 1]) + 'formaction' => $controller->url_for("admin/user/change_password/{$user->id}", ['from_index' => 1]) ] ); - } else { - $actionMenu->addLink( - $controller->url_for("admin/user/lock_comment/{$user->id}", ['from_index' => 1]), - _('Nutzeraccount sperren'), - Icon::create('lock-locked'), - ['data-dialog' => 'size=auto'] - ); } - if ($user->auth_plugin !== 'preliminary' && ($GLOBALS['perm']->have_perm('root') || $GLOBALS['perm']->is_fak_admin() || !in_array($user->perms, words('root admin')))) { - if (!StudipAuthAbstract::CheckField('auth_user_md5.password', $user->auth_plugin)) { - $actionMenu->addButton( - 'change_password', - _('Passwortlink zusenden'), - Icon::create('key'), - [ - 'formaction' => $controller->url_for("admin/user/change_password/{$user->id}", ['from_index' => 1]) - ] - ); - } - - $actionMenu->addButton( - 'delete_user', - _('Nutzer löschen'), - Icon::create('trash'), - ['formaction' => $controller->url_for("admin/user/bulk/{$user->id}", ['method' => 'delete'])] - ); + $actionMenu->addButton( + 'delete_user', + _('Nutzer löschen'), + Icon::create('trash'), + ['formaction' => $controller->url_for("admin/user/bulk/{$user->id}", ['method' => 'delete'])] + ); - } + } - if (Privacy::isVisible($user->id)) { - $actionMenu->addLink( - $controller->url_for("privacy/landing/{$user->id}"), - _('Anzeige Personendaten'), - Icon::create('log'), - ['data-dialog' => 'size=medium'] - ); - $actionMenu->addLink( - $controller->url_for("privacy/print/{$user->id}"), - _('Personendaten drucken'), - Icon::create('print'), - ['class' => 'print_action', 'target' => '_blank'] - ); - $actionMenu->addLink( - $controller->url_for("privacy/export/{$user->id}"), - _('Export Personendaten als CSV'), - Icon::create('file-text') - ); - $actionMenu->addLink( - $controller->url_for("privacy/xml/{$user->id}"), - _('Export Personendaten als XML'), - Icon::create('file-text') - ); - $actionMenu->addLink( - $controller->url_for("privacy/filesexport/{$user->id}"), - _('Export persönlicher Dateien als ZIP'), - Icon::create('file-archive') - ); - } - - echo $actionMenu; - ?> -