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.php100
1 files changed, 24 insertions, 76 deletions
diff --git a/Zotlabs/Module/Network.php b/Zotlabs/Module/Network.php
index 3ea813547..ad872e3dd 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)
@@ -133,7 +135,6 @@ class Network extends \Zotlabs\Web\Controller {
$status_editor = '';
-
if (Apps::system_app_installed(local_channel(), 'Affinity Tool')) {
$affinity_locked = intval(get_pconfig(local_channel(), 'affinity', 'lock', 1));
if ($affinity_locked) {
@@ -201,7 +202,7 @@ class Network extends \Zotlabs\Web\Controller {
'default_location' => $channel['channel_location'],
'nickname' => $channel['channel_address'],
'lockstate' => (($private_editing || $channel['channel_allow_cid'] || $channel['channel_allow_gid'] || $channel['channel_deny_cid'] || $channel['channel_deny_gid']) ? 'lock' : 'unlock'),
- 'acl' => populate_acl((($private_editing) ? $def_acl : $channel_acl), true, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'acl_dialog_post'),
+ 'acl' => populate_acl((($private_editing) ? $def_acl : $channel_acl), true, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_stream'), get_post_aclDialogDescription(), 'member/permissions'),
'permissions' => (($private_editing) ? $def_acl : $channel_acl),
'bang' => (($private_editing) ? $bang : ''),
'visitor' => true,
@@ -271,39 +272,9 @@ class Network extends \Zotlabs\Web\Controller {
// This is for nouveau view cid queries (not a public forum)
$sql_extra = " AND author_xchan = '" . dbesc($cid_r[0]['abook_xchan']) . "' ";
}
- elseif($pf && $unseen && $nouveau) {
-
- $vnotify = get_pconfig(local_channel(), 'system', 'vnotify');
- 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');
-
- $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 +364,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) ';
}
@@ -405,17 +376,9 @@ class Network extends \Zotlabs\Web\Controller {
$sql_extra .= " AND ( author_xchan = '" . dbesc($channel['channel_hash']) . "' OR item_mentionsme = 1 ) ";
}
- if($update && ! $load) {
-
- // only setup pagination on initial page view
- $pager_sql = '';
-
- }
- else {
- $itemspage = get_pconfig(local_channel(), 'system', 'itemspage');
- App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 10));
- $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start']));
- }
+ $itemspage = get_pconfig(local_channel(), 'system', 'itemspage');
+ App::set_pager_itemspage(((intval($itemspage)) ? $itemspage : 10));
+ $pager_sql = sprintf(" LIMIT %d OFFSET %d ", intval(App::$pager['itemspage']), intval(App::$pager['start']));
// cmin and cmax are both -1 when the affinity tool is disabled
@@ -445,12 +408,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 = 'list';
- else
- $page_mode = 'client';
+ $page_mode = 'client';
- $parents_str = '';
+ $blog_mode = feature_enabled(local_channel(), 'network_list_mode');
+ if ($blog_mode) {
+ $page_mode = 'list';
+ }
// This fixes a very subtle bug so I'd better explain it. You wake up in the morning or return after a day
// or three and look at your matrix page - after opening up your browser. The first page loads just as it
@@ -472,33 +435,23 @@ 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 "
);
- $parents_str = ids_to_querystr($items, 'item_id');
-
- require_once('include/items.php');
-
xchan_query($items);
$items = fetch_post_tags($items, true);
}
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 +480,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);