|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 00027 require_once 'Zend/Gdata.php'; 00028 00032 require_once 'Zend/Gdata/Calendar/EventFeed.php'; 00033 00037 require_once 'Zend/Gdata/Calendar/EventEntry.php'; 00038 00042 require_once 'Zend/Gdata/Calendar/ListFeed.php'; 00043 00047 require_once 'Zend/Gdata/Calendar/ListEntry.php'; 00048 00059 class Zend_Gdata_Calendar extends Zend_Gdata 00060 { 00061 00062 const CALENDAR_FEED_URI = 'http://www.google.com/calendar/feeds'; 00063 const CALENDAR_EVENT_FEED_URI = 'http://www.google.com/calendar/feeds/default/private/full'; 00064 const AUTH_SERVICE_NAME = 'cl'; 00065 00066 protected $_defaultPostUri = self::CALENDAR_EVENT_FEED_URI; 00067 00073 public static $namespaces = array( 00074 array('gCal', 'http://schemas.google.com/gCal/2005', 1, 0) 00075 ); 00076 00084 public function __construct($client = null, $applicationId = 'MyCompany-MyApp-1.0') 00085 { 00086 $this->registerPackage('Zend_Gdata_Calendar'); 00087 $this->registerPackage('Zend_Gdata_Calendar_Extension'); 00088 parent::__construct($client, $applicationId); 00089 $this->_httpClient->setParameterPost('service', self::AUTH_SERVICE_NAME); 00090 } 00091 00098 public function getCalendarEventFeed($location = null) 00099 { 00100 if ($location == null) { 00101 $uri = self::CALENDAR_EVENT_FEED_URI; 00102 } else if ($location instanceof Zend_Gdata_Query) { 00103 $uri = $location->getQueryUrl(); 00104 } else { 00105 $uri = $location; 00106 } 00107 return parent::getFeed($uri, 'Zend_Gdata_Calendar_EventFeed'); 00108 } 00109 00115 public function getCalendarEventEntry($location = null) 00116 { 00117 if ($location == null) { 00118 require_once 'Zend/Gdata/App/InvalidArgumentException.php'; 00119 throw new Zend_Gdata_App_InvalidArgumentException( 00120 'Location must not be null'); 00121 } else if ($location instanceof Zend_Gdata_Query) { 00122 $uri = $location->getQueryUrl(); 00123 } else { 00124 $uri = $location; 00125 } 00126 return parent::getEntry($uri, 'Zend_Gdata_Calendar_EventEntry'); 00127 } 00128 00129 00135 public function getCalendarListFeed() 00136 { 00137 $uri = self::CALENDAR_FEED_URI . '/default'; 00138 return parent::getFeed($uri,'Zend_Gdata_Calendar_ListFeed'); 00139 } 00140 00146 public function getCalendarListEntry($location = null) 00147 { 00148 if ($location == null) { 00149 require_once 'Zend/Gdata/App/InvalidArgumentException.php'; 00150 throw new Zend_Gdata_App_InvalidArgumentException( 00151 'Location must not be null'); 00152 } else if ($location instanceof Zend_Gdata_Query) { 00153 $uri = $location->getQueryUrl(); 00154 } else { 00155 $uri = $location; 00156 } 00157 return parent::getEntry($uri,'Zend_Gdata_Calendar_ListEntry'); 00158 } 00159 00160 public function insertEvent($event, $uri=null) 00161 { 00162 if ($uri == null) { 00163 $uri = $this->_defaultPostUri; 00164 } 00165 $newEvent = $this->insertEntry($event, $uri, 'Zend_Gdata_Calendar_EventEntry'); 00166 return $newEvent; 00167 } 00168 00169 }