Added reset method for collapsible handler
authorMarcel Werk <burntime@woltlab.com>
Tue, 15 Nov 2011 16:28:49 +0000 (17:28 +0100)
committerMarcel Werk <burntime@woltlab.com>
Tue, 15 Nov 2011 16:28:49 +0000 (17:28 +0100)
wcfsetup/install/files/lib/system/user/collapsible/content/UserCollapsibleContentHandler.class.php

index 6463bf8c16922e050d41035d5e99b0dc10a6787a..4337b965fe5a3637ffea02538ff2c1806115a0a8 100644 (file)
@@ -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);
+               }
+       }
 }