Restruct showOrder after object deletion
authorJoshua Rüsweg <ruesweg@woltlab.com>
Sun, 12 May 2019 15:24:06 +0000 (17:24 +0200)
committerJoshua Rüsweg <ruesweg@woltlab.com>
Sun, 12 May 2019 15:24:06 +0000 (17:24 +0200)
See #2508

wcfsetup/install/files/lib/data/reaction/type/ReactionTypeAction.class.php

index 67262a9e1e397d425d65609a4b50e3350ff327d7..3bdae6773ca02138ceb0ada36718a056d92435ca 100644 (file)
@@ -203,4 +203,23 @@ class ReactionTypeAction extends AbstractDatabaseObjectAction implements ISortab
                }
                WCF::getDB()->commitTransaction();
        }
+       
+       /**
+        * @inheritDoc
+        */
+       public function delete() {
+               $returnValues = parent::delete();
+               
+               $sql = "UPDATE  wcf" . WCF_N . "_reaction_type
+                               SET     showOrder = showOrder - 1
+                               WHERE   showOrder > ?";
+               $statement = WCF::getDB()->prepareStatement($sql);
+               foreach ($this->getObjects() as $object) {
+                       $statement->execute([
+                               $object->showOrder
+                       ]);
+               }
+               
+               return $returnValues;
+       }
 }