From 9d554d880692755b5855296b7b8f6f3afee4c2ed Mon Sep 17 00:00:00 2001
From: Moritz Strohm <strohm@data-quest.de>
Date: Mon, 13 Nov 2023 17:09:34 +0000
Subject: [PATCH] admin/user: made matriculation_number sortable, fixes #3455

Closes #3455

Merge request studip/studip!2351
---
 app/views/admin/user/_results.php | 6 +++++-
 lib/models/User.class.php         | 3 +++
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/app/views/admin/user/_results.php b/app/views/admin/user/_results.php
index 8751436164c..729e24ada4d 100644
--- a/app/views/admin/user/_results.php
+++ b/app/views/admin/user/_results.php
@@ -22,7 +22,11 @@
                     </a>
                 </th>
                 <th>&nbsp;</th>
-                <th><?= _('Matrikelnummer') ?></th>
+                <th <?= $sortby === 'matriculation_number' ? 'class="sort' . $order . '"' : '' ?>>
+                    <a href="<?= $controller->link_for('admin/user', ['sortby' => 'matriculation_number', 'order' => $order, 'toggle' => $sortby === 'matriculation_number']) ?>">
+                        <?= _('Matrikelnummer') ?>
+                    </a>
+                </th>
                 <th <?= $sortby === 'perms' ? 'class="sort' . $order . '"' : '' ?>>
                     <a href="<?= $controller->link_for('admin/user',['sortby' =>'perms', 'order'=> $order ,'toggle' => $sortby === 'perms']) ?>">
                         <?= _('Status') ?>
diff --git a/lib/models/User.class.php b/lib/models/User.class.php
index 21f8f873b1b..4f9ccb7b0b8 100644
--- a/lib/models/User.class.php
+++ b/lib/models/User.class.php
@@ -522,6 +522,9 @@ class User extends AuthUserMd5 implements Range, PrivacyObject
                 case "Email":
                     $query .= "ORDER BY au.`Email` {$attributes['order']}, au.`username`";
                     break;
+                case 'matriculation_number':
+                    $query .= "ORDER BY au.`matriculation_number` {$attributes['order']}, au.`username`";
+                    break;
                 case "changed":
                     $query .= "ORDER BY uo.`last_lifesign` {$attributes['order']}, au.`username`";
                     break;
-- 
GitLab