better sorting in listing of user groups
authorMarcel Werk <burntime@woltlab.com>
Fri, 1 Mar 2019 16:52:14 +0000 (17:52 +0100)
committerMarcel Werk <burntime@woltlab.com>
Fri, 1 Mar 2019 16:52:14 +0000 (17:52 +0100)
Closes #2857

wcfsetup/install/files/acp/templates/userGroupList.tpl
wcfsetup/install/files/lib/acp/page/UserGroupListPage.class.php
wcfsetup/install/files/lib/data/user/group/I18nUserGroupList.class.php [new file with mode: 0644]

index 91215f8fd10c654ac300b3052fca5a44881c157e..809dd14764918f030c8469efb4e4fef356d16d5d 100644 (file)
@@ -37,7 +37,7 @@
                <thead>
                        <tr>
                                <th class="columnID columnGroupID{if $sortField == 'groupID'} active {@$sortOrder}{/if}" colspan="2"><a href="{link controller='UserGroupList'}pageNo={@$pageNo}&sortField=groupID&sortOrder={if $sortField == 'groupID' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.global.objectID{/lang}</a></th>
-                               <th class="columnTitle columnGroupName{if $sortField == 'groupName'} active {@$sortOrder}{/if}"><a href="{link controller='UserGroupList'}pageNo={@$pageNo}&sortField=groupName&sortOrder={if $sortField == 'groupName' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.global.name{/lang}</a></th>
+                               <th class="columnTitle columnGroupName{if $sortField == 'groupNameI18n'} active {@$sortOrder}{/if}"><a href="{link controller='UserGroupList'}pageNo={@$pageNo}&sortField=groupNameI18n&sortOrder={if $sortField == 'groupNameI18n' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.global.name{/lang}</a></th>
                                <th class="columnDigits columnMembers{if $sortField == 'members'} active {@$sortOrder}{/if}"><a href="{link controller='UserGroupList'}pageNo={@$pageNo}&sortField=members&sortOrder={if $sortField == 'members' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.group.members{/lang}</a></th>
                                <th class="columnDigits columnPriority{if $sortField == 'priority'} active {@$sortOrder}{/if}"><a href="{link controller='UserGroupList'}pageNo={@$pageNo}&sortField=priority&sortOrder={if $sortField == 'priority' && $sortOrder == 'ASC'}DESC{else}ASC{/if}{/link}">{lang}wcf.acp.group.priority{/lang}</a></th>
                                
index d041745115bd963e7d1c35f5948b495070fe5aff..09b1aee6405ff0cc6929f8d434f5b3d025bfe9d7 100755 (executable)
@@ -1,6 +1,6 @@
 <?php
 namespace wcf\acp\page;
-use wcf\data\user\group\UserGroupList;
+use wcf\data\user\group\I18nUserGroupList;
 use wcf\page\SortablePage;
 use wcf\system\WCF;
 
@@ -12,7 +12,7 @@ use wcf\system\WCF;
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  * @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 (file)
index 0000000..06c559c
--- /dev/null
@@ -0,0 +1,29 @@
+<?php
+namespace wcf\data\user\group;
+use wcf\data\I18nDatabaseObjectList;
+
+/**
+ * I18n implementation of user group list.
+ *
+ * @author     Alexander Ebert
+ * @copyright  2001-2019 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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;
+}