diff options
-rw-r--r-- | Zotlabs/Lib/ThreadItem.php | 10 | ||||
-rw-r--r-- | Zotlabs/Module/Cdav.php | 51 | ||||
-rw-r--r-- | Zotlabs/Module/Channel_calendar.php | 21 | ||||
-rw-r--r-- | Zotlabs/Module/Display.php | 2 | ||||
-rw-r--r-- | Zotlabs/Module/Editpost.php | 2 | ||||
-rw-r--r-- | Zotlabs/Module/Item.php | 16 | ||||
-rw-r--r-- | Zotlabs/Module/Ping.php | 2 | ||||
-rw-r--r-- | Zotlabs/Widget/Cdav.php | 2 | ||||
-rw-r--r-- | include/features.php | 8 | ||||
-rwxr-xr-x | include/items.php | 5 | ||||
-rw-r--r-- | view/js/main.js | 14 | ||||
-rw-r--r-- | view/theme/redbasic/js/redbasic.js | 3 | ||||
-rw-r--r-- | view/tpl/cdav_calendar.tpl | 145 | ||||
-rwxr-xr-x | view/tpl/conv_item.tpl | 5 |
14 files changed, 226 insertions, 60 deletions
diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php index 40c0fca4b..31259f012 100644 --- a/Zotlabs/Lib/ThreadItem.php +++ b/Zotlabs/Lib/ThreadItem.php @@ -305,6 +305,7 @@ class ThreadItem { if($this->is_commentable() && $observer) { $like = array( t("I like this \x28toggle\x29"), t("like")); $dislike = array( t("I don't like this \x28toggle\x29"), t("dislike")); + $reply_to = array( t("Reply on this comment"), t("reply"), t("Reply to")); } if ($shareable) { @@ -348,9 +349,6 @@ class ThreadItem { $list_unseen_txt = (($unseen_comments) ? sprintf('%d unseen',$unseen_comments) : ''); - - - $children = $this->get_children(); $has_tags = (($body['tags'] || $body['categories'] || $body['mentions'] || $body['attachments'] || $body['folders']) ? true : false); @@ -373,6 +371,8 @@ class ThreadItem { 'text' => strip_tags($body['html']), 'id' => $this->get_id(), 'mid' => $item['mid'], + 'parent' => $item['parent'], + 'author_id' => $item['author']['xchan_addr'], 'isevent' => $isevent, 'attend' => $attend, 'consensus' => $consensus, @@ -425,9 +425,10 @@ class ThreadItem { 'has_tags' => $has_tags, 'reactions' => $this->reactions, // Item toolbar buttons - 'emojis' => (($this->is_toplevel() && $this->is_commentable() && $observer && feature_enabled($conv->get_profile_owner(),'emojis')) ? '1' : ''), + 'emojis' => (($this->is_toplevel() && $this->is_commentable() && $observer && feature_enabled($conv->get_profile_owner(),'emojis')) ? '1' : ''), 'like' => $like, 'dislike' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike : ''), + 'reply_to' => (((! $this->is_toplevel()) && feature_enabled($conv->get_profile_owner(),'reply_to')) ? $reply_to : ''), 'share' => $share, 'embed' => $embed, 'rawmid' => $item['mid'], @@ -869,4 +870,3 @@ class ThreadItem { } - diff --git a/Zotlabs/Module/Cdav.php b/Zotlabs/Module/Cdav.php index 8985e257a..6e302935c 100644 --- a/Zotlabs/Module/Cdav.php +++ b/Zotlabs/Module/Cdav.php @@ -890,7 +890,7 @@ class Cdav extends Controller { } //Display calendar(s) here - if(argc() == 2 && argv(1) === 'calendar') { + if(argc() <= 3 && argv(1) === 'calendar') { head_add_css('/library/fullcalendar/packages/core/main.min.css'); head_add_css('/library/fullcalendar/packages/daygrid/main.min.css'); @@ -905,6 +905,50 @@ class Cdav extends Controller { head_add_js('/library/fullcalendar/packages/list/main.min.js'); $sources = ''; + $resource_id = ''; + $resource = null; + + if(argc() == 3) + $resource_id = argv(2); + + if($resource_id) { + $r = q("SELECT event.*, item.author_xchan, item.owner_xchan, item.plink, item.id as item_id FROM event LEFT JOIN item ON event.event_hash = item.resource_id + WHERE event.uid = %d AND event.event_hash = '%s' LIMIT 1", + intval(local_channel()), + dbesc($resource_id) + ); + if($r) { + xchan_query($r); + $r = fetch_post_tags($r,true); + + $r[0]['dtstart'] = (($r[0]['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$r[0]['dtstart'], 'c') : datetime_convert('UTC','UTC',$r[0]['dtstart'],'c')); + $r[0]['dtend'] = (($r[0]['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$r[0]['dtend'], 'c') : datetime_convert('UTC','UTC',$r[0]['dtend'],'c')); + + $r[0]['plink'] = [$r[0]['plink'], t('Link to source')]; + + $resource = $r[0]; + + $catsenabled = feature_enabled(local_channel(),'categories'); + $categories = ''; + if($catsenabled){ + if($r[0]['term']) { + $cats = get_terms_oftype($r[0]['term'], TERM_CATEGORY); + foreach ($cats as $cat) { + if(strlen($categories)) + $categories .= ', '; + $categories .= $cat['term']; + } + } + } + + if($r[0]['dismissed'] == 0) { + q("UPDATE event SET dismissed = 1 WHERE event.uid = %d AND event.event_hash = '%s'", + intval(local_channel()), + dbesc($resource_id) + ); + } + } + } if(get_pconfig(local_channel(), 'cdav_calendar', 'channel_calendar')) { $sources .= '{ @@ -1005,7 +1049,10 @@ class Cdav extends Controller { '$deny_cid' => acl2json($permissions['deny_cid']), '$deny_gid' => acl2json($permissions['deny_gid']), '$catsenabled' => $catsenabled, - '$categories_label' => t('Categories') + '$categories_label' => t('Categories'), + + '$resource' => json_encode($resource), + '$categories' => $categories ]); return $o; diff --git a/Zotlabs/Module/Channel_calendar.php b/Zotlabs/Module/Channel_calendar.php index d47d5ad49..7fa03fb34 100644 --- a/Zotlabs/Module/Channel_calendar.php +++ b/Zotlabs/Module/Channel_calendar.php @@ -147,6 +147,11 @@ class Channel_calendar extends \Zotlabs\Web\Controller { } return; } + + if($x[0]['event_xchan'] !== $channel['xchan_hash']) { + notice( t('Not allowed.') . EOL); + return; + } $acl->set($x[0]); @@ -524,6 +529,14 @@ 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; + $is_first = ($d !== $last_date); $last_date = $d; @@ -550,17 +563,19 @@ class Channel_calendar extends \Zotlabs\Web\Controller { 'start'=> $start, 'end' => $end, 'drop' => $drop, - 'allDay' => false, + 'allDay' => $allDay, 'title' => $title, 'j' => $j, 'd' => $d, - 'is_editable' => $edit ? true : false, + + 'editable' => $edit ? true : false, + 'className' => 'channel_calendar_id_' . $rr['id'], 'is_first'=>$is_first, 'item'=>$rr, 'html'=>$html, - 'plink' => array($rr['plink'],t('Link to Source'),'',''), + 'plink' => [$rr['plink'], t('Link to source')], 'description' => $rr['description'], 'location' => $rr['location'], diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php index 5983578b3..b7d4a5922 100644 --- a/Zotlabs/Module/Display.php +++ b/Zotlabs/Module/Display.php @@ -265,7 +265,7 @@ class Display extends \Zotlabs\Web\Controller { $sysid = $sys['channel_id']; if(local_channel()) { - $r = q("SELECT item.id as item_id from item WHERE uid = %d and mid = '%s' $item_normal limit 1", + $r = q("SELECT item.parent as item_id from item WHERE uid = %d and mid = '%s' $item_normal limit 1", intval(local_channel()), dbesc($target_item['parent_mid']) ); diff --git a/Zotlabs/Module/Editpost.php b/Zotlabs/Module/Editpost.php index 85882bf0a..49b2892e8 100644 --- a/Zotlabs/Module/Editpost.php +++ b/Zotlabs/Module/Editpost.php @@ -45,7 +45,7 @@ class Editpost extends \Zotlabs\Web\Controller { } if($itm[0]['resource_type'] === 'event' && $itm[0]['resource_id']) { - goaway(z_root() . '/cdav/calendar'); + goaway(z_root() . '/cdav/calendar/' . $itm[0]['resource_id']); //goaway(z_root() . '/events/' . $itm[0]['resource_id'] . '?expandform=1'); } diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index 6bc8c645f..11ce1d268 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -216,7 +216,7 @@ class Item extends Controller { $parent = ((x($_REQUEST,'parent')) ? intval($_REQUEST['parent']) : 0); $parent_mid = ((x($_REQUEST,'parent_mid')) ? trim($_REQUEST['parent_mid']) : ''); - + $remote_xchan = ((x($_REQUEST,'remote_xchan')) ? trim($_REQUEST['remote_xchan']) : false); $r = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($remote_xchan) @@ -329,9 +329,14 @@ class Item extends Controller { $obj_type = ACTIVITY_OBJ_COMMENT; if($parent) { - $r = q("SELECT * FROM item WHERE id = %d LIMIT 1", + // Get commented post data + $rr = q("SELECT parent, mid FROM item WHERE id = %d LIMIT 1", intval($parent) ); + // and its parent + $r = q("SELECT * FROM item WHERE id = %d LIMIT 1", + intval($rr[0]['parent']) + ); } elseif($parent_mid && $uid) { // This is coming from an API source, and we are logged in @@ -910,8 +915,7 @@ class Item extends Controller { } if($parent_item) - $parent_mid = $parent_item['mid']; - + $parent_mid = $rr[0]['mid']; // Fallback so that we alway have a thr_parent @@ -1014,7 +1018,7 @@ class Item extends Controller { $datarray['term'] = $post_tags; $datarray['plink'] = $plink; $datarray['route'] = $route; - + // A specific ACL over-rides public_policy completely @@ -1160,7 +1164,7 @@ class Item extends Controller { 'verb' => ACTIVITY_POST, 'otype' => 'item', 'parent' => $parent, - 'parent_mid' => $parent_item['mid'] + 'parent_mid' => $rr[0]['mid'] )); } diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php index f0c3a8821..3dabe0f7b 100644 --- a/Zotlabs/Module/Ping.php +++ b/Zotlabs/Module/Ping.php @@ -447,7 +447,7 @@ class Ping extends \Zotlabs\Web\Controller { $when = day_translate(datetime_convert('UTC', (($rr['adjust']) ? date_default_timezone_get() : 'UTC'), $rr['dtstart'], $bd_format)) . (($today) ? ' ' . t('[today]') : ''); $result[] = array( - 'notify_link' => z_root() . '/cdav/calendar', /// @FIXME this takes you to an edit page and it may not be yours, we really want to just view the single event --> '/events/event/' . $rr['event_hash'], + 'notify_link' => z_root() . '/cdav/calendar/' . $rr['event_hash'], 'name' => $rr['xchan_name'], 'addr' => $rr['xchan_addr'], 'url' => $rr['xchan_url'], diff --git a/Zotlabs/Widget/Cdav.php b/Zotlabs/Widget/Cdav.php index c88530c0b..20c70903f 100644 --- a/Zotlabs/Widget/Cdav.php +++ b/Zotlabs/Widget/Cdav.php @@ -22,7 +22,7 @@ class Cdav { $o = ''; - if(argc() == 2 && argv(1) === 'calendar') { + if(argc() <= 3 && argv(1) === 'calendar') { $caldavBackend = new \Sabre\CalDAV\Backend\PDO($pdo); diff --git a/include/features.php b/include/features.php index d021f9394..b0d02c141 100644 --- a/include/features.php +++ b/include/features.php @@ -167,6 +167,14 @@ function get_features($filtered = true, $level = (-1)) { t('Ability to mark special posts with a star indicator'), false, get_config('feature_lock','star_posts'), + ], + + [ + 'reply_to', + t('Reply on comment'), + t('Ability to reply on selected comment'), + false, + get_config('feature_lock','reply_to'), ] ], diff --git a/include/items.php b/include/items.php index 95b696034..7a5c2c3c3 100755 --- a/include/items.php +++ b/include/items.php @@ -1875,9 +1875,12 @@ function item_store($arr, $allow_exec = false, $deliver = true) { // is the new message multi-level threaded? // even though we don't support it now, preserve the info // and re-attach to the conversation parent. + + // @FIXME when we'll start threaded comments support, + // now this respected on mid / parent_mid level (MK) if($r[0]['mid'] != $r[0]['parent_mid']) { - $arr['parent_mid'] = $r[0]['parent_mid']; + //$arr['parent_mid'] = $r[0]['parent_mid']; $z = q("SELECT * FROM item WHERE mid = '%s' AND parent_mid = '%s' AND uid = %d ORDER BY id ASC LIMIT 1", dbesc($r[0]['parent_mid']), diff --git a/view/js/main.js b/view/js/main.js index 1322c2112..325ad9a51 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -231,6 +231,10 @@ function handle_comment_form(e) { $('#' + emptyCommentElm).removeAttr('tabindex'); $('#' + emptySubmitElm).removeAttr('tabindex'); form.find(':not(.comment-edit-text)').hide(); + form.find(':input[name=parent]').val(emptyCommentElm.replace(/\D/g,'')); + var btn = form.find(':button[type=submit]').html(); + form.find(':button[type=submit]').html(btn.replace(/<[^>]*>/g, '').trim()); + form.find(':button[type=submit]').prop('title', ''); } }); @@ -1144,6 +1148,16 @@ function doprofilelike(ident, verb) { $.get('like/' + ident + '?verb=' + verb, function() { window.location.href=window.location.href; }); } +function doreply(parent, ident, owner, hint) { + var form = $('#comment-edit-form-' + parent.toString()); + form.find('input[name=parent]').val(ident); + var i = form.find('button[type=submit]'); + var btn = i.html().replace(/<[^>]*>/g, '').trim(); + i.html('<i class="fa fa-reply" ></i> ' + btn); + i.prop('title', hint); + form.find('textarea').val("@{" + owner + "}\n"); + $('#comment-edit-text-' + parent.toString()).focus(); +} function dropItem(url, object) { diff --git a/view/theme/redbasic/js/redbasic.js b/view/theme/redbasic/js/redbasic.js index 8d3b795cc..b8e7946c2 100644 --- a/view/theme/redbasic/js/redbasic.js +++ b/view/theme/redbasic/js/redbasic.js @@ -21,7 +21,8 @@ $(document).ready(function() { $('#left_aside_wrapper, #right_aside_wrapper').stick_in_parent({ offset_top: parseInt($('aside').css('padding-top')), parent: 'main', - spacer: '.aside_spacer' + spacer: '.aside_spacer', + recalc_every: 10 }); } diff --git a/view/tpl/cdav_calendar.tpl b/view/tpl/cdav_calendar.tpl index 5c2f0080b..827c57b96 100644 --- a/view/tpl/cdav_calendar.tpl +++ b/view/tpl/cdav_calendar.tpl @@ -12,6 +12,10 @@ var group_allow = []; var contact_deny = []; var group_deny = []; +var resource = {{$resource}}; +var default_view = resource !== null ? 'timeGridDay' : 'dayGridMonth'; +var default_date = resource !== null ? new Date(resource.dtstart) : new Date(); + $(document).ready(function() { var calendarEl = document.getElementById('calendar'); calendar = new FullCalendar.Calendar(calendarEl, { @@ -29,6 +33,9 @@ $(document).ready(function() { firstDay: {{$first_day}}, + defaultView: default_view, + defaultDate: default_date, + monthNames: aStr['monthNames'], monthNamesShort: aStr['monthNamesShort'], dayNames: aStr['dayNames'], @@ -75,7 +82,7 @@ $(document).ready(function() { 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>'); @@ -137,8 +144,7 @@ $(document).ready(function() { $('#id_description').attr('disabled', false); $('#id_location').attr('disabled', false); - if(calendar_id == 'channel_calendar' && !event.extendedProps.is_editable) { - console.log(calendar_id) + if(calendar_id == 'channel_calendar' && !event.ui.startEditable) { $('#event_submit').hide(); } } @@ -161,7 +167,7 @@ $(document).ready(function() { }, eventResize: function(info) { - + var event = info.event._def; var dtstart = new Date(info.event._instance.range.start); var dtend = new Date(info.event._instance.range.end); @@ -170,16 +176,41 @@ $(document).ready(function() { $('#id_dtstart').val(dtstart.toUTCString()); $('#id_dtend').val(dtend.toUTCString()); - $.post( 'cdav/calendar', { - 'update': 'resize', - 'id[]': event.extendedProps.calendar_id, - 'uri': event.extendedProps.uri, - 'dtstart': dtstart ? dtstart.toUTCString() : '', - 'dtend': dtend ? dtend.toUTCString() : '' - }) - .fail(function() { - info.revert(); - }); + event_id = event.extendedProps.item ? event.extendedProps.item.id : 0; + + if(event.extendedProps.calendar_id === 'channel_calendar') { + $.post( 'channel_calendar', { + 'event_id': event_id, + 'event_hash': event_uri, + 'xchan': '{{$channel_hash}}', + //'mid': mid, + 'type': 'event', + 'preview': 0, + 'summary': event.title, + 'dtstart': dtstart.toUTCString(), + 'dtend': dtend.toUTCString(), + 'adjust': event.extendedProps.item.adjust, + 'categories': event.extendedProps.categories, + 'desc': event.extendedProps.description, + 'location': event.extendedProps.location, + //'submit': $('#event_submit').val() + }) + .fail(function() { + info.revert(); + }); + } + else { + $.post( 'cdav/calendar', { + 'update': 'resize', + 'id[]': event.extendedProps.calendar_id, + 'uri': event.extendedProps.uri, + 'dtstart': dtstart ? dtstart.toUTCString() : '', + 'dtend': dtend ? dtend.toUTCString() : '' + }) + .fail(function() { + info.revert(); + }); + } }, eventDrop: function(info) { @@ -191,19 +222,44 @@ $(document).ready(function() { $('#id_title').val(event.title); $('#id_dtstart').val(dtstart.toUTCString()); $('#id_dtend').val(dtend.toUTCString()); - - $.post( 'cdav/calendar', { - 'update': 'drop', - 'id[]': event.extendedProps.calendar_id, - 'uri': event.extendedProps.uri, - 'dtstart': dtstart ? dtstart.toUTCString() : '', - 'dtend': dtend ? dtend.toUTCString() : '' - }) - .fail(function() { - info.revert(); - }); + + event_id = event.extendedProps.item ? event.extendedProps.item.id : 0; + + if(event.extendedProps.calendar_id === 'channel_calendar') { + $.post( 'channel_calendar', { + 'event_id': event_id, + 'event_hash': event_uri, + 'xchan': '{{$channel_hash}}', + //'mid': mid, + 'type': 'event', + 'preview': 0, + 'summary': event.title, + 'dtstart': dtstart.toUTCString(), + 'dtend': dtend.toUTCString(), + 'adjust': event.extendedProps.item.adjust, + 'categories': event.extendedProps.categories, + 'desc': event.extendedProps.description, + 'location': event.extendedProps.location, + //'submit': $('#event_submit').val() + }) + .fail(function() { + info.revert(); + }); + } + else { + $.post( 'cdav/calendar', { + 'update': 'drop', + 'id[]': event.extendedProps.calendar_id, + 'uri': event.extendedProps.uri, + 'dtstart': dtstart ? dtstart.toUTCString() : '', + 'dtend': dtend ? dtend.toUTCString() : '' + }) + .fail(function() { + info.revert(); + }); + } }, - + loading: function(isLoading, view) { $('#events-spinner').show(); $('#today-btn > i').hide(); @@ -216,7 +272,7 @@ $(document).ready(function() { }); calendar.render(); - + $('#title').text(calendar.view.title); $('#view_selector').html(views[calendar.view.type]); @@ -250,6 +306,28 @@ $(document).ready(function() { $(document).on('click','#event_more', on_more); $(document).on('click','#event_cancel, #event_cancel_recurrent', reset_form); $(document).on('click','#event_delete, #event_delete_recurrent', on_delete); + + if(resource !== null) { + $('.section-content-tools-wrapper, #event_form_wrapper').show(); + + $('#id_title_wrapper').prepend('<span id="l2s" class="float-right"></span>'); + $('#l2s').html('<a href="' + resource.plink[0] + '" target="_blank"><i class="fa fa-external-link"></i> ' + resource.plink[1] + '</a>'); + + event_id = resource.id; + event_uri = resource.event_hash; + $('#calendar_select').val('channel_calendar').attr('disabled', true); + $('#id_title').val(resource.summary); + $('#id_dtstart').val(new Date(resource.dtstart).toUTCString()); + $('#id_dtend').val(new Date(resource.dtend).toUTCString()); + $('#id_categories').tagsinput('add', '{{$categories}}'), + $('#id_description').val(resource.description); + $('#id_location').val(resource.location); + + if(resource.event_xchan !== '{{$channel_hash}}') + $('#event_submit').hide(); + else + $('#event_submit').html('{{$update}}'); + } }); @@ -332,21 +410,12 @@ function on_submit() { 'categories': $('#id_categories').val(), 'desc': $('#id_description').val(), 'location': $('#id_location').val(), - 'submit': $('#event_submit').val(), + //'submit': $('#event_submit').val(), 'contact_allow[]': contact_allow, 'group_allow[]': group_allow, 'contact_deny[]': contact_deny, 'group_deny[]': group_deny -/* - 'submit': $('#event_submit').val(), - 'target': $('#calendar_select').val(), - 'uri': $('#event_uri').val(), - 'title': $('#id_title').val(), - 'dtstart': $('#id_dtstart').val(), - 'dtend': $('#id_dtend').val(), - 'description': $('#id_description').val(), - 'location': $('#id_location').val() -*/ + }) .done(function() { var eventSource = calendar.getEventSourceById('channel_calendar'); diff --git a/view/tpl/conv_item.tpl b/view/tpl/conv_item.tpl index 428529de2..5df706b20 100755 --- a/view/tpl/conv_item.tpl +++ b/view/tpl/conv_item.tpl @@ -102,6 +102,11 @@ <i class="fa fa-thumbs-o-down{{if $item.my_responses.dislike}} ivoted{{/if}}" ></i> </button> {{/if}} + {{if $item.reply_to}} + <button type="button" title="{{$item.reply_to.0}}" class="btn btn-outline-secondary btn-sm" onclick="doreply({{$item.parent}},{{$item.id}},'{{$item.author_id}}', '{{$item.reply_to.2}} {{$item.name}}'); return false;"> + <i class="fa fa-reply" ></i> + </button> + {{/if}} {{if $item.isevent}} <div class="btn-group"> <button type="button" class="btn btn-outline-secondary btn-sm dropdown-toggle" data-toggle="dropdown" id="wall-item-attend-menu-{{$item.id}}" title="{{$item.attend_title}}"> |