streams/Zotlabs/Module/Notifications.php

49 lines
1.1 KiB
PHP
Raw Normal View History

2016-04-19 03:38:38 +00:00
<?php
namespace Zotlabs\Module;
2016-10-04 04:48:53 +00:00
require_once('include/bbcode.php');
2016-04-19 03:38:38 +00:00
class Notifications extends \Zotlabs\Web\Controller {
2016-10-04 04:48:53 +00:00
function get() {
2016-04-19 03:38:38 +00:00
if(! local_channel()) {
notice( t('Permission denied.') . EOL);
return;
}
nav_set_selected('notifications');
$o = '';
2016-10-04 04:48:53 +00:00
$r = q("SELECT * from notify where uid = %d and seen = 0 order by created desc",
intval(local_channel())
);
2016-04-19 03:38:38 +00:00
2016-10-04 04:48:53 +00:00
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'])
));
2016-04-19 03:38:38 +00:00
}
2016-10-04 04:48:53 +00:00
}
else {
$notif_content .= t('No more system notifications.');
}
2016-04-19 03:38:38 +00:00
2016-10-04 04:48:53 +00:00
$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,
));
2016-04-19 03:38:38 +00:00
return $o;
}
}