aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorredmatrix <redmatrix@redmatrix.me>2015-07-29 18:57:52 -0700
committerredmatrix <redmatrix@redmatrix.me>2015-07-29 18:57:52 -0700
commit00fa2e2fe889d1f65f858d4dcb93ede4fdaa8636 (patch)
tree2917599518405ff6288dad6cd051aca7adcd61e4 /include
parent4c83e9b6b49061cbd87ddb5e09976625e43c8394 (diff)
downloadvolse-hubzilla-00fa2e2fe889d1f65f858d4dcb93ede4fdaa8636.tar.gz
volse-hubzilla-00fa2e2fe889d1f65f858d4dcb93ede4fdaa8636.tar.bz2
volse-hubzilla-00fa2e2fe889d1f65f858d4dcb93ede4fdaa8636.zip
convert ics import to sabre/vobject
Diffstat (limited to 'include')
-rw-r--r--include/event.php71
1 files changed, 42 insertions, 29 deletions
diff --git a/include/event.php b/include/event.php
index af828495b..a1fae617d 100644
--- a/include/event.php
+++ b/include/event.php
@@ -395,7 +395,7 @@ require_once('vendor/autoload.php');
date_default_timezone_set($saved_timezone);
- logger('vobject: ' . print_r($ical,true));
+// logger('vobject: ' . print_r($ical,true));
return true;
// require_once('library/ical.php');
@@ -428,10 +428,16 @@ function event_import_ical($ical, $uid) {
$ev = array();
+ if(! isset($ical->DTSTART)) {
+ logger('no event start');
+ return false;
+ }
+ $dtstart = $ical->DTSTART->getDateTime();
- $dtstart = $event->DTSTART->getDateTime();
- if(($dtstart['timezone_type'] == 2) || (($dtstart['timezone_type'] == 3) && ($dtstart['timezone'] === 'UTC'))) {
+// logger('dtstart: ' . var_export($dtstart,true));
+
+ if(($dtstart->timezone_type == 2) || (($dtstart->timezone_type == 3) && ($dtstart->timezone === 'UTC'))) {
$ev['adjust'] = 1;
}
else {
@@ -442,49 +448,56 @@ function event_import_ical($ical, $uid) {
$dtstart->format(\DateTime::W3C));
-
-// logger('event: ' . print_r($event->DTSTART->getDateTime(),true));
+ if(isset($ical->DTEND)) {
+ $dtend = $ical->DTEND->getDateTime();
+ $ev['finish'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC',
+ $dtend->format(\DateTime::W3C));
+ }
+ else
+ $ev['nofinish'] = 1;
+ if($ev['start'] === $ev['finish'])
+ $ev['nofinish'] = 1;
+ if(isset($ical->CREATED)) {
+ $created = $ical->CREATED->getDateTime();
+ $ev['created'] = datetime_convert('UTC','UTC',$created->format(\DateTime::W3C));
+ }
+ if(isset($ical->{'LAST-MODIFIED'})) {
+ $edited = $ical->{'LAST-MODIFIED'}->getDateTime();
+ $ev['edited'] = datetime_convert('UTC','UTC',$edited->format(\DateTime::W3C));
+ }
- if($ical['CREATED'])
- $ev['created'] = datetime_convert('UTC','UTC',$ical['CREATED']);
- if($ical['LAST-MODIFIED'])
- $ev['edited'] = datetime_convert('UTC','UTC',$ical['LAST-MODIFIED']);
- if($ical['LOCATION'])
- $ev['location'] = $ical['LOCATION'];
- if($ical['DESCRIPTION'])
- $ev['description'] = $ical['DESCRIPTION'];
- if($ical['SUMMARY'])
- $ev['summary'] = $ical['SUMMARY'];
- if($ical['DTEND'])
- $ev['finish'] = datetime_convert('UTC','UTC', $ical['DTEND']);
- else
- $ev['nofinish'] = 1;
- $ev['start'] = datetime_convert('UTC','UTC',$ical['DTSTART']);
- if(substr($ical['DTSTART'],-1) === 'Z')
- $ev['adjust'] = 1;
+ if(isset($ical->LOCATION))
+ $ev['location'] = (string) $ical->LOCATION;
+ if(isset($ical->DESCRIPTION))
+ $ev['description'] = (string) $ical->DESCRIPTION;
+ if(isset($ical->SUMMARY))
+ $ev['summary'] = (string) $ical->SUMMARY;
- if($ical['UID']) {
+ if(isset($ical->UID)) {
+ $evuid = (string) $ical->UID;
$r = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1",
- dbesc($ical['UID']),
- intval($arr['uid'])
+ dbesc($evuid),
+ intval($uid)
);
if($r)
- $ev['event_hash'] = $ical['UID'];
+ $ev['event_hash'] = $evuid;
else
- $ev['external_id'] = $ical['UID'];
+ $ev['external_id'] = $evuid;
}
- if($ical['SUMMARY'] && $ical['DTSTART']) {
+ if($ev['summary'] && $ev['start']) {
$ev['event_xchan'] = $channel['channel_hash'];
$ev['uid'] = $channel['channel_id'];
$ev['account'] = $channel['channel_account_id'];
$ev['private'] = 1;
+ $ev['allow_cid'] = '<' . $channel['channel_hash'] . '>';
+
- logger('storing event: ' . print_r($ev,true), LOGGER_ALL);
+// logger('storing event: ' . print_r($ev,true), LOGGER_ALL);
$event = event_store_event($ev);
if($event) {
$item_id = event_store_item($ev,$event);