2 require_once('include/NotificationsManager.php');
5 function notify_init(&$a) {
6 if(! local_user()) return;
7 $nm = new NotificationsManager();
9 if($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
10 $note = $nm->getByID($a->argv[2]);
14 // The friendica client has problems with the GUID. this is some workaround
15 if ($a->is_friendica_app()) {
16 require_once("include/items.php");
17 $urldata = parse_url($note['link']);
18 $guid = basename($urldata["path"]);
19 $itemdata = get_item_id($guid, local_user());
20 if ($itemdata["id"] != 0)
21 $note['link'] = $a->get_baseurl().'/display/'.$itemdata["nick"].'/'.$itemdata["id"];
24 goaway($note['link']);
27 goaway($a->get_baseurl(true));
30 if($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all' ) {
31 $r = $nm->setAllSeen();
32 $j = json_encode(array('result' => ($r) ? 'success' : 'fail'));
39 function notify_content(&$a) {
40 if(! local_user()) return login();
42 $nm = new NotificationsManager();
44 $notif_tpl = get_markup_template('notifications.tpl');
46 $not_tpl = get_markup_template('notify.tpl');
47 require_once('include/bbcode.php');
49 $r = $nm->getAll(array('seen'=>0));
50 if ($r!==false && count($r) > 0) {
52 $notif_content .= replace_macros($not_tpl,array(
53 '$item_link' => $a->get_baseurl(true).'/notify/view/'. $it['id'],
54 '$item_image' => $it['photo'],
55 '$item_text' => strip_tags(bbcode($it['msg'])),
56 '$item_when' => relative_date($it['date'])
60 $notif_content .= t('No more system notifications.');
63 $o .= replace_macros($notif_tpl, array(
64 '$notif_header' => t('System Notifications'),
65 '$tabs' => false, // $tabs,
66 '$notif_content' => $notif_content,