2 require_once('include/NotificationsManager.php');
3 if(! function_exists('notify_init')) {
4 function notify_init(&$a) {
5 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 if(! function_exists('notify_content')) {
40 function notify_content(&$a) {
41 if(! local_user()) return login();
43 $nm = new NotificationsManager();
45 $notif_tpl = get_markup_template('notifications.tpl');
47 $not_tpl = get_markup_template('notify.tpl');
48 require_once('include/bbcode.php');
50 $r = $nm->getAll(array('seen'=>0));
51 if ($r!==false && count($r) > 0) {
53 $notif_content .= replace_macros($not_tpl,array(
54 '$item_link' => $a->get_baseurl(true).'/notify/view/'. $it['id'],
55 '$item_image' => $it['photo'],
56 '$item_text' => strip_tags(bbcode($it['msg'])),
57 '$item_when' => relative_date($it['date'])
61 $notif_content .= t('No more system notifications.');
64 $o .= replace_macros($notif_tpl, array(
65 '$notif_header' => t('System Notifications'),
66 '$tabs' => false, // $tabs,
67 '$notif_content' => $notif_content,