New function to fetch item data especially for users
This commit is contained in:
parent
0280a46ab4
commit
6e10de9284
|
@ -1626,7 +1626,7 @@ function api_search($type)
|
|||
}
|
||||
|
||||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Item::select(api_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
|
||||
$statuses = Item::selectForUser(api_user(), [], $condition, $params);
|
||||
|
||||
$data['status'] = api_format_items(dba::inArray($statuses), $user_info);
|
||||
|
||||
|
@ -1693,7 +1693,7 @@ function api_statuses_home_timeline($type)
|
|||
}
|
||||
|
||||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Item::select(api_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
|
||||
$statuses = Item::selectForUser(api_user(), [], $condition, $params);
|
||||
|
||||
$items = dba::inArray($statuses);
|
||||
|
||||
|
@ -1770,7 +1770,7 @@ function api_statuses_public_timeline($type)
|
|||
}
|
||||
|
||||
$params = ['order' => ['iid' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Item::selectThread(api_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
|
||||
$statuses = Item::selectThreadForUser(api_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
|
||||
|
||||
$r = dba::inArray($statuses);
|
||||
} else {
|
||||
|
@ -1787,7 +1787,7 @@ function api_statuses_public_timeline($type)
|
|||
}
|
||||
|
||||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Item::select(api_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
|
||||
$statuses = Item::selectForUser(api_user(), [], $condition, $params);
|
||||
|
||||
$r = dba::inArray($statuses);
|
||||
}
|
||||
|
@ -1846,7 +1846,7 @@ function api_statuses_networkpublic_timeline($type)
|
|||
}
|
||||
|
||||
$params = ['order' => ['iid' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Item::selectThread(api_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
|
||||
$statuses = Item::selectThreadForUser(api_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
|
||||
|
||||
$ret = api_format_items(dba::inArray($statuses), $user_info, false, $type);
|
||||
|
||||
|
@ -1917,7 +1917,7 @@ function api_statuses_show($type)
|
|||
$params = [];
|
||||
}
|
||||
|
||||
$statuses = Item::select(api_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
|
||||
$statuses = Item::selectForUser(api_user(), [], $condition, $params);
|
||||
|
||||
/// @TODO How about copying this to above methods which don't check $r ?
|
||||
if (!DBM::is_result($statuses)) {
|
||||
|
@ -1998,7 +1998,7 @@ function api_conversation_show($type)
|
|||
}
|
||||
|
||||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Item::select(api_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
|
||||
$statuses = Item::selectForUser(api_user(), [], $condition, $params);
|
||||
|
||||
if (!DBM::is_result($statuses)) {
|
||||
throw new BadRequestException("There is no status with id $id.");
|
||||
|
@ -2048,7 +2048,7 @@ function api_statuses_repeat($type)
|
|||
logger('API: api_statuses_repeat: '.$id);
|
||||
|
||||
$fields = ['body', 'author-name', 'author-link', 'author-avatar', 'guid', 'created', 'plink'];
|
||||
$item = Item::selectFirst(api_user(), $fields, ['id' => $id, 'private' => false]);
|
||||
$item = Item::selectFirst($fields, ['id' => $id, 'private' => false]);
|
||||
|
||||
if (DBM::is_result($item) && $item['body'] != "") {
|
||||
if (strpos($item['body'], "[/share]") !== false) {
|
||||
|
@ -2168,7 +2168,7 @@ function api_statuses_mentions($type)
|
|||
}
|
||||
|
||||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Item::select(api_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
|
||||
$statuses = Item::selectForUser(api_user(), [], $condition, $params);
|
||||
|
||||
$ret = api_format_items(dba::inArray($statuses), $user_info, false, $type);
|
||||
|
||||
|
@ -2248,7 +2248,7 @@ function api_statuses_user_timeline($type)
|
|||
}
|
||||
|
||||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Item::select(api_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
|
||||
$statuses = Item::selectForUser(api_user(), [], $condition, $params);
|
||||
|
||||
$ret = api_format_items(dba::inArray($statuses), $user_info, true, $type);
|
||||
|
||||
|
@ -2300,7 +2300,7 @@ function api_favorites_create_destroy($type)
|
|||
$itemid = intval($_REQUEST['id']);
|
||||
}
|
||||
|
||||
$item = Item::selectFirst(api_user(), Item::DISPLAY_FIELDLIST, ['id' => $itemid, 'uid' => api_user()]);
|
||||
$item = Item::selectFirstForUser(api_user(), [], ['id' => $itemid, 'uid' => api_user()]);
|
||||
|
||||
if (!DBM::is_result($item)) {
|
||||
throw new BadRequestException("Invalid item.");
|
||||
|
@ -2390,7 +2390,7 @@ function api_favorites($type)
|
|||
$condition[] = $max_id;
|
||||
}
|
||||
|
||||
$statuses = Item::select(api_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
|
||||
$statuses = Item::selectForUser(api_user(), [], $condition, $params);
|
||||
|
||||
$ret = api_format_items(dba::inArray($statuses), $user_info, false, $type);
|
||||
}
|
||||
|
@ -3198,7 +3198,7 @@ function api_lists_statuses($type)
|
|||
}
|
||||
|
||||
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
|
||||
$statuses = Item::select(api_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
|
||||
$statuses = Item::selectForUser(api_user(), [], $condition, $params);
|
||||
|
||||
$items = api_format_items(dba::inArray($statuses), $user_info, false, $type);
|
||||
|
||||
|
@ -4723,7 +4723,7 @@ function prepare_photo_data($type, $scale, $photo_id)
|
|||
$condition = ["`parent` = ? AND `uid` = ? AND (`verb` = ? OR `type`='photo')",
|
||||
$item[0]['parent'], api_user(), ACTIVITY_POST];
|
||||
|
||||
$statuses = Item::select(api_user(), Item::DISPLAY_FIELDLIST, $condition);
|
||||
$statuses = Item::selectForUser(api_user(), [], $condition);
|
||||
|
||||
// prepare output of comments
|
||||
$commentData = api_format_items(dba::inArray($statuses), $user_info, false, $type);
|
||||
|
@ -5716,7 +5716,7 @@ function api_friendica_notification_seen($type)
|
|||
$nm->setSeen($note);
|
||||
if ($note['otype']=='item') {
|
||||
// would be really better with an ItemsManager and $im->getByID() :-P
|
||||
$item = Item::selectFirst(api_user(), Item::DISPLAY_FIELDLIST, ['id' => $note['iid'], 'uid' => api_user()]);
|
||||
$item = Item::selectFirstForUser(api_user(), [], ['id' => $note['iid'], 'uid' => api_user()]);
|
||||
if (DBM::is_result($$item)) {
|
||||
// we found the item, return it to the user
|
||||
$ret = api_format_items([$item], $user_info, false, $type);
|
||||
|
|
|
@ -788,7 +788,7 @@ function conversation_add_children($parents, $block_authors, $order, $uid) {
|
|||
if ($block_authors) {
|
||||
$condition[0] .= "AND NOT `author`.`hidden`";
|
||||
}
|
||||
$thread_items = Item::select(local_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
|
||||
$thread_items = Item::selectForUser(local_user(), [], $condition, $params);
|
||||
|
||||
$comments = dba::inArray($thread_items);
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ function notification($params)
|
|||
$item = null;
|
||||
|
||||
if ($params['otype'] === 'item' && $parent_id) {
|
||||
$item = Item::selectFirst($params['uid'], [], ['id' => $parent_id]);
|
||||
$item = Item::selectFirstForUser($params['uid'], [], ['id' => $parent_id]);
|
||||
}
|
||||
|
||||
$item_post_type = item_post_type($item);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -407,7 +407,7 @@ class NotificationsManager extends BaseObject
|
|||
$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], 'limit' => [$start, $limit]];
|
||||
$items = Item::select(local_user(), $fields, $condition, $params);
|
||||
$items = Item::selectForUser(local_user(), $fields, $condition, $params);
|
||||
|
||||
if (DBM::is_result($items)) {
|
||||
$notifs = $this->formatNotifs(dba::inArray($items), $ident);
|
||||
|
@ -492,7 +492,7 @@ class NotificationsManager extends BaseObject
|
|||
$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], 'limit' => [$start, $limit]];
|
||||
$items = Item::select(local_user(), $fields, $condition, $params);
|
||||
$items = Item::selectForUser(local_user(), $fields, $condition, $params);
|
||||
|
||||
if (DBM::is_result($items)) {
|
||||
$notifs = $this->formatNotifs(dba::inArray($items), $ident);
|
||||
|
@ -532,7 +532,7 @@ class NotificationsManager extends BaseObject
|
|||
$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], 'limit' => [$start, $limit]];
|
||||
$items = Item::select(local_user(), $fields, $condition, $params);
|
||||
$items = Item::selectForUser(local_user(), $fields, $condition, $params);
|
||||
|
||||
if (DBM::is_result($items)) {
|
||||
$notifs = $this->formatNotifs(dba::inArray($items), $ident);
|
||||
|
|
|
@ -1068,7 +1068,7 @@ class Contact extends BaseObject
|
|||
$author_id, ACTIVITY_POST, local_user()];
|
||||
$params = ['order' => ['created' => true],
|
||||
'limit' => [$a->pager['start'], $a->pager['itemspage']]];
|
||||
$r = Item::select(local_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
|
||||
$r = Item::selectForUser(local_user(), [], $condition, $params);
|
||||
|
||||
$items = dba::inArray($r);
|
||||
|
||||
|
|
|
@ -57,7 +57,7 @@ class Item extends BaseObject
|
|||
'signed_text', 'signature', 'signer'];
|
||||
|
||||
/**
|
||||
* Retrieve a single record from the item table and returns it in an associative array
|
||||
* Retrieve a single record from the item table for a given user and returns it in an associative array
|
||||
*
|
||||
* @brief Retrieve a single record from a table
|
||||
* @param integer $uid User ID
|
||||
|
@ -67,10 +67,53 @@ class Item extends BaseObject
|
|||
* @return bool|array
|
||||
* @see dba::select
|
||||
*/
|
||||
public static function selectFirst($uid, array $fields = [], array $condition = [], $params = [])
|
||||
public static function selectFirstForUser($uid, array $selected = [], array $condition = [], $params = [])
|
||||
{
|
||||
$params['uid'] = $uid;
|
||||
|
||||
if (empty($selected)) {
|
||||
$selected = Item::DISPLAY_FIELDLIST;
|
||||
}
|
||||
|
||||
return self::selectFirst($selected, $condition, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Select rows from the item table for a given user
|
||||
*
|
||||
* @param integer $uid User ID
|
||||
* @param array $selected Array of selected fields, empty for all
|
||||
* @param array $condition Array of fields for condition
|
||||
* @param array $params Array of several parameters
|
||||
*
|
||||
* @return boolean|object
|
||||
*/
|
||||
public static function selectForUser($uid, array $selected = [], array $condition = [], $params = [])
|
||||
{
|
||||
$params['uid'] = $uid;
|
||||
|
||||
if (empty($selected)) {
|
||||
$selected = Item::DISPLAY_FIELDLIST;
|
||||
}
|
||||
|
||||
return self::select($selected, $condition, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a single record from the item table and returns it in an associative array
|
||||
*
|
||||
* @brief Retrieve a single record from a table
|
||||
* @param array $fields
|
||||
* @param array $condition
|
||||
* @param array $params
|
||||
* @return bool|array
|
||||
* @see dba::select
|
||||
*/
|
||||
public static function selectFirst(array $fields = [], array $condition = [], $params = [])
|
||||
{
|
||||
$params['limit'] = 1;
|
||||
$result = self::select($uid, $fields, $condition, $params);
|
||||
|
||||
$result = self::select($fields, $condition, $params);
|
||||
|
||||
if (is_bool($result)) {
|
||||
return $result;
|
||||
|
@ -84,15 +127,22 @@ class Item extends BaseObject
|
|||
/**
|
||||
* @brief Select rows from the item table
|
||||
*
|
||||
* @param integer $uid User ID
|
||||
* @param array $fields Array of selected fields, empty for all
|
||||
* @param array $selected Array of selected fields, empty for all
|
||||
* @param array $condition Array of fields for condition
|
||||
* @param array $params Array of several parameters
|
||||
*
|
||||
* @return boolean|object
|
||||
*/
|
||||
public static function select($uid, array $selected = [], array $condition = [], $params = [])
|
||||
public static function select(array $selected = [], array $condition = [], $params = [])
|
||||
{
|
||||
$uid = 0;
|
||||
$usermode = false;
|
||||
|
||||
if (isset($params['uid'])) {
|
||||
$uid = $params['uid'];
|
||||
$usermode = true;
|
||||
}
|
||||
|
||||
$fields = self::fieldlist($selected);
|
||||
|
||||
$select_fields = self::constructSelectFields($fields, $selected);
|
||||
|
@ -101,7 +151,9 @@ class Item extends BaseObject
|
|||
|
||||
$condition_string = self::addTablesToFields($condition_string, $fields);
|
||||
|
||||
$condition_string = $condition_string . ' AND ' . self::condition(false);
|
||||
if ($usermode) {
|
||||
$condition_string = $condition_string . ' AND ' . self::condition(false);
|
||||
}
|
||||
|
||||
$param_string = self::addTablesToFields(dba::buildParameter($params), $fields);
|
||||
|
||||
|
@ -123,10 +175,10 @@ class Item extends BaseObject
|
|||
* @return bool|array
|
||||
* @see dba::select
|
||||
*/
|
||||
public static function selectFirstThread($uid, array $fields = [], array $condition = [], $params = [])
|
||||
public static function selectFirstThreadForUser($uid, array $fields = [], array $condition = [], $params = [])
|
||||
{
|
||||
$params['limit'] = 1;
|
||||
$result = self::selectThread($uid, $fields, $condition, $params);
|
||||
$result = self::selectThreadForUser($uid, $fields, $condition, $params);
|
||||
|
||||
if (is_bool($result)) {
|
||||
return $result;
|
||||
|
@ -147,8 +199,12 @@ class Item extends BaseObject
|
|||
*
|
||||
* @return boolean|object
|
||||
*/
|
||||
public static function selectThread($uid, array $selected = [], array $condition = [], $params = [])
|
||||
public static function selectThreadForUser($uid, array $selected = [], array $condition = [], $params = [])
|
||||
{
|
||||
if (empty($selected)) {
|
||||
$selected = Item::DISPLAY_FIELDLIST;
|
||||
}
|
||||
|
||||
$fields = self::fieldlist($selected);
|
||||
|
||||
$threadfields = ['thread' => ['iid', 'uid', 'contact-id', 'owner-id', 'author-id',
|
||||
|
@ -183,10 +239,6 @@ class Item extends BaseObject
|
|||
*/
|
||||
private static function fieldlist($selected)
|
||||
{
|
||||
/*
|
||||
These Fields are not added below. They are here to for bug search.
|
||||
*/
|
||||
|
||||
$item_fields = ['author-id', 'owner-id', 'contact-id', 'uid', 'id', 'parent',
|
||||
'uri', 'thr-parent', 'parent-uri', 'content-warning',
|
||||
'commented', 'created', 'edited', 'received', 'verb', 'object-type', 'postopts', 'plink',
|
||||
|
|
|
@ -244,15 +244,19 @@ class DFRN
|
|||
$ids[] = $item['id'];
|
||||
}
|
||||
|
||||
$condition = ['id' => $ids];
|
||||
$fields = ['author-id', 'uid', 'id', 'parent', 'uri', 'thr-parent',
|
||||
'parent-uri', 'created', 'edited', 'verb', 'object-type',
|
||||
'guid', 'private', 'title', 'body', 'location', 'coord', 'app',
|
||||
'attach', 'object', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
|
||||
'extid', 'target', 'tag', 'bookmark', 'deleted',
|
||||
'author-link', 'owner-link', 'signed_text', 'signature', 'signer'];
|
||||
$ret = Item::select($owner_id, $fields, $condition);
|
||||
$items = dba::inArray($ret);
|
||||
if (!empty($ids)) {
|
||||
$condition = ['id' => $ids];
|
||||
$fields = ['author-id', 'uid', 'id', 'parent', 'uri', 'thr-parent',
|
||||
'parent-uri', 'created', 'edited', 'verb', 'object-type',
|
||||
'guid', 'private', 'title', 'body', 'location', 'coord', 'app',
|
||||
'attach', 'object', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
|
||||
'extid', 'target', 'tag', 'bookmark', 'deleted',
|
||||
'author-link', 'owner-link', 'signed_text', 'signature', 'signer'];
|
||||
$ret = Item::select($fields, $condition);
|
||||
$items = dba::inArray($ret);
|
||||
} else {
|
||||
$items = [];
|
||||
}
|
||||
|
||||
/*
|
||||
* Will check further below if this actually returned results.
|
||||
|
@ -338,7 +342,7 @@ class DFRN
|
|||
'attach', 'object', 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
|
||||
'extid', 'target', 'tag', 'bookmark', 'deleted',
|
||||
'author-link', 'owner-link', 'signed_text', 'signature', 'signer'];
|
||||
$ret = Item::select(0, $fields, $condition);
|
||||
$ret = Item::select($fields, $condition);
|
||||
$items = dba::inArray($ret);
|
||||
if (!DBM::is_result($items)) {
|
||||
killme();
|
||||
|
|
|
@ -69,7 +69,7 @@ class Diaspora
|
|||
|
||||
if (Config::get("system", "relay_directly", false)) {
|
||||
// We distribute our stuff based on the parent to ensure that the thread will be complete
|
||||
$parent = Item::selectFirst(0, ['parent'], ['id' => $item_id]);
|
||||
$parent = Item::selectFirst(['parent'], ['id' => $item_id]);
|
||||
if (!DBM::is_result($parent)) {
|
||||
return;
|
||||
}
|
||||
|
@ -1170,7 +1170,7 @@ class Diaspora
|
|||
*/
|
||||
private static function messageExists($uid, $guid)
|
||||
{
|
||||
$item = Item::selectFirst($uid, ['id'], ['uid' => $uid, 'guid' => $guid]);
|
||||
$item = Item::selectFirst(['id'], ['uid' => $uid, 'guid' => $guid]);
|
||||
if (DBM::is_result($item)) {
|
||||
logger("message ".$guid." already exists for user ".$uid);
|
||||
return $item["id"];
|
||||
|
@ -1384,7 +1384,7 @@ class Diaspora
|
|||
'author-name', 'author-link', 'author-avatar',
|
||||
'owner-name', 'owner-link', 'owner-avatar'];
|
||||
$condition = ['uid' => $uid, 'guid' => $guid];
|
||||
$item = Item::selectFirst($uid, $fields, $condition);
|
||||
$item = Item::selectFirst($fields, $condition);
|
||||
|
||||
if (!DBM::is_result($item)) {
|
||||
$result = self::storeByGuid($guid, $contact["url"], $uid);
|
||||
|
@ -1397,7 +1397,7 @@ class Diaspora
|
|||
if ($result) {
|
||||
logger("Fetched missing item ".$guid." - result: ".$result, LOGGER_DEBUG);
|
||||
|
||||
$item = Item::selectFirst($uid, $fields, $condition);
|
||||
$item = Item::selectFirst($fields, $condition);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1587,7 +1587,7 @@ class Diaspora
|
|||
*/
|
||||
private static function getUriFromGuid($author, $guid, $onlyfound = false)
|
||||
{
|
||||
$item = Item::selectFirst(0, ['uri'], ['guid' => $guid]);
|
||||
$item = Item::selectFirst(['uri'], ['guid' => $guid]);
|
||||
if (DBM::is_result($item)) {
|
||||
return $item["uri"];
|
||||
} elseif (!$onlyfound) {
|
||||
|
@ -1617,7 +1617,7 @@ class Diaspora
|
|||
*/
|
||||
private static function getGuidFromUri($uri, $uid)
|
||||
{
|
||||
$item = Item::selectFirst($uid, ['guid'], ['uri' => $uri, 'uid' => $uid]);
|
||||
$item = Item::selectFirst(['guid'], ['uri' => $uri, 'uid' => $uid]);
|
||||
if (DBM::is_result($item)) {
|
||||
return $item["guid"];
|
||||
} else {
|
||||
|
@ -1634,7 +1634,7 @@ class Diaspora
|
|||
*/
|
||||
private static function importerForGuid($guid)
|
||||
{
|
||||
$item = Item::selectFirst(0, ['uid'], ['origin' => true, 'guid' => $guid]);
|
||||
$item = Item::selectFirst(['uid'], ['origin' => true, 'guid' => $guid]);
|
||||
if (DBM::is_result($item)) {
|
||||
logger("Found user ".$item['uid']." as owner of item ".$guid, LOGGER_DEBUG);
|
||||
$contact = dba::selectFirst('contact', [], ['self' => true, 'uid' => $item['uid']]);
|
||||
|
@ -2059,7 +2059,7 @@ class Diaspora
|
|||
|
||||
// like on comments have the comment as parent. So we need to fetch the toplevel parent
|
||||
if ($parent_item["id"] != $parent_item["parent"]) {
|
||||
$toplevel = Item::selectFirst($importer["uid"], ['origin'], ['id' => $parent_item["parent"]]);
|
||||
$toplevel = Item::selectFirst(['origin'], ['id' => $parent_item["parent"]]);
|
||||
$origin = $toplevel["origin"];
|
||||
} else {
|
||||
$origin = $parent_item["origin"];
|
||||
|
@ -2196,7 +2196,7 @@ class Diaspora
|
|||
return false;
|
||||
}
|
||||
|
||||
$item = Item::selectFirst(0, ['id'], ['guid' => $parent_guid, 'origin' => true, 'private' => false]);
|
||||
$item = Item::selectFirst(['id'], ['guid' => $parent_guid, 'origin' => true, 'private' => false]);
|
||||
if (!DBM::is_result($item)) {
|
||||
logger('Item not found, no origin or private: '.$parent_guid);
|
||||
return false;
|
||||
|
@ -2217,7 +2217,7 @@ class Diaspora
|
|||
}
|
||||
|
||||
// Send all existing comments and likes to the requesting server
|
||||
$comments = Item::select(0, ['id', 'verb', 'self'], ['parent' => $item['id']]);
|
||||
$comments = Item::select(['id', 'verb', 'self'], ['parent' => $item['id']]);
|
||||
while ($comment = dba::fetch($comments)) {
|
||||
if ($comment['id'] == $comment['parent']) {
|
||||
continue;
|
||||
|
@ -2579,7 +2579,7 @@ class Diaspora
|
|||
$fields = ['body', 'tag', 'app', 'created', 'object-type', 'uri', 'guid',
|
||||
'author-name', 'author-link', 'author-avatar'];
|
||||
$condition = ['guid' => $guid, 'visible' => true, 'deleted' => false, 'private' => false];
|
||||
$item = Item::selectFirst(0, $fields, $condition);
|
||||
$item = Item::selectFirst($fields, $condition);
|
||||
|
||||
if (DBM::is_result($item)) {
|
||||
logger("reshared message ".$guid." already exists on system.");
|
||||
|
@ -2623,7 +2623,7 @@ class Diaspora
|
|||
$fields = ['body', 'tag', 'app', 'created', 'object-type', 'uri', 'guid',
|
||||
'author-name', 'author-link', 'author-avatar'];
|
||||
$condition = ['guid' => $guid, 'visible' => true, 'deleted' => false, 'private' => false];
|
||||
$item = Item::selectFirst(0, $fields, $condition);
|
||||
$item = Item::selectFirst($fields, $condition);
|
||||
|
||||
if (DBM::is_result($item)) {
|
||||
// If it is a reshared post from another network then reformat to avoid display problems with two share elements
|
||||
|
@ -2765,7 +2765,7 @@ class Diaspora
|
|||
} else {
|
||||
$condition = ["`guid` = ? AND `uid` = ? AND NOT `file` LIKE '%%[%%' AND NOT `deleted`", $target_guid, $importer['uid']];
|
||||
}
|
||||
$r = Item::select($importer['uid'], $fields, $condition);
|
||||
$r = Item::select($fields, $condition);
|
||||
if (!DBM::is_result($r)) {
|
||||
logger("Target guid ".$target_guid." was not found on this system for user ".$importer['uid'].".");
|
||||
return false;
|
||||
|
@ -2773,7 +2773,7 @@ class Diaspora
|
|||
|
||||
while ($item = dba::fetch($r)) {
|
||||
// Fetch the parent item
|
||||
$parent = Item::selectFirst(0, ['author-link'], ['id' => $item["parent"]]);
|
||||
$parent = Item::selectFirst(['author-link'], ['id' => $item["parent"]]);
|
||||
|
||||
// Only delete it if the parent author really fits
|
||||
if (!link_compare($parent["author-link"], $contact["url"]) && !link_compare($item["author-link"], $contact["url"])) {
|
||||
|
@ -3409,7 +3409,7 @@ class Diaspora
|
|||
|
||||
if (($guid != "") && $complete) {
|
||||
$condition = ['guid' => $guid, 'network' => [NETWORK_DFRN, NETWORK_DIASPORA]];
|
||||
$item = Item::selectFirst(0, ['contact-id'], $condition);
|
||||
$item = Item::selectFirst(['contact-id'], $condition);
|
||||
if (DBM::is_result($item)) {
|
||||
$ret= [];
|
||||
$ret["root_handle"] = self::handleFromContact($item["contact-id"]);
|
||||
|
@ -3676,7 +3676,7 @@ class Diaspora
|
|||
*/
|
||||
private static function constructLike($item, $owner)
|
||||
{
|
||||
$parent = Item::selectFirst(0, ['guid', 'uri', 'parent-uri'], ['uri' => $item["thr-parent"]]);
|
||||
$parent = Item::selectFirst(['guid', 'uri', 'parent-uri'], ['uri' => $item["thr-parent"]]);
|
||||
if (!DBM::is_result($parent)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -3707,7 +3707,7 @@ class Diaspora
|
|||
*/
|
||||
private static function constructAttend($item, $owner)
|
||||
{
|
||||
$parent = Item::selectFirst(0, ['guid', 'uri', 'parent-uri'], ['uri' => $item["thr-parent"]]);
|
||||
$parent = Item::selectFirst(['guid', 'uri', 'parent-uri'], ['uri' => $item["thr-parent"]]);
|
||||
if (!DBM::is_result($parent)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -3751,7 +3751,7 @@ class Diaspora
|
|||
return $result;
|
||||
}
|
||||
|
||||
$parent = Item::selectFirst(0, ['guid'], ['id' => $item["parent"], 'parent' => $item["parent"]]);
|
||||
$parent = Item::selectFirst(['guid'], ['id' => $item["parent"], 'parent' => $item["parent"]]);
|
||||
if (!DBM::is_result($parent)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -4224,7 +4224,7 @@ class Diaspora
|
|||
|
||||
$contact["uprvkey"] = $r[0]['prvkey'];
|
||||
|
||||
$item = Item::selectFirst(0, [], ['id' => $post_id]);
|
||||
$item = Item::selectFirst([], ['id' => $post_id]);
|
||||
if (!DBM::is_result($item)) {
|
||||
return false;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue