Fix validation of uniqueness of smiley codes
authorTim Düsterhus <duesterhus@woltlab.com>
Fri, 24 May 2013 19:36:12 +0000 (21:36 +0200)
committerTim Düsterhus <duesterhus@woltlab.com>
Fri, 24 May 2013 19:36:12 +0000 (21:36 +0200)
wcfsetup/install/files/lib/acp/form/SmileyAddForm.class.php

index 9ab70371e6f41d332b58dcf7ae5d3495a4e7f840..10a0dbd7000bddd3a86fb6b3110c35e87e586a27 100644 (file)
@@ -6,6 +6,7 @@ use wcf\data\package\PackageCache;
 use wcf\data\smiley\SmileyAction;
 use wcf\data\smiley\SmileyEditor;
 use wcf\form\AbstractForm;
+use wcf\system\database\util\PreparedStatementConditionBuilder;
 use wcf\system\exception\UserInputException;
 use wcf\system\language\I18nHandler;
 use wcf\system\WCF;
@@ -201,10 +202,15 @@ class SmileyAddForm extends AbstractForm {
                }
                
                // validate smiley code and aliases against existing smilies
+               $conditionBuilder = new PreparedStatementConditionBuilder();
+               if (isset($this->smiley)) {
+                       $conditionBuilder->add('smileyID <> ?', array($this->smiley->smileyID));
+               }
                $sql = "SELECT  smileyCode, aliases
-                       FROM    wcf".WCF_N."_smiley";
+                       FROM    wcf".WCF_N."_smiley
+                       ".$conditionBuilder;
                $statement = WCF::getDB()->prepareStatement($sql);
-               $statement->execute();
+               $statement->execute($conditionBuilder->getParameters());
                
                $aliases = explode("\n", $this->aliases);
                while ($row = $statement->fetchArray()) {