ShowOrderFormField::create()
->description('wcf.acp.reactionType.showOrder.description')
->required()
- ->options(new ReactionTypeList()),
+ ->options(function () {
+ $list = new ReactionTypeList();
+ $list->sqlOrderBy = 'showOrder ASC';
+ $list->readObjects();
+
+ $returnValues = [];
+
+ foreach ($list as $reactionType) {
+ $returnValues[$reactionType->showOrder + 1] = $reactionType->getTitle();
+ }
+
+ return $returnValues;
+
+ }),
IsDisabledFormField::create()
->label('wcf.acp.reactionType.isDisabled')
]);
* @inheritDoc
*/
public function create() {
+ if (isset($this->parameters['data']['showOrder']) && $this->parameters['data']['showOrder'] !== null) {
+ $sql = "UPDATE wcf" . WCF_N . "_reaction_type
+ SET showOrder = showOrder + 1
+ WHERE showOrder >= ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute([
+ $this->parameters['data']['showOrder']
+ ]);
+ }
+
/** @var ReactionType $reactionType */
$reactionType = parent::create();
$reactionTypeEditor = new ReactionTypeEditor($reactionType);
}
}
+ // update show order
+ if (isset($this->parameters['data']['showOrder']) && $this->parameters['data']['showOrder'] !== null) {
+ $sql = "UPDATE wcf" . WCF_N . "_reaction_type
+ SET showOrder = showOrder + 1
+ WHERE showOrder >= ?
+ AND reactionTypeID <> ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute([
+ $this->parameters['data']['showOrder'],
+ $object->reactionTypeID
+ ]);
+
+ $sql = "UPDATE wcf" . WCF_N . "_reaction_type
+ SET showOrder = showOrder - 1
+ WHERE showOrder >= ?";
+ $statement = WCF::getDB()->prepareStatement($sql);
+ $statement->execute([
+ $object->showOrder
+ ]);
+ }
+
if (!empty($updateData)) {
$object->update($updateData);
}