summaryrefslogtreecommitdiff
path: root/forum/utils/googlecalendar.php
diff options
context:
space:
mode:
Diffstat (limited to 'forum/utils/googlecalendar.php')
-rw-r--r--forum/utils/googlecalendar.php60
1 files changed, 60 insertions, 0 deletions
diff --git a/forum/utils/googlecalendar.php b/forum/utils/googlecalendar.php
new file mode 100644
index 0000000..e6305f8
--- /dev/null
+++ b/forum/utils/googlecalendar.php
@@ -0,0 +1,60 @@
+<?php
+
+include_once($UTIL_DIR . "/events.php");
+
+function googleCalendarEvent($event)
+{
+ global $ZEND_DIR, $GOOGLE_CALENDAR_USER, $GOOGLE_CALENDAR_PASSWD;
+
+ set_include_path(get_include_path() . PATH_SEPARATOR . $ZEND_DIR);
+
+ // load classes
+ require_once 'Zend/Loader.php';
+ Zend_Loader::loadClass('Zend_Gdata');
+ Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
+ Zend_Loader::loadClass('Zend_Gdata_Calendar');
+ Zend_Loader::loadClass('Zend_Http_Client');
+
+ // connect to service
+ $gcal = Zend_Gdata_Calendar::AUTH_SERVICE_NAME;
+ $user = $GOOGLE_CALENDAR_USER;
+ $pass = $GOOGLE_CALENDAR_PASSWD;
+ $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $gcal);
+ $gcal = new Zend_Gdata_Calendar($client);
+
+ /*
+ // validate input
+ if (empty($_POST['title'])) {
+ die('ERROR: Missing title');
+ }
+
+ if (!checkdate($_POST['sdate_mm'], $_POST['sdate_dd'], $_POST['sdate_yy'])) {
+ die('ERROR: Invalid start date/time');
+ }
+
+ if (!checkdate($_POST['edate_mm'], $_POST['edate_dd'], $_POST['edate_yy'])) {
+ die('ERROR: Invalid end date/time');
+ }
+ */
+ $title = htmlentities(utf8_decode($event->title . "\n" . $event->description));
+ $start = date(DATE_ATOM, $event->starttime);
+ $end = date(DATE_ATOM, $event->starttime + $event->duration);
+
+ // construct event object
+ // save to server
+
+ try {
+ $gevent = $gcal->newEventEntry();
+ $gevent->title = $gcal->newTitle($title);
+ $when = $gcal->newWhen();
+ $when->startTime = $start;
+ $when->endTime = $end;
+ $gevent->when = array($when);
+ $gcal->insertEvent($gevent);
+ } catch (Zend_Gdata_App_Exception $e) {
+ echo "Error: " . $e->getResponse();
+ }
+
+ // echo 'Event successfully added!';
+}
+?>