X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FItem%2FStar.php;h=8f444d54edfdf79c95eb99964622cf6f539226c5;hb=d7df0825db598012871d8555de04575d0c30247a;hp=47dfe1875036b0a9f361f2278f7299c02b8f1510;hpb=befc2af5043a3afde251721c0d27df695db1bb7e;p=friendica.git diff --git a/src/Module/Item/Star.php b/src/Module/Item/Star.php index 47dfe18750..8f444d54ed 100644 --- a/src/Module/Item/Star.php +++ b/src/Module/Item/Star.php @@ -1,6 +1,6 @@ t('Access denied.')); } - if (empty($parameters['id'])) { + if (empty($this->parameters['id'])) { throw new HTTPException\BadRequestException(); } - $itemId = intval($parameters['id']); + $itemId = intval($this->parameters['id']); - $item = Post::selectFirstForUser(local_user(), ['starred'], ['uid' => local_user(), 'id' => $itemId]); + + $item = Post::selectFirstForUser(local_user(), ['uid', 'uri-id', 'starred'], ['uid' => [0, local_user()], 'id' => $itemId]); if (empty($item)) { throw new HTTPException\NotFoundException(); } + if ($item['uid'] == 0) { + $stored = Item::storeForUserByUriId($item['uri-id'], local_user()); + if (!empty($stored)) { + $item = Post::selectFirst(['starred'], ['id' => $stored]); + if (!DBA::isResult($item)) { + throw new HTTPException\NotFoundException(); + } + $itemId = $stored; + } else { + throw new HTTPException\NotFoundException(); + } + } + $starred = !(bool)$item['starred']; Item::update(['starred' => $starred], ['id' => $itemId]);