aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Lib/Activity.php2
-rw-r--r--Zotlabs/Lib/ThreadItem.php7
-rw-r--r--Zotlabs/Module/Embed.php22
-rw-r--r--Zotlabs/Module/Item.php2
-rw-r--r--Zotlabs/Module/Share.php135
-rwxr-xr-xview/tpl/conv_item.tpl3
-rwxr-xr-xview/tpl/conv_list.tpl3
-rwxr-xr-xview/tpl/jot-header.tpl11
8 files changed, 128 insertions, 57 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 259419f54..bcbe53df7 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -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'])
diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php
index 7ce0d0f9e..ba7217c8f 100644
--- a/Zotlabs/Lib/ThreadItem.php
+++ b/Zotlabs/Lib/ThreadItem.php
@@ -304,8 +304,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 = '';
@@ -419,6 +421,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 : ''),
diff --git a/Zotlabs/Module/Embed.php b/Zotlabs/Module/Embed.php
new file mode 100644
index 000000000..77b9254dd
--- /dev/null
+++ b/Zotlabs/Module/Embed.php
@@ -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();
+
+ }
+
+}
diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php
index a48a25e03..f19d4907b 100644
--- a/Zotlabs/Module/Item.php
+++ b/Zotlabs/Module/Item.php
@@ -639,9 +639,9 @@ class Item extends Controller {
if(preg_match_all('/(\[share=(.*?)\](.*?)\[\/share\])/',$body,$match)) {
+
// process share by id
- $verb = ACTIVITY_SHARE;
$i = 0;
foreach($match[2] as $mtch) {
$reshare = new \Zotlabs\Lib\Share($mtch);
diff --git a/Zotlabs/Module/Share.php b/Zotlabs/Module/Share.php
index c6d0be051..58b70318d 100644
--- a/Zotlabs/Module/Share.php
+++ b/Zotlabs/Module/Share.php
@@ -1,6 +1,11 @@
<?php
namespace Zotlabs\Module;
+use App;
+use Zotlabs\Daemon\Master;
+use Zotlabs\Lib\Activity;
+
+
require_once('include/security.php');
require_once('include/bbcode.php');
@@ -14,23 +19,21 @@ class Share extends \Zotlabs\Web\Controller {
if(! $post_id)
killme();
- echo '[share=' . $post_id . '][/share]';
- killme();
+ if(! local_channel()) {
+ killme();
+ }
+ $observer = App::get_observer();
+
+ $channel = App::get_channel();
- /**
- * The remaining code is deprecated and handled in Zotlabs/Lib/Share.php at post
- * submission time.
- */
- if(! (local_channel() || remote_channel()))
- killme();
-
$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 +50,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();
}
+
+ $r = q("select * from xchan where xchan_hash = '%s' limit 1",
+ dbesc($item['owner_xchan'])
+ );
+
+ if($r)
+ $thread_owner = $r[0];
+ else
+ killme();
- $observer = \App::get_observer();
- $parsed = $observer['xchan_url'];
- if($parsed) {
- $post_url = $parsed['scheme'] . '://' . $parsed['host'] . (($parsed['port']) ? ':' . $parsed['port'] : '')
- . '/rpost';
+ $r = q("select * from xchan where xchan_hash = '%s' limit 1",
+ dbesc($item['author_xchan'])
+ );
+ if($r)
+ $item_author = $r[0];
+ else
+ killme();
- /**
- * @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
- */
+
+ $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('&#x1f501; Repeated %1$s\'s %2$s'), $mention, Activity::activity_obj_mapper($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;
- $x = z_post_url($post_url, array('f' => '', 'body' => $o ));
- killme();
+ 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();
+
}
}
diff --git a/view/tpl/conv_item.tpl b/view/tpl/conv_item.tpl
index 69e09b272..428529de2 100755
--- a/view/tpl/conv_item.tpl
+++ b/view/tpl/conv_item.tpl
@@ -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}}
diff --git a/view/tpl/conv_list.tpl b/view/tpl/conv_list.tpl
index 28e120d17..63e74b159 100755
--- a/view/tpl/conv_list.tpl
+++ b/view/tpl/conv_list.tpl
@@ -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}}
diff --git a/view/tpl/jot-header.tpl b/view/tpl/jot-header.tpl
index b286b6071..42537f5e3 100755
--- a/view/tpl/jot-header.tpl
+++ b/view/tpl/jot-header.tpl
@@ -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);