'smileyCode' => $this->smileyCode,
'showOrder' => $this->showOrder,
'categoryID' => $this->categoryID ?: null,
- 'packageID' => PackageCache::getInstance()->getPackageID('com.woltlab.wcf.bbcode'),
+ 'packageID' => 1,
'aliases' => $this->aliases
)
));
$smileyID = $returnValues['returnValues']->smileyID;
if (!I18nHandler::getInstance()->isPlainValue('smileyTitle')) {
- I18nHandler::getInstance()->save('smileyTitle', 'wcf.smiley.title'.$smileyID, 'wcf.smiley', PackageCache::getInstance()->getPackageID('com.woltlab.wcf.bbcode'));
+ I18nHandler::getInstance()->save('smileyTitle', 'wcf.smiley.title'.$smileyID, 'wcf.smiley', 1);
// update title
$smileyEditor->update(array(
throw new UserInputException('smileyTitle');
}
- if ($this->categoryID !== 0) {
+ if ($this->categoryID) {
$category = new Category($this->categoryID);
if (!$category->categoryID) {
throw new UserInputException('categoryID', 'notValid');
}
}
- if ($this->smileyCode === '') {
+ if (empty($this->smileyCode)) {
throw new UserInputException('smileyCode');
}
- // TODO: Validate uniqueness of smileyCode and aliases
+ // validate smiley code and aliases against existing smilies
+ $sql = "SELECT smileyCode, aliases
+ FROM wcf".WCF_N."_smiley";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute();
+
+ $aliases = explode("\n", $this->aliases);
+ while ($row = $statement->fetchArray()) {
+ $known = array();
+ if (!empty($row['aliases'])) {
+ $known = explode("\n", $row['aliases']);
+ }
+ $known[] = $row['smileyCode'];
+
+ if (in_array($this->smileyCode, $known)) {
+ throw new UserInputException('smileyCode', 'notUnique');
+ }
+ else {
+ $conflicts = array_intersect($aliases, $known);
+ if (!empty($conflicts)) {
+ throw new UserInputException('aliases', 'notUnique');
+ }
+ }
+ }
}
}
<item name="wcf.acp.smiley.categoryID.default"><![CDATA[Standard-Kategorie]]></item>
<item name="wcf.acp.smiley.categoryID.error.notValid"><![CDATA[Die gewählte Kategorie ist nicht gültig.]]></item>
<item name="wcf.acp.smiley.smileyCode"><![CDATA[Primärer Smiley-Code]]></item>
+ <item name="wcf.acp.smiley.smileyCode.error.notUnique"><![CDATA[Dieser Smiley-Code wird bereits von einem anderen Smiley verwendet]]></item>
<item name="wcf.acp.smiley.aliases"><![CDATA[Alternative Smiley-Codes]]></item>
+ <item name="wcf.acp.smiley.aliases.error.notUnique"><![CDATA[Mindestens ein alternative Smiley-Code wird bereits von einem anderen Smiley verwendet]]></item>
<item name="wcf.acp.smiley.showOrder"><![CDATA[Position]]></item>
</category>
<item name="wcf.acp.smiley.categoryID.default"><![CDATA[Default Category]]></item>
<item name="wcf.acp.smiley.categoryID.error.notValid"><![CDATA[Chosen category is invalid.]]></item>
<item name="wcf.acp.smiley.smileyCode"><![CDATA[Primary Smiley Code]]></item>
+ <item name="wcf.acp.smiley.smileyCode.error.notUnique"><![CDATA[This smiley code is already in use by an other smiley]]></item>
<item name="wcf.acp.smiley.aliases"><![CDATA[Alternative Smiley Codes]]></item>
+ <item name="wcf.acp.smiley.aliases.error.notUnique"><![CDATA[At least one alternative smiley code is already in use by an other smiley]]></item>
<item name="wcf.acp.smiley.showOrder"><![CDATA[Show Order]]></item>
</category>