"selectForUser" and "" selectFirstForUser" is now moved to Post
This commit is contained in:
parent
c1226bff07
commit
2b1d0b9db8
29 changed files with 179 additions and 121 deletions
|
@ -63,7 +63,7 @@ function display_init(App $a)
|
|||
|
||||
// Does the local user have this item?
|
||||
if (local_user()) {
|
||||
$item = Item::selectFirstForUser(local_user(), $fields, ['guid' => $a->argv[1], 'uid' => local_user()]);
|
||||
$item = Post::selectFirstForUser(local_user(), $fields, ['guid' => $a->argv[1], 'uid' => local_user()]);
|
||||
if (DBA::isResult($item)) {
|
||||
$nick = $a->user["nickname"];
|
||||
}
|
||||
|
@ -83,14 +83,14 @@ function display_init(App $a)
|
|||
|
||||
// Is it an item with uid=0?
|
||||
if (!DBA::isResult($item)) {
|
||||
$item = Item::selectFirstForUser(local_user(), $fields, ['guid' => $a->argv[1], 'private' => [Item::PUBLIC, Item::UNLISTED], 'uid' => 0]);
|
||||
$item = Post::selectFirstForUser(local_user(), $fields, ['guid' => $a->argv[1], 'private' => [Item::PUBLIC, Item::UNLISTED], 'uid' => 0]);
|
||||
}
|
||||
} elseif ($a->argc >= 3 && $nick == 'feed-item') {
|
||||
$item_id = $a->argv[2];
|
||||
if (substr($item_id, -5) == '.atom') {
|
||||
$item_id = substr($item_id, 0, -5);
|
||||
}
|
||||
$item = Item::selectFirstForUser(local_user(), $fields, ['id' => $item_id, 'private' => [Item::PUBLIC, Item::UNLISTED], 'uid' => 0]);
|
||||
$item = Post::selectFirstForUser(local_user(), $fields, ['id' => $item_id, 'private' => [Item::PUBLIC, Item::UNLISTED], 'uid' => 0]);
|
||||
}
|
||||
|
||||
if (!DBA::isResult($item)) {
|
||||
|
@ -107,7 +107,7 @@ function display_init(App $a)
|
|||
}
|
||||
|
||||
if ($item['gravity'] != GRAVITY_PARENT) {
|
||||
$parent = Item::selectFirstForUser($item_user, $fields, ['id' => $item['parent']]);
|
||||
$parent = Post::selectFirstForUser($item_user, $fields, ['id' => $item['parent']]);
|
||||
$item = $parent ?: $item;
|
||||
}
|
||||
|
||||
|
@ -206,7 +206,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
|
|||
|
||||
if (local_user()) {
|
||||
$condition = ['guid' => $a->argv[1], 'uid' => local_user()];
|
||||
$item = Item::selectFirstForUser(local_user(), $fields, $condition);
|
||||
$item = Post::selectFirstForUser(local_user(), $fields, $condition);
|
||||
if (DBA::isResult($item)) {
|
||||
$item_id = $item['id'];
|
||||
$item_parent = $item['parent'];
|
||||
|
@ -225,7 +225,7 @@ function display_content(App $a, $update = false, $update_uid = 0)
|
|||
|
||||
if ($item_parent == 0) {
|
||||
$condition = ['private' => [Item::PUBLIC, Item::UNLISTED], 'guid' => $a->argv[1], 'uid' => 0];
|
||||
$item = Item::selectFirstForUser(local_user(), $fields, $condition);
|
||||
$item = Post::selectFirstForUser(local_user(), $fields, $condition);
|
||||
if (DBA::isResult($item)) {
|
||||
$item_id = $item['id'];
|
||||
$item_parent = $item['parent'];
|
||||
|
@ -315,9 +315,9 @@ function display_content(App $a, $update = false, $update_uid = 0)
|
|||
return '';
|
||||
}
|
||||
|
||||
$condition = ["`id` = ? AND `item`.`uid` IN (0, ?) " . $sql_extra, $item_id, $item_uid];
|
||||
$condition = ["`id` = ? AND `uid` IN (0, ?) " . $sql_extra, $item_id, $item_uid];
|
||||
$fields = ['parent-uri', 'body', 'title', 'author-name', 'author-avatar', 'plink', 'author-id', 'owner-id', 'contact-id'];
|
||||
$item = Item::selectFirstForUser($a->profile['uid'], $fields, $condition);
|
||||
$item = Post::selectFirstForUser($a->profile['uid'], $fields, $condition);
|
||||
|
||||
if (!DBA::isResult($item)) {
|
||||
throw new HTTPException\NotFoundException(DI::l10n()->t('The requested item doesn\'t exist or has been deleted.'));
|
||||
|
|
|
@ -28,6 +28,7 @@ use Friendica\DI;
|
|||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\FileTag;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Util\Crypto;
|
||||
|
||||
function editpost_content(App $a)
|
||||
|
@ -49,7 +50,7 @@ function editpost_content(App $a)
|
|||
$fields = ['allow_cid', 'allow_gid', 'deny_cid', 'deny_gid',
|
||||
'type', 'body', 'title', 'file', 'wall', 'post-type', 'guid'];
|
||||
|
||||
$item = Item::selectFirstForUser(local_user(), $fields, ['id' => $post_id, 'uid' => local_user()]);
|
||||
$item = Post::selectFirstForUser(local_user(), $fields, ['id' => $post_id, 'uid' => local_user()]);
|
||||
|
||||
if (!DBA::isResult($item)) {
|
||||
notice(DI::l10n()->t('Item not found'));
|
||||
|
|
|
@ -861,7 +861,7 @@ function drop_item(int $id, string $return = '')
|
|||
{
|
||||
// locate item to be deleted
|
||||
$fields = ['id', 'uid', 'guid', 'contact-id', 'deleted', 'gravity', 'parent'];
|
||||
$item = Item::selectFirstForUser(local_user(), $fields, ['id' => $id]);
|
||||
$item = Post::selectFirstForUser(local_user(), $fields, ['id' => $id]);
|
||||
|
||||
if (!DBA::isResult($item)) {
|
||||
notice(DI::l10n()->t('Item not found.'));
|
||||
|
@ -881,7 +881,7 @@ function drop_item(int $id, string $return = '')
|
|||
|
||||
if ((local_user() == $item['uid']) || $contact_id) {
|
||||
if (!empty($item['parent'])) {
|
||||
$parentitem = Item::selectFirstForUser(local_user(), ['guid'], ['id' => $item['parent']]);
|
||||
$parentitem = Post::selectFirstForUser(local_user(), ['guid'], ['id' => $item['parent']]);
|
||||
}
|
||||
|
||||
// delete the item
|
||||
|
|
|
@ -86,7 +86,7 @@ function notes_content(App $a, $update = false)
|
|||
$count = 0;
|
||||
|
||||
if (DBA::isResult($r)) {
|
||||
$notes = Item::inArray($r);
|
||||
$notes = Item::toArray($r);
|
||||
|
||||
$count = count($notes);
|
||||
|
||||
|
|
|
@ -1276,13 +1276,12 @@ function photos_content(App $a)
|
|||
|
||||
if (!empty($link_item['parent']) && !empty($link_item['uid'])) {
|
||||
$condition = ["`parent` = ? AND `gravity` != ?", $link_item['parent'], GRAVITY_PARENT];
|
||||
$total = DBA::count('item', $condition);
|
||||
$total = Post::count($condition);
|
||||
|
||||
$pager = new Pager(DI::l10n(), DI::args()->getQueryString());
|
||||
|
||||
$params = ['order' => ['id'], 'limit' => [$pager->getStart(), $pager->getItemsPerPage()]];
|
||||
$result = Item::selectForUser($link_item['uid'], Item::ITEM_FIELDLIST, $condition, $params);
|
||||
$items = Item::inArray($result);
|
||||
$items = Post::toArray(Post::selectForUser($link_item['uid'], Item::ITEM_FIELDLIST, $condition, $params));
|
||||
|
||||
if (local_user() == $link_item['uid']) {
|
||||
Item::update(['unseen' => false], ['parent' => $link_item['parent']]);
|
||||
|
|
|
@ -28,8 +28,8 @@ use Friendica\Database\DBA;
|
|||
use Friendica\DI;
|
||||
use Friendica\Model\Contact;
|
||||
use Friendica\Model\Group;
|
||||
use Friendica\Model\Item;
|
||||
use Friendica\Model\Notify\Type;
|
||||
use Friendica\Model\Post;
|
||||
use Friendica\Model\Verb;
|
||||
use Friendica\Protocol\Activity;
|
||||
use Friendica\Util\DateTimeFormat;
|
||||
|
@ -137,9 +137,9 @@ function ping_init(App $a)
|
|||
|
||||
$condition = ["`unseen` AND `uid` = ? AND NOT `origin` AND (`vid` != ? OR `vid` IS NULL)",
|
||||
local_user(), Verb::getID(Activity::FOLLOW)];
|
||||
$items = Item::selectForUser(local_user(), ['wall', 'uid', 'uri-id'], $condition);
|
||||
$items = Post::selectForUser(local_user(), ['wall', 'uid', 'uri-id'], $condition);
|
||||
if (DBA::isResult($items)) {
|
||||
$items_unseen = Item::inArray($items);
|
||||
$items_unseen = Post::toArray($items);
|
||||
$arr = ['items' => $items_unseen];
|
||||
Hook::callAll('network_ping', $arr);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue