friendica/src/Module/GnuSocial/Notice.php

35 lines
748 B
PHP
Raw Normal View History

2019-05-18 20:02:21 +02:00
<?php
namespace Friendica\Module\GnuSocial;
use Friendica\BaseModule;
use Friendica\Core\L10n;
2019-05-18 20:37:37 +02:00
use Friendica\Database\DBA;
2019-05-18 20:02:21 +02:00
use Friendica\Network\HTTPException;
/**
* GNU Social -> friendica items permanent-url compatibility
*/
class Notice extends BaseModule
{
2019-05-18 20:04:57 +02:00
public static function content()
2019-05-18 20:02:21 +02:00
{
$a = self::getApp();
// @TODO: Replace with parameter from router
$id = ($a->argc > 1) ? $a->argv[1] : 0;
if (empty($id)) {
throw new HTTPException\NotFoundException(L10n::t('Item not found.'));
}
2019-05-18 20:37:37 +02:00
$item = DBA::selectFirst('item', ['guid'], ['id' => $id]);
2019-05-18 20:02:21 +02:00
2019-05-18 20:37:37 +02:00
if (empty($item )) {
2019-05-18 20:02:21 +02:00
throw new HTTPException\NotFoundException(L10n::t('Item not found.'));
} else {
2019-05-18 20:37:37 +02:00
$a->internalRedirect('display/' . $item['guid']);
2019-05-18 20:02:21 +02:00
}
}
}