}
if (x($_GET, 'offset')) {
- $sql_extra3 .= sprintf(" AND $sql_order <= '%s'", dbesc($_GET["offset"]));
+ $sql_range = sprintf(" AND $sql_order <= '%s'", dbesc($_GET["offset"]));
+ } else {
+ $sql_range = '';
}
$pager_sql = networkPager($a, $update);
case 'received':
if ($last_received != '') {
$last_date = $last_received;
- $sql_extra3 .= sprintf(" AND $sql_table.`received` < '%s'", dbesc($last_received));
+ $sql_range .= sprintf(" AND $sql_table.`received` < '%s'", dbesc($last_received));
$a->set_pager_page(1);
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
}
case 'commented':
if ($last_commented != '') {
$last_date = $last_commented;
- $sql_extra3 .= sprintf(" AND $sql_table.`commented` < '%s'", dbesc($last_commented));
+ $sql_range .= sprintf(" AND $sql_table.`commented` < '%s'", dbesc($last_commented));
$a->set_pager_page(1);
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
}
case 'created':
if ($last_created != '') {
$last_date = $last_created;
- $sql_extra3 .= sprintf(" AND $sql_table.`created` < '%s'", dbesc($last_created));
+ $sql_range .= sprintf(" AND $sql_table.`created` < '%s'", dbesc($last_created));
$a->set_pager_page(1);
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
}
break;
case 'id':
if (($last_id > 0) && ($sql_table == "`thread`")) {
- $sql_extra3 .= sprintf(" AND $sql_table.`iid` < '%s'", dbesc($last_id));
+ $sql_range .= sprintf(" AND $sql_table.`iid` < '%s'", dbesc($last_id));
$a->set_pager_page(1);
$pager_sql = sprintf(" LIMIT %d, %d ",intval($a->pager['start']), intval($a->pager['itemspage']));
}
AND (NOT `contact`.`blocked` OR `contact`.`pending`)
WHERE `item`.`uid` = %d AND `item`.`visible` AND NOT `item`.`deleted` $sql_extra4
AND NOT `item`.`moderated` AND `item`.`unseen`
- $sql_extra3 $sql_extra $sql_nets
- ORDER BY `item_id` DESC LIMIT 100",
+ $sql_extra3 $sql_extra $sql_range $sql_nets
+ ORDER BY `order_date` DESC LIMIT 100",
intval(local_user())
);
} else {
AND (NOT `contact`.`blocked` OR `contact`.`pending`)
WHERE `thread`.`uid` = %d AND `thread`.`visible` AND NOT `thread`.`deleted`
AND NOT `thread`.`moderated`
- $sql_extra2 $sql_extra3 $sql_extra $sql_nets
+ $sql_extra2 $sql_extra3 $sql_range $sql_extra $sql_nets
ORDER BY $sql_order DESC $pager_sql",
intval(local_user())
);
}
- if (count($r) > 0) {
+ // Only show it when unfiltered (no groups, no networks, ...)
+ if ((count($r) > 0) && (strlen($sql_extra . $sql_extra2 . $sql_extra3 . $sql_extra4 . $sql_nets) == 0)) {
$top_limit = current($r)['order_date'];
$bottom_limit = end($r)['order_date'];
+ // When checking for updates we need to fetch from the newest date to the newest date before
+ if ($update && !empty($_SESSION['network_last_date']) && ($bottom_limit > $_SESSION['network_last_date'])) {
+ $bottom_limit = $_SESSION['network_last_date'];
+ }
+ $_SESSION['network_last_date'] = $top_limit;
+
if ($last_date > $top_limit) {
$top_limit = $last_date;
}
$data = dba::inArray($items);
if (count($data) > 0) {
- logger('Tagged items: '.count($data).' - '.$bottom_limit." - ".$top_limit.' - '.$last_date);
-
- // ToDo: Doppelte URI rausfiltern
+ logger('Tagged items: '.count($data).' - '.$bottom_limit." - ".$top_limit.' - '.local_user()); //$last_date);
$r = array_merge($r, $data);
}
}