5 use wcf\data\user\User
;
6 use wcf\data\user\UserAction
;
7 use wcf\system\exception\PermissionDeniedException
;
8 use wcf\system\html\input\HtmlInputProcessor
;
9 use wcf\system\menu\user\UserMenu
;
10 use wcf\system\message\embedded\
object\MessageEmbeddedObjectManager
;
11 use wcf\system\user\signature\SignatureCache
;
15 * Shows the signature edit form.
17 * @author Alexander Ebert
18 * @copyright 2001-2019 WoltLab GmbH
19 * @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
21 class SignatureEditForm
extends MessageForm
26 public $disallowedBBCodesPermission = 'user.signature.disallowedBBCodes';
31 public $loginRequired = true;
36 public $messageObjectType = 'com.woltlab.wcf.user.signature';
41 public $attachmentObjectType = 'com.woltlab.wcf.user.signature';
46 public $neededModules = ['MODULE_USER_SIGNATURE'];
51 public $showSignatureSetting = false;
54 * parsed signature cache
57 public $signatureCache;
62 public $templateName = 'signatureEdit';
67 public $neededPermissions = ['user.signature.canEditSignature'];
72 public function readParameters()
74 parent
::readParameters();
76 // get max text length
77 $this->maxTextLength
= WCF
::getSession()->getPermission('user.signature.maxLength');
78 $this->attachmentObjectID
= WCF
::getUser()->userID
;
84 public function validate()
86 if (WCF
::getUser()->disableSignature
) {
87 throw new PermissionDeniedException();
90 AbstractForm
::validate();
92 if (!empty($this->text
)) {
93 $this->validateText();
95 $this->htmlInputProcessor
= new HtmlInputProcessor();
96 $this->htmlInputProcessor
->process($this->text
, $this->messageObjectType
, WCF
::getUser()->userID
);
103 public function readData()
109 $this->text
= WCF
::getUser()->signature
;
112 $this->signatureCache
= SignatureCache
::getInstance()->getSignature(WCF
::getUser());
118 public function assignVariables()
120 parent
::assignVariables();
122 WCF
::getTPL()->assign([
123 'signatureCache' => $this->signatureCache
,
130 public function show()
133 UserMenu
::getInstance()->setActiveMenuItem('wcf.user.menu.profile.signature');
141 public function save()
144 $this->htmlInputProcessor
->setObjectID(WCF
::getUser()->userID
);
145 MessageEmbeddedObjectManager
::getInstance()->registerObjects($this->htmlInputProcessor
);
147 $this->objectAction
= new UserAction([WCF
::getUser()], 'update', [
148 'data' => \array_merge
($this->additionalFields
, [
149 'signature' => $this->htmlInputProcessor
->getHtml(),
150 'signatureEnableHtml' => 1,
152 'signatureAttachmentHandler' => $this->attachmentHandler
,
154 $this->objectAction
->executeAction();
155 SignatureCache
::getInstance()->getSignature(new User(WCF
::getUser()->userID
));
158 // show success message
159 WCF
::getTPL()->assign('success', true);