Ejemplo n.º 1
0
 /**
  * @return array
  */
 public function AjaxCalendarAppointmentSetAction()
 {
     $oAccount = $this->getAccountFromParam();
     $oDefaultAccount = $this->getDefaultAccountFromParam();
     $mResult = false;
     $sCalendarId = (string) $this->getParamValue('CalendarId', '');
     $sEventId = (string) $this->getParamValue('EventId', '');
     $sTempFile = (string) $this->getParamValue('File', '');
     $sAction = (string) $this->getParamValue('AppointmentAction', '');
     $sAttendee = (string) $this->getParamValue('Attendee', '');
     if (empty($sAction) || empty($sCalendarId)) {
         throw new \ProjectCore\Exceptions\ClientException(\ProjectCore\Notifications::InvalidInputParameter);
     }
     if ($this->oApiCapability->isCalendarAppointmentsSupported($oDefaultAccount)) {
         $sData = '';
         if (!empty($sEventId)) {
             $aEventData = $this->oApiCalendar->getEvent($oDefaultAccount, $sCalendarId, $sEventId);
             if (isset($aEventData) && isset($aEventData['vcal']) && $aEventData['vcal'] instanceof \Sabre\VObject\Component\VCalendar) {
                 $oVCal = $aEventData['vcal'];
                 $oVCal->METHOD = 'REQUEST';
                 $sData = $oVCal->serialize();
             }
         } else {
             if (!empty($sTempFile)) {
                 $oApiFileCache = \CApi::Manager('filecache');
                 $sData = $oApiFileCache->get($oAccount, $sTempFile);
             }
         }
         if (!empty($sData)) {
             $oCalendarApi = \CApi::Manager('calendar');
             if ($oCalendarApi) {
                 $mProcessResult = $oCalendarApi->appointmentAction($oDefaultAccount, $sAttendee, $sAction, $sCalendarId, $sData);
                 if ($mProcessResult) {
                     $mResult = array('Uid' => $mProcessResult);
                 }
             }
         }
     }
     return $this->DefaultResponse($oDefaultAccount, __FUNCTION__, $mResult);
 }