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