aboutsummaryrefslogtreecommitdiffstats
path: root/include/event.php
diff options
context:
space:
mode:
authorredmatrix <git@macgirvin.com>2016-06-01 21:48:54 -0700
committerredmatrix <git@macgirvin.com>2016-06-01 21:48:54 -0700
commita9d7acda279ebb7f2b3cd61a91a5e1d8b590dcf2 (patch)
treede0ac6910e13926df60cfed458e50310c5642055 /include/event.php
parentb1259876bf398880e7b0c1b44d90f94983243e72 (diff)
downloadvolse-hubzilla-a9d7acda279ebb7f2b3cd61a91a5e1d8b590dcf2.tar.gz
volse-hubzilla-a9d7acda279ebb7f2b3cd61a91a5e1d8b590dcf2.tar.bz2
volse-hubzilla-a9d7acda279ebb7f2b3cd61a91a5e1d8b590dcf2.zip
the rest of the schema updates - WARNING: some third party plugins may fail; e.g. embedphotos and chess. $item['object'] is now $item['obj'] and $photo['type'] is $photo['mimetype'], $photo['scale'] is $photo['imgscale'] and $photo['data'] is now $photo['content']. There are a number of other changes, but these are the ones noted to cause issues with third-party plugins. The project plugins have been updated. Please note any new issues as this effort touched a lot of code in a lot of files.
Diffstat (limited to 'include/event.php')
-rw-r--r--include/event.php169
1 files changed, 98 insertions, 71 deletions
diff --git a/include/event.php b/include/event.php
index 81e403d37..a4118ec78 100644
--- a/include/event.php
+++ b/include/event.php
@@ -28,22 +28,22 @@ function format_event_html($ev) {
$o .= '<div class="event-title"><h3><i class="fa fa-calendar"></i>&nbsp;' . bbcode($ev['summary']) . '</h3></div>' . "\r\n";
$o .= '<div class="event-start"><span class="event-label">' . t('Starts:') . '</span>&nbsp;<span class="dtstart" title="'
- . datetime_convert('UTC', 'UTC', $ev['start'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
+ . datetime_convert('UTC', 'UTC', $ev['dtstart'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
. '" >'
. (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(),
- $ev['start'] , $bd_format ))
+ $ev['dtstart'] , $bd_format ))
: day_translate(datetime_convert('UTC', 'UTC',
- $ev['start'] , $bd_format)))
+ $ev['dtstart'] , $bd_format)))
. '</span></div>' . "\r\n";
if(! $ev['nofinish'])
$o .= '<div class="event-end" ><span class="event-label">' . t('Finishes:') . '</span>&nbsp;<span class="dtend" title="'
- . datetime_convert('UTC','UTC',$ev['finish'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
+ . datetime_convert('UTC','UTC',$ev['dtend'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
. '" >'
. (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(),
- $ev['finish'] , $bd_format ))
+ $ev['dtend'] , $bd_format ))
: day_translate(datetime_convert('UTC', 'UTC',
- $ev['finish'] , $bd_format )))
+ $ev['dtend'] , $bd_format )))
. '</span></div>' . "\r\n";
$o .= '<div class="event-description">' . bbcode($ev['description']) . '</div>' . "\r\n";
@@ -58,6 +58,37 @@ function format_event_html($ev) {
return $o;
}
+function format_event_obj($jobject) {
+ $event = array();
+
+ $object = json_decode($jobject,true);
+
+ //ensure compatibility with older items - this check can be removed at a later point
+ if(array_key_exists('description', $object)) {
+
+ $bd_format = t('l F d, Y \@ g:i A'); // Friday January 18, 2011 @ 8:01 AM
+
+ $event['header'] = replace_macros(get_markup_template('event_item_header.tpl'),array(
+ '$title' => bbcode($object['title']),
+ '$dtstart_label' => t('Starts:'),
+ '$dtstart_title' => datetime_convert('UTC', 'UTC', $object['dtstart'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )),
+ '$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtstart'] , $bd_format))),
+ '$finish' => (($object['nofinish']) ? false : true),
+ '$dtend_label' => t('Finishes:'),
+ '$dtend_title' => datetime_convert('UTC','UTC',$object['dtend'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )),
+ '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtend'] , $bd_format )))
+ ));
+
+ $event['content'] = replace_macros(get_markup_template('event_item_content.tpl'),array(
+ '$description' => bbcode($object['description']),
+ '$location_label' => t('Location:'),
+ '$location' => bbcode($object['location'])
+ ));
+
+ }
+
+ return $event;
+}
function ical_wrapper($ev) {
@@ -68,7 +99,7 @@ function ical_wrapper($ev) {
$o .= "\r\nVERSION:2.0";
$o .= "\r\nMETHOD:PUBLISH";
$o .= "\r\nPRODID:-//" . get_config('system','sitename') . "//" . Zotlabs\Lib\System::get_platform_name() . "//" . strtoupper(App::$language). "\r\n";
- if(array_key_exists('start', $ev))
+ if(array_key_exists('dtstart', $ev))
$o .= format_event_ical($ev);
else {
foreach($ev as $e) {
@@ -82,7 +113,7 @@ function ical_wrapper($ev) {
function format_event_ical($ev) {
- if($ev['type'] === 'task')
+ if($ev['etype'] === 'task')
return format_todo_ical($ev);
$o = '';
@@ -92,10 +123,10 @@ function format_event_ical($ev) {
$o .= "\r\nCREATED:" . datetime_convert('UTC','UTC', $ev['created'],'Ymd\\THis\\Z');
$o .= "\r\nLAST-MODIFIED:" . datetime_convert('UTC','UTC', $ev['edited'],'Ymd\\THis\\Z');
$o .= "\r\nDTSTAMP:" . datetime_convert('UTC','UTC', $ev['edited'],'Ymd\\THis\\Z');
- if($ev['start'])
- $o .= "\r\nDTSTART:" . datetime_convert('UTC','UTC', $ev['start'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : ''));
- if($ev['finish'] && ! $ev['nofinish'])
- $o .= "\r\nDTEND:" . datetime_convert('UTC','UTC', $ev['finish'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : ''));
+ if($ev['dtstart'])
+ $o .= "\r\nDTSTART:" . datetime_convert('UTC','UTC', $ev['dtstart'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : ''));
+ if($ev['dtend'] && ! $ev['nofinish'])
+ $o .= "\r\nDTEND:" . datetime_convert('UTC','UTC', $ev['dtend'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : ''));
if($ev['summary'])
$o .= "\r\nSUMMARY:" . format_ical_text($ev['summary']);
if($ev['location'])
@@ -119,10 +150,10 @@ function format_todo_ical($ev) {
$o .= "\r\nCREATED:" . datetime_convert('UTC','UTC', $ev['created'],'Ymd\\THis\\Z');
$o .= "\r\nLAST-MODIFIED:" . datetime_convert('UTC','UTC', $ev['edited'],'Ymd\\THis\\Z');
$o .= "\r\nDTSTAMP:" . datetime_convert('UTC','UTC', $ev['edited'],'Ymd\\THis\\Z');
- if($ev['start'])
- $o .= "\r\nDTSTART:" . datetime_convert('UTC','UTC', $ev['start'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : ''));
- if($ev['finish'] && ! $ev['nofinish'])
- $o .= "\r\nDUE:" . datetime_convert('UTC','UTC', $ev['finish'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : ''));
+ if($ev['dtstart'])
+ $o .= "\r\nDTSTART:" . datetime_convert('UTC','UTC', $ev['dtstart'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : ''));
+ if($ev['dtend'] && ! $ev['nofinish'])
+ $o .= "\r\nDUE:" . datetime_convert('UTC','UTC', $ev['dtend'],'Ymd\\THis' . (($ev['adjust']) ? '\\Z' : ''));
if($ev['summary'])
$o .= "\r\nSUMMARY:" . format_ical_text($ev['summary']);
if($ev['event_status']) {
@@ -166,11 +197,11 @@ function format_event_bbcode($ev) {
if($ev['description'])
$o .= '[event-description]' . $ev['description'] . '[/event-description]';
- if($ev['start'])
- $o .= '[event-start]' . $ev['start'] . '[/event-start]';
+ if($ev['dtstart'])
+ $o .= '[event-start]' . $ev['dtstart'] . '[/event-start]';
- if(($ev['finish']) && (! $ev['nofinish']))
- $o .= '[event-finish]' . $ev['finish'] . '[/event-finish]';
+ if(($ev['dtend']) && (! $ev['nofinish']))
+ $o .= '[event-finish]' . $ev['dtend'] . '[/event-finish]';
if($ev['location'])
$o .= '[event-location]' . $ev['location'] . '[/event-location]';
@@ -207,10 +238,10 @@ function bbtoevent($s) {
$ev['description'] = $match[1];
$match = '';
if(preg_match("/\[event\-start\](.*?)\[\/event\-start\]/is",$s,$match))
- $ev['start'] = $match[1];
+ $ev['dtstart'] = $match[1];
$match = '';
if(preg_match("/\[event\-finish\](.*?)\[\/event\-finish\]/is",$s,$match))
- $ev['finish'] = $match[1];
+ $ev['dtend'] = $match[1];
$match = '';
if(preg_match("/\[event\-location\](.*?)\[\/event\-location\]/is",$s,$match))
$ev['location'] = $match[1];
@@ -220,11 +251,11 @@ function bbtoevent($s) {
$match = '';
if(preg_match("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",$s,$match))
$ev['adjust'] = $match[1];
- if(array_key_exists('start',$ev)) {
- if(array_key_exists('finish',$ev)) {
- if($ev['finish'] === $ev['start'])
+ if(array_key_exists('dtstart',$ev)) {
+ if(array_key_exists('dtend',$ev)) {
+ if($ev['dtend'] === $ev['dtstart'])
$ev['nofinish'] = 1;
- elseif($ev['finish'])
+ elseif($ev['dtend'])
$ev['nofinish'] = 0;
else
$ev['nofinish'] = 1;
@@ -260,8 +291,8 @@ function sort_by_date($arr) {
*/
function ev_compare($a, $b) {
- $date_a = (($a['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$a['start']) : $a['start']);
- $date_b = (($b['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$b['start']) : $b['start']);
+ $date_a = (($a['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$a['dtstart']) : $a['dtstart']);
+ $date_b = (($b['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$b['dtstart']) : $b['dtstart']);
if ($date_a === $date_b)
return strcasecmp($a['description'], $b['description']);
@@ -274,7 +305,7 @@ function event_store_event($arr) {
$arr['created'] = (($arr['created']) ? $arr['created'] : datetime_convert());
$arr['edited'] = (($arr['edited']) ? $arr['edited'] : datetime_convert());
- $arr['type'] = (($arr['type']) ? $arr['type'] : 'event' );
+ $arr['etype'] = (($arr['etype']) ? $arr['etype'] : 'event' );
$arr['event_xchan'] = (($arr['event_xchan']) ? $arr['event_xchan'] : '');
$arr['event_priority'] = (($arr['event_priority']) ? $arr['event_priority'] : 0);
@@ -324,12 +355,12 @@ function event_store_event($arr) {
$r = q("UPDATE `event` SET
`edited` = '%s',
- `start` = '%s',
- `finish` = '%s',
+ `dtstart` = '%s',
+ `dtend` = '%s',
`summary` = '%s',
`description` = '%s',
`location` = '%s',
- `type` = '%s',
+ `etype` = '%s',
`adjust` = %d,
`nofinish` = %d,
`event_status` = '%s',
@@ -345,12 +376,12 @@ function event_store_event($arr) {
WHERE `id` = %d AND `uid` = %d",
dbesc($arr['edited']),
- dbesc($arr['start']),
- dbesc($arr['finish']),
+ dbesc($arr['dtstart']),
+ dbesc($arr['dtend']),
dbesc($arr['summary']),
dbesc($arr['description']),
dbesc($arr['location']),
- dbesc($arr['type']),
+ dbesc($arr['etype']),
intval($arr['adjust']),
intval($arr['nofinish']),
dbesc($arr['event_status']),
@@ -378,7 +409,7 @@ function event_store_event($arr) {
else
$hash = random_string() . '@' . App::get_hostname();
- $r = q("INSERT INTO event ( uid,aid,event_xchan,event_hash,created,edited,start,finish,summary,description,location,type,
+ $r = q("INSERT INTO event ( uid,aid,event_xchan,event_hash,created,edited,dtstart,dtend,summary,description,location,etype,
adjust,nofinish, event_status, event_status_date, event_percent, event_repeat, event_sequence, event_priority, allow_cid,allow_gid,deny_cid,deny_gid)
VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', %d, '%s', %d, %d, '%s', '%s', '%s', '%s' ) ",
intval($arr['uid']),
@@ -387,12 +418,12 @@ function event_store_event($arr) {
dbesc($hash),
dbesc($arr['created']),
dbesc($arr['edited']),
- dbesc($arr['start']),
- dbesc($arr['finish']),
+ dbesc($arr['dtstart']),
+ dbesc($arr['dtend']),
dbesc($arr['summary']),
dbesc($arr['description']),
dbesc($arr['location']),
- dbesc($arr['type']),
+ dbesc($arr['etype']),
intval($arr['adjust']),
intval($arr['nofinish']),
dbesc($arr['event_status']),
@@ -441,7 +472,7 @@ function event_addtocal($item_id, $uid) {
$ev = bbtoevent($r[0]['body']);
- if(x($ev,'summary') && x($ev,'start')) {
+ if(x($ev,'summary') && x($ev,'dtstart')) {
$ev['event_xchan'] = $item['author_xchan'];
$ev['uid'] = $channel['channel_id'];
$ev['account'] = $channel['channel_account_id'];
@@ -554,20 +585,20 @@ function event_import_ical($ical, $uid) {
// logger('dtstart: ' . var_export($dtstart,true));
- $ev['start'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC',
+ $ev['dtstart'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC',
$dtstart->format(\DateTime::W3C));
if(isset($ical->DTEND)) {
$dtend = $ical->DTEND->getDateTime();
- $ev['finish'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC',
+ $ev['dtend'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC',
$dtend->format(\DateTime::W3C));
}
else
$ev['nofinish'] = 1;
- if($ev['start'] === $ev['finish'])
+ if($ev['dtstart'] === $ev['dtend'])
$ev['nofinish'] = 1;
if(isset($ical->CREATED)) {
@@ -601,7 +632,7 @@ function event_import_ical($ical, $uid) {
$ev['external_id'] = $evuid;
}
- if($ev['summary'] && $ev['start']) {
+ if($ev['summary'] && $ev['dtstart']) {
$ev['event_xchan'] = $channel['channel_hash'];
$ev['uid'] = $channel['channel_id'];
$ev['account'] = $channel['channel_account_id'];
@@ -640,29 +671,24 @@ function event_import_ical_task($ical, $uid) {
$dtstart = $ical->DTSTART->getDateTime();
+ $ev['adjust'] = (($ical->DTSTART->isFloating()) ? 1 : 0);
+
// logger('dtstart: ' . var_export($dtstart,true));
- if(($dtstart->timezone_type == 2) || (($dtstart->timezone_type == 3) && ($dtstart->timezone === 'UTC'))) {
- $ev['adjust'] = 1;
- }
- else {
- $ev['adjust'] = 0;
- }
-
- $ev['start'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC',
+ $ev['dtstart'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC',
$dtstart->format(\DateTime::W3C));
if(isset($ical->DUE)) {
$dtend = $ical->DUE->getDateTime();
- $ev['finish'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC',
+ $ev['dtend'] = datetime_convert((($ev['adjust']) ? 'UTC' : date_default_timezone_get()),'UTC',
$dtend->format(\DateTime::W3C));
}
else
$ev['nofinish'] = 1;
- if($ev['start'] === $ev['finish'])
+ if($ev['dtstart'] === $ev['dtend'])
$ev['nofinish'] = 1;
if(isset($ical->CREATED)) {
@@ -727,9 +753,9 @@ function event_import_ical_task($ical, $uid) {
$ev['event_percent'] = (string) $ical->{'PERCENT-COMPLETE'} ;
}
- $ev['type'] = 'task';
+ $ev['etype'] = 'task';
- if($ev['summary'] && $ev['start']) {
+ if($ev['summary'] && $ev['dtstart']) {
$ev['event_xchan'] = $channel['channel_hash'];
$ev['uid'] = $channel['channel_id'];
$ev['account'] = $channel['channel_account_id'];
@@ -781,7 +807,7 @@ function event_store_item($arr, $event) {
if(($event) && array_key_exists('event_hash',$event) && (! array_key_exists('event_hash',$arr)))
$arr['event_hash'] = $event['event_hash'];
- if($event['type'] === 'birthday') {
+ if($event['etype'] === 'birthday') {
if(! is_sys_channel($arr['uid']))
$prefix = t('This event has been added to your calendar.');
// $birthday = true;
@@ -805,21 +831,22 @@ function event_store_item($arr, $event) {
'type' => ACTIVITY_OBJ_EVENT,
'id' => z_root() . '/event/' . $r[0]['resource_id'],
'title' => $arr['summary'],
- 'start' => $arr['start'],
- 'finish' => $arr['finish'],
+ 'dtstart' => $arr['dtstart'],
+ 'dtend' => $arr['dtend'],
'nofinish' => $arr['nofinish'],
'description' => $arr['description'],
'location' => $arr['location'],
'adjust' => $arr['adjust'],
'content' => format_event_bbcode($arr),
'author' => array(
- 'name' => $r[0]['xchan_name'],
- 'address' => $r[0]['xchan_addr'],
- 'guid' => $r[0]['xchan_guid'],
- 'guid_sig' => $r[0]['xchan_guid_sig'],
- 'link' => array(
- array('rel' => 'alternate', 'type' => 'text/html', 'href' => $r[0]['xchan_url']),
- array('rel' => 'photo', 'type' => $r[0]['xchan_photo_mimetype'], 'href' => $r[0]['xchan_photo_m'])),
+ 'name' => $r[0]['xchan_name'],
+ 'address' => $r[0]['xchan_addr'],
+ 'guid' => $r[0]['xchan_guid'],
+ 'guid_sig' => $r[0]['xchan_guid_sig'],
+ 'link' => array(
+ array('rel' => 'alternate', 'type' => 'text/html', 'href' => $r[0]['xchan_url']),
+ array('rel' => 'photo', 'type' => $r[0]['xchan_photo_mimetype'], 'href' => $r[0]['xchan_photo_m'])
+ ),
),
));
@@ -830,7 +857,7 @@ function event_store_item($arr, $event) {
$sig = '';
- q("UPDATE item SET title = '%s', body = '%s', object = '%s', allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s', edited = '%s', sig = '%s', item_flags = %d, item_private = %d, obj_type = '%s' WHERE id = %d AND uid = %d",
+ q("UPDATE item SET title = '%s', body = '%s', obj = '%s', allow_cid = '%s', allow_gid = '%s', deny_cid = '%s', deny_gid = '%s', edited = '%s', sig = '%s', item_flags = %d, item_private = %d, obj_type = '%s' WHERE id = %d AND uid = %d",
dbesc($arr['summary']),
dbesc($prefix . format_event_bbcode($arr)),
dbesc($object),
@@ -946,12 +973,12 @@ function event_store_item($arr, $event) {
dbesc($arr['event_xchan'])
);
if($x) {
- $item_arr['object'] = json_encode(array(
+ $item_arr['obj'] = json_encode(array(
'type' => ACTIVITY_OBJ_EVENT,
'id' => z_root() . '/event/' . $event['event_hash'],
'title' => $arr['summary'],
- 'start' => $arr['start'],
- 'finish' => $arr['finish'],
+ 'dtstart' => $arr['dtstart'],
+ 'dtend' => $arr['dtend'],
'nofinish' => $arr['nofinish'],
'description' => $arr['description'],
'location' => $arr['location'],
@@ -1001,7 +1028,7 @@ function tasks_fetch($arr) {
if($arr && $arr['all'] == 1)
$sql_extra = '';
- $r = q("select * from event where type = 'task' and uid = %d $sql_extra order by created desc",
+ $r = q("select * from event where etype = 'task' and uid = %d $sql_extra order by created desc",
intval(local_channel())
);