X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=src%2FModule%2FDebug%2FItemBody.php;h=6bc1419d3463e08e0d550c03b756bbb09d6013f9;hb=1d6f5c33a1a7c538d4e529d22701fd735855da15;hp=fead2553585bf6162665c64ba0f82a2ecc8f7d76;hpb=c1f99c70b1c7d62120723f3b142e843ba25ab338;p=friendica.git diff --git a/src/Module/Debug/ItemBody.php b/src/Module/Debug/ItemBody.php index fead255358..6bc1419d34 100644 --- a/src/Module/Debug/ItemBody.php +++ b/src/Module/Debug/ItemBody.php @@ -1,10 +1,30 @@ . + * + */ namespace Friendica\Module\Debug; use Friendica\BaseModule; -use Friendica\Core\L10n; -use Friendica\Model\Item; +use Friendica\Core\System; +use Friendica\DI; +use Friendica\Model\Post; use Friendica\Network\HTTPException; /** @@ -12,32 +32,29 @@ use Friendica\Network\HTTPException; */ class ItemBody extends BaseModule { - public static function content() + protected function content(array $request = []): string { - if (!local_user()) { - throw new HTTPException\UnauthorizedException(L10n::t('Access denied.')); + if (!DI::userSession()->getLocalUserId()) { + throw new HTTPException\UnauthorizedException(DI::l10n()->t('Access denied.')); } - $app = self::getApp(); - - // @TODO: Replace with parameter from router - $itemId = (($app->argc > 1) ? intval($app->argv[1]) : 0); - - if (!$itemId) { - throw new HTTPException\NotFoundException(L10n::t('Item not found.')); + if (empty($this->parameters['item'])) { + throw new HTTPException\NotFoundException(DI::l10n()->t('Item not found.')); } - $item = Item::selectFirst(['body'], ['uid' => local_user(), 'id' => $itemId]); + $itemId = intval($this->parameters['item']); + + $item = Post::selectFirst(['body'], ['uid' => [0, DI::userSession()->getLocalUserId()], 'uri-id' => $itemId]); if (!empty($item)) { - if ($app->isAjax()) { + if (DI::mode()->isAjax()) { echo str_replace("\n", '
', $item['body']); - exit(); + System::exit(); } else { return str_replace("\n", '
', $item['body']); } } else { - throw new HTTPException\NotFoundException(L10n::t('Item not found.')); + throw new HTTPException\NotFoundException(DI::l10n()->t('Item not found.')); } } }