0010454: cli script for comparing calendars
authorPhilipp Schüle <p.schuele@metaways.de>
Fri, 14 Nov 2014 11:17:08 +0000 (12:17 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Fri, 14 Nov 2014 13:17:52 +0000 (14:17 +0100)
* ignore events only in displaycontainer

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

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

index e88d4f2..aafa94b 100644 (file)
@@ -1405,6 +1405,7 @@ class Calendar_Controller_EventTests extends Calendar_TestCase
      * - event3+4: in both calendars
      * - event5: slightly different from event1 (same summary) / in cal2
      * - event6: only in cal1 (next week)
+     * - event7: only in displaycontainer
      * 
      * @param Tinebase_Model_Container $cal1
      * @param Tinebase_Model_Container $cal2
@@ -1444,6 +1445,25 @@ class Calendar_Controller_EventTests extends Calendar_TestCase
         $event6->dtstart->addDay(8);
         $event6->dtend->addDay(8);
         $this->_controller->create($event6);
+        
+        // add event that is only in displaycontainer (should not appear in report)
+        $currentDefault = Tinebase_Core::getPreference('Calendar')->getValueForUser(Calendar_Preference::DEFAULTCALENDAR, Tinebase_Core::getUser()->getId());
+        Tinebase_Core::getPreference('Calendar')->setValue(Calendar_Preference::DEFAULTCALENDAR, $cal1->getId());
+        $event7 = $this->_getEvent(true);
+        $event7->summary = 'event 7';
+        $event7->attendee = new Tinebase_Record_RecordSet('Calendar_Model_Attender', array(
+            array(
+                'user_id'   => Tinebase_Core::getUser()->contact_id,
+                'user_type' => Calendar_Model_Attender::USERTYPE_USER,
+                'role'      => Calendar_Model_Attender::ROLE_REQUIRED,
+            ),
+        ));
+        Tinebase_Core::set(Tinebase_Core::USER, $this->_personas['sclever']);
+        $cal3 = $this->_getTestContainer('Calendar');
+        $event7->container_id = $cal3->getId();
+        $this->_controller->create($event7);
+        Tinebase_Core::set(Tinebase_Core::USER, $this->_originalTestUser);
+        Tinebase_Core::getPreference('Calendar')->setValue(Calendar_Preference::DEFAULTCALENDAR, $currentDefault);
     }
     
     public function testRepairAttendee()
index 1d6a2c5..97abdc3 100644 (file)
@@ -2266,6 +2266,13 @@ class Calendar_Controller_Event extends Tinebase_Controller_Record_Abstract impl
                 if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
                     . ' Checking event "' . $event->summary . '" ' . $event->dtstart . ' - ' . $event->dtend);
                 
+                if ($event->container_id != $cal1) {
+                    if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
+                            . ' Event is in another calendar - skip');
+                    $cal1Events->removeRecord($event);
+                    continue;
+                }
+                
                 $summaryMatch = $cal2Events->filter('summary', $event->summary);
                 if (count($summaryMatch) > 0) {
                     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
@@ -2300,6 +2307,12 @@ class Calendar_Controller_Event extends Tinebase_Controller_Record_Abstract impl
                 if (in_array($event->getId(), $cal2EventIdsAlreadyProcessed)) {
                     continue;
                 }
+                if ($event->container_id != $cal2) {
+                    if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__
+                            . ' Event is in another calendar - skip');
+                    continue;
+                }
+                
                 $missingEventsInCal1->addRecord($event);
             }
         }