Add trophy conditions
authorJoshua Rüsweg <josh@bastelstu.be>
Mon, 3 Jul 2017 20:00:54 +0000 (22:00 +0200)
committerJoshua Rüsweg <josh@bastelstu.be>
Mon, 3 Jul 2017 20:12:44 +0000 (22:12 +0200)
See #2315

com.woltlab.wcf/objectType.xml
com.woltlab.wcf/objectTypeDefinition.xml
wcfsetup/install/files/lib/system/trophy/condition/TrophyConditionHandler.class.php [new file with mode: 0644]

index c6ecef933cda784642da2319a03146dd042b05bb..4b229009066695ec40482df76ca6ab49cf84b91e 100644 (file)
                </type>
                <!-- /user group assignment conditions -->
                
+               <!-- trophy conditions -->
+               <type>
+                       <name>com.woltlab.wcf.username</name>
+                       <definitionname>com.woltlab.wcf.condition.trophy</definitionname>
+                       <classname>wcf\system\condition\UserUsernameCondition</classname>
+                       <conditiongroup>general</conditiongroup>
+               </type>
+               <type>
+                       <name>com.woltlab.wcf.email</name>
+                       <definitionname>com.woltlab.wcf.condition.trophy</definitionname>
+                       <classname>wcf\system\condition\UserEmailCondition</classname>
+                       <conditiongroup>general</conditiongroup>
+               </type>
+               <type>
+                       <name>com.woltlab.wcf.userGroup</name>
+                       <definitionname>com.woltlab.wcf.condition.trophy</definitionname>
+                       <classname>wcf\system\condition\UserGroupCondition</classname>
+                       <conditiongroup>general</conditiongroup>
+               </type>
+               <type>
+                       <name>com.woltlab.wcf.languages</name>
+                       <definitionname>com.woltlab.wcf.condition.trophy</definitionname>
+                       <classname>wcf\system\condition\UserLanguageCondition</classname>
+                       <conditiongroup>general</conditiongroup>
+               </type>
+               <type>
+                       <name>com.woltlab.wcf.registrationDate</name>
+                       <definitionname>com.woltlab.wcf.condition.trophy</definitionname>
+                       <classname>wcf\system\condition\UserRegistrationDateCondition</classname>
+                       <conditiongroup>general</conditiongroup>
+               </type>
+               <type>
+                       <name>com.woltlab.wcf.registrationDateInterval</name>
+                       <definitionname>com.woltlab.wcf.condition.trophy</definitionname>
+                       <classname>wcf\system\condition\UserRegistrationDateIntervalCondition</classname>
+                       <conditiongroup>general</conditiongroup>
+               </type>
+               <type>
+                       <name>com.woltlab.wcf.avatar</name>
+                       <definitionname>com.woltlab.wcf.condition.trophy</definitionname>
+                       <classname>wcf\system\condition\UserAvatarCondition</classname>
+                       <conditiongroup>general</conditiongroup>
+               </type>
+               <type>
+                       <name>com.woltlab.wcf.state</name>
+                       <definitionname>com.woltlab.wcf.condition.trophy</definitionname>
+                       <classname>wcf\system\condition\UserStateCondition</classname>
+                       <conditiongroup>general</conditiongroup>
+               </type>
+               <type>
+                       <name>com.woltlab.wcf.activityPoints</name>
+                       <definitionname>com.woltlab.wcf.condition.trophy</definitionname>
+                       <classname>wcf\system\condition\UserIntegerPropertyCondition</classname>
+                       <conditiongroup>contents</conditiongroup>
+                       <propertyname>activityPoints</propertyname>
+                       <minvalue>0</minvalue>
+               </type>
+               <type>
+                       <name>com.woltlab.wcf.likesReceived</name>
+                       <definitionname>com.woltlab.wcf.condition.trophy</definitionname>
+                       <classname>wcf\system\condition\UserIntegerPropertyCondition</classname>
+                       <conditiongroup>contents</conditiongroup>
+                       <propertyname>likesReceived</propertyname>
+                       <minvalue>0</minvalue>
+               </type>
+               <type>
+                       <name>com.woltlab.wcf.userOptions</name>
+                       <definitionname>com.woltlab.wcf.condition.trophy</definitionname>
+                       <classname>wcf\system\condition\UserOptionsCondition</classname>
+                       <conditiongroup>userOptions</conditiongroup>
+               </type>
+               <!-- /trophy conditions -->
+               
                <!-- notice conditions -->
                <type>
                        <name>com.woltlab.wcf.page</name>
index 44b1c54a926ac598f802ac97f1b04bc6b0b4f7ed..7e0f705d1bf1dc6f30fe0f7ea83c8e897619b912 100644 (file)
                        <interfacename>wcf\system\condition\IUserCondition</interfacename>
                </definition>
                
+               <definition>
+                       <name>com.woltlab.wcf.condition.trophy</name>
+                       <interfacename>wcf\system\condition\IUserCondition</interfacename>
+               </definition>
+               
                <definition>
                        <name>com.woltlab.wcf.condition.notice</name>
                        <interfacename>wcf\system\condition\IContentCondition</interfacename>
diff --git a/wcfsetup/install/files/lib/system/trophy/condition/TrophyConditionHandler.class.php b/wcfsetup/install/files/lib/system/trophy/condition/TrophyConditionHandler.class.php
new file mode 100644 (file)
index 0000000..b9d6591
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+namespace wcf\system\trophy\condition;
+use wcf\data\object\type\ObjectType;
+use wcf\data\object\type\ObjectTypeCache;
+use wcf\system\SingletonFactory;
+
+/**
+ * Handles trophy conditions. 
+ *
+ * @author     Joshua Ruesweg
+ * @copyright  2001-2017 WoltLab GmbH
+ * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
+ * @package    WoltLabSuite\Core\System\Trophy\Condition
+ * @since      3.1
+ */
+class TrophyConditionHandler extends SingletonFactory {
+       /**
+        * definition name for trophy conditions
+        * @var string
+        */
+       const CONDITION_DEFINITION_NAME = 'com.woltlab.wcf.condition.trophy';
+       
+       /**
+        * list of grouped trophy condition object types
+        * @var ObjectType[][]
+        */
+       protected $groupedObjectTypes = [];
+       
+       /**
+        * @inheritDoc
+        */
+       protected function init() {
+               $objectTypes = ObjectTypeCache::getInstance()->getObjectTypes(self::CONDITION_DEFINITION_NAME);
+               
+               foreach ($objectTypes as $objectType) {
+                       if (!$objectType->conditiongroup) continue;
+                       
+                       if (!isset($this->groupedObjectTypes[$objectType->conditiongroup])) {
+                               $this->groupedObjectTypes[$objectType->conditiongroup] = [];
+                       }
+                       
+                       $this->groupedObjectTypes[$objectType->conditiongroup][$objectType->objectTypeID] = $objectType;
+               }
+       }
+       
+       /**
+        * Returns the list of grouped trophy condition object types.
+        *
+        * @return      ObjectType[][]
+        */
+       public function getGroupedObjectTypes() {
+               return $this->groupedObjectTypes;
+       }
+}