From 22d45a8d1ecfa0a0a2b8429ec3233e7099e84b66 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 1 Nov 2017 02:53:12 -0700 Subject: support for netselect query --- Zotlabs/Module/Pubstream.php | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'Zotlabs/Module/Pubstream.php') diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index 15e2d8a74..e83de6bc0 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -31,6 +31,7 @@ class Pubstream extends \Zotlabs\Web\Controller { $item_normal_update = item_normal_update(); $static = ((array_key_exists('static',$_REQUEST)) ? intval($_REQUEST['static']) : 0); + $net = ((array_key_exists('net',$_REQUEST)) ? escape_tags($_REQUEST['net']) : ''); if(! $update && !$load) { @@ -81,7 +82,8 @@ class Pubstream extends \Zotlabs\Web\Controller { '$tags' => '', '$dend' => '', '$mid' => $mid, - '$verb' => '', + '$verb' => '', + '$net' => $net, '$dbegin' => '' )); } @@ -112,6 +114,10 @@ class Pubstream extends \Zotlabs\Web\Controller { $page_mode = 'list'; else $page_mode = 'client'; + + + $net_query = (($net) ? " left join xchan on xchan_hash = author_xchan " : ''); + $net_query2 = (($net) ? " and xchan_network = '" . protect_sprintf(dbesc($net)) . "' " : ''); $simple_update = (($update) ? " and item.item_unseen = 1 " : ''); @@ -134,9 +140,10 @@ class Pubstream extends \Zotlabs\Web\Controller { if($mid) { $r = q("SELECT parent AS item_id FROM item left join abook on item.author_xchan = abook.abook_xchan + $net_query WHERE mid like '%s' $uids $item_normal and (abook.abook_blocked = 0 or abook.abook_flags is null) - $sql_extra3 $sql_extra $sql_nets LIMIT 1", + $sql_extra3 $sql_extra $sql_nets $net_query2 LIMIT 1", dbesc($mid . '%') ); } @@ -144,10 +151,11 @@ class Pubstream extends \Zotlabs\Web\Controller { // Fetch a page full of parent items for this page $r = q("SELECT distinct item.id AS item_id, $ordering FROM item left join abook on item.author_xchan = abook.abook_xchan + $net_query WHERE true $uids $item_normal AND item.parent = item.id and (abook.abook_blocked = 0 or abook.abook_flags is null) - $sql_extra3 $sql_extra $sql_nets + $sql_extra3 $sql_extra $sql_nets $net_query2 ORDER BY $ordering DESC $pager_sql " ); } @@ -156,19 +164,21 @@ class Pubstream extends \Zotlabs\Web\Controller { if($mid) { $r = q("SELECT parent AS item_id FROM item left join abook on item.author_xchan = abook.abook_xchan + $net_query WHERE mid like '%s' $uids $item_normal_update $simple_update and (abook.abook_blocked = 0 or abook.abook_flags is null) - $sql_extra3 $sql_extra $sql_nets LIMIT 1", + $sql_extra3 $sql_extra $sql_nets $net_query2 LIMIT 1", dbesc($mid . '%') ); } else { $r = q("SELECT distinct item.id AS item_id, $ordering FROM item left join abook on item.author_xchan = abook.abook_xchan + $net_query WHERE true $uids $item_normal_update AND item.parent = item.id $simple_update and (abook.abook_blocked = 0 or abook.abook_flags is null) - $sql_extra3 $sql_extra $sql_nets" + $sql_extra3 $sql_extra $sql_nets $net_query2" ); } $_SESSION['loadtime'] = datetime_convert(); -- cgit v1.2.3 From e70bd0054c4ffb8aadeec8ee7c14dccdb34ab934 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 2 Nov 2017 18:25:34 -0700 Subject: hubzilla issue #896 --- Zotlabs/Module/Pubstream.php | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'Zotlabs/Module/Pubstream.php') diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index e83de6bc0..4224fa3c8 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -2,6 +2,7 @@ namespace Zotlabs\Module; require_once('include/conversation.php'); +require_once('include/acl_selectors.php'); class Pubstream extends \Zotlabs\Web\Controller { @@ -33,6 +34,47 @@ class Pubstream extends \Zotlabs\Web\Controller { $static = ((array_key_exists('static',$_REQUEST)) ? intval($_REQUEST['static']) : 0); $net = ((array_key_exists('net',$_REQUEST)) ? escape_tags($_REQUEST['net']) : ''); + + if(local_channel() && (! $update)) { + + $channel = \App::get_channel(); + + $channel_acl = array( + 'allow_cid' => $channel['channel_allow_cid'], + 'allow_gid' => $channel['channel_allow_gid'], + 'deny_cid' => $channel['channel_deny_cid'], + 'deny_gid' => $channel['channel_deny_gid'] + ); + + $x = array( + 'is_owner' => true, + 'allow_location' => ((intval(get_pconfig($channel['channel_id'],'system','use_browser_location'))) ? '1' : ''), + 'default_location' => $channel['channel_location'], + 'nickname' => $channel['channel_address'], + 'lockstate' => (($group || $cid || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'), + + 'acl' => populate_acl($channel_acl), + 'permissions' => $channel_acl, + 'bang' => '', + 'visitor' => true, + 'profile_uid' => local_channel(), + 'return_path' => 'channel/' . $channel['channel_address'], + 'expanded' => true, + 'editor_autocomplete' => true, + 'bbco_autocomplete' => 'bbcode', + 'bbcode' => true, + 'jotnets' => true + ); + + $o = '
'; + $o .= status_editor($a,$x); + $o .= '
'; + } + + + + + if(! $update && !$load) { -- cgit v1.2.3 From 67b6d41d57b20a223a0cb6f33cbf81473b0936ab Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 15 Nov 2017 11:26:14 -0800 Subject: This should sort out hubzilla issue #826 but requires a bit more testing. It may also sort out some reported issues with commenting and liking items in the public stream. --- Zotlabs/Module/Pubstream.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Module/Pubstream.php') diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index 4224fa3c8..0e6c2360f 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -240,7 +240,10 @@ class Pubstream extends \Zotlabs\Web\Controller { dbesc($parents_str) ); - xchan_query($items,true,(-1)); + // use effective_uid param of xchan_query to help sort out comment permission + // for sys_channel owned items. + + xchan_query($items,true,(($sys) ? local_channel() : 0)); $items = fetch_post_tags($items,true); $items = conv_sort($items,$ordering); } -- cgit v1.2.3 From 0e91810ed6764fbbee54e918711bfb45a1d9fd72 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 26 Nov 2017 18:29:24 -0800 Subject: pubstream comments and a few other bugfixes that were discovered along the way --- Zotlabs/Module/Pubstream.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'Zotlabs/Module/Pubstream.php') diff --git a/Zotlabs/Module/Pubstream.php b/Zotlabs/Module/Pubstream.php index 0e6c2360f..c469a0eca 100644 --- a/Zotlabs/Module/Pubstream.php +++ b/Zotlabs/Module/Pubstream.php @@ -162,18 +162,16 @@ class Pubstream extends \Zotlabs\Web\Controller { $net_query2 = (($net) ? " and xchan_network = '" . protect_sprintf(dbesc($net)) . "' " : ''); - $simple_update = (($update) ? " and item.item_unseen = 1 " : ''); + $simple_update = (($_SESSION['loadtime']) ? " AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' " : ''); - if($update && $_SESSION['loadtime']) - $simple_update = " AND (( item_unseen = 1 AND item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) OR item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' ) "; if($load) $simple_update = ''; if($static && $simple_update) - $simple_update .= " and item_thread_top = 0 and author_xchan = '" . protect_sprintf(get_observer_hash()) . "' "; + $simple_update .= " and author_xchan = '" . protect_sprintf(get_observer_hash()) . "' "; //logger('update: ' . $update . ' load: ' . $load); - + if($update) { $ordering = "commented"; @@ -214,17 +212,18 @@ class Pubstream extends \Zotlabs\Web\Controller { ); } else { - $r = q("SELECT distinct item.id AS item_id, $ordering FROM item + $r = q("SELECT distinct parent AS item_id, $ordering FROM item left join abook on item.author_xchan = abook.abook_xchan $net_query WHERE true $uids $item_normal_update - AND item.parent = item.id $simple_update + $simple_update and (abook.abook_blocked = 0 or abook.abook_flags is null) $sql_extra3 $sql_extra $sql_nets $net_query2" ); } $_SESSION['loadtime'] = datetime_convert(); } + // Then fetch all the children of the parents that are on this page $parents_str = ''; $update_unseen = ''; @@ -254,7 +253,7 @@ class Pubstream extends \Zotlabs\Web\Controller { } // fake it - $mode = ('network'); + $mode = ('pubstream'); $o .= conversation($items,$mode,$update,$page_mode); -- cgit v1.2.3