Add events to UserProfile::isAccessible, UserProfile::isProtected and UsersOnlineList...
authorFeuerfuchs <vulpes.ignitus+github@gmail.com>
Tue, 3 Jan 2017 23:12:45 +0000 (00:12 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 3 Jan 2017 23:12:45 +0000 (00:12 +0100)
* Add events to UserProfile::isAccessible, UserProfile::isProtected and UsersOnlineList::isVisible

* Editor was messing with tabs

* Implement requested changes

* Fix tabs

* Implement requested changes

* Fix unintentional fall-through

wcfsetup/install/files/lib/data/user/UserProfile.class.php
wcfsetup/install/files/lib/data/user/online/UsersOnlineList.class.php

index bde2bf9acfd2963d2fdda8aa1fa600aae2d51ddc..3781a51e396644713503e12ff8f5b7905f8613e1 100644 (file)
@@ -12,6 +12,7 @@ use wcf\data\DatabaseObjectDecorator;
 use wcf\data\ITitledLinkObject;
 use wcf\system\cache\builder\UserGroupPermissionCacheBuilder;
 use wcf\system\cache\runtime\UserProfileRuntimeCache;
+use wcf\system\event\EventHandler;
 use wcf\system\user\signature\SignatureCache;
 use wcf\system\user\storage\UserStorageHandler;
 use wcf\system\WCF;
@@ -438,23 +439,29 @@ class UserProfile extends DatabaseObjectDecorator implements ITitledLinkObject {
         */
        public function isAccessible($name) {
                /** @noinspection PhpVariableVariableInspection */
+               $data = ['result' => true, 'name' => $name];
+               
                switch ($this->$name) {
                        case self::ACCESS_EVERYONE:
-                               return true;
+                               $data['result'] = true;
                        break;
                        
                        case self::ACCESS_REGISTERED:
-                               return (WCF::getUser()->userID ? true : false);
+                               $data['result'] = (WCF::getUser()->userID ? true : false);
                        break;
                        
                        case self::ACCESS_FOLLOWING:
-                               return ($this->isFollowing(WCF::getUser()->userID) ? true : false);
+                               $data['result'] = ($this->isFollowing(WCF::getUser()->userID) ? true : false);
                        break;
                        
                        case self::ACCESS_NOBODY:
-                               return false;
+                               $data['result'] = false;
                        break;
                }
+               
+               EventHandler::getInstance()->fireAction($this, 'isAccessible', $data);
+               
+               return $data['result'];
        }
        
        /**
index 9e8d9f1c211308672b6113aee22824557db7206c..b442d4d3abf22ea2b2c58121e889e0eb4dea508c 100644 (file)
@@ -4,6 +4,7 @@ use wcf\data\option\OptionAction;
 use wcf\data\session\SessionList;
 use wcf\data\user\group\UserGroup;
 use wcf\data\user\User;
+use wcf\system\event\EventHandler;
 use wcf\system\WCF;
 use wcf\util\StringUtil;
 
@@ -157,19 +158,24 @@ class UsersOnlineList extends SessionList {
         */
        public static function isVisible($userID, $canViewOnlineStatus) {
                if (WCF::getSession()->getPermission('admin.user.canViewInvisible') || $userID == WCF::getUser()->userID) return true;
+
+               $data = ['result' => false, 'userID' => $userID, 'canViewOnlineStatus' => $canViewOnlineStatus];
                
                switch ($canViewOnlineStatus) {
                        case 0: // everyone
-                               return true;
+                               $data['result'] = true;
+                               break;
                        case 1: // registered
-                               if (WCF::getUser()->userID) return true;
+                               if (WCF::getUser()->userID) $data['result'] = true;
                                break;
                        case 2: // following
                                /** @noinspection PhpUndefinedMethodInspection */
-                               if (WCF::getUserProfileHandler()->isFollower($userID)) return true;
+                               if (WCF::getUserProfileHandler()->isFollower($userID)) $data['result'] = true;
                                break;
                }
                
-               return false;
+               EventHandler::getInstance()->fireAction(get_called_class(), 'isVisible', $data);
+               
+               return $data['result'];
        }
 }