diff options
Diffstat (limited to 'Zotlabs/Module/Notify.php')
-rw-r--r-- | Zotlabs/Module/Notify.php | 54 |
1 files changed, 39 insertions, 15 deletions
diff --git a/Zotlabs/Module/Notify.php b/Zotlabs/Module/Notify.php index cffcc8099..4cbcfee05 100644 --- a/Zotlabs/Module/Notify.php +++ b/Zotlabs/Module/Notify.php @@ -1,14 +1,38 @@ <?php namespace Zotlabs\Module; +use \Zotlabs\Lib\PConfig; +use \Zotlabs\Web\Controller; - -class Notify extends \Zotlabs\Web\Controller { +class Notify extends Controller { function init() { if(! local_channel()) return; - + + if($_REQUEST['notify_id']) { + $update_notices_per_parent = PConfig::Get(local_channel(), 'system', 'update_notices_per_parent', 1); + + if($update_notices_per_parent) { + $r = q("SELECT parent FROM notify WHERE id = %d AND uid = %d", + intval($_REQUEST['notify_id']), + intval(local_channel()) + ); + q("update notify set seen = 1 where parent = '%s' and uid = %d", + dbesc($r[0]['parent']), + intval(local_channel()) + ); + } + else { + q("update notify set seen = 1 where id = %d and uid = %d", + intval($_REQUEST['notify_id']), + intval(local_channel()) + ); + } + + killme(); + } + if(argc() > 2 && argv(1) === 'view' && intval(argv(2))) { $r = q("select * from notify where id = %d and uid = %d limit 1", intval(argv(2)), @@ -29,24 +53,24 @@ class Notify extends \Zotlabs\Web\Controller { } goaway(z_root()); } - - + + } - - + + function get() { if(! local_channel()) return login(); - + $notif_tpl = get_markup_template('notifications.tpl'); - + $not_tpl = get_markup_template('notify.tpl'); require_once('include/bbcode.php'); - + $r = q("SELECT * from notify where uid = %d and seen = 0 order by created desc", intval(local_channel()) ); - + if($r) { foreach ($r as $it) { $notif_content .= replace_macros($not_tpl,array( @@ -56,18 +80,18 @@ class Notify extends \Zotlabs\Web\Controller { '$item_when' => relative_date($it['created']) )); } - } + } else { $notif_content .= t('No more system notifications.'); } - + $o .= replace_macros($notif_tpl,array( '$notif_header' => t('System Notifications'), '$tabs' => '', // $tabs, '$notif_content' => $notif_content, )); - + return $o; - + } } |