Fixed user option type 'message'
authorMarcel Werk <burntime@woltlab.com>
Mon, 24 Apr 2017 14:58:49 +0000 (16:58 +0200)
committerMarcel Werk <burntime@woltlab.com>
Mon, 24 Apr 2017 14:58:55 +0000 (16:58 +0200)
com.woltlab.wcf/objectType.xml
wcfsetup/install/files/lib/acp/form/UserOptionAddForm.class.php
wcfsetup/install/files/lib/acp/form/UserOptionEditForm.class.php

index dc6d9dc70ccb3e31c6f4494dbc5ef17a7dd7a599..7c1905cb7206f5c5994fa34ca5d99aab7ee4c821 100644 (file)
                        <name>com.woltlab.wcf.user.signature</name>
                        <definitionname>com.woltlab.wcf.message</definitionname>
                </type>
+               <type>
+                       <name>com.woltlab.wcf.user.option.generic</name>
+                       <definitionname>com.woltlab.wcf.message</definitionname>
+               </type>
                
                <type>
                        <name>com.woltlab.wcf.bbcode.smiley</name>
index dbf19810ee7090ec5e868700885a99d288a395ff..b14cbbda9f9fae0584784ba90a94b32990510004 100644 (file)
@@ -282,6 +282,10 @@ class UserOptionAddForm extends AbstractForm {
        public function save() {
                parent::save();
                
+               $additionalData = array();
+               if ($this->optionType == 'select') $additionalData['allowEmptyValue'] = true;
+               if ($this->optionType == 'message') $additionalData['messageObjectType'] = 'com.woltlab.wcf.user.option.generic';
+               
                $this->objectAction = new UserOptionAction([], 'create', ['data' => array_merge($this->additionalFields, [
                        'optionName' => StringUtil::getRandomID(),
                        'categoryName' => $this->categoryName,
@@ -297,7 +301,7 @@ class UserOptionAddForm extends AbstractForm {
                        'editable' => $this->editable,
                        'visible' => $this->visible,
                        'packageID' => 1,
-                       'additionalData' => $this->optionType == 'select' ? serialize(['allowEmptyValue' => true]) : ''
+                       'additionalData' => !empty($additionalData) ? serialize($additionalData) : ''
                ])]);
                $this->objectAction->executeAction();
                
index 2e3e19be00ce501cbc6964d63b0d59264c5e3b36..030a1d995378f2e026fc5704ef6d1a1c1cb588a5 100644 (file)
@@ -60,6 +60,9 @@ class UserOptionEditForm extends UserOptionAddForm {
                I18nHandler::getInstance()->save('optionName', 'wcf.user.option.'.$this->userOption->optionName, 'wcf.user.option');
                I18nHandler::getInstance()->save('optionDescription', 'wcf.user.option.'.$this->userOption->optionName.'.description', 'wcf.user.option');
                
+               $additionalData = array();
+               if ($this->optionType == 'message') $additionalData['messageObjectType'] = 'com.woltlab.wcf.user.option.generic';
+               
                $this->objectAction = new UserOptionAction([$this->userOption], 'update', ['data' => array_merge($this->additionalFields, [
                        'categoryName' => $this->categoryName,
                        'optionType' => $this->optionType,
@@ -72,7 +75,8 @@ class UserOptionEditForm extends UserOptionAddForm {
                        'askDuringRegistration' => $this->askDuringRegistration,
                        'searchable' => $this->searchable,
                        'editable' => $this->editable,
-                       'visible' => $this->visible
+                       'visible' => $this->visible,
+                       'additionalData' => !empty($additionalData) ? serialize($additionalData) : ''
                ])]);
                $this->objectAction->executeAction();
                $this->saved();