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']),
22 $friendicamobile = ($_SERVER['HTTP_USER_AGENT'] == "Apache-HttpClient/UNAVAILABLE (java 1.4)");
24 // The friendica client has problems with the GUID. this is some workaround
25 if ($friendicamobile) {
26 require_once("include/items.php");
27 $urldata = parse_url($r[0]['link']);
28 $guid = basename($urldata["path"]);
29 $itemdata = get_item_id($guid, local_user());
30 if ($itemdata["id"] != 0)
31 $r[0]['link'] = $a->get_baseurl().'/display/'.$itemdata["nick"].'/'.$itemdata["id"];
34 goaway($r[0]['link']);
37 goaway($a->get_baseurl(true));
40 if($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all' ) {
41 $r = q("update notify set seen = 1 where uid = %d",
44 $j = json_encode(array('result' => ($r) ? 'success' : 'fail'));
52 function notify_content(&$a) {
56 $notif_tpl = get_markup_template('notifications.tpl');
58 $not_tpl = get_markup_template('notify.tpl');
59 require_once('include/bbcode.php');
61 $r = q("SELECT * from notify where uid = %d and seen = 0 order by date desc",
67 $notif_content .= replace_macros($not_tpl,array(
68 '$item_link' => $a->get_baseurl(true).'/notify/view/'. $it['id'],
69 '$item_image' => $it['photo'],
70 '$item_text' => strip_tags(bbcode($it['msg'])),
71 '$item_when' => relative_date($it['date'])
75 $notif_content .= t('No more system notifications.');
78 $o .= replace_macros($notif_tpl, array(
79 '$notif_header' => t('System Notifications'),
80 '$tabs' => '', // $tabs,
81 '$notif_content' => $notif_content,