Merge branch '2013.10' into 2014.11
[tine20] / tine20 / Calendar / Controller / Event.php
index 0e31722..58153c2 100644 (file)
@@ -1111,17 +1111,10 @@ class Calendar_Controller_Event extends Tinebase_Controller_Record_Abstract impl
                 $note = $_event->notes; unset($_event->notes);
                 $persistentExceptionEvent = $this->create($_event, $_checkBusyConflicts && $dtStartHasDiff);
                 
-                // we save attendee seperatly to preserve their attributes
+                // we save attendee separately to preserve their attributes
                 if ($attendees instanceof Tinebase_Record_RecordSet) {
-                    $attendees->cal_event_id = $persistentExceptionEvent->getId();
-                    
                     foreach($attendees as $attendee) {
-                        if (! $attendee->status_authkey) {
-                            // new invitations
-                            $attendee->status_authkey = Tinebase_Record_Abstract::generateUID();
-                        }
-                        $this->_backend->createAttendee($attendee);
-                        $this->_increaseDisplayContainerContentSequence($attendee, $persistentExceptionEvent, Tinebase_Model_ContainerContent::ACTION_CREATE);
+                        $this->_createAttender($attendee, $persistentExceptionEvent, true);
                     }
                 }
                 
@@ -1205,7 +1198,7 @@ class Calendar_Controller_Event extends Tinebase_Controller_Record_Abstract impl
             if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ .
                 ' Got multiple possible base events: ' . print_r($possibleBaseEventIds, true));
         }
-        $baseEventId = array_value(0, $possibleBaseEventIds);
+        $baseEventId = Tinebase_Helper::array_value(0, $possibleBaseEventIds);
         
         if (! $baseEventId) {
             throw new Tinebase_Exception_NotFound('base event of a recurring series not found');
@@ -1421,7 +1414,7 @@ class Calendar_Controller_Event extends Tinebase_Controller_Record_Abstract impl
         // if dtstart of an event changes, we update the originator_tz, alarm times
         if (! $_oldRecord->dtstart->equals($_record->dtstart)) {
             if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' dtstart changed -> adopting organizer_tz');
-            $_record->originator_tz = Tinebase_Core::get(Tinebase_Core::USERTIMEZONE);
+            $_record->originator_tz = Tinebase_Core::getUserTimezone();
             if (! empty($_record->rrule)) {
                 $diff = $_oldRecord->dtstart->diff($_record->dtstart);
                 $this->_updateRecurIdOfExdates($_record, $diff);
@@ -1542,7 +1535,7 @@ class Calendar_Controller_Event extends Tinebase_Controller_Record_Abstract impl
      */
     protected function _inspectOriginatorTZ($record)
     {
-        $record->originator_tz = $record->originator_tz ? $record->originator_tz : Tinebase_Core::get(Tinebase_Core::USERTIMEZONE);
+        $record->originator_tz = $record->originator_tz ? $record->originator_tz : Tinebase_Core::getUserTimezone();
 
         try {
             new DateTimeZone($record->originator_tz);
@@ -1996,6 +1989,7 @@ class Calendar_Controller_Event extends Tinebase_Controller_Record_Abstract impl
     {
         // apply defaults
         $attender->user_type         = isset($attender->user_type) ? $attender->user_type : Calendar_Model_Attender::USERTYPE_USER;
+        $attender->cal_event_id      =  $event->getId();
         $calendar = ($calendar) ? $calendar : Tinebase_Container::getInstance()->getContainerById($event->container_id);
         
         $userAccountId = $attender->getUserAccountId();
@@ -2037,6 +2031,17 @@ class Calendar_Controller_Event extends Tinebase_Controller_Record_Abstract impl
         $this->_increaseDisplayContainerContentSequence($attender, $event, Tinebase_Model_ContainerContent::ACTION_CREATE);
     }
     
+        
+    /**
+     * returns the default calendar
+     * 
+     * @return Tinebase_Model_Container
+     */
+    public function getDefaultCalendar()
+    {
+        return Tinebase_Container::getInstance()->getDefaultContainer($this->_applicationName, NULL, Calendar_Preference::DEFAULTCALENDAR);
+    }
+    
     /**
      * returns default displayContainer id of given attendee
      *