aboutsummaryrefslogtreecommitdiffstats
path: root/mod/network.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-10-29 02:41:25 -0700
committerfriendica <info@friendica.com>2012-10-29 02:41:25 -0700
commita217c8de98329e97c3706ad4351deecd1c31fbc2 (patch)
treeb3bc4e9fe6c26dd773f2f1dd951a8e463aa8d42d /mod/network.php
parent6496a0746062f4cb1ab6132a4ddaab8bc84dd58c (diff)
downloadvolse-hubzilla-a217c8de98329e97c3706ad4351deecd1c31fbc2.tar.gz
volse-hubzilla-a217c8de98329e97c3706ad4351deecd1c31fbc2.tar.bz2
volse-hubzilla-a217c8de98329e97c3706ad4351deecd1c31fbc2.zip
closeness issue - need to work on it more
Diffstat (limited to 'mod/network.php')
-rw-r--r--mod/network.php45
1 files changed, 31 insertions, 14 deletions
diff --git a/mod/network.php b/mod/network.php
index e1629bdd6..0d55438c1 100644
--- a/mod/network.php
+++ b/mod/network.php
@@ -408,11 +408,13 @@ function network_content(&$a, $update = 0, $load = false) {
// desired.
- $sql_options = (($star) ? " and starred = 1 " : '');
+ $sql_options = (($star)
+ ? " and (item_flags & " . intval(ITEM_STARRED) . ")"
+ : '');
$sql_nets = '';
-// fixme
- $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE id = parent $sql_options ) ";
+
+ $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE (item_flags & " . intval(ITEM_THREAD_TOP) . ") $sql_options ) ";
if($group) {
$r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1",
@@ -587,11 +589,24 @@ function network_content(&$a, $update = 0, $load = false) {
if(($cmin != 0) || ($cmax != 99)) {
- $sql_nets .= " AND `contact`.`closeness` >= " . intval($cmin) . " ";
- $sql_nets .= " AND `contact`.`closeness` <= " . intval($cmax) . " ";
+ $sql_nets .= " AND abook.abook_closeness >= " . intval($cmin) . " ";
+ $sql_nets .= " AND abook.abook_closeness <= " . intval($cmax) . " ";
+
+ // This is ugly - but we won't have an abook for everybody as we
+ // used to have a contact for everybody in Friendica.
+ // Might be an unknown poster (99) or our own post (0).
+ // Need to refactor this after a solution presents itself
+
+ if($cmax == 99)
+ $sql_nets .= " OR ( abook.abook_id = NULL AND item.author_xchan != '" . $ch['channel_hash'] . " ) ";
+ if($cmin == 0 && local_user()) {
+ $ch = $a->get_channel();
+ $sql_nets .= " OR ( item.author_xchan = '" . $ch['channel_hash'] . "' ) ";
+ }
+
}
- $simple_update = (($update) ? " and `item`.`unseen` = 1 " : '');
+ $simple_update = (($update) ? " and ( item.flags & " . intval(ITEM_UNSEEN) . " ) " : '');
if($load)
$simple_update = '';
@@ -625,26 +640,28 @@ function network_content(&$a, $update = 0, $load = false) {
$ordering = "`commented`";
// Fetch a page full of parent items for this page
-
+dbg(1);
if($update && (! $load)) {
- $r = q("SELECT `parent` AS `item_id` FROM `item`
- WHERE `item`.`uid` = %d AND `item`.`restrict` = 0
+ $r = q("SELECT item.parent AS item_id FROM item
+ left join abook on item.author_xchan = abook.abook_xchan
+ WHERE item.uid = %d AND item.item_restrict = 0
$sql_extra3 $sql_extra $sql_nets ",
intval(local_user())
);
}
else {
- $r = q("SELECT `item`.`id` AS `item_id`
- FROM `item` WHERE `item`.`uid` = %d AND `item`.`item_restrict` = 0
- AND `item`.`parent` = `item`.`id`
+ $r = q("SELECT item.id AS item_id FROM item
+ left join abook on item.author_xchan = abook.abook_xchan
+ WHERE item.uid = %d AND item.item_restrict = 0
+ AND item.parent = item.id
$sql_extra3 $sql_extra $sql_nets
- ORDER BY `item`.$ordering DESC $pager_sql ",
+ ORDER BY item.$ordering DESC $pager_sql ",
intval(local_user())
);
}
-
+dbg(0);
// Then fetch all the children of the parents that are on this page
if($r && count($r)) {