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']),
20 goaway($r[0]['link']);
23 goaway($a->get_baseurl(true));
26 if($a->argc > 2 && $a->argv[1] === 'mark' && $a->argv[2] === 'all' ) {
27 $r = q("update notify set seen = 1 where uid = %d",
30 $j = json_encode(array('result' => ($r) ? 'success' : 'fail'));
38 function notify_content(&$a) {
42 $notif_tpl = get_markup_template('notifications.tpl');
44 $not_tpl = get_markup_template('notify.tpl');
45 require_once('include/bbcode.php');
47 $r = q("SELECT * from notify where uid = %d and seen = 0 order by date desc",
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' => '', // $tabs,
67 '$notif_content' => $notif_content,