aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r--Zotlabs/Module/Admin/Site.php2
-rw-r--r--Zotlabs/Module/Affinity.php94
-rw-r--r--Zotlabs/Module/Connedit.php2
-rw-r--r--Zotlabs/Module/Embed.php22
-rw-r--r--Zotlabs/Module/Events.php4
-rw-r--r--Zotlabs/Module/Item.php151
-rw-r--r--Zotlabs/Module/Mail.php4
-rw-r--r--Zotlabs/Module/Network.php8
-rw-r--r--Zotlabs/Module/Oep.php11
-rw-r--r--Zotlabs/Module/Photos.php2
-rw-r--r--Zotlabs/Module/Profiles.php28
-rw-r--r--Zotlabs/Module/Settings/Featured.php42
-rw-r--r--Zotlabs/Module/Share.php140
-rw-r--r--Zotlabs/Module/Viewsrc.php4
14 files changed, 386 insertions, 128 deletions
diff --git a/Zotlabs/Module/Admin/Site.php b/Zotlabs/Module/Admin/Site.php
index 09b038729..55c8ca928 100644
--- a/Zotlabs/Module/Admin/Site.php
+++ b/Zotlabs/Module/Admin/Site.php
@@ -119,7 +119,7 @@ class Site {
del_config('system', 'admininfo');
} else {
require_once('include/text.php');
- linkify_tags($a, $admininfo, local_channel());
+ linkify_tags($admininfo, local_channel());
set_config('system', 'admininfo', $admininfo);
}
set_config('system','siteinfo',$siteinfo);
diff --git a/Zotlabs/Module/Affinity.php b/Zotlabs/Module/Affinity.php
new file mode 100644
index 000000000..f0d99f1e7
--- /dev/null
+++ b/Zotlabs/Module/Affinity.php
@@ -0,0 +1,94 @@
+<?php
+
+namespace Zotlabs\Module;
+
+use App;
+use Zotlabs\Lib\Apps;
+use Zotlabs\Lib\Libsync;
+
+class Affinity extends \Zotlabs\Web\Controller {
+
+ function post() {
+
+ if(! local_channel())
+ return;
+
+ if(! Apps::system_app_installed(local_channel(),'Affinity Tool'))
+ return;
+
+ check_form_security_token_redirectOnErr('affinity', 'affinity');
+
+ $cmax = intval($_POST['affinity_cmax']);
+ if($cmax < 0 || $cmax > 99)
+ $cmax = 99;
+
+ $cmin = intval($_POST['affinity_cmin']);
+ if($cmin < 0 || $cmin > 99)
+ $cmin = 0;
+
+ $lock = intval($_POST['affinity_lock']);
+
+ set_pconfig(local_channel(),'affinity','cmin',$cmin);
+ set_pconfig(local_channel(),'affinity','cmax',$cmax);
+ set_pconfig(local_channel(),'affinity','lock',$lock);
+
+ info( t('Affinity Tool settings updated.') . EOL);
+
+ Libsync::build_sync_packet();
+
+ }
+
+
+ function get() {
+
+ if(! local_channel())
+ return;
+
+ $desc = t('This app presents a slider control in your connection editor and also on your network page. The slider represents your degree of friendship (affinity) with each connection. It allows you to zoom in or out and display conversations from only your closest friends or everybody in your stream.');
+ if(! Apps::system_app_installed(local_channel(),'Affinity Tool')) {
+ //Do not display any associated widgets at this point
+ App::$pdl = '';
+
+ $o = '<b>' . t('Affinity Tool App') . ' (' . t('Not Installed') . '):</b><br>';
+ $o .= $desc;
+ return $o;
+ }
+
+ $text = t('The numbers below represent the minimum and maximum slider default positions for your network/stream page as a percentage.');
+
+ $content = '<div class="section-content-info-wrapper">' . $text . '</div>';
+
+ $cmax = intval(get_pconfig(local_channel(),'affinity','cmax'));
+ $cmax = (($cmax) ? $cmax : 99);
+ $content .= replace_macros(get_markup_template('field_input.tpl'), array(
+ '$field' => array('affinity_cmax', t('Default maximum affinity level'), $cmax, t('0-99 default 99'))
+ ));
+
+ $cmin = intval(get_pconfig(local_channel(),'affinity','cmin'));
+ $cmin = (($cmin) ? $cmin : 0);
+ $content .= replace_macros(get_markup_template('field_input.tpl'), array(
+ '$field' => array('affinity_cmin', t('Default minimum affinity level'), $cmin, t('0-99 - default 0'))
+ ));
+
+ $lock = intval(get_pconfig(local_channel(),'affinity','lock',1));
+
+ $content .= replace_macros(get_markup_template('field_checkbox.tpl'), array(
+ '$field' => array('affinity_lock', t('Persistent affinity levels'), $lock, t('If disabled the max and min levels will be reset to default after page reload'), ['No','Yes'])
+ ));
+
+ $tpl = get_markup_template("settings_addon.tpl");
+
+ $o = replace_macros($tpl, array(
+ '$action_url' => 'affinity',
+ '$form_security_token' => get_form_security_token("affinity"),
+ '$title' => t('Affinity Tool Settings'),
+ '$content' => $content,
+ '$baseurl' => z_root(),
+ '$submit' => t('Submit'),
+ ));
+
+ return $o;
+ }
+
+
+}
diff --git a/Zotlabs/Module/Connedit.php b/Zotlabs/Module/Connedit.php
index c14bcd0dd..a587324df 100644
--- a/Zotlabs/Module/Connedit.php
+++ b/Zotlabs/Module/Connedit.php
@@ -710,7 +710,7 @@ class Connedit extends \Zotlabs\Web\Controller {
$tpl = get_markup_template("abook_edit.tpl");
- if(feature_enabled(local_channel(),'affinity')) {
+ if(Apps::system_app_installed(local_channel(),'Affinity Tool')) {
$sections['affinity'] = [
'label' => t('Affinity'),
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/Events.php b/Zotlabs/Module/Events.php
index 7e5204e62..e883db49f 100644
--- a/Zotlabs/Module/Events.php
+++ b/Zotlabs/Module/Events.php
@@ -97,8 +97,8 @@ class Events extends \Zotlabs\Web\Controller {
$type = escape_tags(trim($_POST['type']));
require_once('include/text.php');
- linkify_tags($a, $desc, local_channel());
- linkify_tags($a, $location, local_channel());
+ linkify_tags($desc, local_channel());
+ linkify_tags($location, local_channel());
//$action = ($event_hash == '') ? 'new' : "event/" . $event_hash;
diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php
index 24949c626..ebcf632ef 100644
--- a/Zotlabs/Module/Item.php
+++ b/Zotlabs/Module/Item.php
@@ -6,6 +6,13 @@ use Zotlabs\Lib\IConfig;
use Zotlabs\Lib\Enotify;
use Zotlabs\Web\Controller;
use Zotlabs\Daemon\Master;
+use Zotlabs\Lib\Activity;
+use Zotlabs\Lib\ActivityStreams;
+use Zotlabs\Lib\LDSignatures;
+use Zotlabs\Zot6\HTTPSig;
+use Zotlabs\Lib\Libzot;
+use Zotlabs\Lib\ThreadListener;
+use App;
require_once('include/crypto.php');
require_once('include/items.php');
@@ -30,6 +37,144 @@ require_once('include/security.php');
class Item extends Controller {
+
+ function init() {
+
+ if(Libzot::is_zot_request()) {
+
+ $conversation = false;
+
+ $item_id = argv(1);
+
+ if(! $item_id)
+ http_status_exit(404, 'Not found');
+
+
+ $portable_id = EMPTY_STR;
+
+ $sigdata = HTTPSig::verify(EMPTY_STR);
+ if($sigdata['portable_id'] && $sigdata['header_valid']) {
+ $portable_id = $sigdata['portable_id'];
+ }
+
+ $item_normal = " and item.item_hidden = 0 and item.item_type = 0 and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_blocked = 0 ";
+
+ $sql_extra = item_permissions_sql(0);
+
+ $r = q("select * from item where mid = '%s' $item_normal $sql_extra limit 1",
+ dbesc(z_root() . '/item/' . $item_id)
+ );
+ if(! $r) {
+
+
+ $r = q("select * from item where mid = '%s' $item_normal limit 1",
+ dbesc(z_root() . '/item/' . $item_id)
+ );
+ if($r) {
+ http_status_exit(403, 'Forbidden');
+ }
+ http_status_exit(404, 'Not found');
+ }
+
+
+ $items = q("select parent as item_id from item where mid = '%s' and uid = %d $item_normal $sql_extra ",
+ dbesc($r[0]['parent_mid']),
+ intval($r[0]['uid'])
+ );
+ if(! $items) {
+ http_status_exit(404, 'Not found');
+ }
+
+ $r = $items;
+
+ $parents_str = ids_to_querystr($r,'item_id');
+
+ $items = q("SELECT item.*, item.id AS item_id FROM item WHERE item.parent IN ( %s ) $item_normal $sql_extra ",
+ dbesc($parents_str)
+ );
+
+ if(! $items) {
+ http_status_exit(404, 'Not found');
+ }
+
+ $r = $items;
+ xchan_query($r,true);
+ $items = fetch_post_tags($r,true);
+
+ $observer = App::get_observer();
+ $parent = $items[0];
+ $recips = (($parent['owner']['xchan_network'] === 'activitypub') ? get_iconfig($parent['id'],'activitypub','recips', []) : []);
+ $to = (($recips && array_key_exists('to',$recips) && is_array($recips['to'])) ? $recips['to'] : null);
+ $nitems = [];
+ foreach($items as $i) {
+
+ $mids = [];
+
+ if(intval($i['item_private'])) {
+ if(! $observer) {
+ continue;
+ }
+ // ignore private reshare, possibly from hubzilla
+ if($i['verb'] === 'Announce') {
+ if(! in_array($i['thr_parent'],$mids)) {
+ $mids[] = $i['thr_parent'];
+ }
+ continue;
+ }
+ // also ignore any children of the private reshares
+ if(in_array($i['thr_parent'],$mids)) {
+ continue;
+ }
+
+ if((! $to) || (! in_array($observer['xchan_url'],$to))) {
+ continue;
+ }
+
+ }
+ $nitems[] = $i;
+ }
+
+ if(! $nitems)
+ http_status_exit(404, 'Not found');
+
+ $chan = channelx_by_n($nitems[0]['uid']);
+
+ if(! $chan)
+ http_status_exit(404, 'Not found');
+
+ if(! perm_is_allowed($chan['channel_id'],get_observer_hash(),'view_stream'))
+ http_status_exit(403, 'Forbidden');
+
+ $i = Activity::encode_item_collection($nitems,'conversation/' . $item_id,'OrderedCollection',( defined('NOMADIC') ? false : true));
+ if($portable_id) {
+ ThreadListener::store(z_root() . '/item/' . $item_id,$portable_id);
+ }
+
+ if(! $i)
+ http_status_exit(404, 'Not found');
+
+ $x = array_merge(['@context' => [
+ ACTIVITYSTREAMS_JSONLD_REV,
+ 'https://w3id.org/security/v1',
+ z_root() . ZOT_APSCHEMA_REV
+ ]], $i);
+
+ $headers = [];
+ $headers['Content-Type'] = 'application/x-zot+json' ;
+ $x['signature'] = LDSignatures::sign($x,$chan);
+ $ret = json_encode($x, JSON_UNESCAPED_SLASHES);
+ $headers['Digest'] = HTTPSig::generate_digest_header($ret);
+ $headers['(request-target)'] = strtolower($_SERVER['REQUEST_METHOD']) . ' ' . $_SERVER['REQUEST_URI'];
+ $h = HTTPSig::create_sig($headers,$chan['channel_prvkey'],channel_url($chan));
+ HTTPSig::set_headers($h);
+ echo $ret;
+ killme();
+
+ }
+ }
+
+
+
function post() {
// This will change. Figure out who the observer is and whether or not
@@ -553,8 +698,8 @@ class Item extends Controller {
// Look for tags and linkify them
- $results = linkify_tags($a, $summary, ($uid) ? $uid : $profile_uid);
- $results = linkify_tags($a, $body, ($uid) ? $uid : $profile_uid);
+ $results = linkify_tags($summary, ($uid) ? $uid : $profile_uid);
+ $results = linkify_tags($body, ($uid) ? $uid : $profile_uid);
if($results) {
@@ -639,9 +784,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/Mail.php b/Zotlabs/Module/Mail.php
index d38c1d88c..3202d38a5 100644
--- a/Zotlabs/Module/Mail.php
+++ b/Zotlabs/Module/Mail.php
@@ -34,7 +34,7 @@ class Mail extends \Zotlabs\Web\Controller {
}
else {
$body = cleanup_bbcode($body);
- $results = linkify_tags($a, $body, local_channel());
+ $results = linkify_tags($body, local_channel());
if(preg_match_all('/(\[attachment\](.*?)\[\/attachment\])/',$body,$match)) {
$attachments = array();
@@ -111,7 +111,7 @@ class Mail extends \Zotlabs\Web\Controller {
}
require_once('include/text.php');
- linkify_tags($a, $body, local_channel());
+ linkify_tags($body, local_channel());
if(! $recipient) {
diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php
index d5cc06d09..2019082ed 100644
--- a/Zotlabs/Module/Network.php
+++ b/Zotlabs/Module/Network.php
@@ -1,6 +1,8 @@
<?php
namespace Zotlabs\Module;
+use Zotlabs\Lib\Group;
+use Zotlabs\Lib\Apps;
use App;
require_once('include/items.php');
@@ -114,8 +116,8 @@ class Network extends \Zotlabs\Web\Controller {
$def_acl = array('allow_gid' => '<' . $r[0]['hash'] . '>');
}
- $default_cmin = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmin',0) : (-1));
- $default_cmax = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmax',99) : (-1));
+ $default_cmin = ((Apps::system_app_installed(local_channel(),'Affinity Tool')) ? get_pconfig(local_channel(),'affinity','cmin',0) : (-1));
+ $default_cmax = ((Apps::system_app_installed(local_channel(),'Affinity Tool')) ? get_pconfig(local_channel(),'affinity','cmax',99) : (-1));
$cid = ((x($_GET,'cid')) ? intval($_GET['cid']) : 0);
$star = ((x($_GET,'star')) ? intval($_GET['star']) : 0);
@@ -132,7 +134,7 @@ class Network extends \Zotlabs\Web\Controller {
$deftag = '';
- if (feature_enabled(local_channel(),'affinity')) {
+ if (Apps::system_app_installed(local_channel(),'Affinity Tool')) {
$affinity_locked = intval(get_pconfig(local_channel(),'affinity','lock',1));
if ($affinity_locked) {
set_pconfig(local_channel(),'affinity','cmin',$cmin);
diff --git a/Zotlabs/Module/Oep.php b/Zotlabs/Module/Oep.php
index 0f20a5f9a..c0d8e15e5 100644
--- a/Zotlabs/Module/Oep.php
+++ b/Zotlabs/Module/Oep.php
@@ -181,7 +181,7 @@ class Oep extends \Zotlabs\Web\Controller {
dbesc($res)
);
if($r) {
- $sql_extra = "and item.id = " . intval($r[0]['iid']) . " ";
+ $sql_extra .= " and item.id = " . intval($r[0]['iid']) . " ";
}
else {
return $ret;
@@ -194,6 +194,9 @@ class Oep extends \Zotlabs\Web\Controller {
intval(ITEM_TYPE_CARD)
);
+ if(! $r)
+ return;
+
$item_normal = " and item.item_hidden = 0 and item.item_type in (0,6) and item.item_deleted = 0
and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0
and item.item_blocked = 0 ";
@@ -255,7 +258,6 @@ class Oep extends \Zotlabs\Web\Controller {
if(! $channel)
return $ret;
-
if(! perm_is_allowed($channel['channel_id'],get_observer_hash(),'view_pages'))
return $ret;
@@ -265,7 +267,7 @@ class Oep extends \Zotlabs\Web\Controller {
dbesc($res)
);
if($r) {
- $sql_extra = "and item.id = " . intval($r[0]['iid']) . " ";
+ $sql_extra .= " and item.id = " . intval($r[0]['iid']) . " ";
}
else {
return $ret;
@@ -278,6 +280,9 @@ class Oep extends \Zotlabs\Web\Controller {
intval(ITEM_TYPE_ARTICLE)
);
+ if(! $r)
+ return;
+
$item_normal = " and item.item_hidden = 0 and item.item_type in (0,7) and item.item_deleted = 0
and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0
and item.item_blocked = 0 ";
diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php
index 3833d5088..a761dbd14 100644
--- a/Zotlabs/Module/Photos.php
+++ b/Zotlabs/Module/Photos.php
@@ -422,7 +422,7 @@ class Photos extends \Zotlabs\Web\Controller {
require_once('include/text.php');
$profile_uid = \App::$profile['profile_uid'];
- $results = linkify_tags($a, $rawtags, (local_channel()) ? local_channel() : $profile_uid);
+ $results = linkify_tags($rawtags, (local_channel()) ? local_channel() : $profile_uid);
$success = $results['success'];
$post_tags = array();
diff --git a/Zotlabs/Module/Profiles.php b/Zotlabs/Module/Profiles.php
index de4075ba9..33e7d8a9d 100644
--- a/Zotlabs/Module/Profiles.php
+++ b/Zotlabs/Module/Profiles.php
@@ -354,20 +354,20 @@ class Profiles extends \Zotlabs\Web\Controller {
require_once('include/text.php');
- linkify_tags($a, $likes, local_channel());
- linkify_tags($a, $dislikes, local_channel());
- linkify_tags($a, $about, local_channel());
- linkify_tags($a, $interest, local_channel());
- linkify_tags($a, $interest, local_channel());
- linkify_tags($a, $contact, local_channel());
- linkify_tags($a, $channels, local_channel());
- linkify_tags($a, $music, local_channel());
- linkify_tags($a, $book, local_channel());
- linkify_tags($a, $tv, local_channel());
- linkify_tags($a, $film, local_channel());
- linkify_tags($a, $romance, local_channel());
- linkify_tags($a, $work, local_channel());
- linkify_tags($a, $education, local_channel());
+ linkify_tags($likes, local_channel());
+ linkify_tags($dislikes, local_channel());
+ linkify_tags($about, local_channel());
+ linkify_tags($interest, local_channel());
+ linkify_tags($interest, local_channel());
+ linkify_tags($contact, local_channel());
+ linkify_tags($channels, local_channel());
+ linkify_tags($music, local_channel());
+ linkify_tags($book, local_channel());
+ linkify_tags($tv, local_channel());
+ linkify_tags($film, local_channel());
+ linkify_tags($romance, local_channel());
+ linkify_tags($work, local_channel());
+ linkify_tags($education, local_channel());
$with = ((x($_POST,'with')) ? escape_tags(trim($_POST['with'])) : '');
diff --git a/Zotlabs/Module/Settings/Featured.php b/Zotlabs/Module/Settings/Featured.php
index 1d903fcf7..d5d740aff 100644
--- a/Zotlabs/Module/Settings/Featured.php
+++ b/Zotlabs/Module/Settings/Featured.php
@@ -10,24 +10,6 @@ class Featured {
call_hooks('feature_settings_post', $_POST);
- if($_POST['affinity_slider-submit']) {
- $cmax = intval($_POST['affinity_cmax']);
- if($cmax < 0 || $cmax > 99)
- $cmax = 99;
- $cmin = intval($_POST['affinity_cmin']);
- if($cmin < 0 || $cmin > 99)
- $cmin = 0;
-
- $lock = ($_POST['affinity_lock']) ? intval($_POST['affinity_lock']) : 1;
-
- set_pconfig(local_channel(),'affinity','cmin',$cmin);
- set_pconfig(local_channel(),'affinity','cmax',$cmax);
- set_pconfig(local_channel(),'affinity','lock',$lock);
-
- info( t('Affinity Slider settings updated.') . EOL);
-
- }
-
build_sync_packet();
return;
}
@@ -41,34 +23,10 @@ class Featured {
if(! $r)
$settings_addons = t('No feature settings configured');
- if(feature_enabled(local_channel(),'affinity')) {
-
- $cmax = intval(get_pconfig(local_channel(),'affinity','cmax'));
- $cmax = (($cmax) ? $cmax : 99);
- $setting_fields .= replace_macros(get_markup_template('field_input.tpl'), array(
- '$field' => array('affinity_cmax', t('Default maximum affinity level'), $cmax, t('0-99 default 99'))
- ));
- $cmin = intval(get_pconfig(local_channel(),'affinity','cmin'));
- $cmin = (($cmin) ? $cmin : 0);
- $setting_fields .= replace_macros(get_markup_template('field_input.tpl'), array(
- '$field' => array('affinity_cmin', t('Default minimum affinity level'), $cmin, t('0-99 - default 0'))
- ));
- $lock = intval(get_pconfig(local_channel(),'affinity','lock',1));
- $setting_fields .= replace_macros(get_markup_template('field_checkbox.tpl'), array(
- '$field' => array('affinity_lock', t('Always reset on new page visit.'), $lock, t('default: yes'), Array('No','Yes'))
- ));
-
- $settings_addons .= replace_macros(get_markup_template('generic_addon_settings.tpl'), array(
- '$addon' => array('affinity_slider', '' . t('Affinity Slider Settings'), '', t('Submit')),
- '$content' => $setting_fields
- ));
- }
-
call_hooks('feature_settings', $settings_addons);
$this->sortpanels($settings_addons);
-
$tpl = get_markup_template("settings_addons.tpl");
$o .= replace_macros($tpl, array(
'$form_security_token' => get_form_security_token("settings_featured"),
diff --git a/Zotlabs/Module/Share.php b/Zotlabs/Module/Share.php
index c6d0be051..53a06b072 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,23 @@ class Share extends \Zotlabs\Web\Controller {
if(! $post_id)
killme();
- echo '[share=' . $post_id . '][/share]';
- killme();
+ if(! local_channel()) {
+ killme();
+ }
+ $observer = App::get_observer();
- /**
- * The remaining code is deprecated and handled in Zotlabs/Lib/Share.php at post
- * submission time.
- */
+ $channel = App::get_channel();
- 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();
@@ -46,59 +51,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['uuid'] = item_message_id();
+ $arr['mid'] = z_root() . '/activity/' . $arr['uuid'];
+ $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/Zotlabs/Module/Viewsrc.php b/Zotlabs/Module/Viewsrc.php
index 119990b57..b73d81283 100644
--- a/Zotlabs/Module/Viewsrc.php
+++ b/Zotlabs/Module/Viewsrc.php
@@ -28,7 +28,7 @@ class Viewsrc extends \Zotlabs\Web\Controller {
$item_normal = item_normal();
if(local_channel() && $item_id) {
- $r = q("select id, item_flags, mimetype, item_obscured, body, llink, plink from item where uid in (%d , %d) and id = %d $item_normal limit 1",
+ $r = q("select id, mid, item_flags, mimetype, item_obscured, body, llink, plink from item where uid in (%d , %d) and id = %d $item_normal limit 1",
intval(local_channel()),
intval($sys['channel_id']),
intval($item_id)
@@ -53,7 +53,7 @@ class Viewsrc extends \Zotlabs\Web\Controller {
if(is_ajax()) {
echo '<div class="p-1">';
- echo '<div>id: ' . $r[0]['id'] . ' | <a href="' . $r[0]['plink'] . '" target="_blank">plink</a> | <a href="' . $r[0]['llink'] . '" target="_blank">llink</a></div>';
+ echo '<div>id: ' . $r[0]['id'] . ' | <a href="' . $r[0]['plink'] . '" target="_blank">plink</a> | <a href="' . $r[0]['llink'] . '" target="_blank">llink</a><br>mid: ' . $r[0]['mid'] . '</div>';
echo '<hr>';
echo '<pre class="p-1">' . $o . '</pre>';
echo '</div>';