]> git.mxchange.org Git - friendica.git/blob - src/Module/GnuSocial/Notice.php
correct notice redirect
[friendica.git] / src / Module / GnuSocial / Notice.php
1 <?php
2
3 namespace Friendica\Module\GnuSocial;
4
5 use Friendica\BaseModule;
6 use Friendica\Core\L10n;
7 use Friendica\Database\DBA;
8 use Friendica\Model\Item;
9 use Friendica\Model\ItemUser;
10 use Friendica\Network\HTTPException;
11
12 /**
13  * GNU Social -> friendica items permanent-url compatibility
14  */
15 class Notice extends BaseModule
16 {
17         public static function content()
18         {
19                 $a = self::getApp();
20
21                 // @TODO: Replace with parameter from router
22                 $id = ($a->argc > 1) ? $a->argv[1] : 0;
23
24                 if (empty($id)) {
25                         throw new HTTPException\NotFoundException(L10n::t('Item not found.'));
26                 }
27
28                 $item = DBA::selectFirst('item', ['guid'], ['id' => $id]);
29
30                 if (empty($item )) {
31                         throw new HTTPException\NotFoundException(L10n::t('Item not found.'));
32                 } else {
33                         $a->internalRedirect('display/' . $item['guid']);
34                 }
35         }
36 }