From fc521fb9d5d9c78129889ad0960a05da7ee8a02d Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Wed, 31 Dec 2014 17:09:49 +0100 Subject: [PATCH] Add UserCollapsibleContentHandler::resetAll() --- .../UserCollapsibleContentHandler.class.php | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) 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); + } } -- 2.20.1