2 require_once('include/NotificationsManager.php');
4 function notify_init(App $a) {
9 $nm = new NotificationsManager();
11 if ($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
12 $note = $nm->getByID($a->argv[2]);
16 // The friendica client has problems with the GUID. this is some workaround
17 if ($a->is_friendica_app()) {
18 require_once("include/items.php");
19 $urldata = parse_url($note['link']);
20 $guid = basename($urldata["path"]);
21 $itemdata = get_item_id($guid, local_user());
22 if ($itemdata["id"] != 0) {
23 $note['link'] = App::get_baseurl().'/display/'.$itemdata["nick"].'/'.$itemdata["id"];
27 goaway($note['link']);
30 goaway(App::get_baseurl(true));
33 if ($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all' ) {
34 $r = $nm->setAllSeen();
35 $j = json_encode(array('result' => ($r) ? 'success' : 'fail'));
42 function notify_content(App $a) {
47 $nm = new NotificationsManager();
49 $notif_tpl = get_markup_template('notifications.tpl');
51 $not_tpl = get_markup_template('notify.tpl');
52 require_once('include/bbcode.php');
54 $r = $nm->getAll(array('seen'=>0));
55 if (dbm::is_result($r) > 0) {
57 $notif_content .= replace_macros($not_tpl,array(
58 '$item_link' => App::get_baseurl(true).'/notify/view/'. $it['id'],
59 '$item_image' => $it['photo'],
60 '$item_text' => strip_tags(bbcode($it['msg'])),
61 '$item_when' => relative_date($it['date'])
65 $notif_content .= t('No more system notifications.');
68 $o .= replace_macros($notif_tpl, array(
69 '$notif_header' => t('System Notifications'),
70 '$tabs' => false, // $tabs,
71 '$notif_content' => $notif_content,