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