From 855cda20b67c6f157aa986796e3d0ed2ff073de2 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Fri, 1 Mar 2019 17:52:14 +0100 Subject: [PATCH] better sorting in listing of user groups Closes #2857 --- .../files/acp/templates/userGroupList.tpl | 2 +- .../lib/acp/page/UserGroupListPage.class.php | 13 +++++---- .../user/group/I18nUserGroupList.class.php | 29 +++++++++++++++++++ 3 files changed, 37 insertions(+), 7 deletions(-) create mode 100644 wcfsetup/install/files/lib/data/user/group/I18nUserGroupList.class.php diff --git a/wcfsetup/install/files/acp/templates/userGroupList.tpl b/wcfsetup/install/files/acp/templates/userGroupList.tpl index 91215f8fd1..809dd14764 100644 --- a/wcfsetup/install/files/acp/templates/userGroupList.tpl +++ b/wcfsetup/install/files/acp/templates/userGroupList.tpl @@ -37,7 +37,7 @@ {lang}wcf.global.objectID{/lang} - {lang}wcf.global.name{/lang} + {lang}wcf.global.name{/lang} {lang}wcf.acp.group.members{/lang} {lang}wcf.acp.group.priority{/lang} diff --git a/wcfsetup/install/files/lib/acp/page/UserGroupListPage.class.php b/wcfsetup/install/files/lib/acp/page/UserGroupListPage.class.php index d041745115..09b1aee640 100755 --- a/wcfsetup/install/files/lib/acp/page/UserGroupListPage.class.php +++ b/wcfsetup/install/files/lib/acp/page/UserGroupListPage.class.php @@ -1,6 +1,6 @@ * @package WoltLabSuite\Core\Acp\Page * - * @property UserGroupList $objectList + * @property I18nUserGroupList $objectList */ class UserGroupListPage extends SortablePage { /** @@ -28,17 +28,17 @@ class UserGroupListPage extends SortablePage { /** * @inheritDoc */ - public $defaultSortField = 'groupName'; + public $defaultSortField = 'groupNameI18n'; /** * @inheritDoc */ - public $validSortFields = ['groupID', 'groupName', 'groupType', 'members', 'priority']; + public $validSortFields = ['groupID', 'groupNameI18n', 'groupType', 'members', 'priority']; /** * @inheritDoc */ - public $objectListClassName = UserGroupList::class; + public $objectListClassName = I18nUserGroupList::class; /** * indicates if a group has just been deleted @@ -64,6 +64,7 @@ class UserGroupListPage extends SortablePage { protected function initObjectList() { parent::initObjectList(); + if (!empty($this->objectList->sqlSelects)) $this->objectList->sqlSelects .= ','; $this->objectList->sqlSelects .= "(SELECT COUNT(*) FROM wcf".WCF_N."_user_to_group WHERE groupID = user_group.groupID) AS members"; } @@ -71,7 +72,7 @@ class UserGroupListPage extends SortablePage { * @inheritDoc */ protected function readObjects() { - $this->sqlOrderBy = ($this->sortField != 'members' ? 'user_group.' : '').$this->sortField." ".$this->sortOrder; + $this->sqlOrderBy = (($this->sortField != 'members' && $this->sortField != 'groupNameI18n') ? 'user_group.' : '').$this->sortField." ".$this->sortOrder; parent::readObjects(); } diff --git a/wcfsetup/install/files/lib/data/user/group/I18nUserGroupList.class.php b/wcfsetup/install/files/lib/data/user/group/I18nUserGroupList.class.php new file mode 100644 index 0000000000..06c559cebc --- /dev/null +++ b/wcfsetup/install/files/lib/data/user/group/I18nUserGroupList.class.php @@ -0,0 +1,29 @@ + + * @package WoltLabSuite\Core\Data\User\Group + * @since 5.2 + * + * @method UserGroup current() + * @method UserGroup[] getObjects() + * @method UserGroup|null search($objectID) + * @property UserGroup[] $objects + */ +class I18nUserGroupList extends I18nDatabaseObjectList { + /** + * @inheritDoc + */ + public $i18nFields = ['groupName' => 'groupNameI18n']; + + /** + * @inheritDoc + */ + public $className = UserGroup::class; +} -- 2.20.1