5 require_once('include/NotificationsManager.php');
7 function notify_init(App $a) {
12 $nm = new NotificationsManager();
14 if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
15 $note = $nm->getByID($a->argv[2]);
19 // The friendica client has problems with the GUID. this is some workaround
20 if ($a->is_friendica_app()) {
21 require_once("include/items.php");
22 $urldata = parse_url($note['link']);
23 $guid = basename($urldata["path"]);
24 $itemdata = get_item_id($guid, local_user());
25 if ($itemdata["id"] != 0) {
26 $note['link'] = App::get_baseurl().'/display/'.$itemdata["nick"].'/'.$itemdata["id"];
30 goaway($note['link']);
33 goaway(App::get_baseurl(true));
36 if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all' ) {
37 $r = $nm->setAllSeen();
38 $j = json_encode(array('result' => ($r) ? 'success' : 'fail'));
45 function notify_content(App $a) {
50 $nm = new NotificationsManager();
52 $notif_tpl = get_markup_template('notifications.tpl');
54 $not_tpl = get_markup_template('notify.tpl');
55 require_once('include/bbcode.php');
57 $r = $nm->getAll(array('seen'=>0));
58 if (dbm::is_result($r) > 0) {
60 $notif_content .= replace_macros($not_tpl,array(
61 '$item_link' => App::get_baseurl(true).'/notify/view/'. $it['id'],
62 '$item_image' => $it['photo'],
63 '$item_text' => strip_tags(bbcode($it['msg'])),
64 '$item_when' => relative_date($it['date'])
68 $notif_content .= t('No more system notifications.');
71 $o .= replace_macros($notif_tpl, array(
72 '$notif_header' => t('System Notifications'),
73 '$tabs' => false, // $tabs,
74 '$notif_content' => $notif_content,