Merge branch '2013.03' into 2013.10
authorPhilipp Schüle <p.schuele@metaways.de>
Thu, 9 Jan 2014 14:20:41 +0000 (15:20 +0100)
committerPhilipp Schüle <p.schuele@metaways.de>
Thu, 9 Jan 2014 14:20:41 +0000 (15:20 +0100)
Conflicts:
tests/tine20/Calendar/Controller/MSEventFacadeTest.php
tests/tine20/Calendar/TestCase.php
tine20/Calendar/Controller/MSEventFacade.php
tine20/Calendar/Convert/Event/VCalendar/Abstract.php
tine20/Tinebase/ActionQueue.php
tine20/Tinebase/js/widgets/form/RecordPickerComboBox.js

1  2 
tests/tine20/Calendar/Controller/MSEventFacadeTest.php
tests/tine20/Calendar/TestCase.php
tine20/Calendar/Controller/Event.php
tine20/Calendar/Controller/MSEventFacade.php
tine20/Calendar/Convert/Event/VCalendar/Abstract.php
tine20/Calendar/js/AttendeeGridPanel.js
tine20/Tinebase/js/widgets/form/RecordPickerComboBox.js

@@@ -317,14 -315,9 +320,15 @@@ class Calendar_Controller_MSEventFacade
      {
          $event = $this->testCreate();
          
 +        $testAttendee = new Calendar_Model_Attender(array(
 +            'user_type' => Calendar_Model_Attender::USERTYPE_USER,
 +            'user_id'   => Tinebase_Core::getUser()->contact_id,
 +            'organizer' => Tinebase_Core::getUser()->contact_id
 +        ));
 +        
          // update base events status
-         Calendar_Model_Attender::getAttendee($event->attendee, $testAttendee)->status = Calendar_Model_Attender::STATUS_TENTATIVE;
 -        $testAttendee = $this->_getAttenderFromAttendeeSet($event->attendee);
++        $testAttendee = Calendar_Model_Attender::getAttendee($event->attendee, $testAttendee);
+         $testAttendee->status = Calendar_Model_Attender::STATUS_TENTATIVE;
          $updatedEvent = $this->_uit->attenderStatusUpdate($event, $testAttendee);
          
          $this->assertEquals(2, count($updatedEvent->exdate), 'num exdate mismatch');
@@@ -203,23 -211,31 +208,41 @@@ abstract class Calendar_TestCase extend
      }
      
      /**
 -     * unset transaction id to make sure this tests transaction is never rolled back
 +     * get all calendar grants
 +     * 
 +     * @param Tinebase_Model_User $user
 +     * @return array
       */
 -    protected function _testNeedsTransaction()
 +    protected function _getAllCalendarGrants($user = null)
      {
 -        if ($this->_transactionId) {
 -            Tinebase_TransactionManager::getInstance()->commitTransaction($this->_transactionId);
 -            $this->_transactionId = NULL;
 -        }
 +        return array(
 +            'account_id'    => $user ? $user->getId() : Tinebase_Core::getUser()->getId(),
 +            'account_type'  => 'user',
 +            Tinebase_Model_Grants::GRANT_READ     => true,
 +            Tinebase_Model_Grants::GRANT_ADD      => true,
 +            Tinebase_Model_Grants::GRANT_EDIT     => true,
 +            Tinebase_Model_Grants::GRANT_DELETE   => true,
 +            Tinebase_Model_Grants::GRANT_PRIVATE  => true,
 +            Tinebase_Model_Grants::GRANT_ADMIN    => true,
 +            Tinebase_Model_Grants::GRANT_FREEBUSY => true,
 +        );
      }
+     
+     /**
+      * helper function for getting attender (current user or persona) from attendee set
+      * 
+      * @param Tinebase_Record_RecordSet $attendee
+      * @param string $persona
+      * @return Calendar_Model_Attender
+      */
+     protected function _getAttenderFromAttendeeSet($attendee, $persona = null)
+     {
+         $contactId = $persona ? $this->_personasContacts[$persona]->getId() : Tinebase_Core::getUser()->contact_id;
+         $attender = new Calendar_Model_Attender(array(
+             'user_id'        => $contactId,
+             'user_type'      => Calendar_Model_Attender::USERTYPE_USER,
+         ));
+         
+         return Calendar_Model_Attender::getAttendee($attendee, $attender);
+     }
  }
