Ejemplo n.º 1
0
 public function GetReminders($iStart, $iEnd)
 {
     $aReminders = $this->oApiCalendarManager->GetReminders($iStart, $iEnd);
     $aEvents = array();
     if ($aReminders && is_array($aReminders) && count($aReminders) > 0) {
         $aCacheEvents = array();
         foreach ($aReminders as $aReminder) {
             $oAccount = $this->getAccount($aReminder['user']);
             $sCalendarUri = $aReminder['calendaruri'];
             $sEventId = $aReminder['eventid'];
             $iStartTime = $aReminder['starttime'];
             if (!isset($aCacheEvents[$sEventId]) && isset($oAccount)) {
                 $aCacheEvents[$sEventId]['data'] = $this->oApiCalendarManager->GetEvent($oAccount, $sCalendarUri, $sEventId);
                 $dt = new \DateTime();
                 $dt->setTimestamp($iStartTime);
                 $sDefaultTimeZone = new \DateTimeZone($oAccount->GetDefaultStrTimeZone());
                 $dt->setTimezone($sDefaultTimeZone);
                 $aCacheEvents[$sEventId]['time'] = $dt->format($this->getDateTimeFormat($oAccount));
             }
             if (isset($aCacheEvents[$sEventId])) {
                 $aEvents[$aReminder['user']][$sCalendarUri][$sEventId] = $aCacheEvents[$sEventId];
             }
         }
     }
     return $aEvents;
 }
Ejemplo n.º 2
0
	/**
	 * @return array
	 */
	public function AjaxAppointmentAction()
	{
		$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 \ProjectSeven\Exceptions\ClientException(\ProjectSeven\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 = /* @var $oApiFileCache \CApiFilecacheManager */ \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);
	}