Reset user notification count when removing notifications
authorMatthias Schmidt <gravatronics@live.com>
Sun, 27 Jul 2014 12:21:18 +0000 (14:21 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 27 Jul 2014 12:21:18 +0000 (14:21 +0200)
wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php

index a4c6cb69ee68d71d8a67c5115e69b226a3bdcee5..878adb17cb09701b93997e8aede03fe0f981a482 100644 (file)
@@ -614,6 +614,23 @@ class UserNotificationHandler extends SingletonFactory {
                        $conditions->add("eventID IN (?)", array($eventIDs));
                        $conditions->add("objectID IN (?)", array($objectIDs));
                        
+                       $sql = "SELECT  userID
+                               FROM    wcf".WCF_N."_user_notification
+                               ".$conditions;
+                       $statement = WCF::getDB()->prepareStatement($sql);
+                       $statement->execute($conditions->getParameters());
+                       
+                       $userIDs = array();
+                       while ($userID = $statement->fetchColumn()) {
+                               $userIDs[] = $userID;
+                       }
+                       
+                       // reset number of notifications
+                       if (!empty($userIDs)) {
+                               UserStorageHandler::getInstance()->reset($userIDs, 'userNotificationCount');
+                       }
+                       
+                       // delete notifications
                        $sql = "DELETE FROM     wcf".WCF_N."_user_notification
                                ".$conditions;
                        $statement = WCF::getDB()->prepareStatement($sql);