Merge branch 'dev' into 4.2RC

This commit is contained in:
Mario Vavti 2019-05-23 08:37:52 +02:00
commit f86d12c8f4
8 changed files with 173 additions and 120 deletions

View File

@ -271,11 +271,17 @@ class Cdav extends Controller {
if(!cdav_perms($id[0],$calendars,true)) if(!cdav_perms($id[0],$calendars,true))
return; return;
$timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : '');
$tz = (($timezone) ? $timezone : date_default_timezone_get());
$allday = $_REQUEST['allday'];
$title = $_REQUEST['title']; $title = $_REQUEST['title'];
$start = datetime_convert(App::$timezone, 'UTC', $_REQUEST['dtstart']); $start = datetime_convert($tz, 'UTC', $_REQUEST['dtstart']);
$dtstart = new \DateTime($start); $dtstart = new \DateTime($start);
if($_REQUEST['dtend']) { if($_REQUEST['dtend']) {
$end = datetime_convert(App::$timezone, 'UTC', $_REQUEST['dtend']); $end = datetime_convert($tz, 'UTC', $_REQUEST['dtend']);
$dtend = new \DateTime($end); $dtend = new \DateTime($end);
} }
$description = $_REQUEST['description']; $description = $_REQUEST['description'];
@ -301,16 +307,23 @@ class Cdav extends Controller {
'DTSTART' => $dtstart 'DTSTART' => $dtstart
] ]
]); ]);
if($dtend) { if($dtend) {
$vcalendar->VEVENT->add('DTEND', $dtend); $vcalendar->VEVENT->add('DTEND', $dtend);
$vcalendar->VEVENT->DTEND['TZID'] = App::$timezone; if($allday)
$vcalendar->VEVENT->DTEND['VALUE'] = 'DATE';
else
$vcalendar->VEVENT->DTEND['TZID'] = $tz;
} }
if($description) if($description)
$vcalendar->VEVENT->add('DESCRIPTION', $description); $vcalendar->VEVENT->add('DESCRIPTION', $description);
if($location) if($location)
$vcalendar->VEVENT->add('LOCATION', $location); $vcalendar->VEVENT->add('LOCATION', $location);
$vcalendar->VEVENT->DTSTART['TZID'] = App::$timezone; if($allday)
$vcalendar->VEVENT->DTSTART['VALUE'] = 'DATE';
else
$vcalendar->VEVENT->DTSTART['TZID'] = $tz;
$calendarData = $vcalendar->serialize(); $calendarData = $vcalendar->serialize();
@ -348,12 +361,17 @@ class Cdav extends Controller {
if(!cdav_perms($id[0],$calendars,true)) if(!cdav_perms($id[0],$calendars,true))
return; return;
$timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : '');
$tz = (($timezone) ? $timezone : date_default_timezone_get());
$allday = $_REQUEST['allday'];
$uri = $_REQUEST['uri']; $uri = $_REQUEST['uri'];
$title = $_REQUEST['title']; $title = $_REQUEST['title'];
$start = datetime_convert(App::$timezone, 'UTC', $_REQUEST['dtstart']); $start = datetime_convert($tz, 'UTC', $_REQUEST['dtstart']);
$dtstart = new \DateTime($start); $dtstart = new \DateTime($start);
if($_REQUEST['dtend']) { if($_REQUEST['dtend']) {
$end = datetime_convert(App::$timezone, 'UTC', $_REQUEST['dtend']); $end = datetime_convert($tz, 'UTC', $_REQUEST['dtend']);
$dtend = new \DateTime($end); $dtend = new \DateTime($end);
} }
$description = $_REQUEST['description']; $description = $_REQUEST['description'];
@ -365,12 +383,23 @@ class Cdav extends Controller {
if($title) if($title)
$vcalendar->VEVENT->SUMMARY = $title; $vcalendar->VEVENT->SUMMARY = $title;
if($dtstart) if($dtstart) {
$vcalendar->VEVENT->DTSTART = $dtstart; $vcalendar->VEVENT->DTSTART = $dtstart;
if($dtend) if($allday)
$vcalendar->VEVENT->DTSTART['VALUE'] = 'DATE';
else
$vcalendar->VEVENT->DTSTART['TZID'] = $tz;
}
if($dtend) {
$vcalendar->VEVENT->DTEND = $dtend; $vcalendar->VEVENT->DTEND = $dtend;
if($allday)
$vcalendar->VEVENT->DTEND['VALUE'] = 'DATE';
else
$vcalendar->VEVENT->DTEND['TZID'] = $tz;
}
else else
unset($vcalendar->VEVENT->DTEND); unset($vcalendar->VEVENT->DTEND);
if($description) if($description)
$vcalendar->VEVENT->DESCRIPTION = $description; $vcalendar->VEVENT->DESCRIPTION = $description;
if($location) if($location)
@ -406,11 +435,16 @@ class Cdav extends Controller {
if(!cdav_perms($id[0],$calendars,true)) if(!cdav_perms($id[0],$calendars,true))
return; return;
$timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : '');
$tz = (($timezone) ? $timezone : date_default_timezone_get());
$allday = $_REQUEST['allday'];
$uri = $_REQUEST['uri']; $uri = $_REQUEST['uri'];
$start = datetime_convert(App::$timezone, 'UTC', $_REQUEST['dtstart']); $start = datetime_convert($tz, 'UTC', $_REQUEST['dtstart']);
$dtstart = new \DateTime($start); $dtstart = new \DateTime($start);
if($_REQUEST['dtend']) { if($_REQUEST['dtend']) {
$end = datetime_convert(App::$timezone, 'UTC', $_REQUEST['dtend']); $end = datetime_convert($tz, 'UTC', $_REQUEST['dtend']);
$dtend = new \DateTime($end); $dtend = new \DateTime($end);
} }
@ -420,13 +454,20 @@ class Cdav extends Controller {
if($dtstart) { if($dtstart) {
$vcalendar->VEVENT->DTSTART = $dtstart; $vcalendar->VEVENT->DTSTART = $dtstart;
if($allday)
$vcalendar->VEVENT->DTSTART['VALUE'] = 'DATE';
else
$vcalendar->VEVENT->DTSTART['TZID'] = $tz;
} }
if($dtend) { if($dtend) {
$vcalendar->VEVENT->DTEND = $dtend; $vcalendar->VEVENT->DTEND = $dtend;
if($allday)
$vcalendar->VEVENT->DTEND['VALUE'] = 'DATE';
else
$vcalendar->VEVENT->DTEND['TZID'] = $tz;
} }
else { else
unset($vcalendar->VEVENT->DTEND); unset($vcalendar->VEVENT->DTEND);
}
$calendarData = $vcalendar->serialize(); $calendarData = $vcalendar->serialize();
@ -915,8 +956,13 @@ class Cdav extends Controller {
xchan_query($r); xchan_query($r);
$r = fetch_post_tags($r,true); $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')); $tz = get_iconfig($r[0], 'event', 'timezone');
$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')); 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')]; $r[0]['plink'] = [$r[0]['plink'], t('Link to source')];
@ -984,9 +1030,11 @@ class Cdav extends Controller {
$first_day = feature_enabled(local_channel(), 'cal_first_day'); $first_day = feature_enabled(local_channel(), 'cal_first_day');
$first_day = (($first_day) ? $first_day : 0); $first_day = (($first_day) ? $first_day : 0);
$title = ['title', t('Event title')]; $title = ['title', t('Event title') ];
$dtstart = ['dtstart', t('Start date and time')]; $dtstart = ['dtstart', t('Start date and time')];
$dtend = ['dtend', t('End date and time')]; $dtend = ['dtend', t('End date and time')];
$timezone_select = ['timezone_select' , t('Timezone:'), date_default_timezone_get(), '', get_timezones()];
$description = ['description', t('Description')]; $description = ['description', t('Description')];
$location = ['location', t('Location')]; $location = ['location', t('Location')];
@ -1000,14 +1048,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 = (($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')); $acl = populate_acl($perm_defaults, false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_stream'));
//$permissions = ((x($orig_event)) ? $orig_event : $perm_defaults); $permissions = (($resource_id) ? $resource : $perm_defaults);
$permissions = $perm_defaults;
$o .= replace_macros(get_markup_template('cdav_calendar.tpl'), [ $o .= replace_macros(get_markup_template('cdav_calendar.tpl'), [
'$sources' => $sources, '$sources' => $sources,
'$color' => $color, '$color' => $color,
'$lang' => App::$language, '$lang' => App::$language,
'$timezone' => App::$timezone, '$timezone' => date_default_timezone_get(),
'$first_day' => $first_day, '$first_day' => $first_day,
'$prev' => t('Previous'), '$prev' => t('Previous'),
'$next' => t('Next'), '$next' => t('Next'),
@ -1047,7 +1094,8 @@ class Cdav extends Controller {
'$categories_label' => t('Categories'), '$categories_label' => t('Categories'),
'$resource' => json_encode($resource), '$resource' => json_encode($resource),
'$categories' => $categories '$categories' => $categories,
'$timezone_select' => ((feature_enabled(local_channel(),'event_tz_select')) ? $timezone_select : '')
]); ]);
return $o; return $o;
@ -1076,8 +1124,8 @@ class Cdav extends Controller {
$filters['comp-filters'][0]['time-range']['end'] = $end; $filters['comp-filters'][0]['time-range']['end'] = $end;
$uris = $caldavBackend->calendarQuery($id, $filters); $uris = $caldavBackend->calendarQuery($id, $filters);
if($uris) { if($uris) {
$objects = $caldavBackend->getMultipleCalendarObjects($id, $uris); $objects = $caldavBackend->getMultipleCalendarObjects($id, $uris);
foreach($objects as $object) { foreach($objects as $object) {
@ -1096,30 +1144,33 @@ class Cdav extends Controller {
$dtend = (string)$vevent->DTEND; $dtend = (string)$vevent->DTEND;
$description = (string)$vevent->DESCRIPTION; $description = (string)$vevent->DESCRIPTION;
$location = (string)$vevent->LOCATION; $location = (string)$vevent->LOCATION;
$timezone = (string)$vevent->DTSTART['TZID']; $timezone_str = (string)$vevent->DTSTART['TZID'];
$rw = ((cdav_perms($id[0],$calendars,true)) ? true : false); $rw = ((cdav_perms($id[0],$calendars,true)) ? true : false);
$editable = $rw ? true : false; $editable = $rw ? true : false;
$recurrent = ((isset($vevent->{'RECURRENCE-ID'})) ? true : false); $recurrent = ((isset($vevent->{'RECURRENCE-ID'})) ? true : false);
if($recurrent) { if($recurrent) {
$editable = false; $editable = false;
$timezone = $recurrent_timezone; $timezone_str = $recurrent_timezone;
} }
$allDay = false; // Try to get an usable olson format timezone
$timezone_obj = \Sabre\VObject\TimeZoneUtil::getTimeZone($timezone_str, $vcalendar);
$timezone = $timezone_obj->getName();
// allDay event rules // If we got nothing fallback to UTC
if(!strpos($dtstart, 'T') && !strpos($dtend, 'T')) if(! $timezone)
$allDay = true; $timezone = 'UTC';
if(strpos($dtstart, 'T000000') && strpos($dtend, 'T000000'))
$allDay = true; $allDay = (((string)$vevent->DTSTART['VALUE'] == 'DATE') ? true : false);
$events[] = [ $events[] = [
'calendar_id' => $id, 'calendar_id' => $id,
'uri' => $object['uri'], 'uri' => $object['uri'],
'title' => $title, 'title' => $title,
'start' => datetime_convert($timezone, $timezone, $dtstart, 'c'), 'timezone' => $timezone,
'end' => (($dtend) ? datetime_convert($timezone, $timezone, $dtend, 'c') : ''), 'start' => datetime_convert($timezone, date_default_timezone_get(), $dtstart, 'c'),
'end' => (($dtend) ? datetime_convert($timezone, date_default_timezone_get(), $dtend, 'c') : ''),
'description' => $description, 'description' => $description,
'location' => $location, 'location' => $location,
'allDay' => $allDay, 'allDay' => $allDay,

View File

@ -22,52 +22,20 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
$xchan = ((x($_POST,'xchan')) ? dbesc($_POST['xchan']) : ''); $xchan = ((x($_POST,'xchan')) ? dbesc($_POST['xchan']) : '');
$uid = local_channel(); $uid = local_channel();
$start_text = escape_tags($_REQUEST['dtstart']);
$finish_text = escape_tags($_REQUEST['dtend']);
$adjust = intval($_POST['adjust']); // only allow editing your own events.
$nofinish = intval($_POST['nofinish']); if(($xchan) && ($xchan !== get_observer_hash()))
return;
$timezone = ((x($_POST,'timezone_select')) ? notags(trim($_POST['timezone_select'])) : '');
$timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : '');
$tz = (($timezone) ? $timezone : date_default_timezone_get()); $tz = (($timezone) ? $timezone : date_default_timezone_get());
$categories = escape_tags(trim($_POST['categories'])); $categories = escape_tags(trim($_POST['categories']));
// only allow editing your own events. $adjust = intval($_POST['adjust']);
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);
}
if($finish_text) { $start = (($adjust) ? datetime_convert($tz, 'UTC', escape_tags($_REQUEST['dtstart'])) : datetime_convert('UTC', 'UTC', escape_tags($_REQUEST['dtstart'])));
$finish = $finish_text; $finish = (($adjust) ? datetime_convert($tz, 'UTC', escape_tags($_REQUEST['dtend'])) : datetime_convert('UTC', 'UTC', escape_tags($_REQUEST['dtend'])));
}
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);
}
$summary = escape_tags(trim($_POST['summary'])); $summary = escape_tags(trim($_POST['summary']));
$desc = escape_tags(trim($_POST['desc'])); $desc = escape_tags(trim($_POST['desc']));
@ -176,7 +144,7 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
$datarray['location'] = $location; $datarray['location'] = $location;
$datarray['etype'] = $type; $datarray['etype'] = $type;
$datarray['adjust'] = $adjust; $datarray['adjust'] = $adjust;
$datarray['nofinish'] = $nofinish; $datarray['nofinish'] = 0;
$datarray['uid'] = local_channel(); $datarray['uid'] = local_channel();
$datarray['account'] = get_account_id(); $datarray['account'] = get_account_id();
$datarray['event_xchan'] = $channel['channel_hash']; $datarray['event_xchan'] = $channel['channel_hash'];
@ -188,6 +156,8 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
$datarray['id'] = $event_id; $datarray['id'] = $event_id;
$datarray['created'] = $created; $datarray['created'] = $created;
$datarray['edited'] = $edited; $datarray['edited'] = $edited;
$datarray['timezone'] = $tz;
if(intval($_REQUEST['preview'])) { if(intval($_REQUEST['preview'])) {
$html = format_event_html($datarray); $html = format_event_html($datarray);
@ -322,10 +292,9 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
$start = datetime_convert('UTC','UTC',$start); $start = datetime_convert('UTC','UTC',$start);
$finish = datetime_convert('UTC','UTC',$finish); $finish = datetime_convert('UTC','UTC',$finish);
$adjust_start = datetime_convert('UTC', date_default_timezone_get(), $start); $adjust_start = datetime_convert('UTC', date_default_timezone_get(), $start);
$adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish); $adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish);
if (x($_GET,'id')){ if (x($_GET,'id')){
$r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan, item.id as item_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 from event left join item on item.resource_id = event.event_hash
@ -357,13 +326,11 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
dbesc($adjust_start), dbesc($adjust_start),
dbesc($adjust_finish) dbesc($adjust_finish)
); );
} }
if($r && ! $export) { if($r && ! $export) {
xchan_query($r); xchan_query($r);
$r = fetch_post_tags($r,true); $r = fetch_post_tags($r,true);
$r = sort_by_date($r); $r = sort_by_date($r);
} }
@ -373,15 +340,23 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
foreach($r as $rr) { 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';
if($rr['etype'] === 'birthday') {
$rr['adjust'] = 1; //intval(feature_enabled(local_channel(), 'smart_birthdays'));
}
$start = (($rr['adjust']) ? datetime_convert($tz, date_default_timezone_get(), $rr['dtstart'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtstart'], 'c'));
if ($rr['nofinish']){ if ($rr['nofinish']){
$end = null; $end = null;
} else { } 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 // give a fake end to birthdays so they get crammed into a
// single day on the calendar // single day on the calendar
if($rr['etype'] === 'birthday') if($rr['etype'] === 'birthday')
$end = null; $end = null;
} }
@ -399,13 +374,13 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
} }
} }
$allDay = false; //$allDay = false;
// allDay event rules // allDay event rules
if(!strpos($start, 'T') && !strpos($end, 'T')) //if(!strpos($start, 'T') && !strpos($end, 'T'))
$allDay = true; // $allDay = true;
if(strpos($start, 'T00:00:00') && strpos($end, 'T00:00:00')) //if(strpos($start, 'T00:00:00') && strpos($end, 'T00:00:00'))
$allDay = true; // $allDay = true;
$edit = ((local_channel() && $rr['author_xchan'] == get_observer_hash()) ? array(z_root().'/events/'.$rr['event_hash'].'?expandform=1',t('Edit event'),'','') : false); $edit = ((local_channel() && $rr['author_xchan'] == get_observer_hash()) ? array(z_root().'/events/'.$rr['event_hash'].'?expandform=1',t('Edit event'),'','') : false);
@ -416,13 +391,14 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
'rw' => true, 'rw' => true,
'id'=>$rr['id'], 'id'=>$rr['id'],
'uri' => $rr['event_hash'], 'uri' => $rr['event_hash'],
'timezone' => $tz,
'start'=> $start, 'start'=> $start,
'end' => $end, 'end' => $end,
'drop' => $drop, 'drop' => $drop,
'allDay' => $allDay, 'allDay' => (($rr['adjust']) ? 0 : 1),
'title' => htmlentities($rr['summary'], ENT_COMPAT, 'UTF-8', false), 'title' => htmlentities($rr['summary'], ENT_COMPAT, 'UTF-8', false),
'editable' => $edit ? true : false, 'editable' => $edit ? true : false,
'item'=>$rr, 'item' => $rr,
'plink' => [$rr['plink'], t('Link to source')], 'plink' => [$rr['plink'], t('Link to source')],
'description' => htmlentities($rr['description'], ENT_COMPAT, 'UTF-8', false), 'description' => htmlentities($rr['description'], ENT_COMPAT, 'UTF-8', false),
'location' => htmlentities($rr['location'], ENT_COMPAT, 'UTF-8', false), 'location' => htmlentities($rr['location'], ENT_COMPAT, 'UTF-8', false),

View File

@ -69,7 +69,7 @@ class Notifications {
'label' => t('New Events'), 'label' => t('New Events'),
'title' => t('New Events Notifications'), 'title' => t('New Events Notifications'),
'viewall' => [ 'viewall' => [
'url' => 'events', 'url' => 'cdav/calendar',
'label' => t('View events') 'label' => t('View events')
], ],
'markall' => [ 'markall' => [

View File

@ -50,7 +50,7 @@ require_once('include/attach.php');
require_once('include/bbcode.php'); require_once('include/bbcode.php');
define ( 'PLATFORM_NAME', 'hubzilla' ); define ( 'PLATFORM_NAME', 'hubzilla' );
define ( 'STD_VERSION', '4.2RC' ); define ( 'STD_VERSION', '4.3' );
define ( 'ZOT_REVISION', '6.0a' ); define ( 'ZOT_REVISION', '6.0a' );
define ( 'DB_UPDATE_VERSION', 1234 ); define ( 'DB_UPDATE_VERSION', 1234 );

View File

@ -516,7 +516,7 @@ function update_birthdays() {
'event_xchan' => $rr['xchan_hash'], 'event_xchan' => $rr['xchan_hash'],
'dtstart' => datetime_convert('UTC', 'UTC', $rr['abook_dob']), 'dtstart' => datetime_convert('UTC', 'UTC', $rr['abook_dob']),
'dtend' => datetime_convert('UTC', 'UTC', $rr['abook_dob'] . ' + 1 day '), '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']), '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]'), 'description' => sprintf( t('Happy Birthday %1$s'), '[zrl=' . $rr['xchan_url'] . ']' . $rr['xchan_name'] . '[/zrl]'),
'etype' => 'birthday', 'etype' => 'birthday',

View File

@ -75,17 +75,19 @@ function format_event_obj($jobject) {
//ensure compatibility with older items - this check can be removed at a later point //ensure compatibility with older items - this check can be removed at a later point
if(array_key_exists('description', $object)) { 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 $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( $event['header'] = replace_macros(get_markup_template('event_item_header.tpl'),array(
'$title' => zidify_links(smilies(bbcode($object['title']))), '$title' => zidify_links(smilies(bbcode($object['title']))),
'$dtstart_label' => t('Starts:'), '$dtstart_label' => t('Starts:'),
'$dtstart_title' => datetime_convert('UTC', 'UTC', $object['dtstart'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), '$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), '$finish' => (($object['nofinish']) ? false : true),
'$dtend_label' => t('Finishes:'), '$dtend_label' => t('Finishes:'),
'$dtend_title' => datetime_convert('UTC','UTC',$object['dtend'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )), '$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 )))
)); ));
$event['content'] = replace_macros(get_markup_template('event_item_content.tpl'),array( $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, 'type' => ACTIVITY_OBJ_EVENT,
'id' => z_root() . '/event/' . $r[0]['resource_id'], 'id' => z_root() . '/event/' . $r[0]['resource_id'],
'title' => $arr['summary'], 'title' => $arr['summary'],
'timezone' => $arr['timezone'],
'dtstart' => $arr['dtstart'], 'dtstart' => $arr['dtstart'],
'dtend' => $arr['dtend'], 'dtend' => $arr['dtend'],
'nofinish' => $arr['nofinish'], 'nofinish' => $arr['nofinish'],
@ -1107,6 +1110,8 @@ function event_store_item($arr, $event) {
} }
$item_id = $r[0]['id']; $item_id = $r[0]['id'];
set_iconfig($item_id, 'event', 'timezone', $arr['timezone'], true);
/** /**
* @hooks event_updated * @hooks event_updated
* Called when an event record is modified. * Called when an event record is modified.
@ -1197,6 +1202,7 @@ function event_store_item($arr, $event) {
'type' => ACTIVITY_OBJ_EVENT, 'type' => ACTIVITY_OBJ_EVENT,
'id' => z_root() . '/event/' . $event['event_hash'], 'id' => z_root() . '/event/' . $event['event_hash'],
'title' => $arr['summary'], 'title' => $arr['summary'],
'timezone' => $arr['timezone'],
'dtstart' => $arr['dtstart'], 'dtstart' => $arr['dtstart'],
'dtend' => $arr['dtend'], 'dtend' => $arr['dtend'],
'nofinish' => $arr['nofinish'], 'nofinish' => $arr['nofinish'],
@ -1223,6 +1229,7 @@ function event_store_item($arr, $event) {
// activities refer to the item message_id as the parent. // 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, 'system','event_id',$event['event_hash'],true);
set_iconfig($item_arr, 'event','timezone',$arr['timezone'],true);
$res = item_store($item_arr); $res = item_store($item_arr);

View File

@ -87,7 +87,24 @@ function get_features($filtered = true, $level = (-1)) {
t('Default is Sunday'), t('Default is Sunday'),
false, false,
get_config('feature_lock','cal_first_day') 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'),
],
/*
[
'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'),
] ]
*/
], ],
@ -282,22 +299,6 @@ function get_features($filtered = true, $level = (-1)) {
t('Default is Sunday'), t('Default is Sunday'),
false, false,
get_config('feature_lock','events_cal_first_day') 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'),
],
[
'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'),
] ]
], ],

View File

@ -17,6 +17,8 @@ var resource = {{$resource}};
var default_view = resource !== null ? 'timeGridDay' : 'dayGridMonth'; var default_view = resource !== null ? 'timeGridDay' : 'dayGridMonth';
var default_date = resource !== null ? new Date(resource.dtstart) : new Date(); var default_date = resource !== null ? new Date(resource.dtstart) : new Date();
var allday;
$(document).ready(function() { $(document).ready(function() {
var calendarEl = document.getElementById('calendar'); var calendarEl = document.getElementById('calendar');
calendar = new FullCalendar.Calendar(calendarEl, { calendar = new FullCalendar.Calendar(calendarEl, {
@ -43,7 +45,6 @@ $(document).ready(function() {
dayNamesShort: aStr['dayNamesShort'], dayNamesShort: aStr['dayNamesShort'],
allDayText: aStr['allday'], allDayText: aStr['allday'],
defaultTimedEventDuration: '01:00:00',
snapDuration: '00:15:00', snapDuration: '00:15:00',
dateClick: function(info) { dateClick: function(info) {
@ -53,8 +54,10 @@ $(document).ready(function() {
new_event = {}; new_event = {};
} }
allday = info.allDay;
var dtend = new Date(info.date.toUTCString()); var dtend = new Date(info.date.toUTCString());
if(info.view.type == 'dayGridMonth') { if(allday) {
dtend.setDate(dtend.getDate() + 1); dtend.setDate(dtend.getDate() + 1);
} }
else{ else{
@ -76,12 +79,11 @@ $(document).ready(function() {
$('#event_submit').val('create_event').html('{{$create}}'); $('#event_submit').val('create_event').html('{{$create}}');
$('#event_delete').hide(); $('#event_delete').hide();
new_event = { id: new_event_id, title : 'New event', start: $('#id_dtstart').val(), end: $('#id_dtend').val(), editable: true, color: '#bbb' }; new_event = { id: new_event_id, title: 'New event', start: $('#id_dtstart').val(), end: $('#id_dtend').val(), allDay: info.allDay, editable: true, color: '#bbb' };
calendar.addEvent(new_event); calendar.addEvent(new_event);
}, },
eventClick: function(info) {
eventClick: function(info) {
//reset categories //reset categories
$('#id_categories').tagsinput('removeAll'); $('#id_categories').tagsinput('removeAll');
@ -131,6 +133,8 @@ $(document).ready(function() {
event_uri = event.extendedProps.uri; event_uri = event.extendedProps.uri;
$('#id_title').val(event.title); $('#id_title').val(event.title);
$('#calendar_select').val(calendar_id).attr('disabled', true).trigger('change'); $('#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_categories').tagsinput('add', event.extendedProps.categories);
$('#id_dtstart').val(dtstart.toUTCString()); $('#id_dtstart').val(dtstart.toUTCString());
$('#id_dtend').val(dtend.toUTCString()); $('#id_dtend').val(dtend.toUTCString());
@ -179,11 +183,12 @@ $(document).ready(function() {
}, },
eventResize: function(info) { eventResize: function(info) {
console.log(info);
var event = info.event._def; var event = info.event._def;
var dtstart = new Date(info.event._instance.range.start); var dtstart = new Date(info.event._instance.range.start);
var dtend = new Date(info.event._instance.range.end); var dtend = new Date(info.event._instance.range.end);
$('#id_title').val(event.title); $('#id_title').val(event.title);
$('#id_dtstart').val(dtstart.toUTCString()); $('#id_dtstart').val(dtstart.toUTCString());
$('#id_dtend').val(dtend.toUTCString()); $('#id_dtend').val(dtend.toUTCString());
@ -199,9 +204,10 @@ $(document).ready(function() {
'type': 'event', 'type': 'event',
'preview': 0, 'preview': 0,
'summary': event.title, 'summary': event.title,
'timezone_select': event.extendedProps.timezone,
'dtstart': dtstart.toUTCString(), 'dtstart': dtstart.toUTCString(),
'dtend': dtend.toUTCString(), 'dtend': dtend.toUTCString(),
'adjust': event.extendedProps.item.adjust, 'adjust': event.allDay ? 0 : 1,
'categories': event.extendedProps.categories, 'categories': event.extendedProps.categories,
'desc': event.extendedProps.description, 'desc': event.extendedProps.description,
'location': event.extendedProps.location, 'location': event.extendedProps.location,
@ -215,8 +221,10 @@ $(document).ready(function() {
'update': 'resize', 'update': 'resize',
'id[]': event.extendedProps.calendar_id, 'id[]': event.extendedProps.calendar_id,
'uri': event.extendedProps.uri, 'uri': event.extendedProps.uri,
'timezone_select': event.extendedProps.timezone,
'dtstart': dtstart ? dtstart.toUTCString() : '', 'dtstart': dtstart ? dtstart.toUTCString() : '',
'dtend': dtend ? dtend.toUTCString() : '' 'dtend': dtend ? dtend.toUTCString() : '',
'allday': event.allDay ? 1 : 0
}) })
.fail(function() { .fail(function() {
info.revert(); info.revert();
@ -245,9 +253,10 @@ $(document).ready(function() {
'type': 'event', 'type': 'event',
'preview': 0, 'preview': 0,
'summary': event.title, 'summary': event.title,
'timezone_select': event.extendedProps.timezone,
'dtstart': dtstart.toUTCString(), 'dtstart': dtstart.toUTCString(),
'dtend': dtend.toUTCString(), 'dtend': dtend.toUTCString(),
'adjust': event.extendedProps.item.adjust, 'adjust': event.allDay ? 0 : 1,
'categories': event.extendedProps.categories, 'categories': event.extendedProps.categories,
'desc': event.extendedProps.description, 'desc': event.extendedProps.description,
'location': event.extendedProps.location, 'location': event.extendedProps.location,
@ -261,8 +270,10 @@ $(document).ready(function() {
'update': 'drop', 'update': 'drop',
'id[]': event.extendedProps.calendar_id, 'id[]': event.extendedProps.calendar_id,
'uri': event.extendedProps.uri, 'uri': event.extendedProps.uri,
'timezone_select': event.extendedProps.timezone,
'dtstart': dtstart ? dtstart.toUTCString() : '', 'dtstart': dtstart ? dtstart.toUTCString() : '',
'dtend': dtend ? dtend.toUTCString() : '' 'dtend': dtend ? dtend.toUTCString() : '',
'allday': event.allDay ? 1 : 0
}) })
.fail(function() { .fail(function() {
info.revert(); info.revert();
@ -334,6 +345,7 @@ $(document).ready(function() {
$('#id_categories').tagsinput('add', '{{$categories}}'), $('#id_categories').tagsinput('add', '{{$categories}}'),
$('#id_description').val(resource.description); $('#id_description').val(resource.description);
$('#id_location').val(resource.location); $('#id_location').val(resource.location);
$('#id_timezone_select').val(resource.timezone);
if(event_xchan !== '{{$channel_hash}}') if(event_xchan !== '{{$channel_hash}}')
$('#event_submit').hide(); $('#event_submit').hide();
@ -414,10 +426,11 @@ function on_submit() {
'xchan': event_xchan, 'xchan': event_xchan,
'type': 'event', 'type': 'event',
'preview': 0, 'preview': 0,
'timezone_select': $('#id_timezone_select').val(),
'summary': $('#id_title').val(), 'summary': $('#id_title').val(),
'dtstart': $('#id_dtstart').val(), 'dtstart': $('#id_dtstart').val(),
'dtend': $('#id_dtend').val(), 'dtend': $('#id_dtend').val(),
'adjust': 0, 'adjust': allday ? 0 : 1,
'categories': $('#id_categories').val(), 'categories': $('#id_categories').val(),
'desc': $('#id_description').val(), 'desc': $('#id_description').val(),
'location': $('#id_location').val(), 'location': $('#id_location').val(),
@ -439,12 +452,14 @@ function on_submit() {
$.post( 'cdav/calendar', { $.post( 'cdav/calendar', {
'submit': $('#event_submit').val(), 'submit': $('#event_submit').val(),
'target': $('#calendar_select').val(), 'target': $('#calendar_select').val(),
'timezone_select': $('#id_timezone_select').val(),
'uri': event_uri, 'uri': event_uri,
'title': $('#id_title').val(), 'title': $('#id_title').val(),
'dtstart': $('#id_dtstart').val(), 'dtstart': $('#id_dtstart').val(),
'dtend': $('#id_dtend').val(), 'dtend': $('#id_dtend').val(),
'description': $('#id_description').val(), 'description': $('#id_description').val(),
'location': $('#id_location').val() 'location': $('#id_location').val(),
'allday': allday ? 1 : 0
}) })
.done(function() { .done(function() {
var parts = $('#calendar_select').val().split(':'); var parts = $('#calendar_select').val().split(':');
@ -569,6 +584,9 @@ function exportDate() {
{{/foreach}} {{/foreach}}
</optgroup> </optgroup>
</select> </select>
{{if $timezone_select}}
{{include file="field_select_grouped.tpl" field=$timezone_select}}
{{/if}}
<div id="more_block" style="display: none;"> <div id="more_block" style="display: none;">
{{if $catsenabled}} {{if $catsenabled}}
<div id="id_categories_wrapper" class="form-group"> <div id="id_categories_wrapper" class="form-group">