6 use Friendica\Core\NotificationsManager;
7 use Friendica\Core\L10n;
8 use Friendica\Core\System;
9 use Friendica\Database\DBM;
10 use Friendica\Module\Login;
12 function notify_init(App $a)
18 $nm = new NotificationsManager();
20 if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
21 $note = $nm->getByID($a->argv[2]);
25 // The friendica client has problems with the GUID. this is some workaround
26 if ($a->is_friendica_app()) {
27 require_once("include/items.php");
28 $urldata = parse_url($note['link']);
29 $guid = basename($urldata["path"]);
30 $itemdata = get_item_id($guid, local_user());
31 if ($itemdata["id"] != 0) {
32 $note['link'] = System::baseUrl().'/display/'.$itemdata["nick"].'/'.$itemdata["id"];
36 goaway($note['link']);
39 goaway(System::baseUrl(true));
42 if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all') {
43 $r = $nm->setAllSeen();
44 $j = json_encode(['result' => ($r) ? 'success' : 'fail']);
50 function notify_content(App $a)
56 $nm = new NotificationsManager();
58 $notif_tpl = get_markup_template('notifications.tpl');
60 $not_tpl = get_markup_template('notify.tpl');
61 require_once('include/bbcode.php');
63 $r = $nm->getAll(['seen'=>0]);
64 if (DBM::is_result($r) > 0) {
66 $notif_content .= replace_macros($not_tpl, [
67 '$item_link' => System::baseUrl(true).'/notify/view/'. $it['id'],
68 '$item_image' => $it['photo'],
69 '$item_text' => strip_tags(bbcode($it['msg'])),
70 '$item_when' => relative_date($it['date'])
74 $notif_content .= L10n::t('No more system notifications.');
77 $o .= replace_macros($notif_tpl, [
78 '$notif_header' => L10n::t('System Notifications'),
79 '$tabs' => false, // $tabs,
80 '$notif_content' => $notif_content,