Source for file calendar.php
Documentation is available at calendar.php
* @package Joomla.Platform
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved
* @license GNU General Public License version 2 or later; see LICENSE
* Google Calendar data class for the Joomla Platform.
* @package Joomla.Platform
* @param JRegistry $options Google options object
* @param JGoogleAuth $auth Google data http client object
public function __construct(JRegistry $options =
null, JGoogleAuth $auth =
null)
if (isset
($this->auth) &&
!$this->auth->getOption('scope'))
$this->auth->setOption('scope', 'https://www.googleapis.com/auth/calendar');
* Method to remove a calendar from a user's calendar list
* @param string $calendarID ID of calendar to delete
* @return boolean Success or failure
* @throws UnexpectedValueException
$jdata =
$this->query('https://www.googleapis.com/calendar/v3/users/me/calendarList/' .
urlencode($calendarID), null, null, 'delete');
throw
new UnexpectedValueException("Unexpected data received from Google: `{$jdata->body}`.
");
* Method to get a calendar's settings from Google
* @param string $calendarID ID of calendar to get.
* @return mixed Data from Google
* @throws UnexpectedValueException
$jdata =
$this->query('https://www.googleapis.com/calendar/v3/users/me/calendarList/' .
urlencode($calendarID));
throw
new UnexpectedValueException("Unexpected data received from Google: `{$jdata->body}`.
");
* Method to add a calendar to a user's Google Calendar list
* @param string $calendarID New calendar ID
* @param array $options New calendar settings
* @return mixed Data from Google
* @throws UnexpectedValueException
public function addCalendar($calendarID, $options =
array())
$options['id'] =
$calendarID;
$url =
'https://www.googleapis.com/calendar/v3/users/me/calendarList';
$jdata =
$this->query($url, json_encode($options), array('Content-type' =>
'application/json'), 'post');
throw
new UnexpectedValueException("Unexpected data received from Google: `{$jdata->body}`.
");
* Method to retrieve calendar list from Google
* @param array $options Search settings
* @param int $maxpages Maximum number of pages of calendars to return
* @return mixed Data from Google
* @throws UnexpectedValueException
$next =
array_key_exists('nextPageToken', $options) ?
$options['nextPage'] :
null;
unset
($options['nextPageToken']);
$url =
'https://www.googleapis.com/calendar/v3/users/me/calendarList?' .
http_build_query($options);
* Method to edit a Google Calendar's settings
* @param string $calendarID Calendar ID
* @param array $options Calendar settings
* @return mixed Data from Google
* @throws UnexpectedValueException
$url =
'https://www.googleapis.com/calendar/v3/users/me/calendarList/' .
urlencode($calendarID);
$jdata =
$this->query($url, json_encode($options), array('Content-type' =>
'application/json'), 'put');
throw
new UnexpectedValueException("Unexpected data received from Google: `{$jdata->body}`.
");
* Method to clear a Google Calendar
* @param string $calendarID ID of calendar to clear
* @return boolean Success or failure
* @throws UnexpectedValueException
$data =
$this->query('https://www.googleapis.com/calendar/v3/users/me/calendars/' .
urlencode($calendarID) .
'/clear', null, null, 'post');
throw
new UnexpectedValueException("Unexpected data received from Google: `{$data->body}`.
");
* Method to delete a calendar from Google
* @param string $calendarID ID of calendar to delete.
* @return boolean Success or failure
* @throws UnexpectedValueException
$data =
$this->query('https://www.googleapis.com/calendar/v3/users/me/calendars/' .
urlencode($calendarID), null, null, 'delete');
throw
new UnexpectedValueException("Unexpected data received from Google: `{$data->body}`.
");
* Method to create a Google Calendar
* @param string $title New calendar title
* @param array $options New calendar settings
* @return mixed Data from Google.
* @throws UnexpectedValueException
$options['summary'] =
$title;
$url =
'https://www.googleapis.com/calendar/v3/calendars';
$jdata =
$this->query($url, json_encode($options), array('Content-type' =>
'application/json'), 'post');
throw
new UnexpectedValueException("Unexpected data received from Google: `{$jdata->body}`.
");
* Method to edit a Google Calendar
* @param string $calendarID Calendar ID.
* @param array $options Calendar settings.
* @return mixed Data from Google.
* @throws UnexpectedValueException
$url =
'https://www.googleapis.com/calendar/v3/users/me/calendars/' .
urlencode($calendarID);
$jdata =
$this->query($url, json_encode($options), array('Content-type' =>
'application/json'), 'put');
throw
new UnexpectedValueException("Unexpected data received from Google: `{$jdata->body}`.
");
* Method to delete an event from a Google Calendar
* @param string $calendarID ID of calendar to delete from
* @param string $eventID ID of event to delete.
* @return boolean Success or failure.
* @throws UnexpectedValueException
$url =
'https://www.googleapis.com/calendar/v3/users/me/calendars/' .
urlencode($calendarID) .
'/events/' .
urlencode($eventID);
$data =
$this->query($url, null, null, 'delete');
throw
new UnexpectedValueException("Unexpected data received from Google: `{$data->body}`.
");
* Method to get an event from a Google Calendar
* @param string $calendarID ID of calendar
* @param string $eventID ID of event to get
* @param array $options Options to send to Google
* @return mixed Data from Google.
* @throws UnexpectedValueException
public function getEvent($calendarID, $eventID, $options =
array())
$url =
'https://www.googleapis.com/calendar/v3/users/me/calendarList/';
$jdata =
$this->query($url);
throw
new UnexpectedValueException("Unexpected data received from Google: `{$jdata->body}`.
");
* Method to create a Google Calendar event
* @param string $calendarID ID of calendar
* @param mixed $start Event start time
* @param mixed $end Event end time
* @param array $options New event settings
* @param mixed $timezone Timezone for event
* @param boolean $allday Treat event as an all-day event
* @param boolean $notify Notify participants
* @return mixed Data from Google.
* @throws InvalidArgumentException
* @throws UnexpectedValueException
public function createEvent($calendarID, $start, $end =
false, $options =
array(), $timezone =
false, $allday =
false, $notify =
false)
$startobj =
new DateTime;
$startobj =
new DateTime;
$startobj->setTimestamp($start);
$startobj =
new DateTime($start);
elseif (is_a($start, 'DateTime'))
throw
new InvalidArgumentException('Invalid event start time.');
$endobj->setTimestamp($end);
$endobj =
new DateTime($end);
elseif (is_a($end, 'DateTime'))
throw
new InvalidArgumentException('Invalid event end time.');
$options['start'] =
array('date' =>
$startobj->format('Y-m-d'));
$options['end'] =
array('date' =>
$endobj->format('Y-m-d'));
$options['start'] =
array('dateTime' =>
$startobj->format(DateTime::RFC3339));
$options['end'] =
array('dateTime' =>
$endobj->format(DateTime::RFC3339));
$options['start']['timeZone'] =
$startobj->getTimezone()->getName();
$options['end']['timeZone'] =
$endobj->getTimezone()->getName();
elseif (is_a($timezone, 'DateTimeZone'))
$options['start']['timeZone'] =
$timezone->getName();
$options['end']['timeZone'] =
$timezone->getName();
$options['start']['timeZone'] =
$timezone;
$options['end']['timeZone'] =
$timezone;
$url =
'https://www.googleapis.com/calendar/v3/calendars/' .
urlencode($calendarID) .
'/events' .
($notify ?
'?sendNotifications=true' :
'');
$jdata =
$this->query($url, json_encode($options), array('Content-type' =>
'application/json'), 'post');
throw
new UnexpectedValueException("Unexpected data received from Google: `{$jdata->body}`.
");
* Method to retrieve a list of events on a Google calendar
* @param string $calendarID Calendar ID
* @param string $eventID ID of the event to change
* @param array $options Search settings
* @param int $maxpages Minimum number of events to retrieve (more may be retrieved depending on page size)
* @return mixed Data from Google.
* @throws UnexpectedValueException
public function listRecurrences($calendarID, $eventID, $options =
array(), $maxpages =
1)
$next =
array_key_exists('nextPageToken', $options) ?
$options['nextPage'] :
null;
unset
($options['nextPageToken']);
$url =
'https://www.googleapis.com/calendar/v3/users/me/calendars/' .
urlencode($calendarID) .
'/events/' .
urlencode($eventID) .
'/instances';
* Method to retrieve a list of events on a Google calendar
* @param string $calendarID Calendar ID
* @param array $options Calendar settings
* @param int $maxpages Cycle through pages of data to generate a complete list
* @return mixed Data from Google.
* @throws UnexpectedValueException
public function listEvents($calendarID, $options =
array(), $maxpages =
1)
$next =
array_key_exists('nextPageToken', $options) ?
$options['nextPage'] :
null;
unset
($options['nextPageToken']);
$url =
'https://www.googleapis.com/calendar/v3/calendars/' .
urlencode($calendarID) .
'/events?' .
http_build_query($options);
* Method to move an event from one calendar to another
* @param string $calendarID Calendar ID
* @param string $eventID ID of the event to change
* @param string $destID Calendar ID
* @param boolean $notify Notify participants of changes
* @return mixed Data from Google.
* @throws UnexpectedValueException
public function moveEvent($calendarID, $eventID, $destID, $notify =
false)
$url =
'https://www.googleapis.com/calendar/v3/calendars/' .
urlencode($calendarID) .
'/events/' .
urlencode($eventID) .
'/move';
$url .=
'?destination=' .
$destID .
($notify ?
'&sendNotifications=true' :
'');
$jdata =
$this->query($url, null, null, 'post');
throw
new UnexpectedValueException("Unexpected data received from Google: `{$jdata->body}`.
");
* Method to edit a Google Calendar event
* @param string $calendarID Calendar ID
* @param string $eventID ID of the event to change
* @param array $options Event settings
* @param boolean $notify Notify participants of changes
* @return mixed Data from Google.
* @throws UnexpectedValueException
public function editEvent($calendarID, $eventID, $options, $notify =
false)
$url =
'https://www.googleapis.com/calendar/v3/calendars/';
$url .=
urlencode($calendarID) .
'/events/' .
urlencode($eventID) .
($notify ?
'?sendNotifications=true' :
'');
$jdata =
$this->query($url, json_encode($options), array('Content-type' =>
'application/json'), 'put');
throw
new UnexpectedValueException("Unexpected data received from Google: `{$jdata->body}`.
");
Documentation generated on Tue, 19 Nov 2013 14:54:57 +0100 by phpDocumentor 1.4.3