}
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
- $statuses = Item::select(api_user(), [], $condition, $params);
+ $statuses = Item::select(api_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
$data['status'] = api_format_items(dba::inArray($statuses), $user_info);
}
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
- $statuses = Item::select(api_user(), [], $condition, $params);
+ $statuses = Item::select(api_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
$items = dba::inArray($statuses);
}
$params = ['order' => ['iid' => true], 'limit' => [$start, $count]];
- $statuses = Item::selectThread(api_user(), [], $condition, $params);
+ $statuses = Item::selectThread(api_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
$r = dba::inArray($statuses);
} else {
}
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
- $statuses = Item::select(api_user(), [], $condition, $params);
+ $statuses = Item::select(api_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
$r = dba::inArray($statuses);
}
}
$params = ['order' => ['iid' => true], 'limit' => [$start, $count]];
- $statuses = Item::selectThread(api_user(), [], $condition, $params);
+ $statuses = Item::selectThread(api_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
$ret = api_format_items(dba::inArray($statuses), $user_info, false, $type);
$params = [];
}
- $statuses = Item::select(api_user(), [], $condition, $params);
+ $statuses = Item::select(api_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
/// @TODO How about copying this to above methods which don't check $r ?
if (!DBM::is_result($statuses)) {
}
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
- $statuses = Item::select(api_user(), [], $condition, $params);
+ $statuses = Item::select(api_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
if (!DBM::is_result($statuses)) {
throw new BadRequestException("There is no status with id $id.");
}
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
- $statuses = Item::select(api_user(), [], $condition, $params);
+ $statuses = Item::select(api_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
$ret = api_format_items(dba::inArray($statuses), $user_info, false, $type);
}
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
- $statuses = Item::select(api_user(), [], $condition, $params);
+ $statuses = Item::select(api_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
$ret = api_format_items(dba::inArray($statuses), $user_info, true, $type);
$itemid = intval($_REQUEST['id']);
}
- $item = Item::selectFirst(api_user(), [], ['id' => $itemid, 'uid' => api_user()]);
+ $item = Item::selectFirst(api_user(), Item::DISPLAY_FIELDLIST, ['id' => $itemid, 'uid' => api_user()]);
if (!DBM::is_result($item)) {
throw new BadRequestException("Invalid item.");
$condition[] = $max_id;
}
- $statuses = Item::select(api_user(), [], $condition, $params);
+ $statuses = Item::select(api_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
$ret = api_format_items(dba::inArray($statuses), $user_info, false, $type);
}
}
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
- $statuses = Item::select(api_user(), [], $condition, $params);
+ $statuses = Item::select(api_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
$items = api_format_items(dba::inArray($statuses), $user_info, false, $type);
$condition = ["`parent` = ? AND `uid` = ? AND (`verb` = ? OR `type`='photo')",
$item[0]['parent'], api_user(), ACTIVITY_POST];
- $statuses = Item::select(api_user(), [], $condition);
+ $statuses = Item::select(api_user(), Item::DISPLAY_FIELDLIST, $condition);
// prepare output of comments
$commentData = api_format_items(dba::inArray($statuses), $user_info, false, $type);
$nm->setSeen($note);
if ($note['otype']=='item') {
// would be really better with an ItemsManager and $im->getByID() :-P
- $item = Item::selectFirst(api_user(), [], ['id' => $note['iid'], 'uid' => api_user()]);
+ $item = Item::selectFirst(api_user(), Item::DISPLAY_FIELDLIST, ['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);
if ($block_authors) {
$condition[0] .= "AND NOT `author`.`hidden`";
}
- $thread_items = Item::select(local_user(), [], $condition, $params);
+ $thread_items = Item::select(local_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
$comments = dba::inArray($thread_items);
$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(), [], $condition, $params);
+ $r = Item::select(local_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
if (!DBM::is_result($r)) {
notice(L10n::t('Item not found.') . EOL);
}
$params = ['order' => ['id' => true], 'limit' => [$a->pager['start'], $a->pager['itemspage']]];
- $result = Item::select(local_user(), [], $condition, $params);
+ $result = Item::select(local_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
$items = dba::inArray($result);
$condition = ['unseen' => true, 'uid' => local_user()];
dba::close($r);
$condition = ['uid' => local_user(), 'parent' => $parents_arr];
- $result = Item::select(local_user(), [], $condition);
+ $result = Item::select(local_user(), Item::DISPLAY_FIELDLIST, $condition);
if (DBM::is_result($result)) {
$items = conv_sort(dba::inArray($result), 'commented');
$o .= conversation($a, $items, 'notes', $update);
}
$condition = ['uid' => $a->profile['profile_uid'], 'parent' => $parents_arr];
- $result = Item::select($a->profile['profile_uid'], [], $condition);
+ $result = Item::select($a->profile['profile_uid'], Item::DISPLAY_FIELDLIST, $condition);
$items = conv_sort(dba::inArray($result), 'created');
} else {
$items = [];
}
dba::close($terms);
- $items = Item::select(local_user(), [], ['id' => array_reverse($itemids)]);
+ $items = Item::select(local_user(), Item::DISPLAY_FIELDLIST, ['id' => array_reverse($itemids)]);
$r = dba::inArray($items);
} else {
logger("Start fulltext search for '".$search."'", LOGGER_DEBUG);
local_user(), $search];
$params = ['order' => ['id' => true],
'limit' => [$a->pager['start'], $a->pager['itemspage']]];
- $items = Item::select(local_user(), [], $condition, $params);
+ $items = Item::select(local_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
$r = dba::inArray($items);
}
$author_id, ACTIVITY_POST, local_user()];
$params = ['order' => ['created' => true],
'limit' => [$a->pager['start'], $a->pager['itemspage']]];
- $r = Item::select(local_user(), [], $condition, $params);
+ $r = Item::select(local_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
$items = dba::inArray($r);
-
+
$o = conversation($a, $items, 'contact-posts', false);
$o .= alt_pager($a, count($items));
class Item extends BaseObject
{
+ // Field list that is used to display the items
+ const DISPLAY_FIELDLIST = ['uid', 'id', 'parent', 'uri', 'thr-parent', 'parent-uri', 'guid',
+ 'commented', 'created', 'edited', 'received', 'verb', 'object-type', 'postopts', 'plink',
+ 'wall', 'private', 'starred', 'origin', 'title', 'body', 'file', 'attach',
+ 'content-warning', 'location', 'coord', 'app', 'rendered-hash', 'rendered-html', 'object',
+ 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid', 'item_id', 'item_network',
+ 'author-id', 'author-link', 'author-name', 'author-avatar',
+ 'owner-id', 'owner-link', 'owner-name', 'owner-avatar',
+ 'contact-id', 'contact-link', 'contact-name', 'contact-avatar',
+ 'network', 'url', 'name', 'writable', 'self', 'cid', 'alias',
+ 'event-id', 'event-created', 'event-edited', 'event-start', 'event-finish',
+ 'event-summary', 'event-desc', 'event-location', 'event-type',
+ 'event-nofinish', 'event-adjust', 'event-ignore', 'event-id'];
+
+ // Field list that is used to deliver items via the protocols
+ const DELIVER_FIELDLIST = ['uid', 'id', 'parent', 'uri', 'thr-parent', 'parent-uri', 'guid',
+ 'created', 'edited', 'verb', 'object-type', 'object', 'target',
+ 'private', 'title', 'body', 'location', 'coord', 'app',
+ 'attach', 'tag', 'bookmark', 'deleted', 'extid',
+ 'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
+ 'author-id', 'author-link', 'owner-link', 'contact-uid',
+ 'signed_text', 'signature', 'signer'];
+
/**
* Retrieve a single record from the item table and returns it in an associative array
*
'guid', 'wall', 'private', 'starred', 'origin', 'title', 'body', 'file', 'event-id',
'location', 'coord', 'app', 'attach', 'rendered-hash', 'rendered-html', 'object',
'allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
- 'id' => 'item_id', 'network' => 'item_network'];
-
- // The additional fields aren't needed to be selected by default.
- // We need them to select the correct tables. To see the difference we split the arrays
- if (!empty($selected)) {
- $additional_item_fields = ['type', 'extid', 'changed', 'moderated', 'target-type', 'target',
- 'resource-id', 'tag', 'inform', 'pubmail', 'visible', 'bookmark', 'unseen', 'deleted',
- 'forum_mode', 'mention', 'global', 'shadow'];
-
- $item_fields = array_merge($item_fields, $additional_item_fields);
- }
+ 'id' => 'item_id', 'network' => 'item_network',
+ 'type', 'extid', 'changed', 'moderated', 'target-type', 'target',
+ 'resource-id', 'tag', 'inform', 'pubmail', 'visible', 'bookmark', 'unseen', 'deleted',
+ 'forum_mode', 'mention', 'global', 'shadow'];
$author_fields = ['url' => 'author-link', 'name' => 'author-name', 'thumb' => 'author-avatar'];
$owner_fields = ['url' => 'owner-link', 'name' => 'owner-name', 'thumb' => 'owner-avatar'];
$contact_fields = ['url' => 'contact-link', 'name' => 'contact-name', 'thumb' => 'contact-avatar',
- 'network', 'url', 'name', 'writable', 'self', 'id' => 'cid', 'alias',
+ 'network', 'url', 'name', 'writable', 'self', 'id' => 'cid', 'alias', 'uid' => 'contact-uid',
'photo', 'name-date', 'uri-date', 'avatar-date', 'thumb', 'dfrn-id'];
$event_fields = ['created' => 'event-created', 'edited' => 'event-edited',
$fields = ['item' => $item_fields, 'author' => $author_fields, 'owner' => $owner_fields,
'contact' => $contact_fields, 'event' => $event_fields];
- if (!empty($selected)) {
- $fields['parent-item'] = ['guid' => 'parent-guid'];
- $fields['parent-item-author'] = ['url' => 'parent-author-link', 'name' => 'parent-author-name'];
- $fields['sign'] = ['signed_text', 'signature', 'signer'];
- }
+ $fields['parent-item'] = ['guid' => 'parent-guid'];
+ $fields['parent-item-author'] = ['url' => 'parent-author-link', 'name' => 'parent-author-name'];
+ $fields['sign'] = ['signed_text', 'signature', 'signer'];
return $fields;
}