Add condition to exclude recent activity types in boxes
authorMatthias Schmidt <gravatronics@live.com>
Sat, 24 Sep 2016 19:42:58 +0000 (21:42 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sat, 24 Sep 2016 19:42:58 +0000 (21:42 +0200)
com.woltlab.wcf/objectType.xml
com.woltlab.wcf/objectTypeDefinition.xml
wcfsetup/install/files/lib/system/box/RecentActivityListBoxController.class.php
wcfsetup/install/files/lib/system/condition/user/activity/event/UserActivityEventExcludedObjectTypeCondition.class.php [new file with mode: 0644]
wcfsetup/install/lang/de.xml
wcfsetup/install/lang/en.xml

index 238c692a73a40981571dbb24ce59358cfa39be8b..a967df4b5d52d3313647a8334f9501201f69f85d 100644 (file)
                </type>
                <!-- /article list box condition -->
                
+               <!-- recent activity list box condition -->
+               <type>
+                       <name>com.woltlab.wcf.excludedObjectType</name>
+                       <definitionname>com.woltlab.wcf.box.recentActivityList.condition</definitionname>
+                       <classname>wcf\system\condition\user\activity\event\UserActivityEventExcludedObjectTypeCondition</classname>
+               </type>
+               <!-- /recent activity box condition -->
+               
                <!-- deprecated -->
                <type>
                        <name>com.woltlab.wcf.page.controller</name>
index 7980a9f8e754a897ce84b5a98a8f7ee0e10ca9ff..cbdfc79f86761cadc86a9f898c29f296aff1576d 100644 (file)
                        <name>com.woltlab.wcf.box.articleList.condition</name>
                        <interfacename>wcf\system\condition\IObjectListCondition</interfacename>
                </definition>
+               <definition>
+                       <name>com.woltlab.wcf.box.recentActivityList.condition</name>
+                       <interfacename>wcf\system\condition\IObjectListCondition</interfacename>
+               </definition>
                <!-- /box conditions -->
                
                <!-- deprecated -->
index 4877232399565f78303a882e287e038512274c72..81103332069472e86648d31a7dfb945210c66626 100644 (file)
@@ -14,7 +14,7 @@ use wcf\system\WCF;
  * @package    WoltLabSuite\Core\System\Box
  * @since      3.0
  * 
- * @property   ViewableUserActivityEventList   $objectList
+ * @property   ViewableUserActivityEventList   $objectList
  */
 class RecentActivityListBoxController extends AbstractDatabaseObjectListBoxController {
        /**
@@ -24,6 +24,11 @@ class RecentActivityListBoxController extends AbstractDatabaseObjectListBoxContr
         */
        public $canFilterByFollowedUsers = false;
        
+       /**
+        * @inheritDoc
+        */
+       public $conditionDefinition = 'com.woltlab.wcf.box.recentActivityList.condition';
+       
        /**
         * is true if the list of recent activity is filtered to only include
         * activities by followed users
diff --git a/wcfsetup/install/files/lib/system/condition/user/activity/event/UserActivityEventExcludedObjectTypeCondition.class.php b/wcfsetup/install/files/lib/system/condition/user/activity/event/UserActivityEventExcludedObjectTypeCondition.class.php
new file mode 100644 (file)
index 0000000..04c310b
--- /dev/null
@@ -0,0 +1,59 @@
+<?php
+namespace wcf\system\condition\user\activity\event;
+use wcf\data\DatabaseObjectList;
+use wcf\data\object\type\ObjectTypeCache;
+use wcf\data\user\activity\event\UserActivityEventList;
+use wcf\system\condition\AbstractMultiSelectCondition;
+use wcf\system\condition\IObjectListCondition;
+use wcf\system\WCF;
+
+/**
+ * Condition implementation for the excluded object types of user activity events.
+ * 
+ * @author     Matthias Schmidt
+ * @copyright  2001-2016 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    WoltLabSuite\Core\System\Condition\User\Activity\Event
+ * @since      3.0
+ */
+class UserActivityEventExcludedObjectTypeCondition extends AbstractMultiSelectCondition implements IObjectListCondition {
+       /**
+        * @inheritDoc
+        */
+       protected $description = 'wcf.global.multiSelect';
+       
+       /**
+        * @inheritDoc
+        */
+       protected $fieldName = 'userActivityEventExcludedObjectTypeID';
+       
+       /**
+        * @inheritDoc
+        */
+       protected $label = 'wcf.user.recentActivity.condition.excludedObjectType';
+       
+       /**
+        * @inheritDoc
+        */
+       public function addObjectListCondition(DatabaseObjectList $objectList, array $conditionData) {
+               if (!($objectList instanceof UserActivityEventList)) {
+                       throw new \InvalidArgumentException("Object list is no instance of '".UserActivityEventList::class."', instance of '".get_class($objectList)."' given.");
+               }
+               
+               $objectList->getConditionBuilder()->add('user_activity_event.objectTypeID NOT IN (?)', [$conditionData[$this->fieldName]]);
+       }
+       
+       /**
+        * @inheritDoc
+        */
+       public function getOptions() {
+               $objectTypes = ObjectTypeCache::getInstance()->getObjectTypes('com.woltlab.wcf.user.recentActivityEvent');
+               
+               $options = [];
+               foreach ($objectTypes as $objectType) {
+                       $options[$objectType->objectTypeID] = WCF::getLanguage()->get('wcf.user.recentActivity.' . $objectType->objectType);
+               }
+               
+               return $options;
+       }
+}
index edc808b79beca298a5b57256a986241b2efc2b86..41c3c60eb3f23a359ed2e41749d3d51264a9cb44 100644 (file)
@@ -3308,6 +3308,7 @@ Die E-Mail-Adresse des neuen Benutzers lautet: {@$user->email}
                <item name="wcf.user.recentActivity.com.woltlab.wcf.likeableArticle.recentActivityEvent"><![CDATA[Like (Artikel)]]></item>
                <item name="wcf.user.recentActivity.com.woltlab.wcf.articleComment.recentActivityEvent"><![CDATA[Kommentar (Artikel)]]></item>
                <item name="wcf.user.recentActivity.com.woltlab.wcf.articleComment.response.recentActivityEvent"><![CDATA[Antwort (Artikel)]]></item>
+               <item name="wcf.user.recentActivity.condition.excludedObjectType"><![CDATA[Ausgeschlossene Aktivitäten]]></item>
                <item name="wcf.user.recentActivity.scope.all"><![CDATA[Aktivitäten aller Benutzer]]></item>
                <item name="wcf.user.recentActivity.scope.followedUsers"><![CDATA[Aktivitäten von Benutzern, denen {if LANGUAGE_USE_INFORMAL_VARIANT}du folgst{else}Sie folgen{/if}]]></item>
        </category>
index 41ee31cf7a6d6bea5549db3cbe7639fa30a32d52..0d9602103d347d1ef92fd302c5a2dfab6a146619 100644 (file)
@@ -3301,6 +3301,7 @@ Open the link below to access the user profile:
                <item name="wcf.user.recentActivity.com.woltlab.wcf.likeableArticle.recentActivityEvent"><![CDATA[Like (Article)]]></item>
                <item name="wcf.user.recentActivity.com.woltlab.wcf.articleComment.recentActivityEvent"><![CDATA[Comment (Article)]]></item>
                <item name="wcf.user.recentActivity.com.woltlab.wcf.articleComment.response.recentActivityEvent"><![CDATA[Reply (Article)]]></item>
+               <item name="wcf.user.recentActivity.condition.excludedObjectType"><![CDATA[Excluded Activities]]></item>
                <item name="wcf.user.recentActivity.scope.all"><![CDATA[All Activities]]></item>
                <item name="wcf.user.recentActivity.scope.followedUsers"><![CDATA[Filter by Followed Users]]></item>
        </category>