diff --git a/application/Espo/Controllers/Notification.php b/application/Espo/Controllers/Notification.php index 3c2f82379b..03811feadf 100644 --- a/application/Espo/Controllers/Notification.php +++ b/application/Espo/Controllers/Notification.php @@ -54,7 +54,13 @@ class Notification extends \Espo\Core\Controllers\Base public function actionNotReadCount() { $userId = $this->getUser()->id; - return $this->getService('Notification')->getNotReadCount($userId); + return $this->getService('Notification')->getNotReadCount($userId); + } + + public function actionMarkAllRead($params, $data, $request) + { + $userId = $this->getUser()->id; + return $this->getService('Notification')->markAllRead($userId); } } diff --git a/application/Espo/Resources/i18n/en_US/Global.json b/application/Espo/Resources/i18n/en_US/Global.json index 844cce3b28..c00b12156f 100644 --- a/application/Espo/Resources/i18n/en_US/Global.json +++ b/application/Espo/Resources/i18n/en_US/Global.json @@ -114,7 +114,8 @@ "Administration": "Administration", "Run Import": "Run Import", "Duplicate": "Duplicate", - "Notifications": "Notifications" + "Notifications": "Notifications", + "Mark all read": "Mark all read" }, "messages": { "notModified": "You have not modified the record", diff --git a/application/Espo/Services/Notification.php b/application/Espo/Services/Notification.php index 842616d114..fb282af174 100644 --- a/application/Espo/Services/Notification.php +++ b/application/Espo/Services/Notification.php @@ -84,6 +84,14 @@ class Notification extends \Espo\Core\Services\Base ))->count(); } + public function markAllRead($userId) + { + $pdo = $this->getEntityManager()->getPDO(); + $sql = "UPDATE notification SET `read` = 1 WHERE user_id = ".$pdo->quote($userId)." AND `read` = 0"; + $pdo->prepare($sql)->execute(); + return true; + } + public function getList($userId, array $params = array()) { $searchParams = array(); diff --git a/frontend/client/res/templates/notifications/panel.tpl b/frontend/client/res/templates/notifications/panel.tpl index e8907a370f..3e8c537a30 100644 --- a/frontend/client/res/templates/notifications/panel.tpl +++ b/frontend/client/res/templates/notifications/panel.tpl @@ -1,5 +1,5 @@