<type>
<name>com.woltlab.wcf.user.signature</name>
<definitionname>com.woltlab.wcf.message</definitionname>
+ <disallowedBBCodesPermission>user.signature.disallowedBBCodes</disallowedBBCodesPermission>
</type>
<type>
<name>com.woltlab.wcf.user.signature</name>
<type>
<name>com.woltlab.wcf.comment</name>
<definitionname>com.woltlab.wcf.message</definitionname>
+ <disallowedBBCodesPermission>user.comment.disallowedBBCodes</disallowedBBCodesPermission>
</type>
<type>
<name>com.woltlab.wcf.comment.response</name>
<definitionname>com.woltlab.wcf.message</definitionname>
+ <disallowedBBCodesPermission>user.comment.disallowedBBCodes</disallowedBBCodesPermission>
</type>
<type>
<name>com.woltlab.wcf.paidSubscription</name>
namespace wcf\system\form\builder\field\wysiwyg;
use wcf\data\IMessageQuoteAction;
use wcf\data\object\type\ObjectTypeCache;
+use wcf\system\bbcode\BBCodeHandler;
use wcf\system\form\builder\data\processor\CustomFormDataProcessor;
use wcf\system\form\builder\field\AbstractFormField;
use wcf\system\form\builder\field\IMaximumLengthFormField;
use wcf\system\html\input\HtmlInputProcessor;
use wcf\system\message\censorship\Censorship;
use wcf\system\message\quote\MessageQuoteManager;
+use wcf\system\WCF;
use wcf\util\StringUtil;
/**
MessageQuoteManager::getInstance()->assignVariables();
}
+ /** @noinspection PhpUndefinedFieldInspection */
+ $disallowedBBCodesPermission = $this->getObjectType()->disallowedBBCodesPermission;
+ if ($disallowedBBCodesPermission === null) {
+ $disallowedBBCodesPermission = 'user.message.disallowedBBCodes';
+ }
+
+ BBCodeHandler::getInstance()->setDisallowedBBCodes(explode(
+ ',',
+ WCF::getSession()->getPermission($disallowedBBCodesPermission)
+ ));
+
return parent::getHtml();
}
* @inheritDoc
*/
public function validate() {
+ /** @noinspection PhpUndefinedFieldInspection */
+ $disallowedBBCodesPermission = $this->getObjectType()->disallowedBBCodesPermission;
+ if ($disallowedBBCodesPermission === null) {
+ $disallowedBBCodesPermission = 'user.message.disallowedBBCodes';
+ }
+
+ BBCodeHandler::getInstance()->setDisallowedBBCodes(explode(
+ ',',
+ WCF::getSession()->getPermission($disallowedBBCodesPermission)
+ ));
+
$this->htmlInputProcessor = new HtmlInputProcessor();
$this->htmlInputProcessor->process($this->getValue(), $this->getObjectType()->objectType);
$this->addValidationError(new FormFieldValidationError('empty'));
}
else {
- $message = $this->htmlInputProcessor->getTextContent();
- $this->validateMinimumLength($message);
- $this->validateMaximumLength($message);
-
- if (empty($this->getValidationErrors()) && ENABLE_CENSORSHIP) {
- $result = Censorship::getInstance()->test($message);
- if ($result) {
- $this->addValidationError(new FormFieldValidationError(
- 'censoredWords',
- 'wcf.message.error.censoredWordsFound',
- ['censoredWords' => $result]
- ));
+ $disallowedBBCodes = $this->htmlInputProcessor->validate();
+ if (!empty($disallowedBBCodes)) {
+ $this->addValidationError(new FormFieldValidationError(
+ 'disallowedBBCodes',
+ 'wcf.message.error.disallowedBBCodes',
+ ['disallowedBBCodes' => $disallowedBBCodes]
+ ));
+ }
+ else {
+ $message = $this->htmlInputProcessor->getTextContent();
+ $this->validateMinimumLength($message);
+ $this->validateMaximumLength($message);
+
+ if (empty($this->getValidationErrors()) && ENABLE_CENSORSHIP) {
+ $result = Censorship::getInstance()->test($message);
+ if ($result) {
+ $this->addValidationError(new FormFieldValidationError(
+ 'censoredWords',
+ 'wcf.message.error.censoredWordsFound',
+ ['censoredWords' => $result]
+ ));
+ }
}
}
}
use wcf\data\DatabaseObjectList;
use wcf\data\page\PageNode;
use wcf\data\page\PageNodeTree;
+use wcf\data\user\group\option\UserGroupOption;
use wcf\system\application\ApplicationHandler;
use wcf\system\condition\AbstractIntegerCondition;
use wcf\system\condition\UserGroupCondition;
// com.woltlab.wcf.message
$this->getObjectTypeDefinitionDataContainer($form, 'com.woltlab.wcf.message')
->appendChildren([
- BooleanFormField::create('enableToc')
+ // TODO: maximum of one item (see https://github.com/WoltLab/WCF/issues/3040)
+ UserGroupOptionFormField::create('messageObjectDisallowedBBCodesPermission')
+ ->objectProperty('disallowedBBCodesPermission')
+ ->label('wcf.acp.pip.objectType.com.woltlab.wcf.message.disallowedBBCodesPermission')
+ ->description('wcf.acp.pip.objectType.com.woltlab.wcf.message.disallowedBBCodesPermission.description')
+ ->addValidator(new FormFieldValidator('optionType', function(UserGroupOptionFormField $formField) {
+ $value = $formField->getValue();
+ if (empty($value)) return;
+
+ $sql = "SELECT optionType
+ FROM wcf" . WCF_N . "_user_group_option
+ WHERE optionName = ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute([reset($value)]);
+ if ($statement->fetchSingleColumn() !== 'BBCodeSelect') {
+ $formField->addValidationError(
+ new FormFieldValidationError(
+ 'optionType',
+ 'wcf.acp.pip.objectType.com.woltlab.wcf.message.disallowedBBCodesPermission.error.optionType'
+ )
+ );
+ }
+ })),
+
+ BooleanFormField::create('messageObjectTypeEnableToc')
+ ->objectProperty('enableToc')
->label('wcf.acp.pip.objectType.com.woltlab.wcf.message.enableToc')
->description('wcf.acp.pip.objectType.com.woltlab.wcf.message.enableToc.description')
]);
- $this->definitionElementChildren['com.woltlab.wcf.message'] = ['enableToc' => 0];
+ $this->definitionElementChildren['com.woltlab.wcf.message'] = [
+ 'disallowedBBCodesPermission' => '',
+ 'enableToc' => 0
+ ];
// com.woltlab.wcf.notification.objectType
$this->getObjectTypeDefinitionDataContainer($form, 'com.woltlab.wcf.notification.objectType')
<item name="wcf.acp.pip.objectType.com.woltlab.wcf.content.userContentProvider.requiredObjectType"><![CDATA[Benötigte Objekt-Typen]]></item>
<item name="wcf.acp.pip.objectType.com.woltlab.wcf.content.userContentProvider.requiredObjectType.description"><![CDATA[Die durch die angegebenen Objekttypen repräsentierten Benutzerinhalte werden bei der Entfernung der Benutzerinhalte durch <strong>diesen</strong> Anbieter ebenfalls entfernt. Muss dabei eine bestimmte Reihenfolge beachtet werden, müssen nice-Werte angegeben werden.]]></item>
<item name="wcf.acp.pip.objectType.com.woltlab.wcf.message.data.title"><![CDATA[Daten des Nachrichtentyps]]></item>
+ <item name="wcf.acp.pip.objectType.com.woltlab.wcf.message.disallowedBBCodesPermission"><![CDATA[Berechtigung für nicht erlaubte BBCodes]]></item>
+ <item name="wcf.acp.pip.objectType.com.woltlab.wcf.message.disallowedBBCodesPermission.description"><![CDATA[Wird mit der Form Builder-API eine Nachricht dieses Typs erstellt, wird die angegebene Benutzergruppenberechtigung dafür verwendet, für nicht erlaubten BBCodes zu bestimmen. Wird keine Berechtigung angegeben, wird die allgemeine Berechtigung für nicht erlaubte BBCodes für Nachrichten verwendet.]]></item>
+ <item name="wcf.acp.pip.objectType.com.woltlab.wcf.message.disallowedBBCodesPermission.error.optionType"><![CDATA[Die angegebene Benutzergruppenberechtigung muss vom Typ BBCodeSelect sein.]]></item>
<item name="wcf.acp.pip.objectType.com.woltlab.wcf.message.enableToc"><![CDATA[Inhaltsverzeichnis erstellen]]></item>
<item name="wcf.acp.pip.objectType.com.woltlab.wcf.message.enableToc.description"><![CDATA[Wenn ausgewählt wird ein Inhaltsverzeichnis für jede Nachricht dieses Types erstellt.]]></item>
<item name="wcf.acp.pip.objectType.com.woltlab.wcf.notification.objectType.category"><![CDATA[Kategorie]]></item>
<item name="wcf.acp.pip.objectType.integerCondition.propertyName.description"><![CDATA[Name of the object property and column of <kbd>{$tableName}</kbd> database table used for this condition.]]></item>
<item name="wcf.acp.pip.objectType.integerCondition.propertyName"><![CDATA[Object Property Name]]></item>
<item name="wcf.acp.pip.objectType.com.woltlab.wcf.message.data.title"><![CDATA[Message Type Data]]></item>
+ <item name="wcf.acp.pip.objectType.com.woltlab.wcf.message.disallowedBBCodesPermission"><![CDATA[Permission for Disallowed BBCodes]]></item>
+ <item name="wcf.acp.pip.objectType.com.woltlab.wcf.message.disallowedBBCodesPermission.description"><![CDATA[If the form builder API is used to create a message of this type, the given user group permission will be used to determine the disallowed BBCodes. If no permission is given, the general permission for disallowed BBCodes for messages is used.]]></item>
+ <item name="wcf.acp.pip.objectType.com.woltlab.wcf.message.disallowedBBCodesPermission.error.optionType"><![CDATA[The entered user group permission’s type has to be BBCodeSelect.]]></item>
<item name="wcf.acp.pip.objectType.com.woltlab.wcf.message.enableToc"><![CDATA[Generate Table of Contents]]></item>
<item name="wcf.acp.pip.objectType.com.woltlab.wcf.message.enableToc.description"><![CDATA[If selected, a table of contents is created for each message of this type.]]></item>
<item name="wcf.acp.pip.templateListener.niceValue"><![CDATA[Nice Value]]></item>