From: Matthias Schmidt Date: Mon, 18 Aug 2014 17:17:29 +0000 (+0200) Subject: Add IUserNotificationEvent::deleteNoAccessNotification() X-Git-Tag: 2.1.0_Alpha_1~434 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=08b99420abe3d7da1cc6dacacc68ff05c73c4c42;p=GitHub%2FWoltLab%2FWCF.git Add IUserNotificationEvent::deleteNoAccessNotification() --- diff --git a/wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php b/wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php index 2fafb9bc36..7138be36a9 100644 --- a/wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/UserNotificationHandler.class.php @@ -421,6 +421,17 @@ class UserNotificationHandler extends SingletonFactory { $notifications[] = $data; } + // check access + foreach ($notifications as $index => $notificationData) { + if (!$notificationData['event']->checkAccess()) { + if ($notificationData['event']->deleteNoAccessNotification()) { + $deleteNotifications[] = $notificationObjects[$notificationData['notificationID']]; + } + + unset($notifications[$index]); + } + } + if (!empty($deleteNotifications)) { $notificationAction = new UserNotificationAction($deleteNotifications, 'delete'); $notificationAction->executeAction(); @@ -429,13 +440,6 @@ class UserNotificationHandler extends SingletonFactory { UserStorageHandler::getInstance()->reset(array(WCF::getUser()->userID), 'userNotificationCount'); } - // check access - foreach ($notifications as $index => $notificationData) { - if (!$notificationData['event']->checkAccess()) { - unset($notifications[$index]); - } - } - return array( 'count' => count($notifications), 'notifications' => $notifications diff --git a/wcfsetup/install/files/lib/system/user/notification/event/AbstractUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/AbstractUserNotificationEvent.class.php index 46ae4eae46..fa010cb461 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/AbstractUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/AbstractUserNotificationEvent.class.php @@ -232,4 +232,11 @@ abstract class AbstractUserNotificationEvent extends DatabaseObjectDecorator imp public function checkAccess() { return true; } + + /** + * @see \wcf\system\user\notification\event\IUserNotificationEvent::deleteNoAccessNotification() + */ + public function deleteNoAccessNotification() { + return true; + } } diff --git a/wcfsetup/install/files/lib/system/user/notification/event/IUserNotificationEvent.class.php b/wcfsetup/install/files/lib/system/user/notification/event/IUserNotificationEvent.class.php index a52420d79a..4426d07cc9 100644 --- a/wcfsetup/install/files/lib/system/user/notification/event/IUserNotificationEvent.class.php +++ b/wcfsetup/install/files/lib/system/user/notification/event/IUserNotificationEvent.class.php @@ -133,4 +133,12 @@ interface IUserNotificationEvent extends IDatabaseObjectProcessor { * @return boolean */ public function checkAccess(); + + /** + * Returns true if a notification should be deleted if the related object + * is not accessible. + * + * @return boolean + */ + public function deleteNoAccessNotification(); }