4 function notify_init(&$a) {
8 if($a->argc > 2 && $a->argv[1] === 'view' && intval($a->argv[2])) {
9 $r = q("select * from notify where id = %d and uid = %d limit 1",
14 q("update notify set seen = 1 where ( link = '%s' or ( parent != 0 and parent = %d and otype = '%s' )) and uid = %d",
16 intval($r[0]['parent']),
17 dbesc($r[0]['otype']),
21 // The friendica client has problems with the GUID. this is some workaround
22 if ($a->is_friendica_app()) {
23 require_once("include/items.php");
24 $urldata = parse_url($r[0]['link']);
25 $guid = basename($urldata["path"]);
26 $itemdata = get_item_id($guid, local_user());
27 if ($itemdata["id"] != 0)
28 $r[0]['link'] = $a->get_baseurl().'/display/'.$itemdata["nick"].'/'.$itemdata["id"];
31 goaway($r[0]['link']);
34 goaway($a->get_baseurl(true));
37 if($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all' ) {
38 $r = q("update notify set seen = 1 where uid = %d",
41 $j = json_encode(array('result' => ($r) ? 'success' : 'fail'));
49 function notify_content(&$a) {
53 $notif_tpl = get_markup_template('notifications.tpl');
55 $not_tpl = get_markup_template('notify.tpl');
56 require_once('include/bbcode.php');
58 $r = q("SELECT * from notify where uid = %d and seen = 0 order by date desc",
64 $notif_content .= replace_macros($not_tpl,array(
65 '$item_link' => $a->get_baseurl(true).'/notify/view/'. $it['id'],
66 '$item_image' => $it['photo'],
67 '$item_text' => strip_tags(bbcode($it['msg'])),
68 '$item_when' => relative_date($it['date'])
72 $notif_content .= t('No more system notifications.');
75 $o .= replace_macros($notif_tpl, array(
76 '$notif_header' => t('System Notifications'),
77 '$tabs' => '', // $tabs,
78 '$notif_content' => $notif_content,