From 3e431c65be4c7d0cc9640af216ffdff02695401d Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 13 May 2019 12:17:08 +0200 Subject: [PATCH 01/19] bump version --- boot.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/boot.php b/boot.php index ab0f2720f..1b13b335a 100755 --- a/boot.php +++ b/boot.php @@ -50,7 +50,7 @@ require_once('include/attach.php'); require_once('include/bbcode.php'); define ( 'PLATFORM_NAME', 'hubzilla' ); -define ( 'STD_VERSION', '4.2RC' ); +define ( 'STD_VERSION', '4.3' ); define ( 'ZOT_REVISION', '6.0a' ); define ( 'DB_UPDATE_VERSION', 1234 ); From b0c3780667a558b52fbc701378939a3e3637fb69 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 13 May 2019 13:02:23 +0200 Subject: [PATCH 02/19] fix button size --- view/tpl/wiki.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/view/tpl/wiki.tpl b/view/tpl/wiki.tpl index 4a4db03eb..8556d8bad 100644 --- a/view/tpl/wiki.tpl +++ b/view/tpl/wiki.tpl @@ -68,7 +68,7 @@
- +
From 436293713bab05f11981c963139e51cba25967f1 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Mon, 13 May 2019 05:14:43 -0700 Subject: [PATCH 03/19] bbcode map bypass wasn't catching all map forms. --- include/bbcode.php | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/include/bbcode.php b/include/bbcode.php index 1c153677d..33219c67d 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -986,19 +986,22 @@ function bbcode($Text, $options = []) { // leave open the posibility of [map=something] // this is replaced in prepare_body() which has knowledge of the item location - - if (! $cache) { + if ($cache) { + $Text = str_replace([ '[map]','[/map]' ], [ '','' ], $Text); + $Text = preg_replace('/[map=(.*?)\]/ism','$1',$Text); + } + else { if (strpos($Text,'[/map]') !== false) { $Text = preg_replace_callback("/\[map\](.*?)\[\/map\]/ism", 'bb_map_location', $Text); } if (strpos($Text,'[map=') !== false) { $Text = preg_replace_callback("/\[map=(.*?)\]/ism", 'bb_map_coords', $Text); } + if (strpos($Text,'[map]') !== false) { + $Text = preg_replace("/\[map\]/", '
', $Text); + } } - if (strpos($Text,'[map]') !== false) { - $Text = preg_replace("/\[map\]/", '
', $Text); - } - + // Check for bold text if (strpos($Text,'[b]') !== false) { $Text = preg_replace("(\[b\](.*?)\[\/b\])ism", '$1', $Text); From 71064f481b94da11ca8a819c1cec88f8df4b671c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 13 May 2019 15:45:05 +0200 Subject: [PATCH 04/19] deal with privacy mentions in event descriptions --- Zotlabs/Module/Channel_calendar.php | 46 ++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/Zotlabs/Module/Channel_calendar.php b/Zotlabs/Module/Channel_calendar.php index b6ecde64b..e513a7f6e 100644 --- a/Zotlabs/Module/Channel_calendar.php +++ b/Zotlabs/Module/Channel_calendar.php @@ -74,10 +74,6 @@ class Channel_calendar extends \Zotlabs\Web\Controller { $location = escape_tags(trim($_POST['location'])); $type = escape_tags(trim($_POST['type'])); - require_once('include/text.php'); - linkify_tags($desc, local_channel()); - linkify_tags($location, local_channel()); - // Don't allow the event to finish before it begins. // It won't hurt anything, but somebody will file a bug report // and we'll waste a bunch of time responding to it. Time that @@ -130,12 +126,40 @@ class Channel_calendar extends \Zotlabs\Web\Controller { $post_tags = array(); $channel = \App::get_channel(); $ac = $acl->get(); - + + $str_contact_allow = $ac['allow_cid']; + $str_group_allow = $ac['allow_gid']; + $str_contact_deny = $ac['deny_cid']; + $str_group_deny = $ac['deny_gid']; + + $private = $acl->is_private(); + + require_once('include/text.php'); + $results = linkify_tags($desc, local_channel()); + + if($results) { + // Set permissions based on tag replacements + set_linkified_perms($results, $str_contact_allow, $str_group_allow, local_channel(), false, $private); + + foreach($results as $result) { + $success = $result['success']; + if($success['replaced']) { + $post_tags[] = array( + 'uid' => local_channel(), + 'ttype' => $success['termtype'], + 'otype' => TERM_OBJ_POST, + 'term' => $success['term'], + 'url' => $success['url'] + ); + } + } + } + if(strlen($categories)) { $cats = explode(',',$categories); foreach($cats as $cat) { $post_tags[] = array( - 'uid' => $profile_uid, + 'uid' => local_channel(), 'ttype' => TERM_CATEGORY, 'otype' => TERM_OBJ_POST, 'term' => trim($cat), @@ -156,11 +180,11 @@ class Channel_calendar extends \Zotlabs\Web\Controller { $datarray['uid'] = local_channel(); $datarray['account'] = get_account_id(); $datarray['event_xchan'] = $channel['channel_hash']; - $datarray['allow_cid'] = $ac['allow_cid']; - $datarray['allow_gid'] = $ac['allow_gid']; - $datarray['deny_cid'] = $ac['deny_cid']; - $datarray['deny_gid'] = $ac['deny_gid']; - $datarray['private'] = (($acl->is_private()) ? 1 : 0); + $datarray['allow_cid'] = $str_contact_allow; + $datarray['allow_gid'] = $str_group_allow; + $datarray['deny_cid'] = $str_contact_deny; + $datarray['deny_gid'] = $str_group_deny; + $datarray['private'] = intval($private); $datarray['id'] = $event_id; $datarray['created'] = $created; $datarray['edited'] = $edited; From c1f01b7e3515ed823019f133cd73c1752b372f4c Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 13 May 2019 22:00:40 +0200 Subject: [PATCH 05/19] css fixes --- view/tpl/conv_item.tpl | 2 +- view/tpl/peoplefind.tpl | 2 +- view/tpl/searchbox.tpl | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/view/tpl/conv_item.tpl b/view/tpl/conv_item.tpl index eceff51c7..54f1af69d 100755 --- a/view/tpl/conv_item.tpl +++ b/view/tpl/conv_item.tpl @@ -28,7 +28,7 @@ {{/if}}
{{if $item.thr_parent}} -     +     {{/if}}
diff --git a/view/tpl/peoplefind.tpl b/view/tpl/peoplefind.tpl index 206be694e..bbcc0b85b 100755 --- a/view/tpl/peoplefind.tpl +++ b/view/tpl/peoplefind.tpl @@ -4,7 +4,7 @@
- +
diff --git a/view/tpl/searchbox.tpl b/view/tpl/searchbox.tpl index 2fcf3e374..0ff526847 100644 --- a/view/tpl/searchbox.tpl +++ b/view/tpl/searchbox.tpl @@ -3,9 +3,9 @@
- + {{if $savedsearch}} - + {{/if}}
From d0322f5fbdf7a1ec3ac3ee894a8eabc4b252cf57 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 13 May 2019 23:16:36 +0200 Subject: [PATCH 06/19] Fix comments scroll button CSS --- view/js/main.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/view/js/main.js b/view/js/main.js index 48159e6e8..e91bd914d 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1161,7 +1161,7 @@ function doreply(parent, ident, owner, hint) { function doscroll(parent, hidden) { var x = '#hide-comments-outer-' + hidden.toString(); - var back = $('.back-to-reply'); + var back = $('#back-to-reply'); if(back.length == 0) var pos = $(window).scrollTop(); else @@ -1177,11 +1177,11 @@ function doscroll(parent, hidden) { back.remove(); var id = $('[data-mid="' + parent + '"]'); $('html, body').animate({scrollTop:(id.offset().top) - 50}, 'slow'); - $('   ').insertBefore('#wall-item-info-' + id.attr('id').replace(/\D/g,'')); + $('   ').insertBefore('#wall-item-info-' + id.attr('id').replace(/\D/g,'')); } function doscrollback(pos) { - $('.back-to-reply').remove(); + $('#back-to-reply').remove(); $(window).scrollTop(pos); } From 15a000bb4554b0dee168eb595c9390a555c59f74 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 14 May 2019 09:09:48 +0200 Subject: [PATCH 07/19] add autocomplete js to calendar and fix issue with extended likes mid --- Zotlabs/Module/Like.php | 6 +++--- view/js/mod_cdav.js | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) create mode 100644 view/js/mod_cdav.js diff --git a/Zotlabs/Module/Like.php b/Zotlabs/Module/Like.php index 3d1f503b6..052d51d43 100644 --- a/Zotlabs/Module/Like.php +++ b/Zotlabs/Module/Like.php @@ -491,7 +491,7 @@ class Like extends \Zotlabs\Web\Controller { $arr['item_flags'] = $item_flags; $arr['item_wall'] = $item_wall; - $arr['parent_mid'] = (($extended_like) ? $mid : $item['mid']); + $arr['parent_mid'] = (($extended_like) ? $arr['mid'] : $item['mid']); $arr['owner_xchan'] = (($extended_like) ? $ch[0]['xchan_hash'] : $thread_owner['xchan_hash']); $arr['author_xchan'] = $observer['xchan_hash']; @@ -546,7 +546,7 @@ class Like extends \Zotlabs\Web\Controller { dbesc($observer['xchan_hash']), dbesc($ch[0]['channel_hash']), intval($post_id), - dbesc($mid), + dbesc($arr['mid']), dbesc($activity), dbesc(($tgttype)? $tgttype : $objtype), dbesc($obj_id), @@ -555,7 +555,7 @@ class Like extends \Zotlabs\Web\Controller { $r = q("select * from likes where liker = '%s' and likee = '%s' and i_mid = '%s' and verb = '%s' and target_type = '%s' and target_id = '%s' ", dbesc($observer['xchan_hash']), dbesc($ch[0]['channel_hash']), - dbesc($mid), + dbesc($arr['mid']), dbesc($activity), dbesc(($tgttype)? $tgttype : $objtype), dbesc($obj_id) diff --git a/view/js/mod_cdav.js b/view/js/mod_cdav.js new file mode 100644 index 000000000..31ce87f7a --- /dev/null +++ b/view/js/mod_cdav.js @@ -0,0 +1,4 @@ +$(document).ready(function() { + $('#id_description').editor_autocomplete(baseurl + "/acl"); + $('textarea').bbco_autocomplete('bbcode'); +}); From 3c8867a1e861f75cb7a11e2ea6a15b2d2e457b7b Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 15 May 2019 11:38:23 +0200 Subject: [PATCH 08/19] missing backslash --- include/bbcode.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/bbcode.php b/include/bbcode.php index 70183fda3..485a1f5b2 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -987,7 +987,7 @@ function bbcode($Text, $options = []) { // this is replaced in prepare_body() which has knowledge of the item location if ($cache) { $Text = str_replace([ '[map]','[/map]' ], [ '','' ], $Text); - $Text = preg_replace('/[map=(.*?)\]/ism','$1',$Text); + $Text = preg_replace('/\[map=(.*?)\]/ism','$1',$Text); } else { if (strpos($Text,'[/map]') !== false) { From 8be00316025efc424a7b38ab5a2542dd5d1e9fd0 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 15 May 2019 18:21:52 +0200 Subject: [PATCH 09/19] calendar merge: only export events that will not break the importer. this will probably dismiss some old experimental entries --- Zotlabs/Module/Channel_calendar.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Module/Channel_calendar.php b/Zotlabs/Module/Channel_calendar.php index e513a7f6e..9229e6eb2 100644 --- a/Zotlabs/Module/Channel_calendar.php +++ b/Zotlabs/Module/Channel_calendar.php @@ -335,8 +335,9 @@ class Channel_calendar extends \Zotlabs\Web\Controller { ); } elseif($export) { - $r = q("SELECT * from event where uid = %d", - intval(local_channel()) + $r = q("SELECT * from event where uid = %d and dtstart > '%s' and dtend > dtstart", + intval(local_channel()), + dbesc(NULL_DATE) ); } else { From e7f1f496c5977ae290ea1457ea5c117dd29676f6 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 17 May 2019 11:57:41 +0200 Subject: [PATCH 10/19] use escape_tags() wiki headers --- Zotlabs/Module/Wiki.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index 502f96a62..c78cb0fb5 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -293,9 +293,9 @@ class Wiki extends Controller { } //$wikiheaderName = urldecode($wikiUrlName); - $wikiheaderName = NativeWiki::name_decode($wikiUrlName); + $wikiheaderName = escape_tags(NativeWiki::name_decode($wikiUrlName)); //$wikiheaderPage = urldecode($pageUrlName); - $wikiheaderPage = NativeWiki::name_decode($pageUrlName); + $wikiheaderPage = escape_tags(NativeWiki::name_decode($pageUrlName)); $renamePage = (($wikiheaderPage === 'Home') ? '' : t('Rename page')); $sharePage = t('Share'); From aa120e0478b8a7e0eabcbd7b8d7eefd515ff5347 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 17 May 2019 12:24:25 +0200 Subject: [PATCH 11/19] wiki: urlencode the entire share link --- Zotlabs/Module/Wiki.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Zotlabs/Module/Wiki.php b/Zotlabs/Module/Wiki.php index c78cb0fb5..169dc6de1 100644 --- a/Zotlabs/Module/Wiki.php +++ b/Zotlabs/Module/Wiki.php @@ -373,13 +373,13 @@ class Wiki extends Controller { $placeholder = t('Short description of your changes (optional)'); - $zrl = urlencode( z_root() . '/wiki/' . argv(1) . '/' . NativeWiki::name_encode($wikiUrlName) . '/' . NativeWiki::name_encode($pageUrlName) ); + $zrl = z_root() . '/wiki/' . argv(1) . '/' . NativeWiki::name_encode($wikiUrlName) . '/' . NativeWiki::name_encode($pageUrlName); $o .= replace_macros(get_markup_template('wiki.tpl'),array( '$wikiheaderName' => $wikiheaderName, '$wikiheaderPage' => $wikiheaderPage, '$renamePage' => $renamePage, '$sharePage' => $sharePage, - '$shareLink' => '#^[zrl=' . $zrl . ']' . '[ ' . $owner['channel_name'] . ' ] ' . $wikiheaderName . ' - ' . $wikiheaderPage . '[/zrl]', + '$shareLink' => urlencode('#^[zrl=' . $zrl . ']' . '[ ' . $owner['channel_name'] . ' ] ' . $wikiheaderName . ' - ' . $wikiheaderPage . '[/zrl]'), '$showPageControls' => $showPageControls, '$editOrSourceLabel' => (($showPageControls) ? t('Edit') : t('Source')), '$tools_label' => 'Page Tools', From af2b263bc74b16601ec7c123a58f0549613aed27 Mon Sep 17 00:00:00 2001 From: Xanthor Date: Fri, 17 May 2019 03:23:12 +0000 Subject: [PATCH 12/19] Fix a really disturbing comment (cherry picked from commit 823c0434ebcba7b7669203323f9cec4bbb9e0f4b) --- include/html2bbcode.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) 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); From 34d1f797778c71357989d793a6356ed9f8aeefed Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 20 May 2019 12:26:33 +0200 Subject: [PATCH 13/19] calendar merge: initial commit for timezone support --- Zotlabs/Module/Cdav.php | 50 ++++++++++++------- Zotlabs/Module/Channel_calendar.php | 75 +++++++++-------------------- include/event.php | 15 ++++-- include/features.php | 16 +++--- view/tpl/cdav_calendar.tpl | 17 +++++-- 5 files changed, 90 insertions(+), 83 deletions(-) diff --git a/Zotlabs/Module/Cdav.php b/Zotlabs/Module/Cdav.php index 6b4f57ea5..275873db5 100644 --- a/Zotlabs/Module/Cdav.php +++ b/Zotlabs/Module/Cdav.php @@ -271,11 +271,14 @@ class Cdav extends Controller { if(!cdav_perms($id[0],$calendars,true)) return; + $timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : ''); + $tz = (($timezone) ? $timezone : date_default_timezone_get()); + $title = $_REQUEST['title']; - $start = datetime_convert(App::$timezone, 'UTC', $_REQUEST['dtstart']); + $start = datetime_convert($tz, 'UTC', $_REQUEST['dtstart']); $dtstart = new \DateTime($start); if($_REQUEST['dtend']) { - $end = datetime_convert(App::$timezone, 'UTC', $_REQUEST['dtend']); + $end = datetime_convert($tz, 'UTC', $_REQUEST['dtend']); $dtend = new \DateTime($end); } $description = $_REQUEST['description']; @@ -303,14 +306,14 @@ class Cdav extends Controller { ]); if($dtend) { $vcalendar->VEVENT->add('DTEND', $dtend); - $vcalendar->VEVENT->DTEND['TZID'] = App::$timezone; + $vcalendar->VEVENT->DTEND['TZID'] = $tz; } if($description) $vcalendar->VEVENT->add('DESCRIPTION', $description); if($location) $vcalendar->VEVENT->add('LOCATION', $location); - $vcalendar->VEVENT->DTSTART['TZID'] = App::$timezone; + $vcalendar->VEVENT->DTSTART['TZID'] = $tz; $calendarData = $vcalendar->serialize(); @@ -348,12 +351,15 @@ class Cdav extends Controller { if(!cdav_perms($id[0],$calendars,true)) return; + $timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : ''); + $tz = (($timezone) ? $timezone : date_default_timezone_get()); + $uri = $_REQUEST['uri']; $title = $_REQUEST['title']; - $start = datetime_convert(App::$timezone, 'UTC', $_REQUEST['dtstart']); + $start = datetime_convert($tz, 'UTC', $_REQUEST['dtstart']); $dtstart = new \DateTime($start); if($_REQUEST['dtend']) { - $end = datetime_convert(App::$timezone, 'UTC', $_REQUEST['dtend']); + $end = datetime_convert($tz, 'UTC', $_REQUEST['dtend']); $dtend = new \DateTime($end); } $description = $_REQUEST['description']; @@ -406,11 +412,14 @@ class Cdav extends Controller { if(!cdav_perms($id[0],$calendars,true)) return; + $timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : ''); + $tz = (($timezone) ? $timezone : date_default_timezone_get()); + $uri = $_REQUEST['uri']; - $start = datetime_convert(App::$timezone, 'UTC', $_REQUEST['dtstart']); + $start = datetime_convert($tz, 'UTC', $_REQUEST['dtstart']); $dtstart = new \DateTime($start); if($_REQUEST['dtend']) { - $end = datetime_convert(App::$timezone, 'UTC', $_REQUEST['dtend']); + $end = datetime_convert($tz, 'UTC', $_REQUEST['dtend']); $dtend = new \DateTime($end); } @@ -915,8 +924,13 @@ class Cdav extends Controller { xchan_query($r); $r = fetch_post_tags($r,true); - $r[0]['dtstart'] = (($r[0]['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$r[0]['dtstart'], 'c') : datetime_convert('UTC','UTC',$r[0]['dtstart'],'c')); - $r[0]['dtend'] = (($r[0]['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$r[0]['dtend'], 'c') : datetime_convert('UTC','UTC',$r[0]['dtend'],'c')); + $tz = get_iconfig($r[0], 'event', 'timezone'); + if(! $tz) + $tz = 'UTC'; + + $r[0]['timezone'] = $tz; + $r[0]['dtstart'] = (($r[0]['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $r[0]['dtstart'], 'c') : datetime_convert('UTC', 'UTC', $r[0]['dtstart'], 'c')); + $r[0]['dtend'] = (($r[0]['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $r[0]['dtend'], 'c') : datetime_convert('UTC', 'UTC' ,$r[0]['dtend'], 'c')); $r[0]['plink'] = [$r[0]['plink'], t('Link to source')]; @@ -984,7 +998,7 @@ class Cdav extends Controller { $first_day = feature_enabled(local_channel(), 'cal_first_day'); $first_day = (($first_day) ? $first_day : 0); - $title = ['title', t('Event title')]; + $title = ['title', t('Event title') ]; $dtstart = ['dtstart', t('Start date and time')]; $dtend = ['dtend', t('End date and time')]; $description = ['description', t('Description')]; @@ -1000,14 +1014,13 @@ class Cdav extends Controller { //$acl = (($orig_event['event_xchan']) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $perm_defaults), false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_stream'))); $acl = populate_acl($perm_defaults, false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_stream')); - //$permissions = ((x($orig_event)) ? $orig_event : $perm_defaults); - $permissions = $perm_defaults; + $permissions = (($resource_id) ? $resource : $perm_defaults); $o .= replace_macros(get_markup_template('cdav_calendar.tpl'), [ '$sources' => $sources, '$color' => $color, '$lang' => App::$language, - '$timezone' => App::$timezone, + '$timezone' => date_default_timezone_get(), '$first_day' => $first_day, '$prev' => t('Previous'), '$next' => t('Next'), @@ -1047,7 +1060,9 @@ class Cdav extends Controller { '$categories_label' => t('Categories'), '$resource' => json_encode($resource), - '$categories' => $categories + '$categories' => $categories, + '$timezone_select' => ((feature_enabled(local_channel(),'event_tz_select')) ? ['timezone_select' , t('Timezone:'), date_default_timezone_get(), '', get_timezones()] : []) + ]); return $o; @@ -1118,8 +1133,9 @@ class Cdav extends Controller { 'calendar_id' => $id, 'uri' => $object['uri'], 'title' => $title, - 'start' => datetime_convert($timezone, $timezone, $dtstart, 'c'), - 'end' => (($dtend) ? datetime_convert($timezone, $timezone, $dtend, 'c') : ''), + 'timezone' => $timezone, + 'start' => datetime_convert($timezone, date_default_timezone_get(), $dtstart, 'c'), + 'end' => (($dtend) ? datetime_convert($timezone, date_default_timezone_get(), $dtend, 'c') : ''), 'description' => $description, 'location' => $location, 'allDay' => $allDay, diff --git a/Zotlabs/Module/Channel_calendar.php b/Zotlabs/Module/Channel_calendar.php index 9229e6eb2..45f5870d0 100644 --- a/Zotlabs/Module/Channel_calendar.php +++ b/Zotlabs/Module/Channel_calendar.php @@ -22,52 +22,20 @@ class Channel_calendar extends \Zotlabs\Web\Controller { $xchan = ((x($_POST,'xchan')) ? dbesc($_POST['xchan']) : ''); $uid = local_channel(); - - $start_text = escape_tags($_REQUEST['dtstart']); - $finish_text = escape_tags($_REQUEST['dtend']); - $adjust = intval($_POST['adjust']); - $nofinish = intval($_POST['nofinish']); - - $timezone = ((x($_POST,'timezone_select')) ? notags(trim($_POST['timezone_select'])) : ''); + // only allow editing your own events. + if(($xchan) && ($xchan !== get_observer_hash())) + return; + $timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : ''); $tz = (($timezone) ? $timezone : date_default_timezone_get()); $categories = escape_tags(trim($_POST['categories'])); - - // only allow editing your own events. - - if(($xchan) && ($xchan !== get_observer_hash())) - return; - - if($start_text) { - $start = $start_text; - } - else { - $start = sprintf('%d-%d-%d %d:%d:0',$startyear,$startmonth,$startday,$starthour,$startminute); - } + + $adjust = intval($_POST['adjust']); - if($finish_text) { - $finish = $finish_text; - } - else { - $finish = sprintf('%d-%d-%d %d:%d:0',$finishyear,$finishmonth,$finishday,$finishhour,$finishminute); - } - - if($nofinish) { - $finish = NULL_DATE; - } - - if($adjust) { - $start = datetime_convert($tz,'UTC',$start); - if(! $nofinish) - $finish = datetime_convert($tz,'UTC',$finish); - } - else { - $start = datetime_convert('UTC','UTC',$start); - if(! $nofinish) - $finish = datetime_convert('UTC','UTC',$finish); - } + $start = (($adjust) ? datetime_convert($tz, 'UTC', escape_tags($_REQUEST['dtstart'])) : datetime_convert('UTC', 'UTC', escape_tags($_REQUEST['dtstart']))); + $finish = (($adjust) ? datetime_convert($tz, 'UTC', escape_tags($_REQUEST['dtend'])) : datetime_convert('UTC', 'UTC', escape_tags($_REQUEST['dtend']))); $summary = escape_tags(trim($_POST['summary'])); $desc = escape_tags(trim($_POST['desc'])); @@ -176,7 +144,7 @@ class Channel_calendar extends \Zotlabs\Web\Controller { $datarray['location'] = $location; $datarray['etype'] = $type; $datarray['adjust'] = $adjust; - $datarray['nofinish'] = $nofinish; + $datarray['nofinish'] = 0; $datarray['uid'] = local_channel(); $datarray['account'] = get_account_id(); $datarray['event_xchan'] = $channel['channel_hash']; @@ -188,6 +156,8 @@ class Channel_calendar extends \Zotlabs\Web\Controller { $datarray['id'] = $event_id; $datarray['created'] = $created; $datarray['edited'] = $edited; + $datarray['timezone'] = $tz; + if(intval($_REQUEST['preview'])) { $html = format_event_html($datarray); @@ -322,10 +292,9 @@ class Channel_calendar extends \Zotlabs\Web\Controller { $start = datetime_convert('UTC','UTC',$start); $finish = datetime_convert('UTC','UTC',$finish); - $adjust_start = datetime_convert('UTC', date_default_timezone_get(), $start); $adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish); - + if (x($_GET,'id')){ $r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan, item.id as item_id from event left join item on item.resource_id = event.event_hash @@ -347,23 +316,21 @@ class Channel_calendar extends \Zotlabs\Web\Controller { // Ultimately the finish date shouldn't be involved in the query. $r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan, item.id as item_id - from event left join item on event.event_hash = item.resource_id - where item.resource_type = 'event' and event.uid = %d and event.uid = item.uid $ignored - AND (( event.adjust = 0 AND ( event.dtend >= '%s' or event.nofinish = 1 ) AND event.dtstart <= '%s' ) - OR ( event.adjust = 1 AND ( event.dtend >= '%s' or event.nofinish = 1 ) AND event.dtstart <= '%s' )) ", + from event left join item on event_hash = resource_id + where resource_type = 'event' and event.uid = %d and event.uid = item.uid $ignored + AND (( adjust = 0 AND ( dtend >= '%s' or nofinish = 1 ) AND dtstart <= '%s' ) + OR ( adjust = 1 AND ( dtend >= '%s' or nofinish = 1 ) AND dtstart <= '%s' )) ", intval(local_channel()), dbesc($start), dbesc($finish), dbesc($adjust_start), dbesc($adjust_finish) ); - } if($r && ! $export) { xchan_query($r); $r = fetch_post_tags($r,true); - $r = sort_by_date($r); } @@ -373,11 +340,16 @@ class Channel_calendar extends \Zotlabs\Web\Controller { foreach($r as $rr) { - $start = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['dtstart'], 'c') : datetime_convert('UTC','UTC',$rr['dtstart'],'c')); + $tz = get_iconfig($rr, 'event', 'timezone'); + + if(! $tz) + $tz = 'UTC'; + + $start = (($rr['adjust']) ? datetime_convert($tz, date_default_timezone_get(), $rr['dtstart'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtstart'], 'c')); if ($rr['nofinish']){ $end = null; } else { - $end = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['dtend'], 'c') : datetime_convert('UTC','UTC',$rr['dtend'],'c')); + $end = (($rr['adjust']) ? datetime_convert($tz, date_default_timezone_get(), $rr['dtend'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtend'], 'c')); // give a fake end to birthdays so they get crammed into a // single day on the calendar @@ -416,6 +388,7 @@ class Channel_calendar extends \Zotlabs\Web\Controller { 'rw' => true, 'id'=>$rr['id'], 'uri' => $rr['event_hash'], + 'timezone' => $tz, 'start'=> $start, 'end' => $end, 'drop' => $drop, 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'), ] ], diff --git a/view/tpl/cdav_calendar.tpl b/view/tpl/cdav_calendar.tpl index 22579227a..533c0add1 100644 --- a/view/tpl/cdav_calendar.tpl +++ b/view/tpl/cdav_calendar.tpl @@ -81,7 +81,6 @@ $(document).ready(function() { }, eventClick: function(info) { - //reset categories $('#id_categories').tagsinput('removeAll'); @@ -131,6 +130,8 @@ $(document).ready(function() { event_uri = event.extendedProps.uri; $('#id_title').val(event.title); $('#calendar_select').val(calendar_id).attr('disabled', true).trigger('change'); + $('#id_timezone_select').val(event.extendedProps.timezone); + $('#id_location').val(event.extendedProps.location); $('#id_categories').tagsinput('add', event.extendedProps.categories); $('#id_dtstart').val(dtstart.toUTCString()); $('#id_dtend').val(dtend.toUTCString()); @@ -183,7 +184,7 @@ $(document).ready(function() { var event = info.event._def; var dtstart = new Date(info.event._instance.range.start); var dtend = new Date(info.event._instance.range.end); - + $('#id_title').val(event.title); $('#id_dtstart').val(dtstart.toUTCString()); $('#id_dtend').val(dtend.toUTCString()); @@ -199,6 +200,7 @@ $(document).ready(function() { 'type': 'event', 'preview': 0, 'summary': event.title, + 'timezone_select': event.extendedProps.timezone, 'dtstart': dtstart.toUTCString(), 'dtend': dtend.toUTCString(), 'adjust': event.extendedProps.item.adjust, @@ -215,6 +217,7 @@ $(document).ready(function() { 'update': 'resize', 'id[]': event.extendedProps.calendar_id, 'uri': event.extendedProps.uri, + 'timezone_select': event.extendedProps.timezone, 'dtstart': dtstart ? dtstart.toUTCString() : '', 'dtend': dtend ? dtend.toUTCString() : '' }) @@ -245,6 +248,7 @@ $(document).ready(function() { 'type': 'event', 'preview': 0, 'summary': event.title, + 'timezone_select': event.extendedProps.timezone, 'dtstart': dtstart.toUTCString(), 'dtend': dtend.toUTCString(), 'adjust': event.extendedProps.item.adjust, @@ -261,6 +265,7 @@ $(document).ready(function() { 'update': 'drop', 'id[]': event.extendedProps.calendar_id, 'uri': event.extendedProps.uri, + 'timezone_select': event.extendedProps.timezone, 'dtstart': dtstart ? dtstart.toUTCString() : '', 'dtend': dtend ? dtend.toUTCString() : '' }) @@ -334,6 +339,7 @@ $(document).ready(function() { $('#id_categories').tagsinput('add', '{{$categories}}'), $('#id_description').val(resource.description); $('#id_location').val(resource.location); + $('#id_timezone_select').val(resource.timezone); if(event_xchan !== '{{$channel_hash}}') $('#event_submit').hide(); @@ -414,10 +420,11 @@ function on_submit() { 'xchan': event_xchan, 'type': 'event', 'preview': 0, + 'timezone_select': $('#id_timezone_select').val(), 'summary': $('#id_title').val(), 'dtstart': $('#id_dtstart').val(), 'dtend': $('#id_dtend').val(), - 'adjust': 0, + 'adjust': 1, 'categories': $('#id_categories').val(), 'desc': $('#id_description').val(), 'location': $('#id_location').val(), @@ -439,6 +446,7 @@ function on_submit() { $.post( 'cdav/calendar', { 'submit': $('#event_submit').val(), 'target': $('#calendar_select').val(), + 'timezone_select': $('#id_timezone_select').val(), 'uri': event_uri, 'title': $('#id_title').val(), 'dtstart': $('#id_dtstart').val(), @@ -569,6 +577,9 @@ function exportDate() { {{/foreach}} + {{if $timezone_select}} + {{include file="field_select_grouped.tpl" field=$timezone_select}} + {{/if}}