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/Channel.php | 1 + Zotlabs/Module/Display.php | 1 + Zotlabs/Module/Network.php | 16 +++++++++++++--- Zotlabs/Module/Pubstream.php | 20 +++++++++++++++----- Zotlabs/Module/Search.php | 1 + view/tpl/build_query.tpl | 2 ++ 6 files changed, 33 insertions(+), 8 deletions(-) diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php index 14d02d873..7c4c900a1 100644 --- a/Zotlabs/Module/Channel.php +++ b/Zotlabs/Module/Channel.php @@ -332,6 +332,7 @@ class Channel extends \Zotlabs\Web\Controller { '$tags' => (($hashtags) ? urlencode($hashtags) : ''), '$mid' => $mid, '$verb' => '', + '$net' => '', '$dend' => $datequery, '$dbegin' => $datequery2 )); diff --git a/Zotlabs/Module/Display.php b/Zotlabs/Module/Display.php index 785274105..85f08fd08 100644 --- a/Zotlabs/Module/Display.php +++ b/Zotlabs/Module/Display.php @@ -188,6 +188,7 @@ class Display extends \Zotlabs\Web\Controller { '$dend' => '', '$dbegin' => '', '$verb' => '', + '$net' => '', '$mid' => $mid )); diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index ee736ff42..66032aada 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -119,6 +119,7 @@ class Network extends \Zotlabs\Web\Controller { $cmax = ((x($_GET,'cmax')) ? intval($_GET['cmax']) : 99); $file = ((x($_GET,'file')) ? $_GET['file'] : ''); $xchan = ((x($_GET,'xchan')) ? $_GET['xchan'] : ''); + $net = ((x($_GET,'net')) ? $_GET['net'] : ''); $deftag = ''; @@ -326,7 +327,8 @@ class Network extends \Zotlabs\Web\Controller { '$tags' => urlencode($hashtags), '$dend' => $datequery, '$mid' => '', - '$verb' => $verb, + '$verb' => $verb, + '$net' => $net, '$dbegin' => $datequery2 )); } @@ -404,7 +406,10 @@ class Network extends \Zotlabs\Web\Controller { } - + + $net_query = (($net) ? " left join xchan on xchan_hash = author_xchan " : ''); + $net_query2 = (($net) ? " and xchan_network = '" . protect_sprintf(dbesc($net)) . "' " : ''); + $abook_uids = " and abook.abook_channel = " . local_channel() . " "; $uids = " and item.uid = " . local_channel() . " "; @@ -441,10 +446,12 @@ class Network extends \Zotlabs\Web\Controller { $items = q("SELECT item.*, item.id AS item_id, received FROM item left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) + $net_query WHERE true $uids $item_normal and (abook.abook_blocked = 0 or abook.abook_flags is null) $simple_update $sql_extra $sql_nets + $net_query2 ORDER BY item.received DESC $pager_sql " ); @@ -469,10 +476,12 @@ class Network extends \Zotlabs\Web\Controller { $r = q("SELECT distinct item.id AS item_id, $ordering FROM item left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) + $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 + $net_query2 ORDER BY $ordering DESC $pager_sql " ); @@ -482,9 +491,10 @@ class Network extends \Zotlabs\Web\Controller { // this is an update $r = q("SELECT item.parent AS item_id FROM item left join abook on ( item.owner_xchan = abook.abook_xchan $abook_uids ) + $net_query WHERE true $uids $item_normal_update $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(); } 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(); diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php index 37e9a336f..7bc3429b1 100644 --- a/Zotlabs/Module/Search.php +++ b/Zotlabs/Module/Search.php @@ -138,6 +138,7 @@ class Search extends \Zotlabs\Web\Controller { '$tags' => '', '$mid' => '', '$verb' => '', + '$net' => '', '$dend' => '', '$dbegin' => '' )); diff --git a/view/tpl/build_query.tpl b/view/tpl/build_query.tpl index a76d4e549..bfe5c8a08 100755 --- a/view/tpl/build_query.tpl +++ b/view/tpl/build_query.tpl @@ -29,6 +29,7 @@ var bParam_dbegin = "{{$dbegin}}"; var bParam_mid = "{{$mid}}"; var bParam_verb = "{{$verb}}"; + var bParam_net = "{{$net}}"; function buildCmd() { var udargs = ((page_load) ? "/load" : ""); @@ -57,6 +58,7 @@ if(bParam_dbegin != "") bCmd = bCmd + "&dbegin=" + bParam_dbegin; if(bParam_mid != "") bCmd = bCmd + "&mid=" + bParam_mid; if(bParam_verb != "") bCmd = bCmd + "&verb=" + bParam_verb; + if(bParam_net != "") bCmd = bCmd + "&net=" + bParam_net; if(bParam_page != 1) bCmd = bCmd + "&page=" + bParam_page; return(bCmd); } -- cgit v1.2.3