aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Module/Channel_calendar.php23
-rw-r--r--include/event.php43
2 files changed, 36 insertions, 30 deletions
diff --git a/Zotlabs/Module/Channel_calendar.php b/Zotlabs/Module/Channel_calendar.php
index 7d75a7e41..f83a0167d 100644
--- a/Zotlabs/Module/Channel_calendar.php
+++ b/Zotlabs/Module/Channel_calendar.php
@@ -16,7 +16,7 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
if(! local_channel())
return;
-
+
$event_id = ((x($_POST,'event_id')) ? intval($_POST['event_id']) : 0);
$event_hash = ((x($_POST,'event_hash')) ? $_POST['event_hash'] : '');
@@ -32,10 +32,11 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
$categories = escape_tags(trim($_POST['categories']));
+ // allday events have adjust = 0, normal events have adjust = 1
$adjust = intval($_POST['adjust']);
- $start = datetime_convert('UTC', 'UTC', escape_tags($_REQUEST['dtstart']));
- $finish = datetime_convert('UTC', 'UTC', escape_tags($_REQUEST['dtend']));
+ $start = datetime_convert((($adjust) ? $tz : 'UTC'), 'UTC', escape_tags($_REQUEST['dtstart']));
+ $finish = datetime_convert((($adjust) ? $tz : 'UTC'), 'UTC', escape_tags($_REQUEST['dtend']));
$summary = escape_tags(trim($_POST['summary']));
$desc = escape_tags(trim($_POST['desc']));
@@ -337,21 +338,16 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
}
$events = [];
-
+
if($r) {
foreach($r as $rr) {
- $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'));
+ $start = (($rr['adjust']) ? datetime_convert('UTC', 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'));
+ $end = (($rr['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $rr['dtend'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtend'], 'c'));
}
$catsenabled = feature_enabled(local_channel(),'categories');
@@ -371,6 +367,11 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
$drop = array(z_root().'/events/drop/'.$rr['event_hash'],t('Delete event'),'','');
+ $tz = get_iconfig($rr, 'event', 'timezone');
+
+ if(! $tz)
+ $tz = 'UTC';
+
$events[] = array(
'calendar_id' => 'channel_calendar',
'rw' => true,
diff --git a/include/event.php b/include/event.php
index b92d2c8a9..d39da227c 100644
--- a/include/event.php
+++ b/include/event.php
@@ -40,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($tz, date_default_timezone_get(),
+ . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(),
$ev['dtstart'] , $bd_format ))
: day_translate(datetime_convert('UTC', 'UTC',
$ev['dtstart'] , $bd_format)))
@@ -50,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($tz, date_default_timezone_get(),
+ . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(),
$ev['dtend'] , $bd_format ))
: day_translate(datetime_convert('UTC', 'UTC',
$ev['dtend'] , $bd_format )))
@@ -97,12 +97,12 @@ function format_event_obj($jobject) {
$event['header'] = replace_macros(get_markup_template('event_item_header.tpl'),array(
'$title' => zidify_links(smilies(bbcode($object['title']))),
'$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))),
+ '$dtstart_title' => datetime_convert('UTC', 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))),
'$finish' => (($object['nofinish']) ? false : true),
'$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_title' => datetime_convert('UTC', 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 ))),
'$allday' => $allday,
'$oneday' => $oneday
));
@@ -257,7 +257,7 @@ function format_event_bbcode($ev, $utc = false) {
if($ev['event_vdata']) {
$o .= '[event]' . $ev['event_vdata'] . '[/event]';
}
-
+/*
if ($utc && $ev['event-timezone'] !== 'UTC') {
$ev['dtstart'] = datetime_convert($ev['timezone'],'UTC',$ev['dtstart']);
if ($ev['dtend'] && ! $ev['nofinish']) {
@@ -265,7 +265,7 @@ function format_event_bbcode($ev, $utc = false) {
}
$ev['timezone'] = 'UTC';
}
-
+*/
if($ev['summary'])
$o .= '[event-summary]' . $ev['summary'] . '[/event-summary]';
@@ -284,8 +284,8 @@ function format_event_bbcode($ev, $utc = false) {
if($ev['event_hash'])
$o .= '[event-id]' . $ev['event_hash'] . '[/event-id]';
- if($ev['timezone'])
- $o .= '[event-timezone]' . $ev['timezone'] . '[/event-timezone]';
+// if($ev['timezone'])
+// $o .= '[event-timezone]' . $ev['timezone'] . '[/event-timezone]';
if($ev['adjust'])
$o .= '[event-adjust]' . $ev['adjust'] . '[/event-adjust]';
@@ -1091,12 +1091,17 @@ function event_store_item($arr, $event) {
$item_arr['comment_policy'] = 'none';
}
- $r = q("SELECT * FROM item left join xchan on author_xchan = xchan_hash WHERE resource_id = '%s' AND resource_type = 'event' and uid = %d LIMIT 1",
+ $r = q("SELECT * FROM item WHERE resource_id = '%s' AND resource_type = 'event' and uid = %d LIMIT 1",
dbesc($event['event_hash']),
intval($arr['uid'])
);
if($r) {
+
+ set_iconfig($r[0]['id'], 'event', 'timezone', $arr['timezone'], true);
+ xchan_query($r);
+ $r = fetch_post_tags($r,true);
+
$object = json_encode(array(
'type' => ACTIVITY_OBJ_EVENT,
'id' => z_root() . '/event/' . $r[0]['resource_id'],
@@ -1111,13 +1116,13 @@ function event_store_item($arr, $event) {
'content' => format_event_bbcode($arr),
'attachment' => Activity::encode_attachment($r[0]),
'author' => array(
- 'name' => $r[0]['xchan_name'],
- 'address' => $r[0]['xchan_addr'],
- 'guid' => $r[0]['xchan_guid'],
- 'guid_sig' => $r[0]['xchan_guid_sig'],
+ 'name' => $r[0]['author']['xchan_name'],
+ 'address' => $r[0]['author']['xchan_addr'],
+ 'guid' => $r[0]['author']['xchan_guid'],
+ 'guid_sig' => $r[0]['author']['xchan_guid_sig'],
'link' => array(
- array('rel' => 'alternate', 'type' => 'text/html', 'href' => $r[0]['xchan_url']),
- array('rel' => 'photo', 'type' => $r[0]['xchan_photo_mimetype'], 'href' => $r[0]['xchan_photo_m'])
+ array('rel' => 'alternate', 'type' => 'text/html', 'href' => $r[0]['author']['xchan_url']),
+ array('rel' => 'photo', 'type' => $r[0]['author']['xchan_photo_mimetype'], 'href' => $r[0]['author']['xchan_photo_m'])
),
),
));
@@ -1167,7 +1172,6 @@ function event_store_item($arr, $event) {
}
$item_id = $r[0]['id'];
- set_iconfig($item_id, 'event', 'timezone', $arr['timezone'], true);
/**
* @hooks event_updated
@@ -1251,6 +1255,8 @@ function event_store_item($arr, $event) {
else
$item_arr['plink'] = z_root() . '/display/' . gen_link_id($item_arr['mid']);
+ set_iconfig($item_arr, 'event','timezone',$arr['timezone'],true);
+
$x = q("select * from xchan where xchan_hash = '%s' limit 1",
dbesc($arr['event_xchan'])
);
@@ -1286,7 +1292,6 @@ 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);