mirror of
https://codeberg.org/streams/streams.git
synced 2024-09-19 16:15:13 +00:00
some preliminary work on threaded comments refactor, bring back poke app.
This commit is contained in:
parent
869abbea59
commit
3a03e6285c
12 changed files with 126 additions and 193 deletions
|
@ -111,7 +111,7 @@ class Libzotdir {
|
|||
'$forumsurl' => $forumsurl,
|
||||
'$safemode' => array('safemode', t('Safe Mode'),$safe_mode,'',array(t('No'), t('Yes')),' onchange=\'window.location.href="' . $forumsurl . '&safe="+(this.checked ? 1 : 0)\''),
|
||||
'$pubforums' => array('pubforums', t('Groups Only'),(($pubforums == 1) ? true : false),'',array(t('No'), t('Yes')),' onchange=\'window.location.href="' . $forumsurl . '&type="+(this.checked ? 1 : 0)\''),
|
||||
'$collections' => array('collections', t('Collections Only'),(($pubforums == 2) ? true : false),'',array(t('No'), t('Yes')),' onchange=\'window.location.href="' . $forumsurl . '&type="+(this.checked ? 2 : 0)\''),
|
||||
// '$collections' => array('collections', t('Collections Only'),(($pubforums == 2) ? true : false),'',array(t('No'), t('Yes')),' onchange=\'window.location.href="' . $forumsurl . '&type="+(this.checked ? 2 : 0)\''),
|
||||
'$hide_local' => $hide_local,
|
||||
'$globaldir' => array('globaldir', t('This Website Only'), 1-intval($globaldir),'',array(t('No'), t('Yes')),' onchange=\'window.location.href="' . $forumsurl . '&global="+(this.checked ? 0 : 1)\''),
|
||||
'$activedir' => array('activedir', t('Recently Updated'), intval($activedir),'',array(t('No'), t('Yes')),' onchange=\'window.location.href="' . $forumsurl . '&active="+(this.checked ? 1 : 0)\''),
|
||||
|
|
|
@ -914,6 +914,7 @@ class ThreadItem {
|
|||
'$anonurl' => [ 'anonurl', t('Your website URL (optional)') ],
|
||||
'$auto_save_draft' => $feature_auto_save_draft,
|
||||
'$save' => $permanent_draft,
|
||||
'$top' => $this->is_toplevel()
|
||||
));
|
||||
|
||||
return $comment_box;
|
||||
|
|
|
@ -1,76 +1,53 @@
|
|||
<?php
|
||||
namespace Zotlabs\Module; /** @file */
|
||||
namespace Zotlabs\Module;
|
||||
|
||||
use App;
|
||||
use Zotlabs\Lib\Apps;
|
||||
use Zotlabs\Lib\Activity;
|
||||
use Zotlabs\Lib\Libsync;
|
||||
use Zotlabs\Web\Controller;
|
||||
|
||||
/**
|
||||
*
|
||||
* Poke, prod, finger, or otherwise do unspeakable things to somebody - who must be a connection in your address book
|
||||
* This function can be invoked with the required arguments (verb and cid and private and possibly parent) silently via ajax or
|
||||
* other web request. You must be logged in and connected to a channel.
|
||||
* If the required arguments aren't present, we'll display a simple form to choose a recipient and a verb.
|
||||
* parent is a special argument which let's you attach this activity as a comment to an existing conversation, which
|
||||
* may have started with somebody else poking (etc.) somebody, but this isn't necessary. This can be used in the adult
|
||||
* plugin version to have entire conversations where Alice poked Bob, Bob fingered Alice, Alice hugged Bob, etc.
|
||||
*
|
||||
* private creates a private conversation with the recipient. Otherwise your channel's default post privacy is used.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
class Poke extends Controller {
|
||||
|
||||
function init() {
|
||||
|
||||
if(! local_channel())
|
||||
return;
|
||||
|
||||
if(! Apps::system_app_installed(local_channel(), 'Poke')) {
|
||||
return;
|
||||
$uid = local_channel();
|
||||
if (! $uid) {
|
||||
return;
|
||||
}
|
||||
|
||||
$uid = local_channel();
|
||||
$channel = App::get_channel();
|
||||
|
||||
$verb = notags(trim($_REQUEST['verb']));
|
||||
|
||||
if(! $verb)
|
||||
if (! Apps::system_app_installed($uid, 'Poke')) {
|
||||
return;
|
||||
}
|
||||
$channel = App::get_channel();
|
||||
|
||||
$verbs = get_poke_verbs();
|
||||
|
||||
if(! array_key_exists($verb,$verbs))
|
||||
if (isset($_REQUEST['pokeverb']) && array_key_exists(trim($_REQUEST['pokeverb']),$verbs)) {
|
||||
set_pconfig($uid,'system','pokeverb',trim($_REQUEST['pokeverb']));
|
||||
return;
|
||||
}
|
||||
|
||||
$activity = ACTIVITY_POKE . '#' . urlencode($verbs[$verb][0]);
|
||||
$verb = get_pconfig($uid,'system','pokeverb','poke');
|
||||
|
||||
$contact_id = intval($_REQUEST['cid']);
|
||||
if (! array_key_exists($verb,$verbs)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$activity = $verbs[$verb][0];
|
||||
|
||||
$xchan = trim($_REQUEST['xchan']);
|
||||
|
||||
if(! ($contact_id || $xchan))
|
||||
if (! $xchan) {
|
||||
return;
|
||||
|
||||
$parent = ((x($_REQUEST,'parent')) ? intval($_REQUEST['parent']) : 0);
|
||||
|
||||
logger('poke: verb ' . $verb . ' contact ' . $contact_id, LOGGER_DEBUG);
|
||||
|
||||
|
||||
if($contact_id) {
|
||||
$r = q("SELECT * FROM abook left join xchan on xchan_hash = abook_xchan where abook_id = %d and abook_channel = %d LIMIT 1",
|
||||
intval($contact_id),
|
||||
intval($uid)
|
||||
);
|
||||
}
|
||||
if($xchan) {
|
||||
$r = q("SELECT * FROM xchan where xchan_hash like ( '%s' ) LIMIT 1",
|
||||
dbesc($xchan . '%')
|
||||
);
|
||||
}
|
||||
|
||||
if(! $r) {
|
||||
$r = q("SELECT * FROM xchan where xchan_hash = '%s' LIMIT 1",
|
||||
dbesc($xchan)
|
||||
);
|
||||
|
||||
if (! $r) {
|
||||
logger('poke: no target.');
|
||||
return;
|
||||
}
|
||||
|
@ -78,73 +55,52 @@ class Poke extends Controller {
|
|||
$target = $r[0];
|
||||
$parent_item = null;
|
||||
|
||||
if($parent) {
|
||||
$r = q("select mid, item_private, owner_xchan, allow_cid, allow_gid, deny_cid, deny_gid
|
||||
from item where id = %d and parent = %d and uid = %d limit 1",
|
||||
intval($parent),
|
||||
intval($parent),
|
||||
intval($uid)
|
||||
);
|
||||
if($r) {
|
||||
$parent_item = $r[0];
|
||||
$parent_mid = $r[0]['mid'];
|
||||
$item_private = $r[0]['item_private'];
|
||||
$allow_cid = $r[0]['allow_cid'];
|
||||
$allow_gid = $r[0]['allow_gid'];
|
||||
$deny_cid = $r[0]['deny_cid'];
|
||||
$deny_gid = $r[0]['deny_gid'];
|
||||
}
|
||||
$item_private = 1;
|
||||
|
||||
if ($target) {
|
||||
$allow_cid = '<' . $target['abook_xchan']. '>';
|
||||
$allow_gid = EMPTY_STR;
|
||||
$deny_cid = EMPTY_STR;
|
||||
$deny_gid = EMPTY_STR;
|
||||
}
|
||||
elseif($contact_id) {
|
||||
|
||||
$item_private = ((x($_GET,'private')) ? intval($_GET['private']) : 0);
|
||||
|
||||
$allow_cid = (($item_private) ? '<' . $target['abook_xchan']. '>' : $channel['channel_allow_cid']);
|
||||
$allow_gid = (($item_private) ? '' : $channel['channel_allow_gid']);
|
||||
$deny_cid = (($item_private) ? '' : $channel['channel_deny_cid']);
|
||||
$deny_gid = (($item_private) ? '' : $channel['channel_deny_gid']);
|
||||
}
|
||||
|
||||
|
||||
$arr = [];
|
||||
|
||||
|
||||
|
||||
$arr['item_wall'] = 1;
|
||||
$arr['owner_xchan'] = (($parent_item) ? $parent_item['owner_xchan'] : $channel['channel_hash']);
|
||||
$arr['parent_mid'] = (($parent_mid) ? $parent_mid : '');
|
||||
$arr['title'] = '';
|
||||
$arr['owner_xchan'] = $channel['channel_hash'];
|
||||
$arr['author_xchan'] = $channel['channel_hash'];
|
||||
$arr['allow_cid'] = $allow_cid;
|
||||
$arr['allow_gid'] = $allow_gid;
|
||||
$arr['deny_cid'] = $deny_cid;
|
||||
$arr['deny_gid'] = $deny_gid;
|
||||
$arr['verb'] = $activity;
|
||||
$arr['item_private'] = $item_private;
|
||||
$arr['obj_type'] = ACTIVITY_OBJ_PERSON;
|
||||
$arr['verb'] = 'Create';
|
||||
$arr['item_private'] = 1;
|
||||
$arr['obj_type'] = 'Note';
|
||||
$arr['body'] = '[zrl=' . $channel['xchan_url'] . ']' . $channel['xchan_name'] . '[/zrl]' . ' ' . t($verbs[$verb][0]) . ' ' . '[zrl=' . $target['xchan_url'] . ']' . $target['xchan_name'] . '[/zrl]';
|
||||
|
||||
$obj = array(
|
||||
'type' => ACTIVITY_OBJ_PERSON,
|
||||
'title' => $target['xchan_name'],
|
||||
'id' => $target['xchan_hash'],
|
||||
'link' => array(
|
||||
array('rel' => 'alternate', 'type' => 'text/html', 'href' => $target['xchan_url']),
|
||||
array('rel' => 'photo', 'type' => $target['xchan_photo_mimetype'], 'href' => $target['xchan_photo_l'])
|
||||
),
|
||||
);
|
||||
|
||||
$arr['obj'] = json_encode($obj);
|
||||
|
||||
$arr['item_origin'] = 1;
|
||||
$arr['item_wall'] = 1;
|
||||
$arr['item_unseen'] = 1;
|
||||
if(! $parent_item)
|
||||
$item['item_thread_top'] = 1;
|
||||
|
||||
$obj = Activity::encode_item($arr,((get_config('system','activitypub', ACTIVITYPUB_ENABLED)) ? true : false));
|
||||
|
||||
post_activity_item($arr);
|
||||
$i = post_activity_item($arr);
|
||||
|
||||
return;
|
||||
if ($i['success']) {
|
||||
$item_id = $i['item_id'];
|
||||
$r = q("select * from item where id = %d",
|
||||
intval($item_id)
|
||||
);
|
||||
if ($r) {
|
||||
xchan_query($r);
|
||||
$sync_item = fetch_post_tags($r);
|
||||
Libsync::build_sync_packet($uid, [ 'item' => [ encode_item($sync_item[0],true) ] ] );
|
||||
}
|
||||
|
||||
info(sprintf( t('You %1$s %2$s'),t($verbs[$verb][0]), $target['xchan_name']));
|
||||
}
|
||||
|
||||
json_return_and_die([ 'success' => true ]);
|
||||
}
|
||||
|
||||
|
||||
|
@ -157,11 +113,8 @@ class Poke extends Controller {
|
|||
}
|
||||
|
||||
if(! Apps::system_app_installed(local_channel(), 'Poke')) {
|
||||
//Do not display any associated widgets at this point
|
||||
App::$pdl = '';
|
||||
|
||||
$o = '<b>Poke App (Not Installed):</b><br>';
|
||||
$o .= t('Poke somebody in your addressbook');
|
||||
$o = '<b>' . t('Poke App (Not Installed)') . '</b><br>';
|
||||
$o .= t('Poke or do something else to somebody');
|
||||
return $o;
|
||||
}
|
||||
|
||||
|
@ -170,54 +123,28 @@ class Poke extends Controller {
|
|||
$name = '';
|
||||
$id = '';
|
||||
|
||||
if(intval($_REQUEST['c'])) {
|
||||
$r = q("select abook_id, xchan_name from abook left join xchan on abook_xchan = xchan_hash
|
||||
where abook_id = %d and abook_channel = %d limit 1",
|
||||
intval($_REQUEST['c']),
|
||||
intval(local_channel())
|
||||
);
|
||||
if($r) {
|
||||
$name = $r[0]['xchan_name'];
|
||||
$id = $r[0]['abook_id'];
|
||||
}
|
||||
}
|
||||
|
||||
$parent = ((x($_REQUEST,'parent')) ? intval($_REQUEST['parent']) : '0');
|
||||
|
||||
$verbs = get_poke_verbs();
|
||||
|
||||
$shortlist = [];
|
||||
foreach($verbs as $k => $v)
|
||||
if($v[1] !== 'NOTRANSLATION')
|
||||
$shortlist[] = array($k,$v[1]);
|
||||
$current = get_pconfig(local_channel(),'system','pokeverb','poke');
|
||||
foreach($verbs as $k => $v) {
|
||||
$shortlist[] = [ $k,$v[1], (($k === $current) ? true : false) ];
|
||||
}
|
||||
|
||||
|
||||
$poke_basic = get_config('system','poke_basic');
|
||||
if($poke_basic) {
|
||||
$title = t('Poke');
|
||||
$desc = t('Poke somebody');
|
||||
}
|
||||
else {
|
||||
$title = t('Poke/Prod');
|
||||
$desc = t('Poke, prod or do other things to somebody');
|
||||
}
|
||||
$title = t('Poke');
|
||||
$desc = t('Poke, prod or do other things to somebody');
|
||||
|
||||
$o = replace_macros(get_markup_template('poke_content.tpl'),array(
|
||||
'$title' => $title,
|
||||
'$poke_basic' => $poke_basic,
|
||||
'$desc' => $desc,
|
||||
'$clabel' => t('Recipient'),
|
||||
'$choice' => t('Choose what you wish to do to recipient'),
|
||||
'$choice' => t('Choose your default action'),
|
||||
'$verbs' => $shortlist,
|
||||
'$parent' => $parent,
|
||||
'$prv_desc' => t('Make this post private'),
|
||||
'$private' => array('private', t('Make this post private'), false, ''),
|
||||
'$submit' => t('Submit'),
|
||||
'$name' => $name,
|
||||
'$id' => $id
|
||||
));
|
||||
|
||||
return $o;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -927,8 +927,9 @@ function thread_author_menu($item, $mode = '') {
|
|||
}
|
||||
}
|
||||
|
||||
$poke_label = ucfirst( t(get_pconfig($local_channel,'system','pokeverb','poke')) );
|
||||
|
||||
if($contact) {
|
||||
$poke_link = z_root() . '/poke/?f=&c=' . $contact['abook_id'];
|
||||
if (! (isset($contact['abook_self']) && intval($contact['abook_self']))) {
|
||||
$contact_url = z_root() . '/connedit/' . $contact['abook_id'];
|
||||
}
|
||||
|
@ -998,6 +999,16 @@ function thread_author_menu($item, $mode = '') {
|
|||
];
|
||||
}
|
||||
|
||||
if (Apps::system_app_installed($local_channel,'Poke')) {
|
||||
$menu[] = [
|
||||
'menu' => 'poke',
|
||||
'title' => $poke_label,
|
||||
'icon' => 'fw',
|
||||
'action' => 'doPoke(\'' . urlencode($item['author_xchan']) . '\'); return false;',
|
||||
'href' => '#'
|
||||
];
|
||||
}
|
||||
|
||||
if (local_channel()) {
|
||||
$menu[] = [
|
||||
'menu' => 'superblocksite',
|
||||
|
|
|
@ -465,7 +465,7 @@ function post_activity_item($arr, $allow_code = false, $deliver = true) {
|
|||
$arr['mimetype'] = 'text/bbcode';
|
||||
}
|
||||
|
||||
if (! isset($arr['mid']) && $arr['mid']) {
|
||||
if (! (isset($arr['mid']) && $arr['mid'])) {
|
||||
$arr['uuid'] = ((isset($arr['uuid'])) ? $arr['uuid'] : new_uuid());
|
||||
}
|
||||
$arr['mid'] = ((isset($arr['mid'])) ? $arr['mid'] : z_root() . '/item/' . $arr['uuid']);
|
||||
|
@ -493,7 +493,6 @@ function post_activity_item($arr, $allow_code = false, $deliver = true) {
|
|||
$arr['plink'] = substr(z_root() . '/channel/' . $channel['channel_address'] . '/?f=&mid=' . urlencode($arr['mid']),0,190);
|
||||
}
|
||||
|
||||
|
||||
// for the benefit of plugins, we will behave as if this is an API call rather than a normal online post
|
||||
|
||||
$_REQUEST['api_source'] = 1;
|
||||
|
|
|
@ -389,9 +389,11 @@ function import_remote_xchan_photo($photo, $xchan, $thing = false) {
|
|||
// continue using our cached copy, although we still need to figure out the type
|
||||
// for the benefit of upstream callers that may require it
|
||||
|
||||
$info = getimagesize('cache/xp/' . $hash . '-4' . (($thing) ? '.obj' : EMPTY_STR));
|
||||
if (isset($info) && is_array($info) && array_key_exists('mime',$info)) {
|
||||
$type = $info['mime'];
|
||||
if (file_exists($cached_file)) {
|
||||
$info = getimagesize($cached_file);
|
||||
if (isset($info) && is_array($info) && array_key_exists('mime',$info)) {
|
||||
$type = $info['mime'];
|
||||
}
|
||||
}
|
||||
|
||||
$photo = z_root() . '/xp/' . $hash . '-4' . (($thing) ? '.obj' : EMPTY_STR);
|
||||
|
|
|
@ -261,6 +261,12 @@ function handle_comment_form(e) {
|
|||
}
|
||||
}
|
||||
|
||||
function doreply(parent, ident) {
|
||||
showHideCommentBox(parent);
|
||||
openClose('wall-item-comment-wrapper-' + ident.toString());
|
||||
}
|
||||
|
||||
|
||||
function commentClose(obj, id) {
|
||||
if(obj.value === '') {
|
||||
obj.value = aStr.comment;
|
||||
|
@ -434,6 +440,12 @@ function doFollowAuthor(url) {
|
|||
return true;
|
||||
}
|
||||
|
||||
function doPoke(xchan) {
|
||||
$.get('poke?xchan=' + xchan, function(data) { notificationsUpdate(); });
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function update_role_text() {
|
||||
var new_role = $("#id_permissions_role").val();
|
||||
|
|
|
@ -1203,12 +1203,15 @@ img.mail-conv-sender-photo {
|
|||
font-size: 1rem;
|
||||
}
|
||||
|
||||
|
||||
.comment-edit-text {
|
||||
border: 1px solid #ccc;
|
||||
border: 1px solid #007bff;
|
||||
border-radius: $radius;
|
||||
}
|
||||
|
||||
.comment-edit-text.toplevel {
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.divgrow-showmore {
|
||||
display: block;
|
||||
border-top: 1px dashed #ccc;
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
{{$anon_extras}}
|
||||
</div>
|
||||
{{/if}}
|
||||
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text" placeholder="{{$comment}}" name="body" ondragenter="linkdropper(event);" ondragleave="linkdropexit(event);" ondragover="linkdropper(event);" ondrop="linkdrop(event);" ></textarea>
|
||||
<textarea id="comment-edit-text-{{$id}}" class="comment-edit-text {{if $top}}toplevel{{/if}}" placeholder="{{$comment}}" name="body" ondragenter="linkdropper(event);" ondragleave="linkdropexit(event);" ondragover="linkdropper(event);" ondrop="linkdrop(event);" ></textarea>
|
||||
<div id="comment-tools-{{$id}}" class="pt-2 comment-tools">
|
||||
<div id="comment-edit-bb-{{$id}}" class="btn-toolbar pull-left">
|
||||
{{if $feature_markup}}
|
||||
|
|
|
@ -119,7 +119,7 @@
|
|||
</button>
|
||||
{{/if}}
|
||||
{{if $item.comment && $item.thread_level > 1 && $item.thread_level < $item.thread_max }}
|
||||
<button type="button" title="{{$item.comment_lbl}}" class="btn btn-outline-secondary btn-sm" onclick="openClose('wall-item-comment-wrapper-{{$item.id}}'); $('#comment-edit-text-{{$item.id}}').click(); return false;">
|
||||
<button type="button" title="{{$item.comment_lbl}}" class="btn btn-outline-secondary btn-sm" onclick="doreply({{$item.parent}},{{$item.id}}); return false;">
|
||||
<i class="fa fa-reply"></i>
|
||||
</button>
|
||||
{{/if}}
|
||||
|
|
|
@ -5,44 +5,22 @@
|
|||
</div>
|
||||
<div class="section-content-wrapper">
|
||||
|
||||
<div id="poke-desc">{{$desc}}</div>
|
||||
<div id="poke-desc">{{$desc}}</div>
|
||||
<br>
|
||||
<br>
|
||||
|
||||
<br>
|
||||
<br>
|
||||
<form action="poke" method="get">
|
||||
|
||||
<div class="form-group field custom">
|
||||
<label for="poke-verb-select" id="poke-verb-lbl">{{$choice}}</label>
|
||||
<select class="form-control" name="pokeverb" id="poke-verb-select" >
|
||||
{{foreach $verbs as $v}}
|
||||
<option value="{{$v.0}}"{{if $v.2}} selected="selected"{{/if}}>{{$v.0}}</option>
|
||||
{{/foreach}}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<form action="poke" method="get">
|
||||
|
||||
|
||||
<div class="form-group field input">
|
||||
<label id="poke-recip-label" for="poke-recip">{{$clabel}}</label>
|
||||
<input class="form-control" id="poke-recip" type="text" value="{{$name}}" name="pokename" autocomplete="off" />
|
||||
</div>
|
||||
|
||||
<input id="poke-recip-complete" type="hidden" value="{{$id}}" name="cid" />
|
||||
<input id="poke-parent" type="hidden" value="{{$parent}}" name="parent" />
|
||||
|
||||
|
||||
{{if $poke_basic}}
|
||||
<input type="hidden" name="verb" value="poke" />
|
||||
{{else}}
|
||||
<div class="form-group field custom">
|
||||
<label for="poke-verb-select" id="poke-verb-lbl">{{$choice}}</label>
|
||||
<select class="form-control" name="verb" id="poke-verb-select" >
|
||||
{{foreach $verbs as $v}}
|
||||
<option value="{{$v.0}}">{{$v.1}}</option>
|
||||
{{/foreach}}
|
||||
</select>
|
||||
</div>
|
||||
{{/if}}
|
||||
|
||||
{{if ! $parent}}
|
||||
{{include file="field_checkbox.tpl" field=$private}}
|
||||
{{/if}}
|
||||
|
||||
<input type="submit" name="submit" value="{{$submit}}" />
|
||||
</form>
|
||||
|
||||
|
||||
</div>
|
||||
<input type="submit" name="submit" value="{{$submit}}" >
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue