/** * update exdates and recurids if dtstart of an recurevent changes * * @param Calendar_Model_Event $_record * @param DateInterval $diff */ protected function _updateRecurIdOfExdates($_record, $diff) { // update exceptions $exceptions = $this->getRecurExceptions($_record); if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' dtstart of a series changed -> adopting ' . count($exceptions) . ' recurid(s)'); } $exdates = array(); foreach ($exceptions as $exception) { $exception->recurid = new Tinebase_DateTime(substr($exception->recurid, -19)); Calendar_Model_Rrule::addUTCDateDstFix($exception->recurid, $diff, $_record->originator_tz); $exdates[] = $exception->recurid; $exception->setRecurId($_record->getId()); $this->_backend->update($exception); } $_record->exdate = $exdates; }
/** * inspect update of one record * * @param Tinebase_Record_Interface $_record the update record * @param Tinebase_Record_Interface $_oldRecord the current persistent record * @return void */ protected function _inspectBeforeUpdate($_record, $_oldRecord) { // 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); // update exdates and recurids if dtsart of an recurevent changes if (!empty($_record->rrule)) { $diff = $_oldRecord->dtstart->diff($_record->dtstart); // update exceptions $exceptions = $this->getRecurExceptions($_record); if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' dtstart of a series changed -> adopting ' . count($exceptions) . ' recurid(s)'); } $exdates = array(); foreach ($exceptions as $exception) { $exception->recurid = new Tinebase_DateTime(substr($exception->recurid, -19)); Calendar_Model_Rrule::addUTCDateDstFix($exception->recurid, $diff, $_record->originator_tz); $exdates[] = $exception->recurid; $exception->setRecurId(); $this->_backend->update($exception); } $_record->exdate = $exdates; } } // delete recur exceptions if update is not longer a recur series if (!empty($_oldRecord->rrule) && empty($_record->rrule)) { if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' deleteing recur exceptions as event is no longer a recur series'); } $this->_backend->delete($this->getRecurExceptions($_record)); } // touch base event of a recur series if an persisten exception changes if ($_record->recurid) { if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' touch base event of a persisten exception'); } $baseEvent = $this->getRecurBaseEvent($_record); $this->_touch($baseEvent, TRUE); } }