From: Feuerfuchs Date: Tue, 3 Jan 2017 23:12:45 +0000 (+0100) Subject: Add events to UserProfile::isAccessible, UserProfile::isProtected and UsersOnlineList... X-Git-Tag: 3.0.0~64 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=55bf83d40d98ce1388a8ee5f8ae51ab63c832e52;p=GitHub%2FWoltLab%2FWCF.git Add events to UserProfile::isAccessible, UserProfile::isProtected and UsersOnlineList::isVisible (#2153) * 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 --- diff --git a/wcfsetup/install/files/lib/data/user/UserProfile.class.php b/wcfsetup/install/files/lib/data/user/UserProfile.class.php index bde2bf9acf..3781a51e39 100644 --- a/wcfsetup/install/files/lib/data/user/UserProfile.class.php +++ b/wcfsetup/install/files/lib/data/user/UserProfile.class.php @@ -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']; } /** diff --git a/wcfsetup/install/files/lib/data/user/online/UsersOnlineList.class.php b/wcfsetup/install/files/lib/data/user/online/UsersOnlineList.class.php index 9e8d9f1c21..b442d4d3ab 100644 --- a/wcfsetup/install/files/lib/data/user/online/UsersOnlineList.class.php +++ b/wcfsetup/install/files/lib/data/user/online/UsersOnlineList.class.php @@ -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']; } }