Example #1
0
 /**
  * @return array
  */
 public function AjaxCalendarEventUpdate()
 {
     $mResult = false;
     $oAccount = $this->getDefaultAccountFromParam();
     if (!$this->oApiCapability->isCalendarSupported($oAccount)) {
         throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::CalendarsNotAllowed);
     }
     $sNewCalendarId = $this->getParamValue('newCalendarId');
     $oEvent = new \CEvent();
     $oEvent->IdCalendar = $this->getParamValue('calendarId');
     $oEvent->Id = $this->getParamValue('uid');
     $oEvent->Name = $this->getParamValue('subject');
     $oEvent->Description = $this->getParamValue('description');
     $oEvent->Location = $this->getParamValue('location');
     $oEvent->Start = $this->getParamValue('startTS');
     $oEvent->End = $this->getParamValue('endTS');
     $oEvent->AllDay = (bool) $this->getParamValue('allDay');
     $oEvent->Alarms = @json_decode($this->getParamValue('alarms'), true);
     $oEvent->Attendees = @json_decode($this->getParamValue('attendees'), true);
     $aRRule = @json_decode($this->getParamValue('rrule'), true);
     if ($aRRule) {
         $oRRule = new \CRRule($oAccount);
         $oRRule->Populate($aRRule);
         $oEvent->RRule = $oRRule;
     }
     $iAllEvents = (int) $this->getParamValue('allEvents');
     $sRecurrenceId = $this->getParamValue('recurrenceId');
     if ($iAllEvents && $iAllEvents === 1) {
         $mResult = $this->oApiCalendar->updateExclusion($oAccount, $oEvent, $sRecurrenceId);
     } else {
         $mResult = $this->oApiCalendar->updateEvent($oAccount, $oEvent);
         if ($mResult && $sNewCalendarId !== $oEvent->IdCalendar) {
             $mResult = $this->oApiCalendar->moveEvent($oAccount, $oEvent->IdCalendar, $sNewCalendarId, $oEvent->Id);
             $oEvent->IdCalendar = $sNewCalendarId;
         }
     }
     if ($mResult) {
         $iStart = $this->getParamValue('selectStart');
         $iEnd = $this->getParamValue('selectEnd');
         $mResult = $this->oApiCalendar->getExpandedEvent($oAccount, $oEvent->IdCalendar, $oEvent->Id, $iStart, $iEnd);
     }
     return $this->DefaultResponse($oAccount, __FUNCTION__, $mResult);
 }