From: Matthias Schmidt Date: Sat, 16 May 2015 08:43:36 +0000 (+0200) Subject: Add missing condition removal during object deletion X-Git-Tag: 2.1.4~7 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=021b7fb12e982fd6d5b6b0fb1cf6b92d3e5f18a8;p=GitHub%2FWoltLab%2FWCF.git Add missing condition removal during object deletion --- diff --git a/wcfsetup/install/files/lib/data/ad/AdAction.class.php b/wcfsetup/install/files/lib/data/ad/AdAction.class.php index 296451eed0..512eaf1956 100644 --- a/wcfsetup/install/files/lib/data/ad/AdAction.class.php +++ b/wcfsetup/install/files/lib/data/ad/AdAction.class.php @@ -3,6 +3,7 @@ namespace wcf\data\ad; use wcf\data\AbstractDatabaseObjectAction; use wcf\data\ISortableAction; use wcf\data\IToggleAction; +use wcf\system\condition\ConditionHandler; use wcf\system\exception\UserInputException; use wcf\system\WCF; @@ -49,6 +50,15 @@ class AdAction extends AbstractDatabaseObjectAction implements ISortableAction, return new Ad($ad->adID); } + /** + * @see \wcf\data\IDeleteAction::delete() + */ + public function delete() { + ConditionHandler::getInstance()->deleteConditions('com.woltlab.wcf.condition.ad', $this->objectIDs); + + return parent::delete(); + } + /** * @see \wcf\data\IToggleAction::toggle() */ diff --git a/wcfsetup/install/files/lib/data/notice/NoticeAction.class.php b/wcfsetup/install/files/lib/data/notice/NoticeAction.class.php index 6da91edb50..165ca3a3bc 100644 --- a/wcfsetup/install/files/lib/data/notice/NoticeAction.class.php +++ b/wcfsetup/install/files/lib/data/notice/NoticeAction.class.php @@ -3,6 +3,7 @@ namespace wcf\data\notice; use wcf\data\AbstractDatabaseObjectAction; use wcf\data\ISortableAction; use wcf\data\IToggleAction; +use wcf\system\condition\ConditionHandler; use wcf\system\exception\UserInputException; use wcf\system\user\storage\UserStorageHandler; use wcf\system\WCF; @@ -55,6 +56,15 @@ class NoticeAction extends AbstractDatabaseObjectAction implements ISortableActi return new Notice($notice->noticeID); } + /** + * @see \wcf\data\IDeleteAction::delete() + */ + public function delete() { + ConditionHandler::getInstance()->deleteConditions('com.woltlab.wcf.condition.notice', $this->objectIDs); + + return parent::delete(); + } + /** * Dismisses a certain notice. * diff --git a/wcfsetup/install/files/lib/data/user/group/assignment/UserGroupAssignmentAction.class.php b/wcfsetup/install/files/lib/data/user/group/assignment/UserGroupAssignmentAction.class.php index 12ef8c8c3f..c31bd8f8d9 100644 --- a/wcfsetup/install/files/lib/data/user/group/assignment/UserGroupAssignmentAction.class.php +++ b/wcfsetup/install/files/lib/data/user/group/assignment/UserGroupAssignmentAction.class.php @@ -2,6 +2,7 @@ namespace wcf\data\user\group\assignment; use wcf\data\AbstractDatabaseObjectAction; use wcf\data\IToggleAction; +use wcf\system\condition\ConditionHandler; /** * Executes user group assignment-related actions. @@ -29,6 +30,15 @@ class UserGroupAssignmentAction extends AbstractDatabaseObjectAction implements */ protected $requireACP = array('create', 'delete', 'toggle', 'update'); + /** + * @see \wcf\data\IDeleteAction::delete() + */ + public function delete() { + ConditionHandler::getInstance()->deleteConditions('com.woltlab.wcf.condition.userGroupAssignment', $this->objectIDs); + + return parent::delete(); + } + /** * @see \wcf\data\IToggleAction::toggle() */ diff --git a/wcfsetup/install/files/lib/system/condition/ConditionHandler.class.php b/wcfsetup/install/files/lib/system/condition/ConditionHandler.class.php index e21140cdfe..2b61e2d2a1 100644 --- a/wcfsetup/install/files/lib/system/condition/ConditionHandler.class.php +++ b/wcfsetup/install/files/lib/system/condition/ConditionHandler.class.php @@ -1,6 +1,7 @@ $objectID + */ + public function deleteConditions($definitionName, array $objectID) { + if (empty($objectID)) return; + + $definition = ObjectTypeCache::getInstance()->getDefinitionByName($definitionName); + if ($definition === null) { + throw new SystemException("Unknown object type definition with name '".$definitionName."'"); + } + + $objectTypes = ObjectTypeCache::getInstance()->getObjectTypes($definitionName); + $objectTypeIDs = array(); + foreach ($objectTypes as $objectType) { + $objectTypeIDs[] = $objectType->objectTypeID; + } + + if (empty($objectTypeIDs)) return; + + $conditionList = new ConditionList(); + $conditionList->getConditionBuilder()->add('objectTypeID IN (?)', array($objectTypeIDs)); + $conditionList->getConditionBuilder()->add('objectID IN (?)', array($objectID)); + $conditionList->readObjects(); + + if (count($conditionList)) { + $conditionAction = new ConditionAction($conditionList->getObjects(), 'delete'); + $conditionAction->executeAction(); + } + } + /** * Returns the conditions for the conditioned object with the given condition * object type definition and object id.