Simple merge
@@@ -312,13 -309,12 +312,16 @@@ class Calendar_Controller_MSEventFacad
              $this->_eventController->createRecurException($exception, !!$exception->is_deleted);
          }
          
 -        foreach($migration['toUpdate'] as $exception) {
 +        foreach ($migration['toUpdate'] as $exception) {
+             if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' '
+                 . ' Update exdate ' . $exception->getId() . ' at ' . $exception->dtstart->toString());
+             
              $_event->assertCurrentUserAsAttendee(TRUE, TRUE);
              $this->_prepareException($updatedBaseEvent, $exception);
 +            $this->_addStatusAuthkeyForOwnAttender($exception);
 +            
 +            if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ 
 +                . ' Updating exception: ' . print_r($exception->toArray(), TRUE));
              $this->_eventController->update($exception, $_checkBusyConflicts);
          }
          
@@@ -359,8 -351,9 +360,9 @@@ class Calendar_Convert_Event_VCalendar_
          
          // find the main event - the main event has no RECURRENCE-ID
          foreach ($vcalendar->VEVENT as $vevent) {
 -            if(!isset($vevent->{'RECURRENCE-ID'})) {
 +            if (! isset($vevent->{'RECURRENCE-ID'})) {
                  $this->_convertVevent($vevent, $event);
+                 $baseVevent = $vevent;
                  
                  break;
              }
          
          // TODO only do this for events with rrule?
          // if (! empty($event->rrule)) {
-         $this->_parseEventExceptions($event, $vcalendar);
 -        
+         $this->_parseEventExceptions($event, $vcalendar, $baseVevent);
          $event->isValid(true);
          
 -        if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' data ' . print_r($event->toArray(), true));
 +        if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) 
 +            Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' data ' . print_r($event->toArray(), true));
          
          return $event;
      }
      
      /**
 -     * parse event exceptions and add them to tine event record
 +     * parse event exceptions and add them to Tine 2.0 event record
       * 
 -     * @param Calendar_Model_Event $event
 -     * @param Sabre_VObject_Component $vcalendar
 -     * @param Sabre_VObject_Component $baseVevent
 +     * @param  Calendar_Model_Event                $event
 +     * @param  \Sabre\VObject\Component\VCalendar  $vcalendar
++     * @param  \Sabre\VObject\Component\VCalendar  $baseVevent
       */
-     protected function _parseEventExceptions(Calendar_Model_Event $event, \Sabre\VObject\Component\VCalendar $vcalendar)
 -    protected function _parseEventExceptions($event, $vcalendar, $baseVevent = null)
++    protected function _parseEventExceptions(Calendar_Model_Event $event, \Sabre\VObject\Component\VCalendar $vcalendar, $baseVevent = null)
      {
          $oldExdates = $event->exdate instanceof Tinebase_Record_RecordSet ? $event->exdate->filter('is_deleted', false) : new Tinebase_Record_RecordSet('Calendar_Model_Event');
 +        
          foreach ($vcalendar->VEVENT as $vevent) {
              if (isset($vevent->{'RECURRENCE-ID'}) && $event->uid == $vevent->UID) {
                  $recurException = $this->_getRecurException($oldExdates, $vevent);
      }
      
      /**
 -     * converts vcalendar to Tinebase_Record_RecordSet of Calendar_Model_Event
+      * adapt X-MOZ-LASTACK / X-MOZ-SNOOZE-TIME from base vevent
+      * 
+      * @see 0009396: alarm_ack_time and alarm_snooze_time are not updated
+      */
+     protected function _adaptBaseEventProperties($vevent, $baseVevent)
+     {
+         $propertiesToAdapt = array('X-MOZ-LASTACK', 'X-MOZ-SNOOZE-TIME');
+         
+         foreach ($propertiesToAdapt as $property) {
+             if (isset($baseVevent->{$property})) {
+                 $vevent->{$property} = $baseVevent->{$property};
+             }
+         }
+     }
+     
+     /**
 +     * convert VCALENDAR to Tinebase_Record_RecordSet of Calendar_Model_Event
       * 
 -     * @param  mixed                 $_blob   the vcalendar to parse
 +     * @param  mixed  $blob  the vcalendar to parse
       * @return Tinebase_Record_RecordSet
       */
 -    public function toTine20RecordSet($_blob)
 +    public function toTine20RecordSet($blob)
      {
 -        $vcalendar = self::getVcal($_blob);
 +        $vcalendar = self::getVObject($blob);
          
          $result = new Tinebase_Record_RecordSet('Calendar_Model_Event');
          
@@@ -155,9 -150,8 +162,9 @@@ Tine.Tinebase.widgets.form.RecordPicker
              // TODO do we need to set start & limit here?
              start: options.params.start,
              limit: options.params.limit,
 -            sort: (this.sortBy) ? this.sortBy : this.valueField,
 +            // if sort is not set, use display field as default sort
 +            sort: (this.sortBy) ? this.sortBy : this.displayField,
-             dir: 'ASC'
+             dir: this.sortDir
          };
          
          Ext.applyIf(options.params, paging);