aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Network.php
diff options
context:
space:
mode:
Diffstat (limited to 'Zotlabs/Module/Network.php')
-rw-r--r--Zotlabs/Module/Network.php73
1 files changed, 24 insertions, 49 deletions
diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php
index 3ea813547..f95d92fe2 100644
--- a/Zotlabs/Module/Network.php
+++ b/Zotlabs/Module/Network.php
@@ -70,17 +70,19 @@ class Network extends \Zotlabs\Web\Controller {
$dm = ((x($_REQUEST,'dm')) ? $_REQUEST['dm'] : 0);
- $order = get_pconfig(local_channel(), 'mod_network', 'order', 0);
+ $order = get_pconfig(local_channel(), 'mod_network', 'order', 'created');
switch($order) {
- case 0:
- $order = 'comment';
+ case 'commented':
+ $ordering = 'commented';
break;
- case 1:
- $order = 'post';
+ case 'created':
+ $ordering = 'created';
break;
- case 2:
+ case 'unthreaded':
$nouveau = true;
break;
+ default:
+ $ordering = 'created';
}
$search = $_GET['search'] ?? '';
@@ -92,7 +94,7 @@ class Network extends \Zotlabs\Web\Controller {
}
if($datequery)
- $order = 'post';
+ $order = 'created';
// filter by collection (e.g. group)
@@ -274,36 +276,18 @@ class Network extends \Zotlabs\Web\Controller {
elseif($pf && $unseen && $nouveau) {
$vnotify = get_pconfig(local_channel(), 'system', 'vnotify');
- if(! ($vnotify & VNOTIFY_LIKE))
+ $likes_sql = '';
+ if (!($vnotify & VNOTIFY_LIKE)) {
$likes_sql = " AND verb NOT IN ('Like', 'Dislike', '" . dbesc(ACTIVITY_LIKE) . "', '" . dbesc(ACTIVITY_DISLIKE) . "') ";
+ }
// This is for nouveau view public forum cid queries (if a forum notification is clicked)
- //$p = q("SELECT oid AS parent FROM term WHERE uid = %d AND ttype = %d AND term = '%s'",
- //intval(local_channel()),
- //intval(TERM_FORUM),
- //dbesc($cid_r[0]['xchan_name'])
- //);
-
- //$p_str = ids_to_querystr($p, 'parent');
+ $sql_extra = " AND item.parent IN (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) AND item_unseen = 1 AND verb != 'Announce' $likes_sql ";
- $p_sql = '';
- //if($p_str)
- //$p_sql = " OR item.parent IN ( $p_str ) ";
-
- $sql_extra = " AND ( owner_xchan = '" . protect_sprintf(dbesc($cid_r[0]['abook_xchan'])) . "' OR owner_xchan = '" . protect_sprintf(dbesc($cid_r[0]['abook_xchan'])) . "' $p_sql ) AND item_unseen = 1 $likes_sql ";
}
else {
// This is for threaded view cid queries (e.g. if a forum is selected from the forum filter)
- $ttype = (($pf) ? TERM_FORUM : TERM_MENTION);
-
- $p1 = dbq("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 = dbq("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');
- if(! $p_str)
- killme();
-
- $sql_extra = " AND item.parent IN ( $p_str ) ";
+ $sql_extra = " AND item.parent IN (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) ";
}
}
@@ -393,10 +377,10 @@ class Network extends \Zotlabs\Web\Controller {
}
if ($dm) {
- $sql_extra .= ' AND item_private = 2 ';
+ $sql_extra .= ' AND item.item_private = 2 ';
}
else {
- $sql_extra .= ' AND item_private IN (0, 1) ';
+ $sql_extra .= ' AND item.item_private IN (0, 1) ';
}
@@ -445,10 +429,12 @@ class Network extends \Zotlabs\Web\Controller {
$abook_uids = ' and abook.abook_channel = ' . local_channel() . ' ';
$uids = ' and item.uid = ' . local_channel() . ' ';
- if(feature_enabled(local_channel(), 'network_list_mode'))
+ $page_mode = 'client';
+
+ $blog_mode = feature_enabled(local_channel(), 'network_list_mode');
+ if ($blog_mode) {
$page_mode = 'list';
- else
- $page_mode = 'client';
+ }
$parents_str = '';
@@ -472,11 +458,12 @@ class Network extends \Zotlabs\Web\Controller {
if($nouveau && $load) {
// "New Item View" - show all items unthreaded in reverse created date order
- $items = dbq("SELECT item.*, item.id AS item_id, created FROM item
+ $items = dbq("SELECT item.*, item.id AS item_id 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)
+ AND item.verb NOT IN ('Add', 'Remove')
$sql_extra $sql_options $sql_nets
$net_query2
ORDER BY item.created DESC $pager_sql "
@@ -492,13 +479,6 @@ class Network extends \Zotlabs\Web\Controller {
}
elseif($update) {
- // Normal conversation view
-
- if($order === 'post')
- $ordering = 'created';
- else
- $ordering = 'commented';
-
if($load) {
// Fetch a page full of parent items for this page
$r = dbq("SELECT item.parent AS item_id FROM item
@@ -527,12 +507,7 @@ class Network extends \Zotlabs\Web\Controller {
// Then fetch all the children of the parents that are on this page
if($r) {
- $parents_str = ids_to_querystr($r, 'item_id');
- $items = dbq("SELECT item.*, item.id AS item_id FROM item
- WHERE true $uids $item_normal
- AND item.parent IN ( $parents_str )
- $sql_extra "
- );
+ $items = items_by_parent_ids($r, blog_mode: $blog_mode);
xchan_query($items, true);
$items = fetch_post_tags($items, true);