aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module/Notifications.php
blob: 2db02c758c8ea6bf21292594ed3c2d94901344e4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace Zotlabs\Module;

require_once('include/bbcode.php');

class Notifications extends \Zotlabs\Web\Controller {

	function get() {
	
		if(! local_channel()) {
			notice( t('Permission denied.') . EOL);
			return;
		}
	
		nav_set_selected('notifications');		
	
		$o = '';
		
		$r = q("SELECT * from notify where uid = %d and seen = 0 order by created desc",
			intval(local_channel())
		);
			
		if($r) {
			$notifications_available = 1;
			foreach ($r as $it) {
				$notif_content .= replace_macros(get_markup_template('notify.tpl'),array(
					'$item_link' => z_root().'/notify/view/'. $it['id'],
					'$item_image' => $it['photo'],
					'$item_text' => strip_tags(bbcode($it['msg'])),
					'$item_when' => relative_date($it['created'])
				));
			}
		}
		else {
			$notif_content .= t('No more system notifications.');
		}
			
		$o .= replace_macros(get_markup_template('notifications.tpl'),array(
			'$notif_header' => t('System Notifications'),
			'$notif_link_mark_seen' => t('Mark all system notifications seen'),
			'$notif_content' => $notif_content,
			'$notifications_available' => $notifications_available,
		));
	
		return $o;
	}
	
}