From e57b56a40f88c20f44695f872a6fe890175a5acb Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Tue, 15 Nov 2011 17:28:49 +0100 Subject: [PATCH] Added reset method for collapsible handler --- .../UserCollapsibleContentHandler.class.php | 30 +++++++++++++++++++ 1 file changed, 30 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 6463bf8c16..4337b965fe 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 @@ -179,4 +179,34 @@ class UserCollapsibleContentHandler extends SingletonFactory { WCF::getSession()->register('collapsedContent', $collapsedContent); } } + + /** + * Deletes all saved states for a specific object type. + * + * @param integer $objectTypeID + */ + public function reset($objectTypeID) { + if (WCF::getUser()->userID) { + $sql = "DELETE FROM wcf".WCF_N."_user_collapsible_content + WHERE objectTypeID = ? + AND userID = ?"; + $statement = WCF::getDB()->prepareStatement($sql); + $statement->execute(array( + $objectTypeID, + WCF::getUser()->userID + )); + } + else { + $collapsedContent = WCF::getSession()->getVar('collapsedContent'); + if ($collapsedContent === null || !is_array($collapsedContent)) { + $collapsedContent = array(); + } + + if (isset($collapsedContent[$objectTypeID])) { + unset($collapsedContent[$objectTypeID]); + } + + WCF::getSession()->register('collapsedContent', $collapsedContent); + } + } } -- 2.20.1