More item calls have been replaced with the new functions

This commit is contained in:
Michael 2018-06-15 22:30:49 +00:00
commit bb79b8f4ac
6 changed files with 54 additions and 132 deletions

View file

@ -435,28 +435,33 @@ function networkFlatView(App $a, $update = 0)
}
}
if (strlen($file)) {
$sql_post_table = sprintf("INNER JOIN (SELECT `oid` FROM `term` WHERE `term` = '%s' AND `otype` = %d AND `type` = %d AND `uid` = %d ORDER BY `tid` DESC) AS `term` ON `item`.`id` = `term`.`oid` ",
dbesc(protect_sprintf($file)), intval(TERM_OBJ_POST), intval(TERM_FILE), intval(local_user()));
} else {
$sql_post_table = " INNER JOIN `thread` ON `thread`.`iid` = `item`.`parent`";
}
$pager_sql = networkPager($a, $update);
// show all items unthreaded in reverse created date order
$items = q("SELECT %s FROM `item` $sql_post_table %s
WHERE %s AND `item`.`uid` = %d
ORDER BY `item`.`id` DESC $pager_sql ",
item_fieldlists(), item_joins(local_user()), item_condition(),
intval(local_user())
);
if (strlen($file)) {
$condition = ["`term` = ? AND `otype` = ? AND `type` = ? AND `uid` = ?",
$file, TERM_OBJ_POST, TERM_FILE, local_user()];
$params = ['order' => ['tid' => true], 'limit' => [$a->pager['start'], $a->pager['itemspage']]];
$result = dba::select('term', ['oid'], $condition);
$posts = [];
while ($term = dba::fetch($result)) {
$posts[] = $term['oid'];
}
dba::close($terms);
$condition = ['uid' => local_user(), 'id' => $posts];
} else {
$condition = ['uid' => local_user()];
}
$params = ['order' => ['id' => true], 'limit' => [$a->pager['start'], $a->pager['itemspage']]];
$result = Item::select(local_user(), [], $condition, $params);
$items = dba::inArray($result);
$condition = ['unseen' => true, 'uid' => local_user()];
networkSetSeen($condition);
$mode = 'network-new';
$o .= networkConversation($a, $items, $mode, $update);
$o .= networkConversation($a, $items, 'network-new', $update);
return $o;
}

View file

@ -15,6 +15,7 @@ use Friendica\Core\System;
use Friendica\Database\DBM;
use Friendica\Model\Contact;
use Friendica\Model\Group;
use Friendica\Model\Item;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Temporal;
use Friendica\Util\XML;
@ -127,20 +128,14 @@ function ping_init(App $a)
$notifs = ping_get_notifications(local_user());
$items_unseen = q(
"SELECT `item`.`id`, `item`.`parent`, `item`.`verb`, `item`.`wall`, `item`.`author-name`,
`item`.`contact-id`, `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
`pitem`.`author-name` AS `pname`, `pitem`.`author-link` AS `plink`
FROM `item` INNER JOIN `item` AS `pitem` ON `pitem`.`id` = `item`.`parent`
WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
`item`.`deleted` = 0 AND `item`.`uid` = %d AND `pitem`.`parent` != 0
AND `item`.`contact-id` != %d
ORDER BY `item`.`created` DESC",
intval(local_user()),
intval(local_user())
);
$condition = ["`unseen` AND `uid` = ? AND `contact-id` != ?", local_user(), local_user()];
$fields = ['id', 'parent', 'verb', 'author-name', 'unseen', 'author-link', 'author-avatar', 'contact-avatar',
'network', 'created', 'object', 'parent-author-name', 'parent-author-link', 'parent-guid'];
$params = ['order' => ['created' => true]];
$items = Item::select(local_user(), $fields, $condition, $params);
if (DBM::is_result($items_unseen)) {
if (DBM::is_result($items)) {
$items_unseen = dba::inArray($items);
$arr = ['items' => $items_unseen];
Addon::callHooks('network_ping', $arr);