From ddebbcc0a08aae9cd33bb3105ce1f2c8863b544c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 27 May 2018 17:46:25 -0700 Subject: hubzilla issue #1200 --- Zotlabs/Module/Network.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Module/Network.php') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 82c88e565..942b48109 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -131,7 +131,7 @@ class Network extends \Zotlabs\Web\Controller { if(x($_GET,'search') || x($_GET,'file')) $nouveau = true; if($cid) { - $r = q("SELECT abook_xchan FROM abook WHERE abook_id = %d AND abook_channel = %d LIMIT 1", + $r = q("SELECT abook_xchan, xchan_addr, xchan_url FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_id = %d AND abook_channel = %d LIMIT 1", intval($cid), intval(local_channel()) ); @@ -144,7 +144,7 @@ class Network extends \Zotlabs\Web\Controller { // NOTREACHED } if($_GET['pf'] === '1') - $deftag = '!' . t('forum') . '+' . intval($cid); + $deftag = '!{' . (($r[0]['xchan_addr']) ? $r[0]['xchan_addr'] : $r[0]['xchan_url']) . '}'; else $def_acl = [ 'allow_cid' => '<' . $r[0]['abook_xchan'] . '>', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '' ]; } -- cgit v1.2.3 From 9fcb3bf2e8fab84f9144eecceaf984b2026e6d08 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 30 May 2018 14:02:58 +0200 Subject: first cut on restructuring the previously called network tabs --- Zotlabs/Module/Network.php | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'Zotlabs/Module/Network.php') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 942b48109..060179217 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -57,13 +57,26 @@ class Network extends \Zotlabs\Web\Controller { $datequery = ((x($_GET,'dend') && is_a_date_arg($_GET['dend'])) ? notags($_GET['dend']) : ''); $datequery2 = ((x($_GET,'dbegin') && is_a_date_arg($_GET['dbegin'])) ? notags($_GET['dbegin']) : ''); - $nouveau = ((x($_GET,'new')) ? intval($_GET['new']) : 0); $static = ((x($_GET,'static')) ? intval($_GET['static']) : 0); $gid = ((x($_GET,'gid')) ? intval($_GET['gid']) : 0); $category = ((x($_REQUEST,'cat')) ? $_REQUEST['cat'] : ''); $hashtags = ((x($_REQUEST,'tag')) ? $_REQUEST['tag'] : ''); $verb = ((x($_REQUEST,'verb')) ? $_REQUEST['verb'] : ''); - + + + $order = get_pconfig(local_channel(), 'mod_network', 'order', 0); + switch($order) { + case 0: + $order = 'comment'; + break; + case 1: + $order = 'post'; + break; + case 2: + $nouveau = true; + break; + } + $search = (($_GET['search']) ? $_GET['search'] : ''); if($search) { $_GET['netsearch'] = escape_tags($search); @@ -84,7 +97,7 @@ class Network extends \Zotlabs\Web\Controller { } if($datequery) - $_GET['order'] = 'post'; + $order = 'post'; // filter by collection (e.g. group) @@ -150,7 +163,7 @@ class Network extends \Zotlabs\Web\Controller { } if(! $update) { - $tabs = network_tabs(); + $tabs = ''; //network_tabs(); $o .= $tabs; // search terms header -- cgit v1.2.3 From 881406f82b455cbd78eb64570a0a41937814a444 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 30 May 2018 14:54:39 +0200 Subject: remove redundant reference for order --- Zotlabs/Module/Network.php | 5 ----- 1 file changed, 5 deletions(-) (limited to 'Zotlabs/Module/Network.php') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 060179217..5e7492fd4 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -120,16 +120,11 @@ 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) : 0); $default_cmax = ((feature_enabled(local_channel(),'affinity')) ? get_pconfig(local_channel(),'affinity','cmax',99) : 99); - - // if no tabs are selected, defaults to comments - $cid = ((x($_GET,'cid')) ? intval($_GET['cid']) : 0); $star = ((x($_GET,'star')) ? intval($_GET['star']) : 0); - $order = ((x($_GET,'order')) ? notags($_GET['order']) : 'comment'); $liked = ((x($_GET,'liked')) ? intval($_GET['liked']) : 0); $conv = ((x($_GET,'conv')) ? intval($_GET['conv']) : 0); $spam = ((x($_GET,'spam')) ? intval($_GET['spam']) : 0); -- cgit v1.2.3 From 6349a7417f41cd697ba2dea82653911a1abaaf94 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 30 May 2018 22:40:22 +0200 Subject: make navbar search use the module search function in /network and /channel --- Zotlabs/Module/Network.php | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'Zotlabs/Module/Network.php') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 5e7492fd4..acd12158c 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -138,6 +138,7 @@ class Network extends \Zotlabs\Web\Controller { if(x($_GET,'search') || x($_GET,'file')) $nouveau = true; + if($cid) { $r = q("SELECT abook_xchan, xchan_addr, xchan_url FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_id = %d AND abook_channel = %d LIMIT 1", intval($cid), @@ -567,6 +568,9 @@ class Network extends \Zotlabs\Web\Controller { } $mode = (($nouveau) ? 'network-new' : 'network'); + + if($search) + $mode = 'search'; $o .= conversation($items,$mode,$update,$page_mode); -- cgit v1.2.3 From 5505f5fa02f35a9c0b64badb1ff3ff2b791d2a41 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 30 May 2018 22:55:28 +0200 Subject: restrict the network/channel navbar search to content and hashtags --- Zotlabs/Module/Network.php | 3 +++ 1 file changed, 3 insertions(+) (limited to 'Zotlabs/Module/Network.php') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index acd12158c..64f9e668c 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -15,6 +15,9 @@ class Network extends \Zotlabs\Web\Controller { notice( t('Permission denied.') . EOL); return; } + + if(strpos($_GET['search'], ['@', '!', '?']) == 0) + goaway('search' . '?f=&search=' . $_GET['search']); if(count($_GET) < 2) { $network_options = get_pconfig(local_channel(),'system','network_page_default'); -- cgit v1.2.3 From 6bfc5aa96c44d3a16962242d0ef02ccfa879ab7b Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Wed, 30 May 2018 23:15:43 +0200 Subject: strpos does not work with arrays :( --- Zotlabs/Module/Network.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs/Module/Network.php') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 64f9e668c..0d4deb736 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -16,7 +16,7 @@ class Network extends \Zotlabs\Web\Controller { return; } - if(strpos($_GET['search'], ['@', '!', '?']) == 0) + if(strpos($_GET['search'], '@') === 0 || strpos($_GET['search'], '!') === 0 || strpos($_GET['search'], '?') === 0) goaway('search' . '?f=&search=' . $_GET['search']); if(count($_GET) < 2) { -- cgit v1.2.3 From cbaaa1c57ffed0b0a11a7d4cf9a492c26e577194 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 31 May 2018 13:05:32 +0200 Subject: merge groups and filed posts into activity filters --- Zotlabs/Module/Network.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Module/Network.php') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 0d4deb736..8a381d678 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -16,7 +16,7 @@ class Network extends \Zotlabs\Web\Controller { return; } - if(strpos($_GET['search'], '@') === 0 || strpos($_GET['search'], '!') === 0 || strpos($_GET['search'], '?') === 0) + if(in_array(substr($_GET['search'],0,1),[ '@', '!', '?'])) goaway('search' . '?f=&search=' . $_GET['search']); if(count($_GET) < 2) { @@ -389,7 +389,7 @@ class Network extends \Zotlabs\Web\Controller { if($conv) { $item_thread_top = ''; - $sql_extra .= sprintf(" AND parent IN (SELECT distinct(parent) from item where ( author_xchan like '%s' or item_mentionsme = 1 )) ", + $sql_extra .= sprintf(" AND parent IN (SELECT distinct(parent) from item where ( author_xchan = '%s' or item_mentionsme = 1 )) ", dbesc(protect_sprintf($channel['channel_hash'])) ); } -- cgit v1.2.3 From 8b76b5a0a6f6784f9d97332cc93b395504f6f527 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sun, 3 Jun 2018 23:03:30 +0200 Subject: improve network cid query --- Zotlabs/Module/Network.php | 46 ++++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 24 deletions(-) (limited to 'Zotlabs/Module/Network.php') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 8a381d678..013e9b763 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -143,11 +143,12 @@ class Network extends \Zotlabs\Web\Controller { $nouveau = true; if($cid) { - $r = q("SELECT abook_xchan, xchan_addr, xchan_url FROM abook left join xchan on abook_xchan = xchan_hash WHERE abook_id = %d AND abook_channel = %d LIMIT 1", + $cid_r = q("SELECT abook.abook_xchan, xchan.xchan_addr, xchan.xchan_name, xchan.xchan_url, xchan.xchan_photo_s, xchan.xchan_pubforum from abook left join xchan on abook_xchan = xchan_hash where abook_id = %d and abook_channel = %d and abook_blocked = 0 limit 1", intval($cid), intval(local_channel()) ); - if(! $r) { + + if(! $cid_r) { if($update) { killme(); } @@ -156,9 +157,9 @@ class Network extends \Zotlabs\Web\Controller { // NOTREACHED } if($_GET['pf'] === '1') - $deftag = '!{' . (($r[0]['xchan_addr']) ? $r[0]['xchan_addr'] : $r[0]['xchan_url']) . '}'; + $deftag = '!{' . (($cid_r[0]['xchan_addr']) ? $cid_r[0]['xchan_addr'] : $cid_r[0]['xchan_url']) . '}'; else - $def_acl = [ 'allow_cid' => '<' . $r[0]['abook_xchan'] . '>', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '' ]; + $def_acl = [ 'allow_cid' => '<' . $cid_r[0]['abook_xchan'] . '>', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '' ]; } if(! $update) { @@ -240,6 +241,7 @@ class Network extends \Zotlabs\Web\Controller { } } $item_thread_top = ''; + $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND (( author_xchan IN ( $contact_str ) OR owner_xchan in ( $contact_str )) or allow_gid like '" . protect_sprintf('%<' . dbesc($group_hash) . '>%') . "' ) and id = parent $item_normal ) "; $x = group_rec_byhash(local_channel(), $group_hash); @@ -255,27 +257,23 @@ class Network extends \Zotlabs\Web\Controller { $o .= $status_editor; } - - elseif($cid) { - - $r = q("SELECT abook.*, xchan.* from abook left join xchan on abook_xchan = xchan_hash where abook_id = %d and abook_channel = %d and abook_blocked = 0 limit 1", - intval($cid), - intval(local_channel()) - ); - if($r) { - $item_thread_top = ''; - $sql_extra = " AND item.parent IN ( SELECT DISTINCT parent FROM item WHERE true $sql_options AND uid = " . intval(local_channel()) . " AND ( author_xchan = '" . dbesc($r[0]['abook_xchan']) . "' or owner_xchan = '" . dbesc($r[0]['abook_xchan']) . "' or (body like '" . protect_sprintf('%' . $r[0]['xchan_url'] . '%') . "' and item_thread_top = 1 )) $item_normal ) "; - $title = replace_macros(get_markup_template("section_title.tpl"),array( - '$title' => '' . urlencode($r[0]['xchan_name']) . ' ' . $r[0]['xchan_name'] . '' - )); - $o = $tabs; - $o .= $title; - $o .= $status_editor; - } - else { - notice( t('Invalid connection.') . EOL); - goaway(z_root() . '/network'); + elseif($cid_r) { + $item_thread_top = ''; + + if($load || $update) { + $p1 = q("SELECT DISTINCT parent FROM item WHERE uid = " . intval(local_channel()) . " AND ( author_xchan = '" . dbesc($cid_r[0]['abook_xchan']) . "' OR owner_xchan = '" . dbesc($cid_r[0]['abook_xchan']) . "' ) $item_normal ORDER BY created DESC"); + $p2 = q("SELECT oid AS parent FROM term WHERE uid = " . intval(local_channel()) . " AND term = '" . dbesc($cid_r[0]['xchan_name']) . "'"); + $p_str = ids_to_querystr(array_merge($p1,$p2),'parent'); + $sql_extra = " AND item.parent IN ( $p_str ) "; } + + $title = replace_macros(get_markup_template("section_title.tpl"),array( + '$title' => '' . urlencode($cid_r[0]['xchan_name']) . ' ' . $cid_r[0]['xchan_name'] . '' + )); + + $o = $tabs; + $o .= $title; + $o .= $status_editor; } elseif($xchan) { $r = q("select * from xchan where xchan_hash = '%s'", -- cgit v1.2.3 From 6019a34da2184519bc535fa771b30695d9580b92 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 4 Jun 2018 15:54:18 +0200 Subject: be specific about the term type and do not sort the results --- Zotlabs/Module/Network.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'Zotlabs/Module/Network.php') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 013e9b763..1ab94eff4 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -261,8 +261,11 @@ class Network extends \Zotlabs\Web\Controller { $item_thread_top = ''; if($load || $update) { - $p1 = q("SELECT DISTINCT parent FROM item WHERE uid = " . intval(local_channel()) . " AND ( author_xchan = '" . dbesc($cid_r[0]['abook_xchan']) . "' OR owner_xchan = '" . dbesc($cid_r[0]['abook_xchan']) . "' ) $item_normal ORDER BY created DESC"); - $p2 = q("SELECT oid AS parent FROM term WHERE uid = " . intval(local_channel()) . " AND term = '" . dbesc($cid_r[0]['xchan_name']) . "'"); + $ttype = (($cid_r[0]['xchan_pubforum']) ? TERM_FORUM : TERM_MENTION); + + $p1 = q("SELECT DISTINCT parent FROM item WHERE uid = " . intval(local_channel()) . " AND ( author_xchan = '" . dbesc($cid_r[0]['abook_xchan']) . "' OR owner_xchan = '" . dbesc($cid_r[0]['abook_xchan']) . "' ) $item_normal "); + $p2 = q("SELECT oid AS parent FROM term WHERE uid = " . intval(local_channel()) . " AND ttype = $ttype AND term = '" . dbesc($cid_r[0]['xchan_name']) . "'"); + $p_str = ids_to_querystr(array_merge($p1,$p2),'parent'); $sql_extra = " AND item.parent IN ( $p_str ) "; } -- cgit v1.2.3 From 7188e719eff137c3a0b47824de97245832441a20 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Tue, 5 Jun 2018 11:56:30 +0200 Subject: rely on the pf argument to determine if we deal with a forum or not. xchan_pubforum is not set for all public forums in the forum filters for some reason. --- Zotlabs/Module/Network.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'Zotlabs/Module/Network.php') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 1ab94eff4..6a24b9453 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -136,6 +136,7 @@ class Network extends \Zotlabs\Web\Controller { $file = ((x($_GET,'file')) ? $_GET['file'] : ''); $xchan = ((x($_GET,'xchan')) ? $_GET['xchan'] : ''); $net = ((x($_GET,'net')) ? $_GET['net'] : ''); + $pf = ((x($_GET,'pf')) ? $_GET['pf'] : ''); $deftag = ''; @@ -156,7 +157,7 @@ class Network extends \Zotlabs\Web\Controller { goaway(z_root() . '/network'); // NOTREACHED } - if($_GET['pf'] === '1') + if($pf) $deftag = '!{' . (($cid_r[0]['xchan_addr']) ? $cid_r[0]['xchan_addr'] : $cid_r[0]['xchan_url']) . '}'; else $def_acl = [ 'allow_cid' => '<' . $cid_r[0]['abook_xchan'] . '>', 'allow_gid' => '', 'deny_cid' => '', 'deny_gid' => '' ]; @@ -261,7 +262,7 @@ class Network extends \Zotlabs\Web\Controller { $item_thread_top = ''; if($load || $update) { - $ttype = (($cid_r[0]['xchan_pubforum']) ? TERM_FORUM : TERM_MENTION); + $ttype = (($pf) ? TERM_FORUM : TERM_MENTION); $p1 = q("SELECT DISTINCT parent FROM item WHERE uid = " . intval(local_channel()) . " AND ( author_xchan = '" . dbesc($cid_r[0]['abook_xchan']) . "' OR owner_xchan = '" . dbesc($cid_r[0]['abook_xchan']) . "' ) $item_normal "); $p2 = q("SELECT oid AS parent FROM term WHERE uid = " . intval(local_channel()) . " AND ttype = $ttype AND term = '" . dbesc($cid_r[0]['xchan_name']) . "'"); @@ -350,7 +351,8 @@ class Network extends \Zotlabs\Web\Controller { '$mid' => '', '$verb' => $verb, '$net' => $net, - '$dbegin' => $datequery2 + '$dbegin' => $datequery2, + '$pf' => (($pf) ? $pf : '0'), )); } -- cgit v1.2.3 From d3bc50e18d77d0f21b2b34560338c2ded4ae59eb Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Thu, 7 Jun 2018 21:58:09 +0200 Subject: do not query for parents if $conv and $nouveau are set --- Zotlabs/Module/Network.php | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'Zotlabs/Module/Network.php') diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php index 6a24b9453..9837d35a3 100644 --- a/Zotlabs/Module/Network.php +++ b/Zotlabs/Module/Network.php @@ -392,9 +392,15 @@ class Network extends \Zotlabs\Web\Controller { if($conv) { $item_thread_top = ''; - $sql_extra .= sprintf(" AND parent IN (SELECT distinct(parent) from item where ( author_xchan = '%s' or item_mentionsme = 1 )) ", - dbesc(protect_sprintf($channel['channel_hash'])) - ); + + if($nouveau) { + $sql_extra .= " AND author_xchan = '" . dbesc($channel['channel_hash']) . "' "; + } + else { + $sql_extra .= sprintf(" AND parent IN (SELECT distinct(parent) from item where ( author_xchan = '%s' or item_mentionsme = 1 )) ", + dbesc(protect_sprintf($channel['channel_hash'])) + ); + } } if($update && ! $load) { @@ -489,9 +495,9 @@ class Network extends \Zotlabs\Web\Controller { // Normal conversation view if($order === 'post') - $ordering = "created"; + $ordering = "created"; else - $ordering = "commented"; + $ordering = "commented"; if($load) { // Fetch a page full of parent items for this page -- cgit v1.2.3