Notes again

This commit is contained in:
Michael 2018-06-10 08:58:03 +00:00
parent b26c5e7f73
commit 8375d4ac4c

View File

@ -78,6 +78,7 @@ function notes_content(App $a, $update = false)
$sql_extra = " AND `item`.`allow_cid` = '<" . $a->contact['id'] . ">' "; $sql_extra = " AND `item`.`allow_cid` = '<" . $a->contact['id'] . ">' ";
/// @todo We seem to need "Item::count" as function as well
$r = q("SELECT COUNT(*) AS `total` $r = q("SELECT COUNT(*) AS `total`
FROM `item` %s FROM `item` %s
WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note' WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note'
@ -93,26 +94,21 @@ function notes_content(App $a, $update = false)
$a->set_pager_itemspage(40); $a->set_pager_itemspage(40);
} }
$r = q("SELECT `item`.`id` AS `item_id` FROM `item` %s $condition = ["`uid` = ? AND `type` = 'note' AND NOT `wall`
WHERE %s AND `item`.`uid` = %d AND `item`.`type` = 'note' AND `id` = `parent` AND `allow_cid` = ?",
AND `item`.`id` = `item`.`parent` AND NOT `item`.`wall` local_user(), '<' . $a->contact['id'] . '>'];
$sql_extra $params = ['order' => ['created' => true],
ORDER BY `item`.`created` DESC LIMIT %d ,%d ", 'limit' => [$a->pager['start'], $a->pager['itemspage']]];
item_joins(local_user()),
item_condition(),
intval(local_user()),
intval($a->pager['start']),
intval($a->pager['itemspage'])
); $r = Item::select(local_user(), ['item_id'], $condition, $params);
$parents_arr = [];
$parents_str = '';
if (DBM::is_result($r)) { if (DBM::is_result($r)) {
foreach ($r as $rr) { $parents_arr = [];
while ($rr = dba::fetch($r)) {
$parents_arr[] = $rr['item_id']; $parents_arr[] = $rr['item_id'];
} }
dba::close($r);
$condition = ['uid' => local_user(), 'parent' => $parents_arr]; $condition = ['uid' => local_user(), 'parent' => $parents_arr];
$result = Item::select(local_user(), [], $condition); $result = Item::select(local_user(), [], $condition);