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;
11 use Friendica\Model\Item;
13 function notify_init(App $a)
19 $nm = new NotificationsManager();
21 if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
22 $note = $nm->getByID($a->argv[2]);
26 // The friendica client has problems with the GUID. this is some workaround
27 if ($a->is_friendica_app()) {
28 require_once("include/items.php");
29 $urldata = parse_url($note['link']);
30 $guid = basename($urldata["path"]);
31 $itemdata = Item::getIdAndNickByGuid($guid, local_user());
32 if ($itemdata["id"] != 0) {
33 $note['link'] = System::baseUrl().'/display/'.$itemdata["nick"].'/'.$itemdata["id"];
37 goaway($note['link']);
40 goaway(System::baseUrl(true));
43 if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all') {
44 $r = $nm->setAllSeen();
45 $j = json_encode(['result' => ($r) ? 'success' : 'fail']);
51 function notify_content(App $a)
57 $nm = new NotificationsManager();
59 $notif_tpl = get_markup_template('notifications.tpl');
61 $not_tpl = get_markup_template('notify.tpl');
62 require_once('include/bbcode.php');
64 $r = $nm->getAll(['seen'=>0]);
65 if (DBM::is_result($r) > 0) {
67 $notif_content .= replace_macros($not_tpl, [
68 '$item_link' => System::baseUrl(true).'/notify/view/'. $it['id'],
69 '$item_image' => $it['photo'],
70 '$item_text' => strip_tags(bbcode($it['msg'])),
71 '$item_when' => relative_date($it['date'])
75 $notif_content .= L10n::t('No more system notifications.');
78 $o .= replace_macros($notif_tpl, [
79 '$notif_header' => L10n::t('System Notifications'),
80 '$tabs' => false, // $tabs,
81 '$notif_content' => $notif_content,