Skip to content

Commit 8a26772

Browse files
authored
Correct sort trophy's by username (#5729)
* Correct sort trophy's by username * Change sort parameter to only username
1 parent c20aada commit 8a26772

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

wcfsetup/install/files/acp/templates/userTrophyList.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@
7979
<thead>
8080
<tr>
8181
<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>
82-
<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>
82+
<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>
8383
<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>
8484
<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>
8585

wcfsetup/install/files/lib/acp/page/UserTrophyListPage.class.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class UserTrophyListPage extends SortablePage
5252
/**
5353
* @inheritDoc
5454
*/
55-
public $validSortFields = ['userTrophyID', 'trophyID', 'userID', 'time'];
55+
public $validSortFields = ['userTrophyID', 'trophyID', 'username', 'time'];
5656

5757
/**
5858
* The filter value for the username search.
@@ -99,6 +99,7 @@ protected function initObjectList()
9999
{
100100
parent::initObjectList();
101101

102+
$this->objectList->sqlJoins .= ' LEFT JOIN wcf' . WCF_N . '_user users ON (users.userID = user_trophy.userID)';
102103
if ($this->trophyID) {
103104
$this->objectList->getConditionBuilder()->add('user_trophy.trophyID = ?', [$this->trophyID]);
104105
}
@@ -115,6 +116,15 @@ protected function initObjectList()
115116
}
116117
}
117118

119+
#[\Override]
120+
protected function readObjects()
121+
{
122+
if ($this->sortField == 'username') {
123+
$this->sqlOrderBy = 'users.username ' . $this->sortOrder . ', user_trophy.trophyID ' . $this->sortOrder;
124+
}
125+
parent::readObjects();
126+
}
127+
118128
/**
119129
* @inheritdoc
120130
*/

0 commit comments

Comments
 (0)