aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Channel_calendar.php
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Module/Channel_calendar.php')
-rw-r--r--Zotlabs/Module/Channel_calendar.php40
1 files changed, 23 insertions, 17 deletions
diff --git a/Zotlabs/Module/Channel_calendar.php b/Zotlabs/Module/Channel_calendar.php
index 7d75a7e41..ae4afb2f3 100644
--- a/Zotlabs/Module/Channel_calendar.php
+++ b/Zotlabs/Module/Channel_calendar.php
@@ -1,6 +1,8 @@
<?php
namespace Zotlabs\Module;
+use Zotlabs\Lib\Libsync;
+
require_once('include/conversation.php');
require_once('include/bbcode.php');
require_once('include/datetime.php');
@@ -16,7 +18,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'] : '');
@@ -27,15 +29,19 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
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']));
+ // 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']));
+
+ $timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : '');
+ $tz = (($timezone) ? $timezone : date_default_timezone_get());
+
+ if(! $adjust)
+ $tz = 'UTC';
$summary = escape_tags(trim($_POST['summary']));
$desc = escape_tags(trim($_POST['desc']));
@@ -184,7 +190,7 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
intval($channel['channel_id'])
);
if($z) {
- build_sync_packet($channel['channel_id'],array('event_item' => array(encode_item($sync_item[0],true)),'event' => $z));
+ Libsync::build_sync_packet($channel['channel_id'],array('event_item' => array(encode_item($sync_item[0],true)),'event' => $z));
}
}
}
@@ -337,21 +343,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 +372,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,
@@ -426,7 +432,7 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
if($r) {
$sync_event['event_deleted'] = 1;
- build_sync_packet(0,array('event' => array($sync_event)));
+ Libsync::build_sync_packet(0,array('event' => array($sync_event)));
$i = q("select * from item where resource_type = 'event' and resource_id = '%s' and uid = %d",
dbesc($event_id),
@@ -475,7 +481,7 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
if($ii) {
xchan_query($ii);
$sync_item = fetch_post_tags($ii);
- build_sync_packet($i[0]['uid'],array('item' => array(encode_item($sync_item[0],true))));
+ Libsync::build_sync_packet($i[0]['uid'],array('item' => array(encode_item($sync_item[0],true))));
}
if($complex) {