From af2b263bc74b16601ec7c123a58f0549613aed27 Mon Sep 17 00:00:00 2001 From: Xanthor Date: Fri, 17 May 2019 03:23:12 +0000 Subject: Fix a really disturbing comment (cherry picked from commit 823c0434ebcba7b7669203323f9cec4bbb9e0f4b) --- include/html2bbcode.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'include') diff --git a/include/html2bbcode.php b/include/html2bbcode.php index 1a03fbdaf..c916421b8 100644 --- a/include/html2bbcode.php +++ b/include/html2bbcode.php @@ -219,8 +219,7 @@ function html2bbcode($message) $message = $doc->saveHTML(); - // I'm removing something really disturbing - // Don't know exactly what it is + // I'm removing the UTF-8 encoding of a NO-BREAK SPACE codepoint $message = str_replace(chr(194).chr(160), ' ', $message); $message = str_replace(" ", " ", $message); -- cgit v1.2.3 From 34d1f797778c71357989d793a6356ed9f8aeefed Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 20 May 2019 12:26:33 +0200 Subject: calendar merge: initial commit for timezone support --- include/event.php | 15 +++++++++++---- include/features.php | 16 ++++++++-------- 2 files changed, 19 insertions(+), 12 deletions(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index 471fb7afa..9bae69f5c 100644 --- a/include/event.php +++ b/include/event.php @@ -75,17 +75,19 @@ 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'); + $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' => zidify_links(smilies(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))), + '$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', date_default_timezone_get(), $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 ))) + '$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', date_default_timezone_get(), $object['dtend'] , $bd_format ))) )); $event['content'] = replace_macros(get_markup_template('event_item_content.tpl'),array( @@ -1042,6 +1044,7 @@ function event_store_item($arr, $event) { 'type' => ACTIVITY_OBJ_EVENT, 'id' => z_root() . '/event/' . $r[0]['resource_id'], 'title' => $arr['summary'], + 'timezone' => $arr['timezone'], 'dtstart' => $arr['dtstart'], 'dtend' => $arr['dtend'], 'nofinish' => $arr['nofinish'], @@ -1107,6 +1110,8 @@ function event_store_item($arr, $event) { } $item_id = $r[0]['id']; + set_iconfig($item_id, 'event', 'timezone', $arr['timezone'], true); + /** * @hooks event_updated * Called when an event record is modified. @@ -1197,6 +1202,7 @@ function event_store_item($arr, $event) { 'type' => ACTIVITY_OBJ_EVENT, 'id' => z_root() . '/event/' . $event['event_hash'], 'title' => $arr['summary'], + 'timezone' => $arr['timezone'], 'dtstart' => $arr['dtstart'], 'dtend' => $arr['dtend'], 'nofinish' => $arr['nofinish'], @@ -1223,6 +1229,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); $res = item_store($item_arr); diff --git a/include/features.php b/include/features.php index d8607f447..431b199a5 100644 --- a/include/features.php +++ b/include/features.php @@ -87,6 +87,14 @@ function get_features($filtered = true, $level = (-1)) { t('Default is Sunday'), false, get_config('feature_lock','cal_first_day') + ], + + [ + 'event_tz_select', + t('Event Timezone Selection'), + t('Allow event creation in timezones other than your own.'), + false, + get_config('feature_lock','event_tz_select'), ] ], @@ -290,14 +298,6 @@ function get_features($filtered = true, $level = (-1)) { t('Make birthday events timezone aware in case your friends are scattered across the planet.'), true, get_config('feature_lock','smart_birthdays'), - ], - - [ - 'event_tz_select', - t('Event Timezone Selection'), - t('Allow event creation in timezones other than your own.'), - false, - get_config('feature_lock','event_tz_select'), ] ], -- cgit v1.2.3 From c9d64d75f3acab6b44d28cd7bcc6e7e5dd042e77 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 20 May 2019 13:51:53 +0200 Subject: move smart birthday feature to calendar settings and override the adjust flag at display time instead of import --- include/datetime.php | 2 +- include/features.php | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) (limited to 'include') diff --git a/include/datetime.php b/include/datetime.php index 3a07f1ccf..d049fc7c5 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -516,7 +516,7 @@ function update_birthdays() { 'event_xchan' => $rr['xchan_hash'], 'dtstart' => datetime_convert('UTC', 'UTC', $rr['abook_dob']), 'dtend' => datetime_convert('UTC', 'UTC', $rr['abook_dob'] . ' + 1 day '), - 'adjust' => intval(feature_enabled($rr['abook_channel'],'smart_birthdays')), + 'adjust' => 1, //intval(feature_enabled($rr['abook_channel'],'smart_birthdays')), 'summary' => sprintf( t('%1$s\'s birthday'), $rr['xchan_name']), 'description' => sprintf( t('Happy Birthday %1$s'), '[zrl=' . $rr['xchan_url'] . ']' . $rr['xchan_name'] . '[/zrl]'), 'etype' => 'birthday', diff --git a/include/features.php b/include/features.php index 431b199a5..a44b424a6 100644 --- a/include/features.php +++ b/include/features.php @@ -95,6 +95,14 @@ function get_features($filtered = true, $level = (-1)) { t('Allow event creation in timezones other than your own.'), false, get_config('feature_lock','event_tz_select'), + ], + + [ + 'smart_birthdays', + t('Smart Birthdays'), + t('Make birthday events timezone aware in case your friends are scattered across the planet.'), + true, + get_config('feature_lock','smart_birthdays'), ] ], @@ -290,14 +298,6 @@ function get_features($filtered = true, $level = (-1)) { t('Default is Sunday'), false, get_config('feature_lock','events_cal_first_day') - ], - - [ - 'smart_birthdays', - t('Smart Birthdays'), - t('Make birthday events timezone aware in case your friends are scattered across the planet.'), - true, - get_config('feature_lock','smart_birthdays'), ] ], -- cgit v1.2.3 From 39613aa2d9298e13629b5b4a7c6b6f1bbe7edca5 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 22 May 2019 12:40:37 +0200 Subject: improve timezone detection for caldav and remove smart birthday feature. Force adjust birthdays until we agree on how to deal with this. --- include/event.php | 4 ++-- include/features.php | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index 9bae69f5c..eb8731f46 100644 --- a/include/event.php +++ b/include/event.php @@ -83,11 +83,11 @@ function format_event_obj($jobject) { '$title' => zidify_links(smilies(bbcode($object['title']))), '$dtstart_label' => t('Starts:'), '$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', date_default_timezone_get(), $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('Finishes:'), '$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', date_default_timezone_get(), $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 ))) )); $event['content'] = replace_macros(get_markup_template('event_item_content.tpl'),array( diff --git a/include/features.php b/include/features.php index a44b424a6..5841395c5 100644 --- a/include/features.php +++ b/include/features.php @@ -96,14 +96,15 @@ function get_features($filtered = true, $level = (-1)) { false, get_config('feature_lock','event_tz_select'), ], - +/* [ 'smart_birthdays', t('Smart Birthdays'), t('Make birthday events timezone aware in case your friends are scattered across the planet.'), - true, + false, get_config('feature_lock','smart_birthdays'), ] +*/ ], -- cgit v1.2.3 From 528b9b6a60d847b0ecb639cb7fb8e01ee79b11d4 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 24 May 2019 10:27:45 +0200 Subject: fix #1374 --- include/markdown.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'include') diff --git a/include/markdown.php b/include/markdown.php index 2513a7d77..7d1f16958 100644 --- a/include/markdown.php +++ b/include/markdown.php @@ -76,6 +76,8 @@ function markdown_to_bb($s, $use_zrl = false, $options = []) { $s = html2bbcode($s); + $s = bb_code_protect($s); + // Convert everything that looks like a link to a link if($use_zrl) { if (strpos($s,'[/img]') !== false) { @@ -88,6 +90,8 @@ function markdown_to_bb($s, $use_zrl = false, $options = []) { $s = preg_replace("/([^\]\=\{\/]|^)(https?\:\/\/)([a-zA-Z0-9\pL\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@\(\)]+)/ismu", '$1[url=$2$3]$2$3[/url]',$s); } + $s = bb_code_unprotect($s); + // remove duplicate adjacent code tags $s = preg_replace("/(\[code\])+(.*?)(\[\/code\])+/ism","[code]$2[/code]", $s); -- cgit v1.2.3 From e466d72058b2543bec69c77d2730828acada38a1 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 26 May 2019 18:05:11 +0200 Subject: adjust birthday handling according to community decision and slightly change display of allday event items --- include/datetime.php | 3 ++- include/event.php | 24 ++++++++++++++++++++---- include/features.php | 9 --------- include/zot.php | 2 +- 4 files changed, 23 insertions(+), 15 deletions(-) (limited to 'include') diff --git a/include/datetime.php b/include/datetime.php index d049fc7c5..ef0927ea4 100644 --- a/include/datetime.php +++ b/include/datetime.php @@ -516,13 +516,14 @@ function update_birthdays() { 'event_xchan' => $rr['xchan_hash'], 'dtstart' => datetime_convert('UTC', 'UTC', $rr['abook_dob']), 'dtend' => datetime_convert('UTC', 'UTC', $rr['abook_dob'] . ' + 1 day '), - 'adjust' => 1, //intval(feature_enabled($rr['abook_channel'],'smart_birthdays')), + 'adjust' => 0, 'summary' => sprintf( t('%1$s\'s birthday'), $rr['xchan_name']), 'description' => sprintf( t('Happy Birthday %1$s'), '[zrl=' . $rr['xchan_url'] . ']' . $rr['xchan_name'] . '[/zrl]'), 'etype' => 'birthday', ]; $z = event_store_event($ev); + if ($z) { $item_id = event_store_item($ev, $z); q("update abook set abook_dob = '%s' where abook_id = %d", diff --git a/include/event.php b/include/event.php index eb8731f46..ca08a67b5 100644 --- a/include/event.php +++ b/include/event.php @@ -76,18 +76,34 @@ function format_event_obj($jobject) { if(array_key_exists('description', $object)) { $tz = (($object['timezone']) ? $object['timezone'] : 'UTC'); + $allday = (($object['adjust']) ? false : true); - $bd_format = t('l F d, Y \@ g:i A'); // Friday January 18, 2011 @ 8:01 AM + $dtstart = new DateTime($object['dtstart']); + $dtend = new DateTime($object['dtend']); + $dtdiff = $dtstart->diff($dtend); + + if($allday && ($dtdiff->days < 2)) + $oneday = 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')); + } + + $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('Starts:'), + '$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))), '$finish' => (($object['nofinish']) ? false : true), - '$dtend_label' => t('Finishes:'), + '$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($tz, date_default_timezone_get(), $object['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtend'] , $bd_format ))), + '$allday' => $allday, + '$oneday' => $oneday )); $event['content'] = replace_macros(get_markup_template('event_item_content.tpl'),array( diff --git a/include/features.php b/include/features.php index 5841395c5..9528d3418 100644 --- a/include/features.php +++ b/include/features.php @@ -95,16 +95,7 @@ function get_features($filtered = true, $level = (-1)) { t('Allow event creation in timezones other than your own.'), false, get_config('feature_lock','event_tz_select'), - ], -/* - [ - 'smart_birthdays', - t('Smart Birthdays'), - t('Make birthday events timezone aware in case your friends are scattered across the planet.'), - false, - get_config('feature_lock','smart_birthdays'), ] -*/ ], diff --git a/include/zot.php b/include/zot.php index b99eeb1ec..a37b7cdb5 100644 --- a/include/zot.php +++ b/include/zot.php @@ -4430,7 +4430,7 @@ function zotinfo($arr) { $profile['description'] = $p[0]['pdesc']; $profile['birthday'] = $p[0]['dob']; - if(($profile['birthday'] != '0000-00-00') && (($bd = z_birthday($p[0]['dob'],$e['channel_timezone'])) !== '')) + if(($profile['birthday'] != '0000-00-00') && (($bd = z_birthday($p[0]['dob'],'UTC')) !== '')) $profile['next_birthday'] = $bd; if($age = age($p[0]['dob'],$e['channel_timezone'],'')) -- cgit v1.2.3 From f1b61d5882cba9584ef35f574b29050397cb8d58 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 26 May 2019 20:22:40 +0200 Subject: mod cal band-aid fixes --- include/event.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/event.php b/include/event.php index ca08a67b5..de4e692b8 100644 --- a/include/event.php +++ b/include/event.php @@ -27,6 +27,7 @@ function format_event_html($ev) { if(! ((is_array($ev)) && count($ev))) return ''; + $tz = (($ev['timezone']) ? $ev['timezone'] : 'UTC'); $bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8:01 AM @@ -39,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))) @@ -49,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 ))) -- cgit v1.2.3