Box controller for the latest profile comments
authorAlexander Ebert <ebert@woltlab.com>
Mon, 9 Jul 2018 10:14:16 +0000 (12:14 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 9 Jul 2018 10:14:16 +0000 (12:14 +0200)
See #2588

com.woltlab.wcf/objectType.xml
wcfsetup/install/files/lib/data/user/profile/comment/ViewableUserProfileComment.class.php [new file with mode: 0644]
wcfsetup/install/files/lib/system/box/ProfileCommentListBoxController.class.php [new file with mode: 0644]
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 30445adad8a7d691a4f2370f5efa795bd9f49d31..1e9f0f394ccae36253b7382914fd3a5b20b570b3 100644 (file)
                        <definitionname>com.woltlab.wcf.boxController</definitionname>
                        <classname>wcf\system\box\UserTrophyListBoxController</classname>
                </type>
+               <type>
+                       <name>com.woltlab.wcf.profileCommentList</name>
+                       <definitionname>com.woltlab.wcf.boxController</definitionname>
+                       <classname>wcf\system\box\ProfileCommentListBoxController</classname>
+               </type>
                <!-- /box controllers -->
                
                <!-- simple acl -->
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 (file)
index 0000000..970d432
--- /dev/null
@@ -0,0 +1,31 @@
+<?php
+declare(strict_types=1);
+namespace wcf\data\user\profile\comment;
+use wcf\data\comment\Comment;
+use wcf\data\comment\ViewableComment;
+use wcf\system\cache\runtime\UserProfileRuntimeCache;
+use wcf\system\WCF;
+
+/**
+ * Represents a viewable user profile comment.
+ * 
+ * @author      Alexander Ebert
+ * @copyright   2001-2018 WoltLab GmbH
+ * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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 (file)
index 0000000..23dac24
--- /dev/null
@@ -0,0 +1,76 @@
+<?php
+declare(strict_types=1);
+namespace wcf\system\box;
+use wcf\data\comment\ViewableCommentList;
+use wcf\data\user\profile\comment\ViewableUserProfileComment;
+use wcf\data\user\User;
+use wcf\data\user\UserProfile;
+use wcf\system\user\UserProfileHandler;
+use wcf\system\WCF;
+
+/**
+ * Box controller implementation for a list of comments on user profiles.
+ *
+ * @author      Alexander Ebert
+ * @copyright   2001-2018 WoltLab GmbH
+ * @license     GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @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');
+               }
+       }
+}
index 0911c2ae8d5ed93c2017b41d0e477fde516f1e11..b696a01dd8aae6fc01b5dc09991fb6b60f288a49 100644 (file)
                <item name="wcf.acp.box.boxController.com.woltlab.wcf.followingsOnline"><![CDATA[Benutzer online, denen der aktive Nutzer folgt]]></item>
                <item name="wcf.acp.box.boxController.com.woltlab.wcf.pageCommentList"><![CDATA[Seiten-Kommentare]]></item>
                <item name="wcf.acp.box.boxController.com.woltlab.wcf.paidSubscriptions"><![CDATA[Bezahlte Mitgliedschaften]]></item>
+               <item name="wcf.acp.box.boxController.com.woltlab.wcf.profileCommentList"><![CDATA[Profil-Kommentare]]></item>
                <item name="wcf.acp.box.boxController.com.woltlab.wcf.recentActivityList"><![CDATA[Letzte Aktivitäten]]></item>
                <item name="wcf.acp.box.boxController.com.woltlab.wcf.registerButton"><![CDATA[Registrierungs-Button]]></item>
                <item name="wcf.acp.box.boxController.com.woltlab.wcf.signedInAs"><![CDATA[Angemeldet als]]></item>
@@ -4126,6 +4127,7 @@ Benachrichtigungen auf <a href="{link isEmail=true}{/link}">{PAGE_TITLE|language
                <item name="wcf.user.profile.user"><![CDATA[Benutzer]]></item>
                <item name="wcf.user.profile.management"><![CDATA[Verwaltung]]></item>
                <item name="wcf.user.profile.customization"><![CDATA[Anpassung]]></item>
+               <item name="wcf.user.profile.title"><![CDATA[Benutzerprofil von {$user->username}]]></item>
        </category>
        
        <category name="wcf.user.objectWatch">
index 817412d9517ff5842ff097f2a08c05b2a361e969..26c00a9e3c4644698deb6871ec5f9f014f39f483 100644 (file)
                <item name="wcf.acp.box.boxController.com.woltlab.wcf.followingsOnline"><![CDATA[Users Online Followed by Active User]]></item>
                <item name="wcf.acp.box.boxController.com.woltlab.wcf.pageCommentList"><![CDATA[Page Comments]]></item>
                <item name="wcf.acp.box.boxController.com.woltlab.wcf.paidSubscriptions"><![CDATA[Paid Subscriptions]]></item>
+               <item name="wcf.acp.box.boxController.com.woltlab.wcf.profileCommentList"><![CDATA[Profile Comments]]></item>
                <item name="wcf.acp.box.boxController.com.woltlab.wcf.recentActivityList"><![CDATA[Recent Activity]]></item>
                <item name="wcf.acp.box.boxController.com.woltlab.wcf.registerButton"><![CDATA[Register Button]]></item>
                <item name="wcf.acp.box.boxController.com.woltlab.wcf.signedInAs"><![CDATA[Signed In As]]></item>
@@ -4121,6 +4122,7 @@ your notifications on <a href="{link isEmail=true}{/link}">{PAGE_TITLE|language}
                <item name="wcf.user.profile.user"><![CDATA[User]]></item>
                <item name="wcf.user.profile.management"><![CDATA[Management]]></item>
                <item name="wcf.user.profile.customization"><![CDATA[Customization]]></item>
+               <item name="wcf.user.profile.title"><![CDATA[User profile of {$user->username}]]></item>
        </category>
        
        <category name="wcf.user.objectWatch">