Example #1
0
 /**
  * @return array
  */
 public function AjaxCalendarEventCreate()
 {
     $mResult = false;
     $oAccount = $this->getDefaultAccountFromParam();
     if (!$this->oApiCapability->IsCalendarSupported($oAccount)) {
         throw new \ProjectSeven\Exceptions\ClientException(\ProjectSeven\Notifications::CalendarsNotAllowed);
     }
     $oEvent = new \CEvent();
     $oEvent->IdCalendar = $this->getParamValue('newCalendarId');
     $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;
     }
     $mResult = $this->oApiCalendar->CreateEvent($oAccount, $oEvent);
     if ($mResult) {
         $iStart = $this->getParamValue('selectStart');
         $iEnd = $this->getParamValue('selectEnd');
         $mResult = $this->oApiCalendar->GetExpandedEvent($oAccount, $oEvent->IdCalendar, $mResult, $iStart, $iEnd);
     }
     return $this->DefaultResponse($oAccount, __FUNCTION__, $mResult);
 }