X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fnotice.php;h=c2d85db166bcc7145dc1f25d765b8b25a3471b4d;hb=c17adaf3333b356d0c7b19226b29cd733a43017b;hp=a42d60dd401f344e4d564229711366c6452ce0e3;hpb=9330a6994c1b9aee49a482efe32e84ca1a944c9b;p=friendica.git diff --git a/mod/notice.php b/mod/notice.php index a42d60dd40..c2d85db166 100644 --- a/mod/notice.php +++ b/mod/notice.php @@ -1,21 +1,26 @@ friendica items permanent-url compatibility */ +/** + * @file mod/notice.php + * GNU Social -> friendica items permanent-url compatibility + */ -if(! function_exists('notice_init')) { - function notice_init(&$a) { - $id = $a->argv[1]; - $r = q("SELECT user.nickname FROM user LEFT JOIN item ON item.uid=user.uid WHERE item.id=%d", - intval($id) - ); - if (count($r)){ - $nick = $r[0]['nickname']; - $url = $a->get_baseurl()."/display/$nick/$id"; - goaway($url); - } else { - $a->error = 404; - notice( t('Item not found.') . EOL); +use Friendica\App; +use Friendica\Core\L10n; +use Friendica\Core\System; +use Friendica\Database\DBM; - } - return; +function notice_init(App $a) +{ + $id = $a->argv[1]; + $r = q("SELECT `user`.`nickname` FROM `user` LEFT JOIN `item` ON `item`.`uid` = `user`.`uid` WHERE `item`.`id` = %d", intval($id)); + if (DBM::is_result($r)) { + $nick = $r[0]['nickname']; + $url = System::baseUrl() . "/display/$nick/$id"; + goaway($url); + } else { + $a->error = 404; + notice(L10n::t('Item not found.') . EOL); } + + return; }