Apply the sort order for the list of users in the birthday list
authorAlexander Ebert <ebert@woltlab.com>
Tue, 22 Sep 2020 13:26:09 +0000 (15:26 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 22 Sep 2020 13:26:09 +0000 (15:26 +0200)
com.woltlab.wcf/templates/boxTodaysBirthdays.tpl
wcfsetup/install/files/lib/data/user/UserBirthdayAction.class.php
wcfsetup/install/files/lib/system/box/TodaysBirthdaysBoxController.class.php

index 2e9b2a4cc472b2ec45e67a5802b4b8e8ad53a553..93a37da6f6d49255c725f5f735a601f257375e3f 100644 (file)
                        var $todaysBirthdays = null;
                        $('.jsTodaysBirthdays').click(function() {
                                if ($todaysBirthdays === null) {
-                                       $todaysBirthdays = new WCF.User.List('wcf\\data\\user\\UserBirthdayAction', '{@$box->getTitle()|encodeJS} ({@TIME_NOW|date})', { date: '{@TIME_NOW|date:'Y-m-d'}' });
+                                       $todaysBirthdays = new WCF.User.List('wcf\\data\\user\\UserBirthdayAction', '{@$box->getTitle()|encodeJS} ({@TIME_NOW|date})', {
+                                               date: '{@TIME_NOW|date:'Y-m-d'}',
+                                               sortField: '{$sortField}',
+                                               sortOrder: '{$sortOrder}'
+                                       });
                                }
                                $todaysBirthdays.open();
                        });
index 0a14ca3e52c0df4c047a78a4aa18d89c13351968..4b51a744f41741ba696c58b6c7b58d1e3cf1ba04 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 namespace wcf\data\user;
+use wcf\data\DatabaseObject;
 use wcf\data\user\option\UserOption;
 use wcf\data\IGroupedUserListAction;
 use wcf\system\cache\builder\UserOptionCacheBuilder;
@@ -27,10 +28,22 @@ class UserBirthdayAction extends UserProfileAction implements IGroupedUserListAc
         */
        public function validateGetGroupedUserList() {
                $this->readString('date');
+               $this->readString('sortField', true);
+               $this->readString('sortOrder', true);
                
                if (!preg_match('/\d{4}-\d{2}-\d{2}/', $this->parameters['date'])) {
                        throw new UserInputException();
                }
+               
+               if ($this->parameters['sortField'] && $this->parameters['sortOrder']) {
+                       if (!in_array($this->parameters['sortField'], ['username', 'activityPoints', 'registrationDate'])) {
+                               throw new UserInputException('sortField');
+                       }
+                       
+                       if (!in_array($this->parameters['sortOrder'], ['ASC', 'DESC'])) {
+                               throw new UserInputException('sortOrder');
+                       }
+               }
        }
        
        /**
@@ -62,6 +75,10 @@ class UserBirthdayAction extends UserProfileAction implements IGroupedUserListAc
                        }
                }
                
+               if ($this->parameters['sortField'] && $this->parameters['sortOrder']) {
+                       DatabaseObject::sort($users, $this->parameters['sortField'], $this->parameters['sortOrder']);
+               }
+               
                WCF::getTPL()->assign([
                        'users' => $users,
                        'year' => $year
index e9f94e0c0f6d61d2122322615cdbfed800a7980a..aee80c2aeffb55668af434ef4972386421673682 100644 (file)
@@ -124,7 +124,9 @@ class TodaysBirthdaysBoxController extends AbstractDatabaseObjectListBoxControll
                                        DatabaseObject::sort($visibleUserProfiles, $this->sortField, $this->sortOrder);
                                        
                                        $this->content = WCF::getTPL()->fetch($this->templateName, 'wcf', [
-                                               'birthdayUserProfiles' => $visibleUserProfiles
+                                               'birthdayUserProfiles' => $visibleUserProfiles,
+                                               'sortField' => $this->sortField,
+                                               'sortOrder' => $this->sortOrder,
                                        ], true);
                                }
                        }