$start = $page * $count;
- $condition = ["`verb` = ? AND `item`.`id` > ?
+ $condition = ["`verb` = ? AND `item`.`id` > ?
AND (`item`.`uid` = 0 OR (`item`.`uid` = ? AND NOT `item`.`global`))
AND `item`.`body` LIKE CONCAT('%',?,'%')",
ACTIVITY_POST, $since_id, api_user(), $_REQUEST['q']];
- if ($max_id > 0) {
- $condition[0] .= " AND `item`.`id` <= ?";
- $condition[] = $max_id;
- }
+ if ($max_id > 0) {
+ $condition[0] .= " AND `item`.`id` <= ?";
+ $condition[] = $max_id;
+ }
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
- $statuses = Item::select(api_user(), [], $condition, $params);
+ $statuses = Item::selectForUser(api_user(), [], $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::selectForUser(api_user(), [], $condition, $params);
- $ret = api_format_items(dba::inArray($statuses), $user_info, false, $type);
+ $items = dba::inArray($statuses);
+
+ $ret = api_format_items($items, $user_info, false, $type);
// Set all posts from the query above to seen
$idarray = [];
- foreach ($r as $item) {
+ foreach ($items as $item) {
$idarray[] = intval($item["id"]);
}
$condition = ["`verb` = ? AND `iid` > ? AND NOT `private` AND `wall` AND NOT `user`.`hidewall`",
ACTIVITY_POST, $since_id];
- if ($max_id > 0) {
- $condition[0] .= " AND `thread`.`iid` <= ?";
- $condition[] = $max_id;
- }
+ if ($max_id > 0) {
+ $condition[0] .= " AND `thread`.`iid` <= ?";
+ $condition[] = $max_id;
+ }
- $params = ['order' => ['iid' => true], 'limit' => [$start, $count]];
- $statuses = Item::selectThread(api_user(), [], $condition, $params);
+ $params = ['order' => ['iid' => true], 'limit' => [$start, $count]];
+ $statuses = Item::selectThreadForUser(api_user(), Item::DISPLAY_FIELDLIST, $condition, $params);
$r = dba::inArray($statuses);
} else {
- $condition = ["`uid` = ? AND `verb` = ? AND `id` > ? AND NOT `user`.`hidewall` AND `item`.`origin`",
- api_user(), ACTIVITY_POST, $since_id];
+ $condition = ["`verb` = ? AND `id` > ? AND NOT `private` AND `wall` AND NOT `user`.`hidewall` AND `item`.`origin`",
+ ACTIVITY_POST, $since_id];
- if ($max_id > 0) {
- $condition[0] .= " AND `item`.`id` <= ?";
- $condition[] = $max_id;
- }
- if ($conversation_id > 0) {
- $condition[0] .= " AND `item`.`parent` = ?";
- $condition[] = $conversation_id;
- }
+ if ($max_id > 0) {
+ $condition[0] .= " AND `item`.`id` <= ?";
+ $condition[] = $max_id;
+ }
+ if ($conversation_id > 0) {
+ $condition[0] .= " AND `item`.`parent` = ?";
+ $condition[] = $conversation_id;
+ }
- $params = ['order' => ['id' => true], 'limit' => [$start, $count]];
- $statuses = Item::select(api_user(), [], $condition, $params);
+ $params = ['order' => ['id' => true], 'limit' => [$start, $count]];
+ $statuses = Item::selectForUser(api_user(), [], $condition, $params);
$r = dba::inArray($statuses);
}
$condition = ["`uid` = 0 AND `verb` = ? AND `thread`.`iid` > ? AND NOT `private`",
ACTIVITY_POST, $since_id];
- if ($max_id > 0) {
- $condition[0] .= " AND `thread`.`iid` <= ?";
- $condition[] = $max_id;
- }
+ if ($max_id > 0) {
+ $condition[0] .= " AND `thread`.`iid` <= ?";
+ $condition[] = $max_id;
+ }
- $params = ['order' => ['iid' => true], 'limit' => [$start, $count]];
- $statuses = Item::selectThread(api_user(), [], $condition, $params);
+ $params = ['order' => ['iid' => true], 'limit' => [$start, $count]];
+ $statuses = Item::selectThreadForUser(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::selectForUser(api_user(), [], $condition, $params);
/// @TODO How about copying this to above methods which don't check $r ?
- if (!DBM::is_result($items)) {
+ if (!DBM::is_result($statuses)) {
throw new BadRequestException("There is no status with this id.");
}
}
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
- $statuses = Item::select(api_user(), [], $condition, $params);
+ $statuses = Item::selectForUser(api_user(), [], $condition, $params);
- if (!DBM::is_result($items)) {
+ if (!DBM::is_result($statuses)) {
throw new BadRequestException("There is no status with id $id.");
}
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) {
}
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
- $statuses = Item::select(api_user(), [], $condition, $params);
+ $statuses = Item::selectForUser(api_user(), [], $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::selectForUser(api_user(), [], $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::selectFirstForUser(api_user(), [], ['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::selectForUser(api_user(), [], $condition, $params);
$ret = api_format_items(dba::inArray($statuses), $user_info, false, $type);
}
$start = $page * $count;
- $condition = ["`uid` = ? AND `verb` = ? AND `id` > ? AND `group_member`.`gid` = ?",
+ $condition = ["`uid` = ? AND `verb` = ? AND `id` > ? AND `group_member`.`gid` = ?",
api_user(), ACTIVITY_POST, $since_id, $_REQUEST['list_id']];
- if ($max_id > 0) {
- $condition[0] .= " AND `item`.`id` <= ?";
- $condition[] = $max_id;
- }
- if ($exclude_replies > 0) {
- $condition[0] .= ' AND `item`.`parent` = `item`.`id`';
- }
- if ($conversation_id > 0) {
- $condition[0] .= " AND `item`.`parent` = ?";
- $condition[] = $conversation_id;
- }
+ if ($max_id > 0) {
+ $condition[0] .= " AND `item`.`id` <= ?";
+ $condition[] = $max_id;
+ }
+ if ($exclude_replies > 0) {
+ $condition[0] .= ' AND `item`.`parent` = `item`.`id`';
+ }
+ if ($conversation_id > 0) {
+ $condition[0] .= " AND `item`.`parent` = ?";
+ $condition[] = $conversation_id;
+ }
$params = ['order' => ['id' => true], 'limit' => [$start, $count]];
- $statuses = Item::select(api_user(), [], $condition, $params);
+ $statuses = Item::selectForUser(api_user(), [], $condition, $params);
$items = api_format_items(dba::inArray($statuses), $user_info, false, $type);
function api_direct_messages_box($type, $box, $verbose)
{
$a = get_app();
- $user_info = api_get_user($a);
-
- if (api_user() === false || $user_info === false) {
+ if (api_user() === false) {
throw new ForbiddenException();
}
-
// params
$count = (x($_GET, 'count') ? $_GET['count'] : 20);
$page = (x($_REQUEST, 'page') ? $_REQUEST['page'] -1 : 0);
unset($_REQUEST["screen_name"]);
unset($_GET["screen_name"]);
+ $user_info = api_get_user($a);
+ if ($user_info === false) {
+ throw new ForbiddenException();
+ }
$profile_url = $user_info["url"];
// pagination
function post_photo_item($hash, $allow_cid, $deny_cid, $allow_gid, $deny_gid, $filetype, $visibility = false)
{
// get data about the api authenticated user
- $uri = item_new_uri(get_app()->get_hostname(), intval(api_user()));
+ $uri = Item::newURI(intval(api_user()));
$owner_record = q("SELECT * FROM `contact` WHERE `uid`= %d AND `self` LIMIT 1", intval(api_user()));
$arr = [];
$condition = ["`parent` = ? AND `uid` = ? AND (`verb` = ? OR `type`='photo')",
$item[0]['parent'], api_user(), ACTIVITY_POST];
- $statuses = Item::select(api_user(), [], $condition);
+ $statuses = Item::selectForUser(api_user(), [], $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::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);