adjust birthday handling according to community decision and slightly change display of allday event items

This commit is contained in:
Mario Vavti 2019-05-26 18:05:11 +02:00
parent 528b9b6a60
commit e466d72058
7 changed files with 30 additions and 33 deletions

View File

@ -2766,7 +2766,7 @@ class Libzot {
$profile['description'] = $p[0]['pdesc']; $profile['description'] = $p[0]['pdesc'];
$profile['birthday'] = $p[0]['dob']; $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; $profile['next_birthday'] = $bd;
if($age = age($p[0]['dob'],$e['channel_timezone'],'')) if($age = age($p[0]['dob'],$e['channel_timezone'],''))

View File

@ -345,20 +345,11 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
if(! $tz) if(! $tz)
$tz = 'UTC'; $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')); $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($tz, 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
if($rr['etype'] === 'birthday')
$end = null;
} }
$catsenabled = feature_enabled(local_channel(),'categories'); $catsenabled = feature_enabled(local_channel(),'categories');
@ -374,14 +365,6 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
} }
} }
//$allDay = false;
// allDay event rules
//if(!strpos($start, 'T') && !strpos($end, 'T'))
// $allDay = true;
//if(strpos($start, 'T00:00:00') && strpos($end, 'T00:00:00'))
// $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);
$drop = array(z_root().'/events/drop/'.$rr['event_hash'],t('Delete event'),'',''); $drop = array(z_root().'/events/drop/'.$rr['event_hash'],t('Delete event'),'','');

View File

@ -516,13 +516,14 @@ 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' => 1, //intval(feature_enabled($rr['abook_channel'],'smart_birthdays')), 'adjust' => 0,
'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',
]; ];
$z = event_store_event($ev); $z = event_store_event($ev);
if ($z) { if ($z) {
$item_id = event_store_item($ev, $z); $item_id = event_store_item($ev, $z);
q("update abook set abook_dob = '%s' where abook_id = %d", q("update abook set abook_dob = '%s' where abook_id = %d",

View File

@ -76,18 +76,34 @@ function format_event_obj($jobject) {
if(array_key_exists('description', $object)) { if(array_key_exists('description', $object)) {
$tz = (($object['timezone']) ? $object['timezone'] : 'UTC'); $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( $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('Start:'),
'$dtstart_title' => datetime_convert($tz, date_default_timezone_get(), $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($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($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('End:'),
'$dtend_title' => datetime_convert($tz, date_default_timezone_get(), $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($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( $event['content'] = replace_macros(get_markup_template('event_item_content.tpl'),array(

View File

@ -95,16 +95,7 @@ function get_features($filtered = true, $level = (-1)) {
t('Allow event creation in timezones other than your own.'), t('Allow event creation in timezones other than your own.'),
false, false,
get_config('feature_lock','event_tz_select'), 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'),
] ]
*/
], ],

View File

@ -4430,7 +4430,7 @@ function zotinfo($arr) {
$profile['description'] = $p[0]['pdesc']; $profile['description'] = $p[0]['pdesc'];
$profile['birthday'] = $p[0]['dob']; $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; $profile['next_birthday'] = $bd;
if($age = age($p[0]['dob'],$e['channel_timezone'],'')) if($age = age($p[0]['dob'],$e['channel_timezone'],''))

View File

@ -1,6 +1,11 @@
<div class="event-item-title"> <div class="event-item-title">
<h3><i class="fa fa-calendar"></i>&nbsp;{{$title}}</h3> <h3><i class="fa fa-calendar"></i>&nbsp;{{$title}}</h3>
</div> </div>
{{if $oneday && $allday}}
<span class="dtstart">{{$dtstart_dt}}</span>
{{else if $allday}}
<span class="dtstart">{{$dtstart_dt}}</span> &mdash; <span class="dtend">{{$dtend_dt}}</span>
{{else}}
<div class="event-item-start"> <div class="event-item-start">
<span class="event-item-label">{{$dtstart_label}}</span>&nbsp;<span class="dtstart" title="{{$dtstart_title}}">{{$dtstart_dt}}</span> <span class="event-item-label">{{$dtstart_label}}</span>&nbsp;<span class="dtstart" title="{{$dtstart_title}}">{{$dtstart_dt}}</span>
</div> </div>
@ -9,3 +14,4 @@
<span class="event-item-label">{{$dtend_label}}</span>&nbsp;<span class="dtend" title="{{$dtend_title}}">{{$dtend_dt}}</span> <span class="event-item-label">{{$dtend_label}}</span>&nbsp;<span class="dtend" title="{{$dtend_title}}">{{$dtend_dt}}</span>
</div> </div>
{{/if}} {{/if}}
{{/if}}