From: Alexander Ebert Date: Mon, 9 Jul 2018 10:14:16 +0000 (+0200) Subject: Box controller for the latest profile comments X-Git-Tag: 5.2.0_Alpha_1~364^2~135 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e4fc3fe47fc6dd6d4fc93f25c2eabb5deff7c1fd;p=GitHub%2FWoltLab%2FWCF.git Box controller for the latest profile comments See #2588 --- diff --git a/com.woltlab.wcf/objectType.xml b/com.woltlab.wcf/objectType.xml index 30445adad8..1e9f0f394c 100644 --- a/com.woltlab.wcf/objectType.xml +++ b/com.woltlab.wcf/objectType.xml @@ -1393,6 +1393,11 @@ com.woltlab.wcf.boxController wcf\system\box\UserTrophyListBoxController + + com.woltlab.wcf.profileCommentList + com.woltlab.wcf.boxController + wcf\system\box\ProfileCommentListBoxController + diff --git a/wcfsetup/install/files/lib/data/user/profile/comment/ViewableUserProfileComment.class.php b/wcfsetup/install/files/lib/data/user/profile/comment/ViewableUserProfileComment.class.php new file mode 100644 index 0000000000..970d4329dd --- /dev/null +++ b/wcfsetup/install/files/lib/data/user/profile/comment/ViewableUserProfileComment.class.php @@ -0,0 +1,31 @@ + + * @package WoltLabSuite\Core\Data\Comment + * + * @method Comment getDecoratedObject() + * @mixin Comment + */ +class ViewableUserProfileComment extends ViewableComment { + /** + * @inheritDoc + */ + public function __get($name) { + if ($name === 'title') { + return WCF::getLanguage()->getDynamicVariable('wcf.user.profile.title', ['user' => UserProfileRuntimeCache::getInstance()->getObject($this->objectID)]); + } + + return parent::__get($name); + } +} diff --git a/wcfsetup/install/files/lib/system/box/ProfileCommentListBoxController.class.php b/wcfsetup/install/files/lib/system/box/ProfileCommentListBoxController.class.php new file mode 100644 index 0000000000..23dac24d32 --- /dev/null +++ b/wcfsetup/install/files/lib/system/box/ProfileCommentListBoxController.class.php @@ -0,0 +1,76 @@ + + * @package WoltLabSuite\Core\System\Box + */ +class ProfileCommentListBoxController extends AbstractCommentListBoxController { + /** + * @inheritDoc + */ + protected $objectTypeName = 'com.woltlab.wcf.user.profileComment'; + + /** + * @inheritDoc + */ + protected function applyObjectTypeFilters(ViewableCommentList $commentList) { + $commentList->decoratorClassName = ViewableUserProfileComment::class; + + if (WCF::getSession()->getPermission('user.profile.canViewUserProfile')) { + $optionID = User::getUserOptionID('canViewProfile'); + $commentList->sqlJoins .= ' INNER JOIN wcf' . WCF_N . '_user_option_value user_option_value ON (user_option_value.userID = comment.objectID)'; + + if (WCF::getUser()->userID) { + $followers = UserProfileHandler::getInstance()->getFollowers(); + if (empty($followers)) { + $commentList->getConditionBuilder()->add("( + user_option_value.userOption{$optionID} IN (?) + OR user_option_value.userID = ? + )", [ + [ + UserProfile::ACCESS_EVERYONE, + UserProfile::ACCESS_REGISTERED + ], + WCF::getUser()->userID + ]); + } + else { + $commentList->getConditionBuilder()->add("( + user_option_value.userOption{$optionID} IN (?) + OR ( + user_option_value.userOption{$optionID} = ? + AND comment.objectID IN (?) + ) + OR user_option_value.userID = ? + )", [ + [ + UserProfile::ACCESS_EVERYONE, + UserProfile::ACCESS_REGISTERED + ], + UserProfile::ACCESS_FOLLOWING, + $followers, + WCF::getUser()->userID + ]); + } + } + else { + $commentList->getConditionBuilder()->add("user_option_value.userOption{$optionID} = ?", [UserProfile::ACCESS_EVERYONE]); + } + } + else { + $commentList->getConditionBuilder()->add('0 = 1'); + } + } +} diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 0911c2ae8d..b696a01dd8 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -217,6 +217,7 @@ + @@ -4126,6 +4127,7 @@ Benachrichtigungen auf {PAGE_TITLE|language + username}]]> diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index 817412d951..26c00a9e3c 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -213,6 +213,7 @@ + @@ -4121,6 +4122,7 @@ your notifications on {PAGE_TITLE|language} + username}]]>