diff options
author | Frederic Guillot <fred@kanboard.net> | 2015-10-17 09:51:15 -0400 |
---|---|---|
committer | Frederic Guillot <fred@kanboard.net> | 2015-10-17 09:51:15 -0400 |
commit | 73a5b9bc75d40a30e7c9674b292957657ac01f63 (patch) | |
tree | ff5bb8a90452a2ff1351c192575e5d241a8b4417 /app/Controller/WebNotification.php | |
parent | 98b203fe691ec1ea9d6d19e916827185b575b05a (diff) |
Make user notifications pluggable
Diffstat (limited to 'app/Controller/WebNotification.php')
-rw-r--r-- | app/Controller/WebNotification.php | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/app/Controller/WebNotification.php b/app/Controller/WebNotification.php new file mode 100644 index 00000000..dca5cb46 --- /dev/null +++ b/app/Controller/WebNotification.php @@ -0,0 +1,50 @@ +<?php + +namespace Kanboard\Controller; + +/** + * Web notification controller + * + * @package controller + * @author Frederic Guillot + */ +class WebNotification extends Base +{ + /** + * Mark all notifications as read + * + * @access public + */ + public function flush() + { + $user_id = $this->getUserId(); + + $this->userUnreadNotification->markAllAsRead($user_id); + $this->response->redirect($this->helper->url->to('app', 'notifications', array('user_id' => $user_id))); + } + + /** + * Mark a notification as read + * + * @access public + */ + public function remove() + { + $user_id = $this->getUserId(); + $notification_id = $this->request->getIntegerParam('notification_id'); + + $this->userUnreadNotification->markAsRead($user_id, $notification_id); + $this->response->redirect($this->helper->url->to('app', 'notifications', array('user_id' => $user_id))); + } + + private function getUserId() + { + $user_id = $this->request->getIntegerParam('user_id'); + + if (! $this->userSession->isAdmin() && $user_id != $this->userSession->getId()) { + $user_id = $this->userSession->getId(); + } + + return $user_id; + } +} |