$this->subject = \mb_substr($this->subject, 0, 255);
}
- // search for censored words
- if (ENABLE_CENSORSHIP) {
- $result = Censorship::getInstance()->test($this->subject);
- if ($result) {
- WCF::getTPL()->assign('censoredWords', $result);
- throw new UserInputException('subject', 'censoredWordsFound');
- }
+ $censoredWords = Censorship::getInstance()->test($this->subject);
+ if ($censoredWords) {
+ WCF::getTPL()->assign('censoredWords', $censoredWords);
+ throw new UserInputException('subject', 'censoredWordsFound');
}
}
}
// search for censored words
- if (ENABLE_CENSORSHIP) {
- $result = Censorship::getInstance()->test($message);
- if ($result) {
- WCF::getTPL()->assign('censoredWords', $result);
- throw new UserInputException('text', 'censoredWordsFound');
- }
+ $censoredWords = Censorship::getInstance()->test($message);
+ if ($censoredWords) {
+ WCF::getTPL()->assign('censoredWords', $censoredWords);
+ throw new UserInputException('text', 'censoredWordsFound');
}
}
*/
public static function enforceCensorship($text)
{
- // search for censored words
- if (ENABLE_CENSORSHIP) {
- $result = Censorship::getInstance()->test($text);
- if ($result) {
- throw new UserInputException(
- 'text',
- WCF::getLanguage()->getDynamicVariable(
- 'wcf.message.error.censoredWordsFound',
- ['censoredWords' => $result]
- )
- );
- }
+ $censoredWords = Censorship::getInstance()->test($text);
+ if ($censoredWords) {
+ throw new UserInputException(
+ 'text',
+ WCF::getLanguage()->getDynamicVariable(
+ 'wcf.message.error.censoredWordsFound',
+ ['censoredWords' => $censoredWords]
+ )
+ );
}
}
}
$this->validateMinimumLength($message);
$this->validateMaximumLength($message);
- if (empty($this->getValidationErrors()) && ENABLE_CENSORSHIP) {
- $result = Censorship::getInstance()->test($message);
- if ($result) {
+ if (empty($this->getValidationErrors())) {
+ $censoredWords = Censorship::getInstance()->test($message);
+ if ($censoredWords) {
$this->addValidationError(new FormFieldValidationError(
'censoredWords',
'wcf.message.error.censoredWordsFound',
- ['censoredWords' => $result]
+ ['censoredWords' => $censoredWords]
));
}
}
throw new UserInputException($option->optionName, 'tooLong');
}
- // search for censored words
- if (ENABLE_CENSORSHIP) {
- $result = Censorship::getInstance()->test($newValue);
- if ($result) {
- WCF::getTPL()->assign('censoredWords', $result);
- throw new UserInputException($option->optionName, 'censoredWordsFound');
- }
+ $censoredWords = Censorship::getInstance()->test($newValue);
+ if ($censoredWords) {
+ WCF::getTPL()->assign('censoredWords', $censoredWords);
+ throw new UserInputException($option->optionName, 'censoredWordsFound');
}
}
}