}
}
+ /**
+ * @see \wcf\data\AbstractDatabaseObjectAction::update()
+ */
+ public function update() {
+ // check if showOrder needs to be recalculated
+ if (count($this->objects) == 1 && isset($this->parameters['data']['parentCategoryID']) && isset($this->parameters['data']['showOrder'])) {
+ if ($this->objects[0]->parentCategoryID != $this->parameters['data']['parentCategoryID'] || $this->objects[0]->showOrder != $this->parameters['data']['showOrder']) {
+ $this->parameters['data']['showOrder'] = $this->objects[0]->updateShowOrder($this->parameters['data']['parentCategoryID'], $this->parameters['data']['showOrder']);
+ }
+ }
+
+ parent::update();
+ }
+
/**
* @see \wcf\data\ISortableAction::updatePosition()
*/
public function updatePosition() {
- $showOrders = array();
-
WCF::getDB()->beginTransaction();
foreach ($this->parameters['data']['structure'] as $parentCategoryID => $categoryIDs) {
- if (!isset($showOrders[$parentCategoryID])) {
- $showOrders[$parentCategoryID] = 1;
- }
-
+ $showOrder = 1;
foreach ($categoryIDs as $categoryID) {
$this->objects[$categoryID]->update(array(
'parentCategoryID' => $parentCategoryID ? $this->objects[$parentCategoryID]->categoryID : 0,
- 'showOrder' => $showOrders[$parentCategoryID]++
+ 'showOrder' => $showOrder++
));
}
}
*/
protected static $baseClass = 'wcf\data\category\Category';
- /**
- * @see \wcf\data\IEditableObject::update()
- */
- public function update(array $parameters = array()) {
- // update show order
- if (isset($parameters['parentCategoryID']) || isset($parameters['showOrder'])) {
- if (!isset($parameters['parentCategoryID'])) {
- $parameters['parentCategoryID'] = $this->parentCategoryID;
- }
-
- if (!isset($parameters['showOrder'])) {
- $parameters['showOrder'] = $this->showOrder;
- }
-
- $parameters['showOrder'] = $this->updateShowOrder($parameters['parentCategoryID'], $parameters['showOrder']);
- }
-
- parent::update($parameters);
- }
-
/**
* Prepares the update of the show order of this category and return the
* correct new show order.