From e7fb8027c9d9b902f566127dcc6eae0832fed727 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Mon, 24 Apr 2017 16:58:49 +0200 Subject: [PATCH] Fixed user option type 'message' --- com.woltlab.wcf/objectType.xml | 4 ++++ .../install/files/lib/acp/form/UserOptionAddForm.class.php | 6 +++++- .../install/files/lib/acp/form/UserOptionEditForm.class.php | 6 +++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/com.woltlab.wcf/objectType.xml b/com.woltlab.wcf/objectType.xml index dc6d9dc70c..7c1905cb72 100644 --- a/com.woltlab.wcf/objectType.xml +++ b/com.woltlab.wcf/objectType.xml @@ -82,6 +82,10 @@ com.woltlab.wcf.user.signature com.woltlab.wcf.message + + com.woltlab.wcf.user.option.generic + com.woltlab.wcf.message + com.woltlab.wcf.bbcode.smiley diff --git a/wcfsetup/install/files/lib/acp/form/UserOptionAddForm.class.php b/wcfsetup/install/files/lib/acp/form/UserOptionAddForm.class.php index dbf19810ee..b14cbbda9f 100644 --- a/wcfsetup/install/files/lib/acp/form/UserOptionAddForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserOptionAddForm.class.php @@ -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(); diff --git a/wcfsetup/install/files/lib/acp/form/UserOptionEditForm.class.php b/wcfsetup/install/files/lib/acp/form/UserOptionEditForm.class.php index 2e3e19be00..030a1d9953 100644 --- a/wcfsetup/install/files/lib/acp/form/UserOptionEditForm.class.php +++ b/wcfsetup/install/files/lib/acp/form/UserOptionEditForm.class.php @@ -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(); -- 2.20.1