From: Marcel Werk Date: Tue, 15 Nov 2011 16:28:49 +0000 (+0100) Subject: Added reset method for collapsible handler X-Git-Tag: 2.0.0_Beta_1~1598 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e57b56a40f88c20f44695f872a6fe890175a5acb;p=GitHub%2FWoltLab%2FWCF.git Added reset method for collapsible handler --- 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); + } + } }