aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Module/Cdav.php6
-rw-r--r--Zotlabs/Module/Channel_calendar.php54
-rw-r--r--view/css/cdav_calendar.css6
-rw-r--r--view/tpl/cdav_calendar.tpl19
4 files changed, 52 insertions, 33 deletions
diff --git a/Zotlabs/Module/Cdav.php b/Zotlabs/Module/Cdav.php
index cd5cbc61e..8985e257a 100644
--- a/Zotlabs/Module/Cdav.php
+++ b/Zotlabs/Module/Cdav.php
@@ -952,6 +952,8 @@ class Cdav extends Controller {
$description = ['description', t('Description')];
$location = ['location', t('Location')];
+ $catsenabled = feature_enabled(local_channel(), 'categories');
+
require_once('include/acl_selectors.php');
$accesslist = new \Zotlabs\Access\AccessList($channel);
@@ -1001,7 +1003,9 @@ class Cdav extends Controller {
'$allow_cid' => acl2json($permissions['allow_cid']),
'$allow_gid' => acl2json($permissions['allow_gid']),
'$deny_cid' => acl2json($permissions['deny_cid']),
- '$deny_gid' => acl2json($permissions['deny_gid'])
+ '$deny_gid' => acl2json($permissions['deny_gid']),
+ '$catsenabled' => $catsenabled,
+ '$categories_label' => t('Categories')
]);
return $o;
diff --git a/Zotlabs/Module/Channel_calendar.php b/Zotlabs/Module/Channel_calendar.php
index 6aada575a..d47d5ad49 100644
--- a/Zotlabs/Module/Channel_calendar.php
+++ b/Zotlabs/Module/Channel_calendar.php
@@ -47,7 +47,7 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
$tz = (($timezone) ? $timezone : date_default_timezone_get());
- $categories = escape_tags(trim($_POST['category']));
+ $categories = escape_tags(trim($_POST['categories']));
// only allow editing your own events.
@@ -106,7 +106,7 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
//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";
+ //$onerror_url = z_root() . "/events";
if(strcmp($finish,$start) < 0 && !$nofinish) {
notice( t('Event can not end before it has started.') . EOL);
@@ -114,7 +114,7 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
echo( t('Unable to generate preview.'));
killme();
}
- goaway($onerror_url);
+ //goaway($onerror_url);
}
if((! $summary) || (! $start)) {
@@ -123,7 +123,7 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
echo( t('Unable to generate preview.'));
killme();
}
- goaway($onerror_url);
+ //goaway($onerror_url);
}
// $share = ((intval($_POST['distr'])) ? intval($_POST['distr']) : 0);
@@ -241,6 +241,8 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
if($share)
\Zotlabs\Daemon\Master::Summon(array('Notifier','event',$item_id));
+
+ killme();
}
@@ -378,26 +380,6 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
$f = get_config('system','event_input_format');
if(! $f)
$f = 'ymd';
-
- $catsenabled = feature_enabled(local_channel(),'categories');
-
- $category = '';
-
- if($catsenabled && x($orig_event)){
- $itm = q("select * from item where resource_type = 'event' and resource_id = '%s' and uid = %d limit 1",
- dbesc($orig_event['event_hash']),
- intval(local_channel())
- );
- $itm = fetch_post_tags($itm);
- if($itm) {
- $cats = get_terms_oftype($itm[0]['term'], TERM_CATEGORY);
- foreach ($cats as $cat) {
- if(strlen($category))
- $category .= ', ';
- $category .= $cat['term'];
- }
- }
- }
$thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y');
$thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m');
@@ -472,7 +454,7 @@ class Channel_calendar 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
+ $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' )
@@ -483,6 +465,8 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
dbesc($adjust_start),
dbesc($adjust_finish)
);
+
+
}
$links = array();
@@ -490,7 +474,7 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
if($r && ! $export) {
xchan_query($r);
$r = fetch_post_tags($r,true);
-
+
$r = sort_by_date($r);
}
@@ -526,8 +510,20 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
if($rr['etype'] === 'birthday')
$end = null;
}
-
-
+
+ $catsenabled = feature_enabled(local_channel(),'categories');
+ $categories = '';
+ if($catsenabled){
+ if($rr['term']) {
+ $cats = get_terms_oftype($rr['term'], TERM_CATEGORY);
+ foreach ($cats as $cat) {
+ if(strlen($categories))
+ $categories .= ', ';
+ $categories .= $cat['term'];
+ }
+ }
+ }
+
$is_first = ($d !== $last_date);
$last_date = $d;
@@ -573,6 +569,8 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
'allow_gid' => expand_acl($rr['allow_gid']),
'deny_cid' => expand_acl($rr['deny_cid']),
'deny_gid' => expand_acl($rr['deny_gid']),
+
+ 'categories' => $categories
);
}
}
diff --git a/view/css/cdav_calendar.css b/view/css/cdav_calendar.css
index 2deff683c..da594b420 100644
--- a/view/css/cdav_calendar.css
+++ b/view/css/cdav_calendar.css
@@ -29,3 +29,9 @@ main.fullscreen .fc td:last-child {
.fc-list-view {
border-width: 0px;
}
+
+.bootstrap-tagsinput {
+ width: 100%;
+ padding: 6px 12px;
+}
+
diff --git a/view/tpl/cdav_calendar.tpl b/view/tpl/cdav_calendar.tpl
index 8df288808..5c2f0080b 100644
--- a/view/tpl/cdav_calendar.tpl
+++ b/view/tpl/cdav_calendar.tpl
@@ -69,10 +69,13 @@ $(document).ready(function() {
eventClick: function(info) {
+ //reset categories
+ $('#id_categories').tagsinput('removeAll');
+
var event = info.event._def;
var dtstart = new Date(info.event._instance.range.start);
var dtend = new Date(info.event._instance.range.end);
-
+ console.log(event.extendedProps.categories);
if(event.extendedProps.plink) {
if(! $('#l2s').length)
$('#id_title_wrapper').prepend('<span id="l2s" class="float-right"></span>');
@@ -110,6 +113,7 @@ $(document).ready(function() {
event_uri = event.extendedProps.uri;
$('#id_title').val(event.title);
$('#calendar_select').val(calendar_id).attr('disabled', true).trigger('change');
+ $('#id_categories').tagsinput('add', event.extendedProps.categories);
$('#id_dtstart').val(dtstart.toUTCString());
$('#id_dtend').val(dtend.toUTCString());
$('#id_description').val(event.extendedProps.description);
@@ -233,9 +237,9 @@ $(document).ready(function() {
$('#calendar_select').on('change', function() {
if(this.value === 'channel_calendar')
- $('#dbtn-acl').removeClass('d-none');
+ $('#dbtn-acl, #id_categories_wrapper').removeClass('d-none');
else
- $('#dbtn-acl').addClass('d-none');
+ $('#dbtn-acl, #id_categories_wrapper').addClass('d-none');
});
$('.color-edit').colorpicker({ input: '.color-edit-input' });
@@ -325,7 +329,7 @@ function on_submit() {
'dtstart': $('#id_dtstart').val(),
'dtend': $('#id_dtend').val(),
'adjust': 0,
- 'category': '',
+ 'categories': $('#id_categories').val(),
'desc': $('#id_description').val(),
'location': $('#id_location').val(),
'submit': $('#event_submit').val(),
@@ -403,6 +407,7 @@ function reset_form() {
$('#calendar_select').val('');
event_uri = '';
$('#id_title').val('');
+ $('#id_categories').tagsinput('removeAll');
$('#id_dtstart').val('');
$('#id_dtend').val('');
@@ -490,6 +495,12 @@ function exportDate() {
</optgroup>
</select>
<div id="more_block" style="display: none;">
+ {{if $catsenabled}}
+ <div id="id_categories_wrapper" class="form-group">
+ <label id="label_categories" for="id_categories">{{$categories_label}}</label>
+ <input name="categories" id="id_categories" class="form-control" type="text" value="{{$categories}}" data-role="cat-tagsinput" />
+ </div>
+ {{/if}}
{{include file="field_input.tpl" field=$dtstart}}
{{include file="field_input.tpl" field=$dtend}}
{{include file="field_textarea.tpl" field=$description}}