* Executes category-related actions.
*
* @author Matthias Schmidt
- * @copyright 2001-2014 WoltLab GmbH
+ * @copyright 2001-2015 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage data.category
}
parent::update();
+
+ if ($this->parameters['data']['parentCategoryID']) {
+ $objectType = null;
+ $parentUpdates = array();
+
+ foreach ($this->objects as $category) {
+ if ($objectType === null) {
+ $objectType = $category->getObjectType();
+ }
+
+ if ($category->parentCategoryID != $this->parameters['data']['parentCategoryID']) {
+ $parentUpdates[$categoryID] = array(
+ 'oldParentCategoryID' => $category->parentCategoryID,
+ 'newParentCategoryID' => $this->parameters['data']['parentCategoryID']
+ );
+ }
+ }
+
+ if (!empty($parentUpdates)) {
+ $objectType->getProcessor()->changedParentCategories($parentUpdates);
+ }
+ }
}
/**
* @see \wcf\data\ISortableAction::updatePosition()
*/
public function updatePosition() {
+ $objectType = null;
+ $parentUpdates = array();
+
WCF::getDB()->beginTransaction();
foreach ($this->parameters['data']['structure'] as $parentCategoryID => $categoryIDs) {
$showOrder = 1;
foreach ($categoryIDs as $categoryID) {
+ $category = CategoryHandler::getInstance()->getCategory($categoryID);
+ if ($objectType === null) {
+ $objectType = $category->getObjectType();
+ }
+
+ if ($category->parentCategoryID != $parentCategoryID) {
+ $parentUpdates[$categoryID] = array(
+ 'oldParentCategoryID' => $category->parentCategoryID,
+ 'newParentCategoryID' => $parentCategoryID
+ );
+ }
+
$this->objects[$categoryID]->update(array(
'parentCategoryID' => $parentCategoryID ? $this->objects[$parentCategoryID]->categoryID : 0,
'showOrder' => $showOrder++
}
}
WCF::getDB()->commitTransaction();
+
+ if (!empty($parentUpdates)) {
+ $objectType->getProcessor()->changedParentCategories($parentUpdates);
+ }
}
/**
* Abstract implementation of a category type.
*
* @author Matthias Schmidt
- * @copyright 2001-2014 WoltLab GmbH
+ * @copyright 2001-2015 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.category
return WCF::getSession()->getPermission($this->permissionPrefix.'.canEditCategory');
}
+ /**
+ * @see \wcf\system\category\ICategoryType::changedParentCategories()
+ */
+ public function changedParentCategories(array $categoryData) {
+ // does nothing
+ }
+
/**
* @see \wcf\system\category\ICategoryType::forceDescription()
*/
* Every category type has to implement this interface.
*
* @author Matthias Schmidt
- * @copyright 2001-2014 WoltLab GmbH
+ * @copyright 2001-2015 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @package com.woltlab.wcf
* @subpackage system.category
*/
public function canEditCategory();
+ /**
+ * Is called after categories were assigned different parent categories.
+ *
+ * Array structure:
+ * [
+ * categoryID => [
+ * oldParentCategoryID => 1,
+ * newParentCategoryID => 2
+ * ],
+ * categoryID => [
+ * oldParentCategoryID => null,
+ * newParentCategoryID => 2
+ * ],
+ * ]
+ */
+ public function changedParentCategories(array $categoryData);
+
/**
* Returns true if a category of this type may have no empty description.
*