4 use Friendica\Core\NotificationsManager;
5 use Friendica\Core\System;
6 use Friendica\Database\DBM;
7 use Friendica\Module\Login;
9 function notify_init(App $a) {
14 $nm = new NotificationsManager();
16 if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
17 $note = $nm->getByID($a->argv[2]);
21 // The friendica client has problems with the GUID. this is some workaround
22 if ($a->is_friendica_app()) {
23 require_once("include/items.php");
24 $urldata = parse_url($note['link']);
25 $guid = basename($urldata["path"]);
26 $itemdata = get_item_id($guid, local_user());
27 if ($itemdata["id"] != 0) {
28 $note['link'] = System::baseUrl().'/display/'.$itemdata["nick"].'/'.$itemdata["id"];
32 goaway($note['link']);
35 goaway(System::baseUrl(true));
38 if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all' ) {
39 $r = $nm->setAllSeen();
40 $j = json_encode(array('result' => ($r) ? 'success' : 'fail'));
47 function notify_content(App $a) {
52 $nm = new NotificationsManager();
54 $notif_tpl = get_markup_template('notifications.tpl');
56 $not_tpl = get_markup_template('notify.tpl');
57 require_once('include/bbcode.php');
59 $r = $nm->getAll(array('seen'=>0));
60 if (DBM::is_result($r) > 0) {
62 $notif_content .= replace_macros($not_tpl,array(
63 '$item_link' => System::baseUrl(true).'/notify/view/'. $it['id'],
64 '$item_image' => $it['photo'],
65 '$item_text' => strip_tags(bbcode($it['msg'])),
66 '$item_when' => relative_date($it['date'])
70 $notif_content .= t('No more system notifications.');
73 $o .= replace_macros($notif_tpl, array(
74 '$notif_header' => t('System Notifications'),
75 '$tabs' => false, // $tabs,
76 '$notif_content' => $notif_content,