aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs')
-rw-r--r--Zotlabs/Lib/Activity.php9
-rw-r--r--Zotlabs/Lib/Apps.php1
-rw-r--r--Zotlabs/Lib/Libzot.php40
-rw-r--r--Zotlabs/Lib/ThreadItem.php34
-rw-r--r--Zotlabs/Lib/ThreadListener.php53
-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
-rw-r--r--Zotlabs/Widget/Affinity.php89
-rw-r--r--Zotlabs/Widget/Settings_menu.php7
21 files changed, 549 insertions, 198 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 8cfa18997..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'])
@@ -1411,6 +1411,9 @@ class Activity {
$s['owner_xchan'] = $act->actor['id'];
$s['author_xchan'] = $act->actor['id'];
+ // ensure we store the original actor
+ self::actor_store($act->actor['id'],$act->actor);
+
$s['mid'] = $act->obj['id'];
$s['parent_mid'] = $act->parent_id;
@@ -1483,7 +1486,8 @@ class Activity {
$s['verb'] = self::activity_decode_mapper($act->type);
- if($act->type === 'Tombstone') {
+
+ if($act->type === 'Tombstone' || ($act->type === 'Create' && $act->obj['type'] === 'Tombstone')) {
$s['item_deleted'] = 1;
}
@@ -1492,7 +1496,6 @@ class Activity {
$s['obj_type'] = ACTIVITY_OBJ_COMMENT;
}
-
if($act->obj['type'] === 'Event') {
$s['obj'] = [];
$s['obj']['asld'] = $act->obj;
diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php
index 9edd00667..56283ff76 100644
--- a/Zotlabs/Lib/Apps.php
+++ b/Zotlabs/Lib/Apps.php
@@ -320,6 +320,7 @@ class Apps {
static public function translate_system_apps(&$arr) {
$apps = array(
'Apps' => t('Apps'),
+ 'Affinity Tool' => t('Affinity Tool'),
'Articles' => t('Articles'),
'Cards' => t('Cards'),
'Admin' => t('Site Admin'),
diff --git a/Zotlabs/Lib/Libzot.php b/Zotlabs/Lib/Libzot.php
index 27502009c..019237568 100644
--- a/Zotlabs/Lib/Libzot.php
+++ b/Zotlabs/Lib/Libzot.php
@@ -1487,8 +1487,31 @@ class Libzot {
$allowed = can_comment_on_post($sender,$parent[0]);
}
}
- if($request) {
- $allowed = true;
+
+ if ($request) {
+
+ // Conversation fetches (e.g. $request == true) take place for
+ // a) new comments on expired posts
+ // b) hyperdrive (friend-of-friend) conversations
+ // c) Repeats of posts by others
+
+
+ // over-ride normal connection permissions for hyperdrive (friend-of-friend) conversations
+ // (if hyperdrive is enabled) and repeated posts by a friend.
+ // If $allowed is already true, this is probably the conversation of a direct friend or a
+ // conversation fetch for a new comment on an expired post
+ // Comments of all these activities are allowed and will only be rejected (later) if the parent
+ // doesn't exist.
+
+ if ($perm === 'send_stream') {
+ if (get_pconfig($channel['channel_id'],'system','hyperdrive',false) || $arr['verb'] === ACTIVITY_SHARE) {
+ $allowed = true;
+ }
+ }
+ else {
+ $allowed = true;
+ }
+
$friendofriend = true;
}
@@ -1500,7 +1523,7 @@ class Libzot {
}
}
- logger('item: ' . print_r($arr,true), LOGGER_DATA);
+ // logger('item: ' . print_r($arr,true), LOGGER_DATA);
if($arr['mid'] !== $arr['parent_mid']) {
@@ -1526,19 +1549,11 @@ class Libzot {
// have the copy and we don't want the request to loop.
// Also don't do this if this comment came from a conversation request packet.
// It's possible that comments are allowed but posting isn't and that could
- // cause a conversation fetch loop. We can detect these packets since they are
- // delivered via a 'notify' packet type that has a message_id element in the
- // initial zot packet (just like the corresponding 'request' packet type which
- // makes the request).
+ // cause a conversation fetch loop.
// We'll also check the send_stream permission - because if it isn't allowed,
// the top level post is unlikely to be imported and
// this is just an exercise in futility.
-
- if((! get_pconfig($channel['channel_id'],'system','hyperdrive',false)) || (! $arr['verb'] === 'Announce')) {
- continue;
- }
-
if((! $relay) && (! $request) && (! $local_public)
&& perm_is_allowed($channel['channel_id'],$sender,'send_stream')) {
self::fetch_conversation($channel,$arr['parent_mid']);
@@ -1814,6 +1829,7 @@ class Libzot {
$arr['owner_xchan'] = $a['signature']['signer'];
}
+
/// @FIXME - spoofable
if($AS->data['hubloc']) {
$arr['item_verified'] = true;
diff --git a/Zotlabs/Lib/ThreadItem.php b/Zotlabs/Lib/ThreadItem.php
index 83d243177..40c0fca4b 100644
--- a/Zotlabs/Lib/ThreadItem.php
+++ b/Zotlabs/Lib/ThreadItem.php
@@ -76,7 +76,7 @@ class ThreadItem {
* _ false on failure
*/
- public function get_template_data($conv_responses, $thread_level=1) {
+ public function get_template_data($conv_responses, $thread_level=1, $conv_flags = []) {
$result = array();
@@ -101,6 +101,7 @@ class ThreadItem {
|| strlen($item['deny_cid']) || strlen($item['deny_gid']))))
? t('Private Message')
: false);
+
$shareable = ((($conv->get_profile_owner() == local_channel() && local_channel()) && ($item['item_private'] != 1)) ? true : false);
// allow an exemption for sharing stuff from your private feeds
@@ -115,6 +116,19 @@ class ThreadItem {
$privacy_warning = true;
}
+ if ($lock) {
+ if (($item['mid'] == $item['parent_mid']) && count(get_terms_oftype($item['term'],TERM_FORUM))) {
+ $privacy_warning = true;
+ $conv_flags['parent_privacy_warning'] = true;
+ }
+ }
+
+ $privacy_warning = (isset($conv_flags['parent_privacy_warning'])) ? $conv_flags['parent_privacy_warning'] : $privacy_warning;
+
+ if ($lock && $privacy_warning) {
+ $lock = t('Privacy conflict. Discretion advised.');
+ }
+
$mode = $conv->get_mode();
switch($item['item_type']) {
@@ -293,8 +307,15 @@ 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) {
+ // This actually turns out not to be possible in some protocol stacks without opening up hundreds of new issues.
+ // Will allow it only for uri resolvable sources.
+ if(strpos($item['mid'],'http') === 0) {
+ $share = []; //Not yet ready for primetime
+ //$share = array( t('Repeat This'), t('repeat'));
+ }
+ $embed = array( t('Share This'), t('share'));
+ }
$dreport = '';
@@ -408,12 +429,13 @@ 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 : ''),
- 'star' => ((feature_enabled($conv->get_profile_owner(),'star_posts')) ? $star : ''),
+ 'star' => ((feature_enabled($conv->get_profile_owner(),'star_posts') && ($item['item_type'] == ITEM_TYPE_POST)) ? $star : ''),
'tagger' => ((feature_enabled($conv->get_profile_owner(),'commtag')) ? $tagger : ''),
- 'filer' => ((feature_enabled($conv->get_profile_owner(),'filing')) ? $filer : ''),
+ 'filer' => ((feature_enabled($conv->get_profile_owner(),'filing') && ($item['item_type'] == ITEM_TYPE_POST)) ? $filer : ''),
'bookmark' => (($conv->get_profile_owner() == local_channel() && local_channel() && $has_bookmarks) ? t('Save Bookmarks') : ''),
'addtocal' => (($has_event) ? t('Add to Calendar') : ''),
'drop' => $drop,
@@ -470,7 +492,7 @@ class ThreadItem {
if(($this->get_display_mode() === 'normal') && ($nb_children > 0)) {
foreach($children as $child) {
- $result['children'][] = $child->get_template_data($conv_responses, $thread_level + 1);
+ $result['children'][] = $child->get_template_data($conv_responses, $thread_level + 1,$conv_flags);
}
// Collapse
if(($nb_children > $visible_comments) || ($thread_level > 1)) {
diff --git a/Zotlabs/Lib/ThreadListener.php b/Zotlabs/Lib/ThreadListener.php
new file mode 100644
index 000000000..308e02255
--- /dev/null
+++ b/Zotlabs/Lib/ThreadListener.php
@@ -0,0 +1,53 @@
+<?php
+
+namespace Zotlabs\Lib;
+
+class ThreadListener {
+
+ static public function store($target_id,$portable_id,$ltype = 0) {
+ $x = self::fetch($target_id,$portable_id,$ltype = 0);
+ if(! $x) {
+ $r = q("insert into listeners ( target_id, portable_id, ltype ) values ( '%s', '%s' , %d ) ",
+ dbesc($target_id),
+ dbesc($portable_id),
+ intval($ltype)
+ );
+ }
+ }
+
+ static public function fetch($target_id,$portable_id,$ltype = 0) {
+ $x = q("select * from listeners where target_id = '%s' and portable_id = '%s' and ltype = %d limit 1",
+ dbesc($target_id),
+ dbesc($portable_id),
+ intval($ltype)
+ );
+ if($x) {
+ return $x[0];
+ }
+ return false;
+ }
+
+ static public function fetch_by_target($target_id,$ltype = 0) {
+ $x = q("select * from listeners where target_id = '%s' and ltype = %d",
+ dbesc($target_id),
+ intval($ltype)
+ );
+
+ return $x;
+ }
+
+ static public function delete_by_target($target_id, $ltype = 0) {
+ return q("delete from listeners where target_id = '%s' and ltype = %d",
+ dbesc($target_id),
+ intval($ltype)
+ );
+ }
+
+ static public function delete_by_pid($portable_id, $ltype = 0) {
+ return q("delete from listeners where portable_id = '%s' and ltype = %d",
+ dbesc($portable_id),
+ intval($ltype)
+ );
+ }
+
+}
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>';
diff --git a/Zotlabs/Widget/Affinity.php b/Zotlabs/Widget/Affinity.php
index 28190e187..572af0503 100644
--- a/Zotlabs/Widget/Affinity.php
+++ b/Zotlabs/Widget/Affinity.php
@@ -2,60 +2,65 @@
namespace Zotlabs\Widget;
+use Zotlabs\Lib\Apps;
+
class Affinity {
function widget($arr) {
if(! local_channel())
- return '';
-
- $default_cmin = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmin',0) : 0);
- $default_cmax = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmax',99) : 99);
+ return;
+
+ if(! Apps::system_app_installed(local_channel(),'Affinity Tool'))
+ return;
+
+ $default_cmin = ((Apps::system_app_installed(local_channel(),'Affinity Tool')) ? get_pconfig(local_channel(),'affinity','cmin',0) : 0);
+ $default_cmax = ((Apps::system_app_installed(local_channel(),'Affinity Tool')) ? get_pconfig(local_channel(),'affinity','cmax',99) : 99);
$cmin = ((x($_REQUEST,'cmin')) ? intval($_REQUEST['cmin']) : $default_cmin);
$cmax = ((x($_REQUEST,'cmax')) ? intval($_REQUEST['cmax']) : $default_cmax);
- if(feature_enabled(local_channel(),'affinity')) {
-
- $affinity_locked = intval(get_pconfig(local_channel(),'affinity','lock',1));
- if ($affinity_locked) {
- set_pconfig(local_channel(),'affinity','cmin',$cmin);
- set_pconfig(local_channel(),'affinity','cmax',$cmax);
- }
-
- $labels = array(
- t('Me'),
- t('Family'),
- t('Friends'),
- t('Acquaintances'),
- t('All')
- );
- call_hooks('affinity_labels',$labels);
- $label_str = '';
-
- if($labels) {
- foreach($labels as $l) {
- if($label_str) {
- $label_str .= ", '|'";
- $label_str .= ", '" . $l . "'";
- }
- else
- $label_str .= "'" . $l . "'";
+ $affinity_locked = intval(get_pconfig(local_channel(),'affinity','lock',1));
+ if ($affinity_locked) {
+ set_pconfig(local_channel(),'affinity','cmin',$cmin);
+ set_pconfig(local_channel(),'affinity','cmax',$cmax);
+ }
+
+ $labels = array(
+ t('Me'),
+ t('Family'),
+ t('Friends'),
+ t('Acquaintances'),
+ t('All')
+ );
+ call_hooks('affinity_labels',$labels);
+
+ $label_str = '';
+
+ if($labels) {
+ foreach($labels as $l) {
+ if($label_str) {
+ $label_str .= ", '|'";
+ $label_str .= ", '" . $l . "'";
}
+ else
+ $label_str .= "'" . $l . "'";
}
-
- $tpl = get_markup_template('main_slider.tpl');
- $x = replace_macros($tpl,array(
- '$val' => $cmin . ',' . $cmax,
- '$refresh' => t('Refresh'),
- '$labels' => $label_str,
- ));
-
- $arr = array('html' => $x);
- call_hooks('main_slider',$arr);
- return $arr['html'];
}
- return '';
+
+ $tpl = get_markup_template('main_slider.tpl');
+ $x = replace_macros($tpl,array(
+ '$val' => $cmin . ',' . $cmax,
+ '$refresh' => t('Refresh'),
+ '$labels' => $label_str,
+ ));
+
+ $arr = array('html' => $x);
+ call_hooks('main_slider',$arr);
+
+ return $arr['html'];
+
+
}
}
diff --git a/Zotlabs/Widget/Settings_menu.php b/Zotlabs/Widget/Settings_menu.php
index c537c3835..25b80a4b4 100644
--- a/Zotlabs/Widget/Settings_menu.php
+++ b/Zotlabs/Widget/Settings_menu.php
@@ -42,19 +42,12 @@ class Settings_menu {
);
-
$tabs[] = array(
'label' => t('Display settings'),
'url' => z_root().'/settings/display',
'selected' => ((argv(1) === 'display') ? 'active' : ''),
);
- $tabs[] = array(
- 'label' => t('Addon settings'),
- 'url' => z_root().'/settings/featured',
- 'selected' => ((argv(1) === 'featured') ? 'active' : ''),
- );
-
if($hublocs) {
$tabs[] = array(
'label' => t('Manage locations'),