0011460: group attendee notifications raise error
authorsstamer <s.stamer@metaways.de>
Thu, 19 Nov 2015 13:58:06 +0000 (14:58 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 3 Dec 2015 12:01:38 +0000 (13:01 +0100)
* adds a test
* prevent sending of notifications to Adb Lists

https://forge.tine20.org/view.php?id=11460

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

index cd07b16..8b1c92b 100644 (file)
@@ -1361,4 +1361,32 @@ class Calendar_Controller_EventNotificationsTests extends Calendar_TestCase
         $this->assertEquals(4, count($messages), 'four mails should be send to current user (resource + attender + everybody whos allowed to edit this resource)');
         $this->assertEquals(3, count($persistentEvent->attendee));
     }
+    
+    /**
+     * testGroupInvitation
+     */
+    public function testGroupInvitation()
+    {
+        $defaultUserGroup = Tinebase_Group::getInstance()->getDefaultGroup();
+        
+        $event = $this->_getEvent(TRUE);
+        
+        $event->attendee = $this->_getAttendee();
+        $event->attendee[1] = new Calendar_Model_Attender(array(
+                'user_id'   => $defaultUserGroup->getId(),
+                'user_type' => Calendar_Model_Attender::USERTYPE_GROUP,
+                'role'      => Calendar_Model_Attender::ROLE_REQUIRED
+        ));
+        
+        self::flushMailer();
+        $persistentEvent = $this->_eventController->create($event);
+        $this->_assertMail('jsmith', NULL);
+        $this->_assertMail('pwulf, sclever, jmcblack, rwright', 'invit');
+        
+        self::flushMailer();
+         
+        $persistentEvent = $this->_eventController->delete($persistentEvent);
+        $this->_assertMail('jsmith', NULL);
+        $this->_assertMail('pwulf, sclever, jmcblack, rwright', 'cancel');
+    }
 }
index ddd6804..e3d0d1f 100644 (file)
             $organizer = $_event->resolveOrganizer();
             $organizerAccountId = $organizer->account_id;
             $attendee = $_attender->getResolvedUser();
+
+            if ($attendee instanceof Addressbook_Model_List) {
+                // don't send notification to lists as we already resolved the list members for individual mails
+                if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
+                    . " Skip notification for list " . $attendee->name);
+                return;
+            }
+
             $attendeeAccountId = $_attender->getUserAccountId();
             
             $prefUserId = $attendeeAccountId ? $attendeeAccountId :
             }
             
             // check if user wants this notification NOTE: organizer gets mails unless she set notificationlevel to NONE
-            // NOTE prefUser is organzier for external notifications
+            // NOTE prefUser is organizer for external notifications
             if (($attendeeAccountId == $_updater->getId() && ! $sendOnOwnActions) 
                 || ($sendLevel < $_notificationLevel && (
                         ((is_object($organizer) && method_exists($attendee, 'getPreferedEmailAddress') && $attendee->getPreferedEmailAddress() != $organizer->getPreferedEmailAddress())