Updated signature implementation
authorAlexander Ebert <ebert@woltlab.com>
Tue, 19 Jul 2016 11:17:22 +0000 (13:17 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 19 Jul 2016 11:17:22 +0000 (13:17 +0200)
wcfsetup/install/files/lib/form/SignatureEditForm.class.php
wcfsetup/install/files/lib/system/user/signature/SignatureCache.class.php
wcfsetup/setup/db/install.sql

index 61920f643f9b6d8f0ed7fb01cfecb3aa145f10e9..ece637f04fedaa040eb17b64c695ae81cb007574 100644 (file)
@@ -35,28 +35,14 @@ class SignatureEditForm extends MessageForm {
         * parsed signature cache
         * @var string
         */
-       public $signatureCache = null;
+       public $signatureCache;
        
        /**
+        * TODO: this is still missing
         * @inheritDoc
         */
        public $allowedBBCodesPermission = 'user.signature.allowedBBCodes';
        
-       /**
-        * @inheritDoc
-        */
-       public $permissionCanUseSmilies = 'user.signature.canUseSmilies';
-       
-       /**
-        * @inheritDoc
-        */
-       public $permissionCanUseHtml = 'user.signature.canUseHtml';
-       
-       /**
-        * @inheritDoc
-        */
-       public $permissionCanUseBBCodes = 'user.signature.canUseBBCodes';
-       
        /**
         * @inheritDoc
         */
@@ -93,11 +79,7 @@ class SignatureEditForm extends MessageForm {
                
                // default values
                if (empty($_POST)) {
-                       $this->enableBBCodes = WCF::getUser()->signatureEnableBBCodes;
-                       $this->enableHtml = WCF::getUser()->signatureEnableHtml;
-                       $this->enableSmilies = WCF::getUser()->signatureEnableSmilies;
                        $this->text = WCF::getUser()->signature;
-                       $this->preParse = true;
                }
                
                $this->signatureCache = SignatureCache::getInstance()->getSignature(WCF::getUser());
@@ -132,10 +114,8 @@ class SignatureEditForm extends MessageForm {
                
                $this->objectAction = new UserAction([WCF::getUser()], 'update', [
                        'data' => array_merge($this->additionalFields, [
-                               'signature' => $this->text,
-                               'signatureEnableBBCodes' => $this->enableBBCodes,
-                               'signatureEnableHtml' => $this->enableHtml,
-                               'signatureEnableSmilies' => $this->enableSmilies
+                               'signature' => $this->htmlInputProcessor->getHtml(),
+                               'signatureEnableHtml' => 1
                        ])
                ]);
                $this->objectAction->executeAction();
index 6ee773deecb973c9b1c305940c736c4a441e4113..1e1dc6e7fd79504055a268fcc13f33db2cca3051 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 namespace wcf\system\user\signature;
 use wcf\data\user\User;
-use wcf\system\bbcode\MessageParser;
+use wcf\system\html\output\HtmlOutputProcessor;
 use wcf\system\SingletonFactory;
 
 /**
@@ -13,6 +13,11 @@ use wcf\system\SingletonFactory;
  * @package    WoltLabSuite\Core\System\User\Signature
  */
 class SignatureCache extends SingletonFactory {
+       /**
+        * @var HtmlOutputProcessor
+        */
+       protected $htmlOutputProcessor;
+       
        /**
         * cached signatures
         * @var string
@@ -22,12 +27,17 @@ class SignatureCache extends SingletonFactory {
        /**
         * Returns a parsed user signature.
         * 
-        * @param       \wcf\data\user\User     $user
-        * @return      string
+        * @param       User            $user           user object
+        * @return      string          parsed signature
         */
        public function getSignature(User $user) {
                if (!isset($this->signatures[$user->userID])) {
-                       $this->signatures[$user->userID] = MessageParser::getInstance()->parse($user->signature, $user->signatureEnableSmilies, $user->signatureEnableHtml, $user->signatureEnableBBCodes, false);
+                       if ($this->htmlOutputProcessor === null) {
+                               $this->htmlOutputProcessor = new HtmlOutputProcessor();
+                       }
+                       
+                       $this->htmlOutputProcessor->process($user->signature, 'com.woltlab.wcf.userSignature', $user->userID);
+                       $this->signatures[$user->userID] = $this->htmlOutputProcessor->getHtml();
                }
                
                return $this->signatures[$user->userID];
index ec3def57231746f518d77aaf7ba01aa8af02c14c..772844eb003ede725ac67f20d1a3f215e1aa76fc 100644 (file)
@@ -1287,9 +1287,7 @@ CREATE TABLE wcf1_user (
        enableGravatar TINYINT(1) NOT NULL DEFAULT 0,
        gravatarFileExtension VARCHAR(3) NOT NULL DEFAULT '',
        signature TEXT,
-       signatureEnableBBCodes TINYINT(1) NOT NULL DEFAULT 1,
        signatureEnableHtml TINYINT(1) NOT NULL DEFAULT 0,
-       signatureEnableSmilies TINYINT(1) NOT NULL DEFAULT 1,
        disableSignature TINYINT(1) NOT NULL DEFAULT 0,
        disableSignatureReason TEXT,
        disableSignatureExpires INT(10) NOT NULL DEFAULT 0,