aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2019-05-27 08:07:26 +0200
committerMario Vavti <mario@mariovavti.com>2019-05-27 08:07:26 +0200
commiteaea947b7488365968cca9989576ffa0c367cc32 (patch)
tree2ba6ad7acd68eca4326c14e9094f04f88329f28f
parent8715f74d29298aebbe32add6cca9820660fd1128 (diff)
parentf1b61d5882cba9584ef35f574b29050397cb8d58 (diff)
downloadvolse-hubzilla-eaea947b7488365968cca9989576ffa0c367cc32.tar.gz
volse-hubzilla-eaea947b7488365968cca9989576ffa0c367cc32.tar.bz2
volse-hubzilla-eaea947b7488365968cca9989576ffa0c367cc32.zip
Merge branch 'dev' into 4.2RC
-rw-r--r--Zotlabs/Lib/Libzot.php2
-rw-r--r--Zotlabs/Module/Cal.php36
-rw-r--r--Zotlabs/Module/Channel_calendar.php17
-rw-r--r--Zotlabs/Photo/PhotoDriver.php2
-rw-r--r--include/datetime.php3
-rw-r--r--include/event.php29
-rw-r--r--include/features.php9
-rw-r--r--include/markdown.php4
-rw-r--r--include/zot.php2
-rwxr-xr-xview/tpl/event_head.tpl1
-rwxr-xr-xview/tpl/event_item_header.tpl6
11 files changed, 61 insertions, 50 deletions
diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php
index 9bf987027..976ed22fa 100644
--- a/Zotlabs/Lib/Libzot.php
+++ b/Zotlabs/Lib/Libzot.php
@@ -2766,7 +2766,7 @@ class Libzot {
$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'],''))
diff --git a/Zotlabs/Module/Cal.php b/Zotlabs/Module/Cal.php
index 70098a2a1..49489f912 100644
--- a/Zotlabs/Module/Cal.php
+++ b/Zotlabs/Module/Cal.php
@@ -84,6 +84,7 @@ class Cal extends \Zotlabs\Web\Controller {
'$module_url' => '/cal/' . $channel['channel_address'],
'$modparams' => 2,
'$lang' => \App::$language,
+ '$timezone' => date_default_timezone_get(),
'$first_day' => $first_day
));
@@ -215,8 +216,8 @@ class Cal extends \Zotlabs\Web\Controller {
$sql_extra .= " and etype != 'birthday' ";
if (x($_GET,'id')){
- $r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan
- from event left join item on resource_id = event_hash where resource_type = 'event' and event.uid = %d and event.id = %d $sql_extra limit 1",
+ $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 resource_id = event_hash where resource_type = 'event' and event.uid = %d and event.id = %d $sql_extra limit 1",
intval($channel['channel_id']),
intval($_GET['id'])
);
@@ -227,12 +228,12 @@ class Cal extends \Zotlabs\Web\Controller {
// Noting this for now - it will need to be fixed here and in Friendica.
// 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
- 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' )) $sql_extra ",
- intval($channel['channel_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 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' )) ",
+ intval(local_channel()),
dbesc($start),
dbesc($finish),
dbesc($adjust_start),
@@ -266,16 +267,23 @@ class Cal extends \Zotlabs\Web\Controller {
if($r) {
foreach($r as $rr) {
-
- $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['dtstart'], 'j') : datetime_convert('UTC','UTC',$rr['dtstart'],'j'));
- $d = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['dtstart'], $fmt) : datetime_convert('UTC','UTC',$rr['dtstart'],$fmt));
+
+ $tz = get_iconfig($rr, 'event', 'timezone');
+
+ if(! $tz)
+ $tz = 'UTC';
+
+ $rr['timezone'] = $tz;
+
+ $j = (($rr['adjust']) ? datetime_convert($tz,date_default_timezone_get(),$rr['dtstart'], 'j') : datetime_convert('UTC','UTC',$rr['dtstart'],'j'));
+ $d = (($rr['adjust']) ? datetime_convert($tz,date_default_timezone_get(),$rr['dtstart'], $fmt) : datetime_convert('UTC','UTC',$rr['dtstart'],$fmt));
$d = day_translate($d);
- $start = (($rr['adjust']) ? datetime_convert('UTC',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']){
$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'));
}
@@ -302,7 +310,7 @@ class Cal extends \Zotlabs\Web\Controller {
'start'=> $start,
'end' => $end,
'drop' => $drop,
- 'allDay' => false,
+ 'allDay' => (($rr['adjust']) ? 0 : 1),
'title' => $title,
'j' => $j,
diff --git a/Zotlabs/Module/Channel_calendar.php b/Zotlabs/Module/Channel_calendar.php
index 44fe261e8..13f879d84 100644
--- a/Zotlabs/Module/Channel_calendar.php
+++ b/Zotlabs/Module/Channel_calendar.php
@@ -345,20 +345,11 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
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']){
$end = null;
} else {
$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');
@@ -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);
$drop = array(z_root().'/events/drop/'.$rr['event_hash'],t('Delete event'),'','');
diff --git a/Zotlabs/Photo/PhotoDriver.php b/Zotlabs/Photo/PhotoDriver.php
index bacf926ff..146ef0ae4 100644
--- a/Zotlabs/Photo/PhotoDriver.php
+++ b/Zotlabs/Photo/PhotoDriver.php
@@ -509,7 +509,7 @@ abstract class PhotoDriver {
$arr['imgscale'] = $scale;
if(boolval(get_config('system','filesystem_storage_thumbnails', 0)) && $scale > 0) {
- $channel = \App::get_channel();
+ $channel = channelx_by_n($arr['uid']);
$arr['os_storage'] = 1;
$arr['os_syspath'] = 'store/' . $channel['channel_address'] . '/' . $arr['os_path'] . '-' . $scale;
if(! $this->saveImage($arr['os_syspath']))
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..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 .= '<div class="event-start"><span class="event-label">' . t('Starts:') . '</span>&nbsp;<span class="dtstart" title="'
. datetime_convert('UTC', 'UTC', $ev['dtstart'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
. '" >'
- . (($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 .= '<div class="event-end" ><span class="event-label">' . t('Finishes:') . '</span>&nbsp;<span class="dtend" title="'
. datetime_convert('UTC','UTC',$ev['dtend'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
. '" >'
- . (($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 )))
@@ -76,18 +77,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/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);
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'],''))
diff --git a/view/tpl/event_head.tpl b/view/tpl/event_head.tpl
index 0e6f7523c..9d56b7fe4 100755
--- a/view/tpl/event_head.tpl
+++ b/view/tpl/event_head.tpl
@@ -52,6 +52,7 @@
header: false,
eventTextColor: 'white',
lang: '{{$lang}}',
+ timeZone: '{{$timezone}}',
firstDay: {{$first_day}},
eventLimit: 3,
diff --git a/view/tpl/event_item_header.tpl b/view/tpl/event_item_header.tpl
index 6247aaf6f..ed46c304f 100755
--- a/view/tpl/event_item_header.tpl
+++ b/view/tpl/event_item_header.tpl
@@ -1,6 +1,11 @@
<div class="event-item-title">
<h3><i class="fa fa-calendar"></i>&nbsp;{{$title}}</h3>
</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">
<span class="event-item-label">{{$dtstart_label}}</span>&nbsp;<span class="dtstart" title="{{$dtstart_title}}">{{$dtstart_dt}}</span>
</div>
@@ -9,3 +14,4 @@
<span class="event-item-label">{{$dtend_label}}</span>&nbsp;<span class="dtend" title="{{$dtend_title}}">{{$dtend_dt}}</span>
</div>
{{/if}}
+{{/if}}