From b033597ada02ef045bc9fbdb2237f81935b73e47 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 11 Nov 2019 21:30:38 +0100 Subject: sse notifications --- include/event.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'include/event.php') diff --git a/include/event.php b/include/event.php index 6be1b6705..9d76aabd6 100644 --- a/include/event.php +++ b/include/event.php @@ -553,9 +553,19 @@ function event_store_event($arr) { dbesc($hash), intval($arr['uid']) ); - if($r) + if($r) { + + /** + * @hooks event_store_event_end + * Called after an event record was stored. + * * \e array \b event + */ + call_hooks('event_store_event_end', $r[0]); + return $r[0]; + } + return false; } -- cgit v1.2.3 From d3cbbe029c1f19a77ac0c278f735d81b9dd3a3ec Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 12 Jan 2020 22:41:28 -0800 Subject: rework activitystreams events - send invite/event activities instead of create/event. Also a first pass at creating a Zap export file from Hubzilla. Much more work is needed before this is functional. --- include/event.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/event.php') diff --git a/include/event.php b/include/event.php index 9d76aabd6..30dca2df2 100644 --- a/include/event.php +++ b/include/event.php @@ -1194,7 +1194,7 @@ function event_store_item($arr, $event) { if(! $arr['mid']) { $arr['uuid'] = $event['event_hash']; - $arr['mid'] = z_root() . '/event/' . $event['event_hash']; + $arr['mid'] = z_root() . '/activity/' . $event['event_hash']; } $item_arr['aid'] = $z[0]['channel_account_id']; -- cgit v1.2.3 From 2a287e6def5ab54037222c963ab0875faf62fc1a Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 14 Jan 2020 13:29:45 -0800 Subject: event compatibility work --- include/event.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'include/event.php') diff --git a/include/event.php b/include/event.php index 30dca2df2..59057e7d5 100644 --- a/include/event.php +++ b/include/event.php @@ -250,7 +250,7 @@ function format_ical_sourcetext($s) { } -function format_event_bbcode($ev) { +function format_event_bbcode($ev, $utc = false) { $o = ''; @@ -258,6 +258,14 @@ function format_event_bbcode($ev) { $o .= '[event]' . $ev['event_vdata'] . '[/event]'; } + if ($utc && $ev['event-timezone'] !== 'UTC') { + $ev['dtstart'] = datetime_convert($ev['timezone'],'UTC',$ev['dtstart'],ATOM_TIME); + if ($ev['dtend'] && ! $ev['nofinish']) { + $ev['dtend'] = datetime_convert($ev['timezone'],'UTC',$ev['dtend'],ATOM_TIME); + } + $ev['timezone'] = 'UTC'; + } + if($ev['summary']) $o .= '[event-summary]' . $ev['summary'] . '[/event-summary]'; -- cgit v1.2.3 From ead56c59e2551f39d00e880a2cdb4b2d02b38705 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 24 Jan 2020 19:38:52 -0800 Subject: bugfix: event_addtocal not preserving original privacy expectation --- include/event.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/event.php') diff --git a/include/event.php b/include/event.php index 59057e7d5..64e63074c 100644 --- a/include/event.php +++ b/include/event.php @@ -614,7 +614,7 @@ function event_addtocal($item_id, $uid) { $ev['event_hash'] = $item['resource_id']; } - if($ev->private) + if($ev['private']) $ev['allow_cid'] = '<' . $channel['channel_hash'] . '>'; else { $acl = new Zotlabs\Access\AccessList($channel); -- cgit v1.2.3 From ac52bebb88306273a481b7114fe190917da49b91 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 2 Apr 2020 12:33:57 +0000 Subject: ATOM_TIME format is not compatible with the DB --- include/event.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'include/event.php') diff --git a/include/event.php b/include/event.php index 64e63074c..b92d2c8a9 100644 --- a/include/event.php +++ b/include/event.php @@ -259,9 +259,9 @@ function format_event_bbcode($ev, $utc = false) { } if ($utc && $ev['event-timezone'] !== 'UTC') { - $ev['dtstart'] = datetime_convert($ev['timezone'],'UTC',$ev['dtstart'],ATOM_TIME); + $ev['dtstart'] = datetime_convert($ev['timezone'],'UTC',$ev['dtstart']); if ($ev['dtend'] && ! $ev['nofinish']) { - $ev['dtend'] = datetime_convert($ev['timezone'],'UTC',$ev['dtend'],ATOM_TIME); + $ev['dtend'] = datetime_convert($ev['timezone'],'UTC',$ev['dtend']); } $ev['timezone'] = 'UTC'; } -- cgit v1.2.3 From 6cfaa5cba32eb1e7f2b4a0ba6bb281ebd610a54b Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 3 Apr 2020 18:34:15 +0000 Subject: set timezone iconfig a little earlier in the process so that it will be included in the object --- include/event.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'include/event.php') diff --git a/include/event.php b/include/event.php index b92d2c8a9..0cc7170d1 100644 --- a/include/event.php +++ b/include/event.php @@ -1251,6 +1251,8 @@ function event_store_item($arr, $event) { else $item_arr['plink'] = z_root() . '/display/' . gen_link_id($item_arr['mid']); + set_iconfig($item_arr, 'event', 'timezone', $arr['timezone'], true); + $x = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($arr['event_xchan']) ); @@ -1286,7 +1288,7 @@ function event_store_item($arr, $event) { // activities refer to the item message_id as the parent. set_iconfig($item_arr, 'system','event_id',$event['event_hash'],true); - set_iconfig($item_arr, 'event','timezone',$arr['timezone'],true); + //set_iconfig($item_arr, 'event','timezone',$arr['timezone'],true); $res = item_store($item_arr); -- cgit v1.2.3 From cec2e92fe381a5e4bb67426290303639dd260358 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 3 Apr 2020 19:50:50 +0000 Subject: more timezone changes --- include/event.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'include/event.php') diff --git a/include/event.php b/include/event.php index 0cc7170d1..f455a0dbf 100644 --- a/include/event.php +++ b/include/event.php @@ -40,7 +40,7 @@ function format_event_html($ev) { $o .= '
' . t('Starts:') . ' ' - . (($ev['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), + . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $ev['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['dtstart'] , $bd_format))) @@ -50,7 +50,7 @@ function format_event_html($ev) { $o .= '
' . t('Finishes:') . ' ' - . (($ev['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), + . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $ev['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['dtend'] , $bd_format ))) @@ -98,11 +98,11 @@ function format_event_obj($jobject) { '$title' => zidify_links(smilies(bbcode($object['title']))), '$dtstart_label' => t('Start:'), '$dtstart_title' => datetime_convert($tz, date_default_timezone_get(), $object['dtstart'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), - '$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $object['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtstart'] , $bd_format))), + '$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('End:'), '$dtend_title' => datetime_convert($tz, date_default_timezone_get(), $object['dtend'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), - '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $object['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtend'] , $bd_format ))), + '$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 ))), '$allday' => $allday, '$oneday' => $oneday )); @@ -1097,6 +1097,8 @@ function event_store_item($arr, $event) { ); if($r) { + set_iconfig($r[0], 'event', 'timezone', $arr['timezone'], true); + $object = json_encode(array( 'type' => ACTIVITY_OBJ_EVENT, 'id' => z_root() . '/event/' . $r[0]['resource_id'], @@ -1167,7 +1169,7 @@ function event_store_item($arr, $event) { } $item_id = $r[0]['id']; - set_iconfig($item_id, 'event', 'timezone', $arr['timezone'], true); + //set_iconfig($item_id, 'event', 'timezone', $arr['timezone'], true); /** * @hooks event_updated -- cgit v1.2.3 From ec9418b2626f343614b3307902551ea68307002c Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 3 Apr 2020 22:01:02 +0200 Subject: Revert "set timezone iconfig a little earlier in the process so that it will be included in the object" This reverts commit 6cfaa5cba32eb1e7f2b4a0ba6bb281ebd610a54b --- include/event.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'include/event.php') diff --git a/include/event.php b/include/event.php index f455a0dbf..fbc46100f 100644 --- a/include/event.php +++ b/include/event.php @@ -1253,8 +1253,6 @@ function event_store_item($arr, $event) { else $item_arr['plink'] = z_root() . '/display/' . gen_link_id($item_arr['mid']); - set_iconfig($item_arr, 'event', 'timezone', $arr['timezone'], true); - $x = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($arr['event_xchan']) ); @@ -1290,7 +1288,7 @@ function event_store_item($arr, $event) { // activities refer to the item message_id as the parent. set_iconfig($item_arr, 'system','event_id',$event['event_hash'],true); - //set_iconfig($item_arr, 'event','timezone',$arr['timezone'],true); + set_iconfig($item_arr, 'event','timezone',$arr['timezone'],true); $res = item_store($item_arr); -- cgit v1.2.3 From cade25a112d3884034090135db421dab805a93d6 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 3 Apr 2020 22:01:44 +0200 Subject: Revert "more timezone changes" This reverts commit cec2e92fe381a5e4bb67426290303639dd260358 --- include/event.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'include/event.php') diff --git a/include/event.php b/include/event.php index fbc46100f..b92d2c8a9 100644 --- a/include/event.php +++ b/include/event.php @@ -40,7 +40,7 @@ function format_event_html($ev) { $o .= '
' . t('Starts:') . ' ' - . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), + . (($ev['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $ev['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['dtstart'] , $bd_format))) @@ -50,7 +50,7 @@ function format_event_html($ev) { $o .= '
' . t('Finishes:') . ' ' - . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), + . (($ev['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $ev['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['dtend'] , $bd_format ))) @@ -98,11 +98,11 @@ function format_event_obj($jobject) { '$title' => zidify_links(smilies(bbcode($object['title']))), '$dtstart_label' => t('Start:'), '$dtstart_title' => datetime_convert($tz, date_default_timezone_get(), $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))), + '$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert($tz, 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('End:'), '$dtend_title' => datetime_convert($tz, date_default_timezone_get(), $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 ))), + '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $object['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtend'] , $bd_format ))), '$allday' => $allday, '$oneday' => $oneday )); @@ -1097,8 +1097,6 @@ function event_store_item($arr, $event) { ); if($r) { - set_iconfig($r[0], 'event', 'timezone', $arr['timezone'], true); - $object = json_encode(array( 'type' => ACTIVITY_OBJ_EVENT, 'id' => z_root() . '/event/' . $r[0]['resource_id'], @@ -1169,7 +1167,7 @@ function event_store_item($arr, $event) { } $item_id = $r[0]['id']; - //set_iconfig($item_id, 'event', 'timezone', $arr['timezone'], true); + set_iconfig($item_id, 'event', 'timezone', $arr['timezone'], true); /** * @hooks event_updated -- cgit v1.2.3 From 44b935f8756ea751371065f1edc4f6fab339ab3d Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 4 Apr 2020 15:41:58 +0000 Subject: another attempt to get events right --- include/event.php | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) (limited to 'include/event.php') diff --git a/include/event.php b/include/event.php index b92d2c8a9..d39da227c 100644 --- a/include/event.php +++ b/include/event.php @@ -40,7 +40,7 @@ function format_event_html($ev) { $o .= '
' . t('Starts:') . ' ' - . (($ev['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), + . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $ev['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['dtstart'] , $bd_format))) @@ -50,7 +50,7 @@ function format_event_html($ev) { $o .= '
' . t('Finishes:') . ' ' - . (($ev['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), + . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $ev['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['dtend'] , $bd_format ))) @@ -97,12 +97,12 @@ function format_event_obj($jobject) { $event['header'] = replace_macros(get_markup_template('event_item_header.tpl'),array( '$title' => zidify_links(smilies(bbcode($object['title']))), '$dtstart_label' => t('Start:'), - '$dtstart_title' => datetime_convert($tz, date_default_timezone_get(), $object['dtstart'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), - '$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $object['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtstart'] , $bd_format))), + '$dtstart_title' => datetime_convert('UTC', date_default_timezone_get(), $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('End:'), - '$dtend_title' => datetime_convert($tz, date_default_timezone_get(), $object['dtend'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), - '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $object['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtend'] , $bd_format ))), + '$dtend_title' => datetime_convert('UTC', date_default_timezone_get(), $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 ))), '$allday' => $allday, '$oneday' => $oneday )); @@ -257,7 +257,7 @@ function format_event_bbcode($ev, $utc = false) { if($ev['event_vdata']) { $o .= '[event]' . $ev['event_vdata'] . '[/event]'; } - +/* if ($utc && $ev['event-timezone'] !== 'UTC') { $ev['dtstart'] = datetime_convert($ev['timezone'],'UTC',$ev['dtstart']); if ($ev['dtend'] && ! $ev['nofinish']) { @@ -265,7 +265,7 @@ function format_event_bbcode($ev, $utc = false) { } $ev['timezone'] = 'UTC'; } - +*/ if($ev['summary']) $o .= '[event-summary]' . $ev['summary'] . '[/event-summary]'; @@ -284,8 +284,8 @@ function format_event_bbcode($ev, $utc = false) { if($ev['event_hash']) $o .= '[event-id]' . $ev['event_hash'] . '[/event-id]'; - if($ev['timezone']) - $o .= '[event-timezone]' . $ev['timezone'] . '[/event-timezone]'; +// if($ev['timezone']) +// $o .= '[event-timezone]' . $ev['timezone'] . '[/event-timezone]'; if($ev['adjust']) $o .= '[event-adjust]' . $ev['adjust'] . '[/event-adjust]'; @@ -1091,12 +1091,17 @@ function event_store_item($arr, $event) { $item_arr['comment_policy'] = 'none'; } - $r = q("SELECT * FROM item left join xchan on author_xchan = xchan_hash WHERE resource_id = '%s' AND resource_type = 'event' and uid = %d LIMIT 1", + $r = q("SELECT * FROM item WHERE resource_id = '%s' AND resource_type = 'event' and uid = %d LIMIT 1", dbesc($event['event_hash']), intval($arr['uid']) ); if($r) { + + set_iconfig($r[0]['id'], 'event', 'timezone', $arr['timezone'], true); + xchan_query($r); + $r = fetch_post_tags($r,true); + $object = json_encode(array( 'type' => ACTIVITY_OBJ_EVENT, 'id' => z_root() . '/event/' . $r[0]['resource_id'], @@ -1111,13 +1116,13 @@ function event_store_item($arr, $event) { 'content' => format_event_bbcode($arr), 'attachment' => Activity::encode_attachment($r[0]), 'author' => array( - 'name' => $r[0]['xchan_name'], - 'address' => $r[0]['xchan_addr'], - 'guid' => $r[0]['xchan_guid'], - 'guid_sig' => $r[0]['xchan_guid_sig'], + 'name' => $r[0]['author']['xchan_name'], + 'address' => $r[0]['author']['xchan_addr'], + 'guid' => $r[0]['author']['xchan_guid'], + 'guid_sig' => $r[0]['author']['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']) + array('rel' => 'alternate', 'type' => 'text/html', 'href' => $r[0]['author']['xchan_url']), + array('rel' => 'photo', 'type' => $r[0]['author']['xchan_photo_mimetype'], 'href' => $r[0]['author']['xchan_photo_m']) ), ), )); @@ -1167,7 +1172,6 @@ function event_store_item($arr, $event) { } $item_id = $r[0]['id']; - set_iconfig($item_id, 'event', 'timezone', $arr['timezone'], true); /** * @hooks event_updated @@ -1251,6 +1255,8 @@ function event_store_item($arr, $event) { else $item_arr['plink'] = z_root() . '/display/' . gen_link_id($item_arr['mid']); + set_iconfig($item_arr, 'event','timezone',$arr['timezone'],true); + $x = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($arr['event_xchan']) ); @@ -1286,7 +1292,6 @@ function event_store_item($arr, $event) { // activities refer to the item message_id as the parent. set_iconfig($item_arr, 'system','event_id',$event['event_hash'],true); - set_iconfig($item_arr, 'event','timezone',$arr['timezone'],true); $res = item_store($item_arr); -- cgit v1.2.3 From 805f8bf98377d17593dfe884eac5c69079b83eed Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 5 Apr 2020 07:59:41 +0000 Subject: show event timezone if it differs from the channel default timezone --- include/event.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'include/event.php') diff --git a/include/event.php b/include/event.php index d39da227c..c8f9d2561 100644 --- a/include/event.php +++ b/include/event.php @@ -76,7 +76,17 @@ function format_event_obj($jobject) { //ensure compatibility with older items - this check can be removed at a later point if(array_key_exists('description', $object)) { - $tz = (($object['timezone']) ? $object['timezone'] : 'UTC'); + $event_tz = ''; + if(is_array($object['asld']) && isset($object['asld']['attachment'])) { + foreach($object['asld']['attachment'] as $attachment) { + if($attachment['type'] === 'PropertyValue' && $attachment['name'] == 'zot.event.timezone' ) { + $event_tz = $attachment['value']; + break; + } + } + + } + $allday = (($object['adjust']) ? false : true); $dtstart = new DateTime($object['dtstart']); @@ -104,7 +114,8 @@ function format_event_obj($jobject) { '$dtend_title' => datetime_convert('UTC', date_default_timezone_get(), $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 ))), '$allday' => $allday, - '$oneday' => $oneday + '$oneday' => $oneday, + '$event_tz' => ['label' => t('Timezone'), 'value' => (($event_tz === date_default_timezone_get()) ? '' : $event_tz)] )); $event['content'] = replace_macros(get_markup_template('event_item_content.tpl'),array( -- cgit v1.2.3 From 84183d9f7ef669779841cfccd65aae8000012e6d Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 5 Apr 2020 09:11:12 +0000 Subject: show event timezone only if adjust ist set and the offset of the event timezone is different from the channel default timezone offset --- include/event.php | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'include/event.php') diff --git a/include/event.php b/include/event.php index c8f9d2561..69ca64e0f 100644 --- a/include/event.php +++ b/include/event.php @@ -77,14 +77,22 @@ function format_event_obj($jobject) { if(array_key_exists('description', $object)) { $event_tz = ''; - if(is_array($object['asld']) && isset($object['asld']['attachment'])) { + if($object['adjust'] && is_array($object['asld']) && is_array($object['asld']['attachment'])) { foreach($object['asld']['attachment'] as $attachment) { if($attachment['type'] === 'PropertyValue' && $attachment['name'] == 'zot.event.timezone' ) { - $event_tz = $attachment['value']; + // check if the offset of the timezones is different and only set event_tz if offset is not the same + $local_tz = new DateTimeZone(date_default_timezone_get()); + $local_dt = new DateTime('now', $local_tz); + + $ev_tz = new DateTimeZone($attachment['value']); + $ev_dt = new DateTime('now', $ev_tz); + + if($local_dt->getOffset() !== $ev_dt->getOffset()) + $event_tz = $attachment['value']; + break; } } - } $allday = (($object['adjust']) ? false : true); -- cgit v1.2.3 From 328685d2fbe505fd5b1bf9892a0cce993210ac52 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 9 Apr 2020 09:38:36 +0000 Subject: move from build_sync_packet() to Libsync::build_sync_packet() --- include/event.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'include/event.php') diff --git a/include/event.php b/include/event.php index 69ca64e0f..c9cbb7c94 100644 --- a/include/event.php +++ b/include/event.php @@ -8,6 +8,7 @@ use Sabre\VObject; use Zotlabs\Lib\Activity; +use Zotlabs\Lib\Libsync; use Ramsey\Uuid\Uuid; use Ramsey\Uuid\Exception\UnsatisfiedDependencyException; @@ -663,7 +664,7 @@ function event_addtocal($item_id, $uid) { intval($channel['channel_id']) ); if($z) { - build_sync_packet($channel['channel_id'],array('event_item' => array(encode_item($sync_item[0],true)),'event' => $z)); + Libsync::build_sync_packet($channel['channel_id'],array('event_item' => array(encode_item($sync_item[0],true)),'event' => $z)); } return true; } -- cgit v1.2.3 From 6a0ac591d161df1b3a1d6182915ed01cfee95b0a Mon Sep 17 00:00:00 2001 From: zotlabs Date: Fri, 10 Apr 2020 14:27:20 -0700 Subject: event issue when using strict sql mode --- include/event.php | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'include/event.php') diff --git a/include/event.php b/include/event.php index c9cbb7c94..6161175f6 100644 --- a/include/event.php +++ b/include/event.php @@ -422,6 +422,10 @@ function event_store_event($arr) { $arr['event_xchan'] = (($arr['event_xchan']) ? $arr['event_xchan'] : ''); $arr['event_priority'] = (($arr['event_priority']) ? $arr['event_priority'] : 0); + if (! $arr['dtend']) { + $arr['dtend'] = NULL_DATE; + $arr['nofinish'] = 1; + } if(array_key_exists('event_status_date',$arr)) $arr['event_status_date'] = datetime_convert('UTC','UTC', $arr['event_status_date']); @@ -507,9 +511,9 @@ function event_store_event($arr) { deny_gid = '%s' WHERE id = %d AND uid = %d", - dbesc($arr['edited']), - dbesc($arr['dtstart']), - dbesc($arr['dtend']), + dbesc(datetime_convert('UTC','UTC',$arr['edited'])), + dbesc(datetime_convert('UTC','UTC',$arr['dtstart'])), + dbesc(datetime_convert('UTC','UTC',$arr['dtend'])), dbesc($arr['summary']), dbesc($arr['description']), dbesc($arr['location']), @@ -517,7 +521,7 @@ function event_store_event($arr) { intval($arr['adjust']), intval($arr['nofinish']), dbesc($arr['event_status']), - dbesc($arr['event_status_date']), + dbesc(datetime_convert('UTC','UTC',$arr['event_status_date'])), intval($arr['event_percent']), dbesc($arr['event_repeat']), intval($arr['event_sequence']), @@ -553,10 +557,10 @@ function event_store_event($arr) { intval($arr['account']), dbesc($arr['event_xchan']), dbesc($hash), - dbesc($arr['created']), - dbesc($arr['edited']), - dbesc($arr['dtstart']), - dbesc($arr['dtend']), + dbesc(datetime_convert('UTC','UTC',$arr['created'])), + dbesc(datetime_convert('UTC','UTC',$arr['edited'])), + dbesc(datetime_convert('UTC','UTC',$arr['dtstart'])), + dbesc(datetime_convert('UTC','UTC',$arr['dtend'])), dbesc($arr['summary']), dbesc($arr['description']), dbesc($arr['location']), @@ -564,7 +568,7 @@ function event_store_event($arr) { intval($arr['adjust']), intval($arr['nofinish']), dbesc($arr['event_status']), - dbesc($arr['event_status_date']), + dbesc(datetime_convert('UTC','UTC',$arr['event_status_date'])), intval($arr['event_percent']), dbesc($arr['event_repeat']), intval($arr['event_sequence']), -- cgit v1.2.3 From 03506bd6cf70719819f35a4979a759a7afee7eab Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 20 Apr 2020 11:58:08 +0000 Subject: use $mid as plink to prevent to long plinks --- include/event.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/event.php') diff --git a/include/event.php b/include/event.php index 6161175f6..82f6ca81e 100644 --- a/include/event.php +++ b/include/event.php @@ -1275,7 +1275,7 @@ function event_store_item($arr, $event) { // otherwise we'll fallback to /display/$message_id if($wall) - $item_arr['plink'] = z_root() . '/channel/' . $z[0]['channel_address'] . '/?f=&mid=' . gen_link_id($item_arr['mid']); + $item_arr['plink'] = $item_arr['mid']; else $item_arr['plink'] = z_root() . '/display/' . gen_link_id($item_arr['mid']); -- cgit v1.2.3 From 2d2cab0aba7026c4b68c9a21ac33b415620e613d Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 31 Jul 2020 08:41:18 +0000 Subject: event display zot/zot6 compatibility --- include/event.php | 102 +++++++++++++++++++++++++++--------------------------- 1 file changed, 51 insertions(+), 51 deletions(-) (limited to 'include/event.php') diff --git a/include/event.php b/include/event.php index 82f6ca81e..679440726 100644 --- a/include/event.php +++ b/include/event.php @@ -74,67 +74,67 @@ function format_event_obj($jobject) { $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)) { - - $event_tz = ''; - if($object['adjust'] && is_array($object['asld']) && is_array($object['asld']['attachment'])) { - foreach($object['asld']['attachment'] as $attachment) { - if($attachment['type'] === 'PropertyValue' && $attachment['name'] == 'zot.event.timezone' ) { - // check if the offset of the timezones is different and only set event_tz if offset is not the same - $local_tz = new DateTimeZone(date_default_timezone_get()); - $local_dt = new DateTime('now', $local_tz); - - $ev_tz = new DateTimeZone($attachment['value']); - $ev_dt = new DateTime('now', $ev_tz); - - if($local_dt->getOffset() !== $ev_dt->getOffset()) - $event_tz = $attachment['value']; - - break; - } + $event_tz = ''; + if($object['adjust'] && is_array($object['asld']) && is_array($object['asld']['attachment'])) { + foreach($object['asld']['attachment'] as $attachment) { + if($attachment['type'] === 'PropertyValue' && $attachment['name'] == 'zot.event.timezone' ) { + // check if the offset of the timezones is different and only set event_tz if offset is not the same + $local_tz = new DateTimeZone(date_default_timezone_get()); + $local_dt = new DateTime('now', $local_tz); + + $ev_tz = new DateTimeZone($attachment['value']); + $ev_dt = new DateTime('now', $ev_tz); + if($local_dt->getOffset() !== $ev_dt->getOffset()) + $event_tz = $attachment['value']; + break; } } - $allday = (($object['adjust']) ? false : true); - - $dtstart = new DateTime($object['dtstart']); - $dtend = new DateTime($object['dtend']); - $dtdiff = $dtstart->diff($dtend); + } - if($allday && ($dtdiff->days < 2)) - $oneday = true; + $allday = (($object['adjust']) ? false : true); - if($allday && !$oneday) { - // Subtract one day from the end date so we can use the "first day - last day" format for display. - $dtend->modify('-1 day'); - $object['dtend'] = datetime_convert('UTC', 'UTC', $dtend->format('Y-m-d H:i:s')); - } + $dtstart = new DateTime($object['dtstart']); + $dtend = new DateTime($object['dtend']); + $dtdiff = $dtstart->diff($dtend); - $bd_format = (($allday) ? t('l F d, Y') : t('l F d, Y \@ g:i A')); // Friday January 18, 2011 @ 8:01 AM or Friday January 18, 2011 for allday events - - $event['header'] = replace_macros(get_markup_template('event_item_header.tpl'),array( - '$title' => zidify_links(smilies(bbcode($object['title']))), - '$dtstart_label' => t('Start:'), - '$dtstart_title' => datetime_convert('UTC', date_default_timezone_get(), $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('End:'), - '$dtend_title' => datetime_convert('UTC', date_default_timezone_get(), $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 ))), - '$allday' => $allday, - '$oneday' => $oneday, - '$event_tz' => ['label' => t('Timezone'), 'value' => (($event_tz === date_default_timezone_get()) ? '' : $event_tz)] - )); + if($allday && ($dtdiff->days < 2)) + $oneday = true; - $event['content'] = replace_macros(get_markup_template('event_item_content.tpl'),array( - '$description' => zidify_links(smilies(bbcode($object['description']))), - '$location_label' => t('Location:'), - '$location' => zidify_links(smilies(bbcode($object['location']))) - )); + if($allday && !$oneday) { + // Subtract one day from the end date so we can use the "first day - last day" format for display. + $dtend->modify('-1 day'); + $object['dtend'] = datetime_convert('UTC', 'UTC', $dtend->format('Y-m-d H:i:s')); + } + $bd_format = (($allday) ? t('l F d, Y') : t('l F d, Y \@ g:i A')); // Friday January 18, 2011 @ 8:01 AM or Friday January 18, 2011 for allday events + + $event['header'] = replace_macros(get_markup_template('event_item_header.tpl'),array( + '$title' => zidify_links(smilies(bbcode($object['title']))), + '$dtstart_label' => t('Start:'), + '$dtstart_title' => datetime_convert('UTC', date_default_timezone_get(), $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('End:'), + '$dtend_title' => datetime_convert('UTC', date_default_timezone_get(), $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 ))), + '$allday' => $allday, + '$oneday' => $oneday, + '$event_tz' => ['label' => t('Timezone'), 'value' => (($event_tz === date_default_timezone_get()) ? '' : $event_tz)] + )); + + $event_src = []; + + if(array_path_exists('asld/source', $object) && $object['asld']['source']['mediaType'] === 'text/bbcode') { + $event_src = bbtoevent($object['asld']['source']['content']); } + $event['content'] = replace_macros(get_markup_template('event_item_content.tpl'),array( + '$description' => zidify_links(smilies(bbcode($event_src ? $event_src['description'] : $object['description']))), + '$location_label' => t('Location:'), + '$location' => zidify_links(smilies(bbcode($event_src ? $event_src['location'] : $object['location']))), + )); + return $event; } -- cgit v1.2.3 From ed845d93bc7ac5f46ccb1ea95d53bc5e5f2756bd Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 10 Oct 2020 19:06:35 +0000 Subject: 5.0RC testing: fix issue with event responses --- include/event.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'include/event.php') diff --git a/include/event.php b/include/event.php index 679440726..765086167 100644 --- a/include/event.php +++ b/include/event.php @@ -1247,7 +1247,7 @@ function event_store_item($arr, $event) { $item_arr['deny_cid'] = $arr['deny_cid']; $item_arr['deny_gid'] = $arr['deny_gid']; $item_arr['item_private'] = $private; - $item_arr['verb'] = ACTIVITY_POST; + $item_arr['verb'] = 'Invite'; $item_arr['item_wall'] = $item_wall; $item_arr['item_origin'] = $item_origin; $item_arr['item_thread_top'] = $item_thread_top; -- cgit v1.2.3