New function to fetch item data especially for users
This commit is contained in:
parent
0280a46ab4
commit
6e10de9284
19 changed files with 133 additions and 77 deletions
|
@ -258,7 +258,7 @@ function acl_content(App $a)
|
|||
|
||||
$condition = ["`parent` = ?", $conv_id];
|
||||
$params = ['order' => ['author-name' => true]];
|
||||
$authors = Item::select(local_user(), ['author-link'], $condition, $params);
|
||||
$authors = Item::selectForUser(local_user(), ['author-link'], $condition, $params);
|
||||
$item_authors = [];
|
||||
while ($author = dba::fetch($authors)) {
|
||||
$item_authors[$author['author-link']] = $author['author-link'];
|
||||
|
|
|
@ -349,7 +349,7 @@ function display_content(App $a, $update = false, $update_uid = 0) {
|
|||
$condition = ["`item`.`parent-uri` = (SELECT `parent-uri` FROM `item` WHERE `id` = ?)
|
||||
AND `item`.`uid` IN (0, ?) " . $sql_extra, $item_id, local_user()];
|
||||
$params = ['order' => ['uid', 'parent' => true, 'gravity', 'id']];
|
||||
$r = Item::select(local_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
|
||||
$r = Item::selectForUser(local_user(), [], $condition, $params);
|
||||
|
||||
if (!DBM::is_result($r)) {
|
||||
notice(L10n::t('Item not found.') . EOL);
|
||||
|
|
|
@ -455,7 +455,7 @@ function networkFlatView(App $a, $update = 0)
|
|||
}
|
||||
|
||||
$params = ['order' => ['id' => true], 'limit' => [$a->pager['start'], $a->pager['itemspage']]];
|
||||
$result = Item::select(local_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
|
||||
$result = Item::selectForUser(local_user(), [], $condition, $params);
|
||||
$items = dba::inArray($result);
|
||||
|
||||
$condition = ['unseen' => true, 'uid' => local_user()];
|
||||
|
|
|
@ -68,7 +68,7 @@ function notes_content(App $a, $update = false)
|
|||
|
||||
$params = ['order' => ['created' => true],
|
||||
'limit' => [$a->pager['start'], $a->pager['itemspage']]];
|
||||
$r = Item::select(local_user(), ['item_id'], $condition, $params);
|
||||
$r = Item::selectForUser(local_user(), ['item_id'], $condition, $params);
|
||||
|
||||
if (DBM::is_result($r)) {
|
||||
$parents_arr = [];
|
||||
|
@ -79,7 +79,7 @@ function notes_content(App $a, $update = false)
|
|||
dba::close($r);
|
||||
|
||||
$condition = ['uid' => local_user(), 'parent' => $parents_arr];
|
||||
$result = Item::select(local_user(), Item::DISPLAY_FIELDLIST, $condition);
|
||||
$result = Item::selectForUser(local_user(), [], $condition);
|
||||
if (DBM::is_result($result)) {
|
||||
$items = conv_sort(dba::inArray($result), 'commented');
|
||||
$o .= conversation($a, $items, 'notes', $update);
|
||||
|
|
|
@ -132,7 +132,7 @@ function ping_init(App $a)
|
|||
$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);
|
||||
$items = Item::selectForUser(local_user(), $fields, $condition, $params);
|
||||
|
||||
if (DBM::is_result($items)) {
|
||||
$items_unseen = dba::inArray($items);
|
||||
|
|
|
@ -71,7 +71,7 @@ function poke_init(App $a) {
|
|||
if ($parent) {
|
||||
$fields = ['uri', 'private', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid'];
|
||||
$condition = ['id' => $parent, 'parent' => $parent, 'uid' => $uid];
|
||||
$item = Item::selectFirst(local_user(), $fields, $condition);
|
||||
$item = Item::selectFirst($fields, $condition);
|
||||
|
||||
if (DBM::is_result($item)) {
|
||||
$parent_uri = $item['uri'];
|
||||
|
|
|
@ -338,7 +338,7 @@ function profile_content(App $a, $update = 0)
|
|||
}
|
||||
|
||||
$condition = ['uid' => $a->profile['profile_uid'], 'parent' => $parents_arr];
|
||||
$result = Item::select($a->profile['profile_uid'], Item::DISPLAY_FIELDLIST, $condition);
|
||||
$result = Item::selectForUser($a->profile['profile_uid'], [], $condition);
|
||||
$items = conv_sort(dba::inArray($result), 'created');
|
||||
} else {
|
||||
$items = [];
|
||||
|
|
|
@ -211,7 +211,7 @@ function search_content(App $a) {
|
|||
}
|
||||
dba::close($terms);
|
||||
|
||||
$items = Item::select(local_user(), Item::DISPLAY_FIELDLIST, ['id' => array_reverse($itemids)]);
|
||||
$items = Item::selectForUser(local_user(), [], ['id' => array_reverse($itemids)]);
|
||||
$r = dba::inArray($items);
|
||||
} else {
|
||||
logger("Start fulltext search for '".$search."'", LOGGER_DEBUG);
|
||||
|
@ -221,7 +221,7 @@ function search_content(App $a) {
|
|||
local_user(), $search];
|
||||
$params = ['order' => ['id' => true],
|
||||
'limit' => [$a->pager['start'], $a->pager['itemspage']]];
|
||||
$items = Item::select(local_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
|
||||
$items = Item::selectForUser(local_user(), [], $condition, $params);
|
||||
$r = dba::inArray($items);
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ function share_init(App $a) {
|
|||
|
||||
$fields = ['private', 'body', 'author-name', 'author-link', 'author-avatar',
|
||||
'guid', 'created', 'plink', 'title'];
|
||||
$item = Item::selectFirst(local_user(), $fields, ['id' => $post_id]);
|
||||
$item = Item::selectFirst($fields, ['id' => $post_id]);
|
||||
|
||||
if (!DBM::is_result($item) || $item['private'] == 1) {
|
||||
killme();
|
||||
|
|
|
@ -23,7 +23,7 @@ function subthread_content(App $a) {
|
|||
$item_id = (($a->argc > 1) ? notags(trim($a->argv[1])) : 0);
|
||||
|
||||
$condition = ["`parent` = ? OR `parent-uri` = ? AND `parent` = `id`", $item_id, $item_id];
|
||||
$item = Item::selectFirst(local_user(), [], $condition);
|
||||
$item = Item::selectFirst([], $condition);
|
||||
|
||||
if (empty($item_id) || !DBM::is_result($item)) {
|
||||
logger('subthread: no item ' . $item_id);
|
||||
|
|
|
@ -32,7 +32,7 @@ function tagger_content(App $a) {
|
|||
logger('tagger: tag ' . $term . ' item ' . $item_id);
|
||||
|
||||
|
||||
$item = Item::selectFirst(local_user(), [], ['id' => $item_id]);
|
||||
$item = Item::selectFirst([], ['id' => $item_id]);
|
||||
|
||||
if (!$item_id || !DBM::is_result($item)) {
|
||||
logger('tagger: no item ' . $item_id);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue