0012428: Suppress resource notifictions should suppress ALL notifications
authorsstamer <s.stamer@metaways.de>
Tue, 13 Dec 2016 12:56:07 +0000 (13:56 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 14 Dec 2016 14:36:46 +0000 (15:36 +0100)
https://forge.tine20.org/view.php?id=12428

Change-Id: I4ca63c70dbe4663e21b0106e5bbebe6e93b7e14a
Reviewed-on: http://gerrit.tine20.com/customers/3960
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Tested-by: Jenkins CI (http://ci.tine20.com/)
tests/tine20/Calendar/Controller/EventNotificationsTests.php
tine20/Calendar/Controller/EventNotifications.php

index fe8a90e..514559d 100644 (file)
@@ -1354,9 +1354,10 @@ class Calendar_Controller_EventNotificationsTests extends Calendar_TestCase
         $messages = self::getMessages();
 
         if ($suppress_notification) {
-            $this->assertEquals(2, count($messages), 'two mails should be send to attender (invite) + resource');
+            $this->assertEquals(1, count($messages), 'one mail should be send to attender (invite sclever) ' . print_r($messages, true));
         } else {
-            $this->assertEquals(2, count($messages), 'two mails should be send to current user (resource + attender)');
+            $this->assertEquals(2, count($messages), 'two mails should be send (resource=pwulf + attender invite=sclever) '
+                . print_r($messages, true));
         }
     }
 
@@ -1404,14 +1405,13 @@ class Calendar_Controller_EventNotificationsTests extends Calendar_TestCase
 
         Tinebase_Container::getInstance()->setGrants($resource->container_id, $grants);
 
-        $this->assertContains('Resource "' . $persistentResource->name . '" was booked', print_r($messages, true));
-        $this->assertContains('Meeting Room (Required, No response)', print_r($messages, true));
-
         if ($suppress_notification) {
-            $this->assertEquals(2, count($messages), 'two mails should be send to current user (resource + attender)');
+            $this->assertEquals(1, count($messages), 'one mail should be send to current user (attender)');
         } else {
             $this->assertEquals(4, count($messages), 'four mails should be send to current user (resource + attender + everybody who is allowed to edit this resource)');
             $this->assertEquals(count($event->attendee), count($persistentEvent->attendee));
+            $this->assertContains('Resource "' . $persistentResource->name . '" was booked', print_r($messages, true));
+            $this->assertContains('Meeting Room (Required, No response)', print_r($messages, true));
         }
     }
 
@@ -1430,6 +1430,7 @@ class Calendar_Controller_EventNotificationsTests extends Calendar_TestCase
      */
     public function testResourceNotificationMuteForEditors()
     {
+        Calendar_Config::getInstance()->set(Calendar_Config::RESOURCE_MAIL_FOR_EDITORS, true);
         $this->testResourceNotification(/* $suppress_notification = */ true);
         $this->testResourceNotificationForGrantedUsers(/* $userIsAttendee = */ false, /* $suppress_notification = */ true);
     }
index 0b0f83a..6d95e4d 100644 (file)
             $calendarPart = null;
             $attachments = $this->_getAttachments($method, $_event, $_action, $_updater, $calendarPart);
             
-            if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " receiver: '{$_attender->getEmail()}'");
-            if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " subject: '$messageSubject'");
-            if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " body: $messageBody");
-
             $sender = $_action == 'alarm' ? $prefUser : $_updater;
-            Tinebase_Notification::getInstance()->send($sender, $recipients, $messageSubject, $messageBody, $calendarPart, $attachments);
+            if (!empty($recipients)) {
+                if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " receiver: " . count($recipients));
+                if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " subject: '$messageSubject'");
+                if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " body: $messageBody");
+                
+                Tinebase_Notification::getInstance()->send($sender, $recipients, $messageSubject, $messageBody, $calendarPart, $attachments);
+            }
         } catch (Exception $e) {
             Tinebase_Exception::log($e);
             return;
              if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
                      . " Do not send Notifications for this resource: ". $resource->name);
              // $recipients will still contain the resource itself
+             // Edit 13.12.2016 Remove resource as well and supress ALL notifications
+             $recipients = array();
              return true;
          }