Correct sort trophy's by username (#5729)
authorOlaf Braun <olaf_schmitz_1@t-online.de>
Thu, 14 Dec 2023 12:59:11 +0000 (13:59 +0100)
committerGitHub <noreply@github.com>
Thu, 14 Dec 2023 12:59:11 +0000 (13:59 +0100)
* Correct sort trophy's by username

* Change sort parameter to only username

wcfsetup/install/files/acp/templates/userTrophyList.tpl
wcfsetup/install/files/lib/acp/page/UserTrophyListPage.class.php

index 50b1c2e5ffcfeebb22150947d04c3c2d14a22172..316a57944a46190fc270e7f485cc210f670fa788 100644 (file)
@@ -79,7 +79,7 @@
                        <thead>
                        <tr>
                                <th class="columnID columnUserTrophyID{if $sortField == 'userTrophyID'} active {@$sortOrder}{/if}" colspan="2"><a href="{link controller='UserTrophyList'}pageNo={@$pageNo}&sortField=userTrophyID&sortOrder={if $sortField == 'userTrophyID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$linkParameters}{/link}">{lang}wcf.global.objectID{/lang}</a></th>
-                               <th class="columnText columnUsername{if $sortField == 'userID'} active {@$sortOrder}{/if}"><a href="{link controller='UserTrophyList'}pageNo={@$pageNo}&sortField=userID&sortOrder={if $sortField == 'userID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$linkParameters}{/link}">{lang}wcf.user.username{/lang}</a></th>
+                               <th class="columnText columnUsername{if $sortField == 'username'} active {@$sortOrder}{/if}"><a href="{link controller='UserTrophyList'}pageNo={@$pageNo}&sortField=username&sortOrder={if $sortField == 'username' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$linkParameters}{/link}">{lang}wcf.user.username{/lang}</a></th>
                                <th class="columnTitle columnTrophy{if $sortField == 'trophyID'} active {@$sortOrder}{/if}"><a href="{link controller='UserTrophyList'}pageNo={@$pageNo}&sortField=trophyID&sortOrder={if $sortField == 'trophyID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$linkParameters}{/link}">{lang}wcf.acp.trophy{/lang}</a></th>
                                <th class="columnDate columnUserTrophyTime{if $sortField == 'time'} active {@$sortOrder}{/if}"><a href="{link controller='UserTrophyList'}pageNo={@$pageNo}&sortField=time&sortOrder={if $sortField == 'time' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{@$linkParameters}{/link}">{lang}wcf.global.date{/lang}</a></th>
 
index 2d4702e20b903f986488de497b4ffb31228a9477..c0b88c50e590bcf9d69509805003b846ba57163c 100644 (file)
@@ -52,7 +52,7 @@ class UserTrophyListPage extends SortablePage
     /**
      * @inheritDoc
      */
-    public $validSortFields = ['userTrophyID', 'trophyID', 'userID', 'time'];
+    public $validSortFields = ['userTrophyID', 'trophyID', 'username', 'time'];
 
     /**
      * The filter value for the username search.
@@ -99,6 +99,7 @@ class UserTrophyListPage extends SortablePage
     {
         parent::initObjectList();
 
+        $this->objectList->sqlJoins .= ' LEFT JOIN wcf' . WCF_N . '_user users ON (users.userID = user_trophy.userID)';
         if ($this->trophyID) {
             $this->objectList->getConditionBuilder()->add('user_trophy.trophyID = ?', [$this->trophyID]);
         }
@@ -115,6 +116,15 @@ class UserTrophyListPage extends SortablePage
         }
     }
 
+    #[\Override]
+    protected function readObjects()
+    {
+        if ($this->sortField == 'username') {
+            $this->sqlOrderBy = 'users.username ' . $this->sortOrder . ', user_trophy.trophyID ' . $this->sortOrder;
+        }
+        parent::readObjects();
+    }
+
     /**
      * @inheritdoc
      */