Update AbstractUserNotificationEvent.class.php
authormichel160 <f.warneke@t-online.de>
Tue, 20 Aug 2013 22:39:09 +0000 (00:39 +0200)
committermichel160 <f.warneke@t-online.de>
Tue, 20 Aug 2013 22:39:09 +0000 (00:39 +0200)
Permissions and options for events should be evaluated by default (may be overwritten by derived classes)

Currently notification settings for conversations are displayed even if module is disabled (not to speak about problems with my own optional notifications)

wcfsetup/install/files/lib/system/user/notification/event/AbstractUserNotificationEvent.class.php

index d5f9c9749901af2554d1dc918bc5c3cb90007969..39e1ce5191439e4f8f702da4c280dd8e266884dd 100644 (file)
@@ -82,6 +82,30 @@ abstract class AbstractUserNotificationEvent extends DatabaseObjectDecorator imp
         * @see wcf\system\user\notification\event\IUserNotificationEvent::isVisible()
         */
        public function isVisible() {
+               if ($this->options) {
+                       $hasEnabledOption = false;
+                       $options = explode(',', strtoupper($this->options));
+                       foreach ($options as $option) {
+                               if (defined($option) && constant($option)) {
+                                       $hasEnabledOption = true;
+                                       break;
+                               }
+                       }
+                       if (!$hasEnabledOption) return false;
+               }
+               
+               $hasPermission = true;
+               if ($this->permissions) {
+                       $hasPermission = false;
+                       $permissions = explode(',', $this->permissions);
+                       foreach ($permissions as $permission) {
+                               if (WCF::getSession()->getPermission($permission)) {
+                                       $hasPermission = true;
+                               break;
+                               }
+                       }
+               }
+               if (!$hasPermission) return false;
                return true;
        }