<name>com.woltlab.wcf.box.content</name>
<definitionname>com.woltlab.wcf.message</definitionname>
</type>
+ <type>
+ <name>com.woltlab.wcf.user.aboutMe</name>
+ <definitionname>com.woltlab.wcf.message</definitionname>
+ </type>
+ <type>
+ <name>com.woltlab.wcf.user.signature</name>
+ <definitionname>com.woltlab.wcf.message</definitionname>
+ </type>
<type>
<name>com.woltlab.wcf.bbcode.smiley</name>
<outputclass>wcf\system\option\user\MessageUserOptionOutput</outputclass>
<visible>15</visible>
<editable>3</editable>
+ <messageObjectType>com.woltlab.wcf.user.aboutMe</messageObjectType>
</option>
<option name="birthday">
<categoryname>profile.personal</categoryname>
<textarea id="{$option->optionName}" name="values[{$option->optionName}]" cols="40" rows="10">{$value}</textarea>
+{include file='wysiwyg' wysiwygSelector=$option->optionName}
<dt><label for="signature">{lang}wcf.user.signature{/lang}</label></dt>
<dd>
<textarea name="signature" id="signature" cols="40" rows="10">{$signature}</textarea>
+ {include file='wysiwyg' wysiwygSelector='signature'}
</dd>
</dl>
use wcf\data\user\group\UserGroup;
use wcf\data\user\UserAction;
use wcf\form\AbstractForm;
+use wcf\system\bbcode\BBCodeHandler;
use wcf\system\database\util\PreparedStatementConditionBuilder;
use wcf\system\exception\UserInputException;
+use wcf\system\html\input\HtmlInputProcessor;
use wcf\system\language\LanguageFactory;
use wcf\system\WCF;
use wcf\util\ArrayUtil;
*/
public $groupIDs = [];
+ /**
+ * @var HtmlInputProcessor
+ */
+ public $htmlInputProcessor;
+
/**
* language id
* @var integer
$this->errorType[$e->getField()] = $e->getType();
}
+ // validate signature
+ $this->htmlInputProcessor = new HtmlInputProcessor();
+ $this->htmlInputProcessor->process($this->signature, 'com.woltlab.wcf.user.signature', 0);
+
+ BBCodeHandler::getInstance()->setDisallowedBBCodes(explode(',', WCF::getSession()->getPermission('user.signature.disallowedBBCodes')));
+ $disallowedBBCodes = $this->htmlInputProcessor->validate();
+ if (!empty($disallowedBBCodes)) {
+ WCF::getTPL()->assign('disallowedBBCodes', $disallowedBBCodes);
+ throw new UserInputException('signature', 'disallowedBBCodes');
+ }
+
// validate dynamic options
parent::validate();
}
'email' => $this->email,
'password' => $this->password,
'userTitle' => $this->userTitle,
- 'signature' => $this->signature
+ 'signature' => $this->htmlInputProcessor->getHtml()
]),
'groups' => $this->groupIDs,
'languageIDs' => $this->visibleLanguages,
$this->userTitle = $this->user->userTitle;
$this->signature = $this->user->signature;
- $this->signatureEnableBBCodes = $this->user->signatureEnableBBCodes;
- $this->signatureEnableSmilies = $this->user->signatureEnableSmilies;
- $this->signatureEnableHtml = $this->user->signatureEnableHtml;
$this->disableSignature = $this->user->disableSignature;
$this->disableSignatureReason = $this->user->disableSignatureReason;
$this->disableSignatureExpires = $this->user->disableSignatureExpires;
'password' => $this->password,
'languageID' => $this->languageID,
'userTitle' => $this->userTitle,
- 'signature' => $this->signature,
- 'signatureEnableBBCodes' => $this->signatureEnableBBCodes,
- 'signatureEnableSmilies' => $this->signatureEnableSmilies,
- 'signatureEnableHtml' => $this->signatureEnableHtml
+ 'signature' => $this->htmlInputProcessor->getHtml()
]),
'groups' => $this->groupIDs,
'languageIDs' => $this->visibleLanguages,
*/
public $loginRequired = true;
+ /**
+ * @inheritDoc
+ */
+ public $messageObjectType = 'com.woltlab.wcf.user.signature';
+
/**
* @inheritDoc
*/
*/
protected $htmlInputProcessor;
+ /**
+ * object type for definition 'com.woltlab.wcf.message'
+ * @var string
+ */
+ protected $messageObjectType = '';
+
/**
* @inheritDoc
*/
- /*public function getData(Option $option, $newValue) {
- if ($option->disallowedbbcodepermission) {
- BBCodeHandler::getInstance()->setDisallowedBBCodes(explode(',', ArrayUtil::trim(WCF::getSession()->getPermission($option->disallowedbbcodepermission))));
+ public function getData(Option $option, $newValue) {
+ if (!$this->messageObjectType) $this->messageObjectType = $option->messageObjectType;
+ if (empty($this->messageObjectType)) {
+ throw new \RuntimeException("Message object type '".$option->optionName."' requires an object type for definition 'com.woltlab.wcf.message'.");
}
+ $permission = ($option->disallowedbbcodepermission) ?: 'user.message.disallowedBBCodes';
+ BBCodeHandler::getInstance()->setDisallowedBBCodes(explode(',', ArrayUtil::trim(WCF::getSession()->getPermission($permission))));
+
$this->htmlInputProcessor = new HtmlInputProcessor();
- $this->htmlInputProcessor->process($newValue, 'com.woltlab.wcf.invalid', 0);
+
+ // the object id is fixed because options are not tied to a specific object
+ // especially when used in the user option context, such as "about me"
+ $this->htmlInputProcessor->process($newValue, $this->messageObjectType, 0);
return parent::getData($option, $this->htmlInputProcessor->getHtml());
- }*/
+ }
/**
* @inheritDoc
*/
public function getFormElement(Option $option, $value) {
- $disallowedBBCodes = [];
- if ($option->disallowedbbcodepermission) {
- $disallowedBBCodes = explode(',', WCF::getSession()->getPermission($option->disallowedbbcodepermission));
- }
- BBCodeHandler::getInstance()->setDisallowedBBCodes($disallowedBBCodes);
+ $permission = ($option->disallowedbbcodepermission) ?: 'user.message.disallowedBBCodes';
+ BBCodeHandler::getInstance()->setDisallowedBBCodes(explode(',', ArrayUtil::trim(WCF::getSession()->getPermission($permission))));
WCF::getTPL()->assign([
'defaultSmilies' => SmileyCache::getInstance()->getCategorySmilies(),
/**
* @inheritDoc
*/
- /*public function validate(Option $option, $newValue) {
+ public function validate(Option $option, $newValue) {
parent::validate($option, $newValue);
- if ($option->disallowedbbcodepermission) {
- $disallowedBBCodes = $this->htmlInputProcessor->validate();
-
- if (!empty($disallowedBBCodes)) {
- WCF::getTPL()->assign('disallowedBBCodes', $disallowedBBCodes);
- throw new UserInputException($option->optionName, 'disallowedBBCodes');
- }
+ $disallowedBBCodes = $this->htmlInputProcessor->validate();
+ if (!empty($disallowedBBCodes)) {
+ WCF::getTPL()->assign('disallowedBBCodes', $disallowedBBCodes);
+ throw new UserInputException($option->optionName, 'disallowedBBCodes');
}
- }*/
+ }
}
$this->htmlOutputProcessor = new HtmlOutputProcessor();
}
- $this->htmlOutputProcessor->process($user->signature, 'com.woltlab.wcf.userSignature', $user->userID);
+ $this->htmlOutputProcessor->process($user->signature, 'com.woltlab.wcf.user.signature', $user->userID);
$this->signatures[$user->userID] = $this->htmlOutputProcessor->getHtml();
}