]> git.mxchange.org Git - friendica.git/blob - src/Module/Debug/ItemBody.php
Group selection: Respect "pubmail" and ignore atchived or blocked contacts
[friendica.git] / src / Module / Debug / ItemBody.php
1 <?php
2
3 namespace Friendica\Module\Debug;
4
5 use Friendica\BaseModule;
6 use Friendica\Core\L10n;
7 use Friendica\Model\Item;
8 use Friendica\Network\HTTPException;
9
10 /**
11  * Print the body of an Item
12  */
13 class ItemBody extends BaseModule
14 {
15         public static function content(array $parameters = [])
16         {
17                 if (!local_user()) {
18                         throw new HTTPException\UnauthorizedException(L10n::t('Access denied.'));
19                 }
20
21                 $app = self::getApp();
22
23                 // @TODO: Replace with parameter from router
24                 $itemId = (($app->argc > 1) ? intval($app->argv[1]) : 0);
25
26                 if (!$itemId) {
27                         throw new HTTPException\NotFoundException(L10n::t('Item not found.'));
28                 }
29
30                 $item = Item::selectFirst(['body'], ['uid' => local_user(), 'id' => $itemId]);
31
32                 if (!empty($item)) {
33                         if ($app->isAjax()) {
34                                 echo str_replace("\n", '<br />', $item['body']);
35                                 exit();
36                         } else {
37                                 return str_replace("\n", '<br />', $item['body']);
38                         }
39                 } else {
40                         throw new HTTPException\NotFoundException(L10n::t('Item not found.'));
41                 }
42         }
43 }