aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2019-05-09 13:43:20 +0200
committerMario Vavti <mario@mariovavti.com>2019-05-09 13:43:20 +0200
commit9efd484e277578bc27f18baac64c0067852044de (patch)
tree967db6f5ae19f05272c681f9cccef1ea2a5ce0f0
parent44d5cf980a7196a49be2ff9f3742ba55929fd2d0 (diff)
downloadvolse-hubzilla-9efd484e277578bc27f18baac64c0067852044de.tar.gz
volse-hubzilla-9efd484e277578bc27f18baac64c0067852044de.tar.bz2
volse-hubzilla-9efd484e277578bc27f18baac64c0067852044de.zip
calendar merge: cleanup and comment out some unused code
-rw-r--r--Zotlabs/Module/Cdav.php5
-rw-r--r--Zotlabs/Module/Channel_calendar.php119
-rw-r--r--Zotlabs/Widget/Cdav.php2
-rw-r--r--include/event.php2
-rw-r--r--view/tpl/cdav_calendar.tpl22
5 files changed, 69 insertions, 81 deletions
diff --git a/Zotlabs/Module/Cdav.php b/Zotlabs/Module/Cdav.php
index 6e302935c..9e6997c05 100644
--- a/Zotlabs/Module/Cdav.php
+++ b/Zotlabs/Module/Cdav.php
@@ -965,7 +965,7 @@ class Cdav extends Controller {
foreach($calendars as $calendar) {
$editable = (($calendar['share-access'] == 2) ? 'false' : 'true'); // false/true must be string since we're passing it to javascript
- $color = (($calendar['{http://apple.com/ns/ical/}calendar-color']) ? $calendar['{http://apple.com/ns/ical/}calendar-color'] : '#3a87ad');
+ $color = (($calendar['{http://apple.com/ns/ical/}calendar-color']) ? $calendar['{http://apple.com/ns/ical/}calendar-color'] : '#6cad39');
$sharer = (($calendar['share-access'] == 3) ? $calendar['{urn:ietf:params:xml:ns:caldav}calendar-description'] : '');
$switch = get_pconfig(local_channel(), 'cdav_calendar', $calendar['id'][0]);
if($switch) {
@@ -1398,12 +1398,13 @@ class Cdav extends Controller {
$caldavBackend = new \Sabre\CalDAV\Backend\PDO($pdo);
$properties = [
'{DAV:}displayname' => t('Default Calendar'),
- '{http://apple.com/ns/ical/}calendar-color' => '#3a87ad',
+ '{http://apple.com/ns/ical/}calendar-color' => '#6cad39',
'{urn:ietf:params:xml:ns:caldav}calendar-description' => $channel['channel_name']
];
$id = $caldavBackend->createCalendar($uri, 'default', $properties);
set_pconfig(local_channel(), 'cdav_calendar' , $id[0], 1);
+ set_pconfig(local_channel(), 'cdav_calendar' , 'channel_calendar', 1);
//create default addressbook
$carddavBackend = new \Sabre\CardDAV\Backend\PDO($pdo);
diff --git a/Zotlabs/Module/Channel_calendar.php b/Zotlabs/Module/Channel_calendar.php
index 67e6557f9..e6c5e6e54 100644
--- a/Zotlabs/Module/Channel_calendar.php
+++ b/Zotlabs/Module/Channel_calendar.php
@@ -72,8 +72,6 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
$finish = NULL_DATE;
}
-
-
if($adjust) {
$start = datetime_convert($tz,'UTC',$start);
if(! $nofinish)
@@ -86,12 +84,10 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
}
-
// Don't allow the event to finish before it begins.
// It won't hurt anything, but somebody will file a bug report
// and we'll waste a bunch of time responding to it. Time that
// could've been spent doing something else.
-
$summary = escape_tags(trim($_POST['summary']));
$desc = escape_tags(trim($_POST['desc']));
@@ -102,28 +98,20 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
linkify_tags($desc, local_channel());
linkify_tags($location, local_channel());
- //$action = ($event_hash == '') ? 'new' : "event/" . $event_hash;
-
- //fixme: this url gives a wsod if there is a linebreak detected in one of the variables ($desc or $location)
- //$onerror_url = z_root() . "/events/" . $action . "?summary=$summary&description=$desc&location=$location&start=$start_text&finish=$finish_text&adjust=$adjust&nofinish=$nofinish&type=$type";
- //$onerror_url = z_root() . "/events";
-
if(strcmp($finish,$start) < 0 && !$nofinish) {
notice( t('Event can not end before it has started.') . EOL);
if(intval($_REQUEST['preview'])) {
echo( t('Unable to generate preview.'));
- killme();
}
- //goaway($onerror_url);
+ killme();
}
if((! $summary) || (! $start)) {
notice( t('Event title and start time are required.') . EOL);
if(intval($_REQUEST['preview'])) {
echo( t('Unable to generate preview.'));
- killme();
}
- //goaway($onerror_url);
+ killme();
}
$channel = \App::get_channel();
@@ -275,8 +263,9 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
$channel = \App::get_channel();
$mode = 'view';
- $y = 0;
- $m = 0;
+ $export = false;
+ //$y = 0;
+ //$m = 0;
$ignored = ((x($_REQUEST,'ignored')) ? " and dismissed = " . intval($_REQUEST['ignored']) . " " : '');
if(argc() > 1) {
@@ -288,10 +277,13 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
$mode = 'drop';
$event_id = argv(2);
}
+ if(argc() <= 2 && argv(1) === 'export') {
+ $export = true;
+ }
if(argc() > 2 && intval(argv(1)) && intval(argv(2))) {
$mode = 'view';
- $y = intval(argv(1));
- $m = intval(argv(2));
+ //$y = intval(argv(1));
+ //$m = intval(argv(2));
}
if(argc() <= 2) {
$mode = 'view';
@@ -317,7 +309,8 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
}
$channel = \App::get_channel();
-
+
+/*
// Passed parameters overrides anything found in the DB
if(!x($orig_event))
$orig_event = array();
@@ -370,10 +363,7 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
if(! $m)
$m = intval($thismonth);
- $export = false;
- if(argc() === 4 && argv(3) === 'export')
- $export = true;
-
+
// Put some limits on dates. The PHP date functions don't seem to do so well before 1900.
// An upper limit was chosen to keep search engines from exploring links millions of years in the future.
@@ -400,7 +390,7 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
$dim = get_dim($y,$m);
$start = sprintf('%d-%d-%d %d:%d:%d',$y,$m,1,0,0,0);
$finish = sprintf('%d-%d-%d %d:%d:%d',$y,$m,$dim,23,59,59);
-
+*/
if (argv(1) === 'json'){
if (x($_GET,'start')) $start = $_GET['start'];
@@ -414,20 +404,16 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
$adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish);
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 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 item.resource_id = event.event_hash
+ where item.resource_type = 'event' and event.uid = %d and event.id = %d limit 1",
intval(local_channel()),
intval($_GET['id'])
);
- } elseif($export) {
- $r = q("SELECT * from event where uid = %d
- AND (( adjust = 0 AND ( dtend >= '%s' or nofinish = 1 ) AND dtstart <= '%s' )
- OR ( adjust = 1 AND ( dtend >= '%s' or nofinish = 1 ) AND dtstart <= '%s' )) ",
- intval(local_channel()),
- dbesc($start),
- dbesc($finish),
- dbesc($adjust_start),
- dbesc($adjust_finish)
+ }
+ elseif($export) {
+ $r = q("SELECT * from event where uid = %d",
+ intval(local_channel())
);
}
else {
@@ -437,10 +423,10 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
// 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, item.id as item_id
- 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' )) ",
+ 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),
@@ -448,10 +434,9 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
dbesc($adjust_finish)
);
-
}
- $links = array();
+ //$links = [];
if($r && ! $export) {
xchan_query($r);
@@ -459,7 +444,8 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
$r = sort_by_date($r);
}
-
+
+/*
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'));
@@ -467,18 +453,19 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
$links[$j] = z_root() . '/' . \App::$cmd . '#link-' . $j;
}
}
+*/
- $events=array();
+ $events = [];
- $last_date = '';
- $fmt = t('l, F j');
+ //$last_date = '';
+ //$fmt = t('l, F j');
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));
- $d = day_translate($d);
+ //$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));
+ //$d = day_translate($d);
$start = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['dtstart'], 'c') : datetime_convert('UTC','UTC',$rr['dtstart'],'c'));
if ($rr['nofinish']){
@@ -514,23 +501,23 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
if(strpos($start, 'T00:00:00') && strpos($end, 'T00:00:00'))
$allDay = true;
- $is_first = ($d !== $last_date);
+ //$is_first = ($d !== $last_date);
- $last_date = $d;
+ //$last_date = $d;
$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'),'','');
- $title = strip_tags(html_entity_decode(zidify_links(bbcode($rr['summary'])),ENT_QUOTES,'UTF-8'));
- if(! $title) {
- list($title, $_trash) = explode("<br",bbcode($rr['desc']),2);
- $title = strip_tags(html_entity_decode($title,ENT_QUOTES,'UTF-8'));
- }
- $html = format_event_html($rr);
- $rr['desc'] = zidify_links(smilies(bbcode($rr['desc'])));
- $rr['description'] = htmlentities(html2plain(bbcode($rr['description'])),ENT_COMPAT,'UTF-8',false);
- $rr['location'] = zidify_links(smilies(bbcode($rr['location'])));
+ //$title = strip_tags(html_entity_decode(zidify_links(bbcode($rr['summary'])),ENT_QUOTES,'UTF-8'));
+ //if(! $title) {
+ // list($title, $_trash) = explode("<br",bbcode($rr['desc']),2);
+ // $title = strip_tags(html_entity_decode($title,ENT_QUOTES,'UTF-8'));
+ //}
+ //$html = format_event_html($rr);
+ //$rr['desc'] = zidify_links(smilies(bbcode($rr['desc'])));
+ //$rr['description'] = htmlentities(html2plain(bbcode($rr['description'])),ENT_COMPAT,'UTF-8',false);
+ //$rr['location'] = zidify_links(smilies(bbcode($rr['location'])));
$events[] = array(
'calendar_id' => 'channel_calendar',
'rw' => true,
@@ -541,20 +528,20 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
'end' => $end,
'drop' => $drop,
'allDay' => $allDay,
- 'title' => $title,
+ 'title' => htmlentities($rr['summary'], ENT_COMPAT, 'UTF-8'),
- 'j' => $j,
- 'd' => $d,
+ //'j' => $j,
+ //'d' => $d,
'editable' => $edit ? true : false,
- 'is_first'=>$is_first,
+ //'is_first'=>$is_first,
'item'=>$rr,
- 'html'=>$html,
+ //'html'=>$html,
'plink' => [$rr['plink'], t('Link to source')],
- 'description' => $rr['description'],
- 'location' => $rr['location'],
+ 'description' => htmlentities($rr['description'], ENT_COMPAT, 'UTF-8'),
+ 'location' => htmlentities($rr['location'], ENT_COMPAT, 'UTF-8'),
'allow_cid' => expand_acl($rr['allow_cid']),
'allow_gid' => expand_acl($rr['allow_gid']),
diff --git a/Zotlabs/Widget/Cdav.php b/Zotlabs/Widget/Cdav.php
index 20c70903f..7794d7617 100644
--- a/Zotlabs/Widget/Cdav.php
+++ b/Zotlabs/Widget/Cdav.php
@@ -57,7 +57,7 @@ class Cdav {
$switch = get_pconfig(local_channel(), 'cdav_calendar', $sabrecal['id'][0]);
- $color = (($sabrecal['{http://apple.com/ns/ical/}calendar-color']) ? $sabrecal['{http://apple.com/ns/ical/}calendar-color'] : '#3a87ad');
+ $color = (($sabrecal['{http://apple.com/ns/ical/}calendar-color']) ? $sabrecal['{http://apple.com/ns/ical/}calendar-color'] : '#6cad39');
$editable = (($sabrecal['share-access'] == 2) ? 'false' : 'true'); // false/true must be string since we're passing it to javascript
diff --git a/include/event.php b/include/event.php
index 01122abed..471fb7afa 100644
--- a/include/event.php
+++ b/include/event.php
@@ -1163,7 +1163,7 @@ function event_store_item($arr, $event) {
$item_arr['item_thread_top'] = $item_thread_top;
$attach = array(array(
- 'href' => z_root() . '/events/ical/' . urlencode($event['event_hash']),
+ 'href' => z_root() . '/channel_calendar/ical/' . urlencode($event['event_hash']),
'length' => 0,
'type' => 'text/calendar',
'title' => t('event') . '-' . $event['event_hash'],
diff --git a/view/tpl/cdav_calendar.tpl b/view/tpl/cdav_calendar.tpl
index 9641e2ab5..7ec56a56b 100644
--- a/view/tpl/cdav_calendar.tpl
+++ b/view/tpl/cdav_calendar.tpl
@@ -63,6 +63,11 @@ $(document).ready(function() {
event_uri = '';
$('#id_title').val('New event');
+ $('#id_title').attr('disabled', false);
+ $('#id_dtstart').attr('disabled', false);
+ $('#id_dtend').attr('disabled', false);
+ $('#id_description').attr('disabled', false);
+ $('#id_location').attr('disabled', false);
$('#calendar_select').val($("#calendar_select option:first").val()).attr('disabled', false);
$('#id_dtstart').val(info.date.toUTCString());
$('#id_dtend').val(dtend ? dtend.toUTCString() : '');
@@ -102,6 +107,11 @@ $(document).ready(function() {
$('.section-content-tools-wrapper, #event_form_wrapper').show();
$('#recurrence_warning').hide();
$('#id_title').focus().val('');
+ $('#id_title').attr('disabled', false);
+ $('#id_dtstart').attr('disabled', false);
+ $('#id_dtend').attr('disabled', false);
+ $('#id_description').attr('disabled', false);
+ $('#id_location').attr('disabled', false);
return false;
}
@@ -186,7 +196,6 @@ $(document).ready(function() {
'event_id': event_id,
'event_hash': event_uri,
'xchan': event_xchan,
- //'mid': mid,
'type': 'event',
'preview': 0,
'summary': event.title,
@@ -196,7 +205,6 @@ $(document).ready(function() {
'categories': event.extendedProps.categories,
'desc': event.extendedProps.description,
'location': event.extendedProps.location,
- //'submit': $('#event_submit').val()
})
.fail(function() {
info.revert();
@@ -234,7 +242,6 @@ $(document).ready(function() {
'event_id': event_id,
'event_hash': event_uri,
'xchan': event_xchan,
- //'mid': mid,
'type': 'event',
'preview': 0,
'summary': event.title,
@@ -244,7 +251,6 @@ $(document).ready(function() {
'categories': event.extendedProps.categories,
'desc': event.extendedProps.description,
'location': event.extendedProps.location,
- //'submit': $('#event_submit').val()
})
.fail(function() {
info.revert();
@@ -406,7 +412,6 @@ function on_submit() {
'event_id': event_id,
'event_hash': event_uri,
'xchan': event_xchan,
- //'mid': mid,
'type': 'event',
'preview': 0,
'summary': $('#id_title').val(),
@@ -416,7 +421,6 @@ function on_submit() {
'categories': $('#id_categories').val(),
'desc': $('#id_description').val(),
'location': $('#id_location').val(),
- //'submit': $('#event_submit').val(),
'contact_allow[]': contact_allow,
'group_allow[]': group_allow,
'contact_deny[]': contact_deny,
@@ -508,11 +512,7 @@ function on_more() {
}
function exportDate() {
- alert('not implemented');
- console.log('not implemented');
- //var moment = $('#events-calendar').fullCalendar('getDate');
- //var sT = 'events/' + moment.year() + '/' + (moment.month() + 1) + '/export';
- //window.location.href=sT;
+ window.location.href= 'channel_calendar/export';
}
</script>