7 use Friendica\Content\Text\BBCode;
8 use Friendica\Core\L10n;
9 use Friendica\Core\NotificationsManager;
10 use Friendica\Core\Renderer;
11 use Friendica\Core\System;
12 use Friendica\Database\DBA;
13 use Friendica\Model\Item;
14 use Friendica\Module\Login;
15 use Friendica\Util\Temporal;
17 function notify_init(App $a)
23 $nm = new NotificationsManager();
25 if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
26 $note = $nm->getByID($a->argv[2]);
29 System::externalRedirect($note['link']);
32 $a->internalRedirect();
35 if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all') {
36 $r = $nm->setAllSeen();
37 $j = json_encode(['result' => ($r) ? 'success' : 'fail']);
43 function notify_content(App $a)
51 $nm = new NotificationsManager();
53 $notif_tpl = Renderer::getMarkupTemplate('notifications.tpl');
55 $not_tpl = Renderer::getMarkupTemplate('notify.tpl');
57 $r = $nm->getAll(['seen'=>0]);
58 if (DBA::isResult($r) > 0) {
60 $notif_content .= Renderer::replaceMacros($not_tpl, [
61 '$item_link' => System::baseUrl(true).'/notify/view/'. $it['id'],
62 '$item_image' => $it['photo'],
63 '$item_text' => strip_tags(BBCode::convert($it['msg'])),
64 '$item_when' => Temporal::getRelativeDate($it['date'])
68 $notif_content .= L10n::t('No more system notifications.');
71 $o = Renderer::replaceMacros($notif_tpl, [
72 '$notif_header' => L10n::t('System Notifications'),
73 '$tabs' => false, // $tabs,
74 '$notif_content' => $notif_content,