From: Matthias Schmidt Date: Wed, 31 Dec 2014 16:09:49 +0000 (+0100) Subject: Add UserCollapsibleContentHandler::resetAll() X-Git-Tag: 2.1.0_Beta_3~46^2~5 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=fc521fb9d5d9c78129889ad0960a05da7ee8a02d;p=GitHub%2FWoltLab%2FWCF.git Add UserCollapsibleContentHandler::resetAll() --- diff --git a/wcfsetup/install/files/lib/system/user/collapsible/content/UserCollapsibleContentHandler.class.php b/wcfsetup/install/files/lib/system/user/collapsible/content/UserCollapsibleContentHandler.class.php index b40104df37..b949f0d282 100644 --- a/wcfsetup/install/files/lib/system/user/collapsible/content/UserCollapsibleContentHandler.class.php +++ b/wcfsetup/install/files/lib/system/user/collapsible/content/UserCollapsibleContentHandler.class.php @@ -1,6 +1,7 @@ register('collapsedContent', $collapsedContent); } } + + /** + * Deletes the saved states for a specific object or all objects of a + * specific object type for all users. + * + * @param string $objectType + * @param integer $objectID + */ + public function resetAll($objectType, $objectID = null) { + $objectTypeID = $this->getObjectTypeID($objectType); + if (!$objectTypeID) { + throw new SystemException("Unknown collapsible object type '".$objectType."'"); + } + + $conditionBuilder = new PreparedStatementConditionBuilder(); + $conditionBuilder->add('objectTypeID = ?', array($objectTypeID)); + if ($objectID) { + $conditionBuilder->add('objectID = ?', array($objectID)); + } + + $sql = "DELETE FROM wcf".WCF_N."_user_collapsible_content + ".$conditionBuilder; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute($conditionBuilder->getParameters()); + + UserStorageHandler::getInstance()->resetAll('collapsedContent-'.$objectTypeID); + } }