webui: Add ability to mark all notifications as read (#7489)

* feature: Add ability to mark all notifications as read

fixes:
https://community.librenms.org/t/ability-to-mark-all-notifications-as-re
ad/2368/1

* Do not add multiple read notifications_attribs

* not archive, yes non-admin

* Oops, hardcoded user_id
This commit is contained in:
Søren Rosiak
2017-11-29 04:22:53 +01:00
committed by Tony Murray
parent d362cd3368
commit 461b39e989
2 changed files with 37 additions and 1 deletions

View File

@@ -41,6 +41,12 @@ if (isset($_REQUEST['notification_id']) && isset($_REQUEST['action'])) {
$status = 'ok';
$message = 'Created';
}
} elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'read-all-notif') {
foreach (dbFetchRows("SELECT `notifications_id` FROM `notifications` LEFT JOIN `notifications_attribs` A USING (`notifications_id`) WHERE A.`notifications_id` IS NULL OR (`user_id`=? AND NOT (`key`='read' AND `value`=1))", array($_SESSION['user_id'])) as $notifications) {
dbInsert(array('notifications_id'=>$notifications['notifications_id'],'user_id'=>$_SESSION['user_id'],'key'=>'read','value'=>1), 'notifications_attribs');
}
$status = 'ok';
$message = 'All notifications set as read';
} else {
$status = 'error';
$message = 'ERROR: Missing Params';