work on repeat/share for Hubzilla
This commit is contained in:
parent
518ceb53a8
commit
29c1797493
@ -236,7 +236,7 @@ class Activity {
|
||||
$ret['id'] = ((strpos($i['mid'],'http') === 0) ? $i['mid'] : z_root() . '/item/' . urlencode($i['mid']));
|
||||
|
||||
if($i['title'])
|
||||
$ret['title'] = bbcode($i['title']);
|
||||
$ret['name'] = $i['title'];
|
||||
|
||||
$ret['published'] = datetime_convert('UTC','UTC',$i['created'],ATOM_TIME);
|
||||
if($i['created'] !== $i['edited'])
|
||||
|
@ -293,8 +293,10 @@ class ThreadItem {
|
||||
$dislike = array( t("I don't like this \x28toggle\x29"), t("dislike"));
|
||||
}
|
||||
|
||||
if ($shareable)
|
||||
$share = array( t('Share This'), t('share'));
|
||||
if ($shareable) {
|
||||
$share = array( t('Repeat This'), t('repeat'));
|
||||
$embed = array( t('Share This'), t('share'));
|
||||
}
|
||||
|
||||
$dreport = '';
|
||||
|
||||
@ -408,6 +410,7 @@ class ThreadItem {
|
||||
'like' => $like,
|
||||
'dislike' => ((feature_enabled($conv->get_profile_owner(),'dislike')) ? $dislike : ''),
|
||||
'share' => $share,
|
||||
'embed' => $embed,
|
||||
'rawmid' => $item['mid'],
|
||||
'plink' => get_plink($item),
|
||||
'edpost' => $edpost, // ((feature_enabled($conv->get_profile_owner(),'edit_posts')) ? $edpost : ''),
|
||||
|
22
Zotlabs/Module/Embed.php
Normal file
22
Zotlabs/Module/Embed.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php
|
||||
namespace Zotlabs\Module;
|
||||
|
||||
require_once('include/security.php');
|
||||
require_once('include/bbcode.php');
|
||||
|
||||
|
||||
class Embed extends \Zotlabs\Web\Controller {
|
||||
|
||||
function init() {
|
||||
|
||||
$post_id = ((argc() > 1) ? intval(argv(1)) : 0);
|
||||
|
||||
if(! $post_id)
|
||||
killme();
|
||||
|
||||
echo '[share=' . $post_id . '][/share]';
|
||||
killme();
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,6 +1,10 @@
|
||||
<?php
|
||||
namespace Zotlabs\Module;
|
||||
|
||||
use App;
|
||||
use Zotlabs\Daemon\Master;
|
||||
|
||||
|
||||
require_once('include/security.php');
|
||||
require_once('include/bbcode.php');
|
||||
|
||||
@ -14,23 +18,21 @@ class Share extends \Zotlabs\Web\Controller {
|
||||
if(! $post_id)
|
||||
killme();
|
||||
|
||||
echo '[share=' . $post_id . '][/share]';
|
||||
killme();
|
||||
|
||||
|
||||
/**
|
||||
* The remaining code is deprecated and handled in Zotlabs/Lib/Share.php at post
|
||||
* submission time.
|
||||
*/
|
||||
|
||||
if(! (local_channel() || remote_channel()))
|
||||
if(! local_channel()) {
|
||||
killme();
|
||||
|
||||
}
|
||||
|
||||
$observer = App::get_observer();
|
||||
|
||||
$channel = App::get_channel();
|
||||
|
||||
|
||||
$r = q("SELECT * from item left join xchan on author_xchan = xchan_hash WHERE id = %d LIMIT 1",
|
||||
intval($post_id)
|
||||
);
|
||||
if(! $r)
|
||||
killme();
|
||||
|
||||
if(($r[0]['item_private']) && ($r[0]['xchan_network'] !== 'rss'))
|
||||
killme();
|
||||
|
||||
@ -47,58 +49,86 @@ class Share extends \Zotlabs\Web\Controller {
|
||||
if($r[0]['mimetype'] !== 'text/bbcode')
|
||||
killme();
|
||||
|
||||
/** @FIXME eventually we want to post remotely via rpost on your home site */
|
||||
// When that works remove this next bit:
|
||||
|
||||
if(! local_channel())
|
||||
killme();
|
||||
|
||||
xchan_query($r);
|
||||
|
||||
$is_photo = (($r[0]['obj_type'] === ACTIVITY_OBJ_PHOTO) ? true : false);
|
||||
if($is_photo) {
|
||||
$object = json_decode($r[0]['obj'],true);
|
||||
$photo_bb = $object['body'];
|
||||
}
|
||||
|
||||
if (strpos($r[0]['body'], "[/share]") !== false) {
|
||||
$pos = strpos($r[0]['body'], "[share");
|
||||
$o = substr($r[0]['body'], $pos);
|
||||
} else {
|
||||
$o = "[share author='" . urlencode($r[0]['author']['xchan_name']) .
|
||||
"' profile='" . $r[0]['author']['xchan_url'] .
|
||||
"' avatar='" . $r[0]['author']['xchan_photo_s'] .
|
||||
"' link='" . $r[0]['plink'] .
|
||||
"' auth='" . (($r[0]['author']['network'] === 'zot') ? 'true' : 'false') .
|
||||
"' posted='" . $r[0]['created'] .
|
||||
"' message_id='" . $r[0]['mid'] .
|
||||
"']";
|
||||
if($r[0]['title'])
|
||||
$o .= '[b]'.$r[0]['title'].'[/b]'."\r\n";
|
||||
$o .= (($is_photo) ? $photo_bb . "\r\n" . $r[0]['body'] : $r[0]['body']);
|
||||
$o .= "[/share]";
|
||||
}
|
||||
|
||||
if(local_channel()) {
|
||||
echo $o;
|
||||
$arr = [];
|
||||
|
||||
$item = $r[0];
|
||||
|
||||
$owner_uid = $r[0]['uid'];
|
||||
$owner_aid = $r[0]['aid'];
|
||||
|
||||
$can_comment = false;
|
||||
if((array_key_exists('owner',$item)) && intval($item['owner']['abook_self']))
|
||||
$can_comment = perm_is_allowed($item['uid'],$observer['xchan_hash'],'post_comments');
|
||||
else
|
||||
$can_comment = can_comment_on_post($observer['xchan_hash'],$item);
|
||||
|
||||
if(! $can_comment) {
|
||||
notice( t('Permission denied') . EOL);
|
||||
killme();
|
||||
}
|
||||
|
||||
$observer = \App::get_observer();
|
||||
$parsed = $observer['xchan_url'];
|
||||
if($parsed) {
|
||||
$post_url = $parsed['scheme'] . '://' . $parsed['host'] . (($parsed['port']) ? ':' . $parsed['port'] : '')
|
||||
. '/rpost';
|
||||
|
||||
/**
|
||||
* @FIXME we were probably called from JS so we don't know the return page.
|
||||
* In fact we won't be able to load the remote page.
|
||||
* we might need an iframe
|
||||
*/
|
||||
|
||||
$x = z_post_url($post_url, array('f' => '', 'body' => $o ));
|
||||
|
||||
$r = q("select * from xchan where xchan_hash = '%s' limit 1",
|
||||
dbesc($item['owner_xchan'])
|
||||
);
|
||||
|
||||
if($r)
|
||||
$thread_owner = $r[0];
|
||||
else
|
||||
killme();
|
||||
|
||||
$r = q("select * from xchan where xchan_hash = '%s' limit 1",
|
||||
dbesc($item['author_xchan'])
|
||||
);
|
||||
if($r)
|
||||
$item_author = $r[0];
|
||||
else
|
||||
killme();
|
||||
|
||||
|
||||
$arr['aid'] = $owner_aid;
|
||||
$arr['uid'] = $owner_uid;
|
||||
|
||||
$arr['item_origin'] = 1;
|
||||
$arr['item_wall'] = $item['item_wall'];
|
||||
$arr['mid'] = item_message_id();
|
||||
$arr['mid'] = str_replace('/item/','/activity/',$arr['mid']);
|
||||
$arr['parent_mid'] = $item['mid'];
|
||||
|
||||
$mention = '@[zrl=' . $item['author']['xchan_url'] . ']' . $item['author']['xchan_name'] . '[/zrl]';
|
||||
$arr['body'] = sprintf( t('🔁 Repeated %1$s\'s %2$s'), $mention, $item['obj_type']);
|
||||
|
||||
$arr['author_xchan'] = $channel['channel_hash'];
|
||||
$arr['owner_xchan'] = $item['author_xchan'];
|
||||
$arr['obj'] = Activity::encode_item($item);
|
||||
$arr['obj_type'] = $item['obj_type'];
|
||||
$arr['verb'] = 'Announce';
|
||||
|
||||
$post = item_store($arr);
|
||||
|
||||
$post_id = $post['item_id'];
|
||||
|
||||
$arr['id'] = $post_id;
|
||||
|
||||
call_hooks('post_local_end', $arr);
|
||||
|
||||
info( t('Post repeated') . EOL);
|
||||
|
||||
$r = q("select * from item where id = %d",
|
||||
intval($post_id)
|
||||
);
|
||||
if($r) {
|
||||
xchan_query($r);
|
||||
$sync_item = fetch_post_tags($r);
|
||||
build_sync_packet($channel['channel_id'], [ 'item' => [ encode_item($sync_item[0],true) ] ]);
|
||||
}
|
||||
|
||||
Master::Summon([ 'Notifier','like',$post_id ]);
|
||||
|
||||
killme();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -146,6 +146,9 @@
|
||||
{{if $item.share}}
|
||||
<a class="dropdown-item" href="#" onclick="jotShare({{$item.id}},{{$item.item_type}}); return false"><i class="generic-icons-nav fa fa-fw fa-retweet" title="{{$item.share.0}}"></i>{{$item.share.0}}</a>
|
||||
{{/if}}
|
||||
{{if $item.embed}}
|
||||
<a class="dropdown-item" href="#" onclick="jotEmbed({{$item.id}},{{$item.item_type}}); return false"><i class="generic-icons-nav fa fa-fw fa-share" title="{{$item.embed.0}}"></i>{{$item.embed.0}}</a>
|
||||
{{/if}}
|
||||
{{if $item.plink}}
|
||||
<a class="dropdown-item" href="{{$item.plink.href}}" title="{{$item.plink.title}}" class="u-url"><i class="generic-icons-nav fa fa-fw fa-external-link"></i>{{$item.plink.title}}</a>
|
||||
{{/if}}
|
||||
|
@ -139,6 +139,9 @@
|
||||
{{if $item.share}}
|
||||
<a class="dropdown-item" href="#" onclick="jotShare({{$item.id}},{{$item.item_type}}); return false"><i class="generic-icons-nav fa fa-fw fa-retweet" title="{{$item.share.0}}"></i>{{$item.share.0}}</a>
|
||||
{{/if}}
|
||||
{{if $item.embed}}
|
||||
<a class="dropdown-item" href="#" onclick="jotEmbed({{$item.id}},{{$item.item_type}}); return false"><i class="generic-icons-nav fa fa-fw fa-share" title="{{$item.embed.0}}"></i>{{$item.embed.0}}</a>
|
||||
{{/if}}
|
||||
{{if $item.plink}}
|
||||
<a class="dropdown-item" href="{{$item.plink.href}}" title="{{$item.plink.title}}" class="u-url"><i class="generic-icons-nav fa fa-fw fa-external-link"></i>{{$item.plink.title}}</a>
|
||||
{{/if}}
|
||||
|
@ -200,14 +200,23 @@ var activeCommentText = '';
|
||||
|
||||
|
||||
function jotShare(id,post_type) {
|
||||
$('#like-rotator-' + id).show();
|
||||
$.get('{{$baseurl}}/share/' + id, function(data) {
|
||||
$('#like-rotator-' + id).hide();
|
||||
notificationsUpdate();
|
||||
});
|
||||
}
|
||||
|
||||
function jotEmbed(id,post_type) {
|
||||
if(post_type == 6) {
|
||||
window.location.href = 'rpost?f=&post_id='+id;
|
||||
}
|
||||
else {
|
||||
|
||||
if ($('#jot-popup').length != 0) $('#jot-popup').show();
|
||||
|
||||
$('#like-rotator-' + id).show();
|
||||
$.get('{{$baseurl}}/share/' + id, function(data) {
|
||||
$.get('{{$baseurl}}/embed/' + id, function(data) {
|
||||
if (!editor) $("#profile-jot-text").val("");
|
||||
initEditor(function(){
|
||||
addeditortext(data);
|
||||
|
Reference in New Issue
Block a user