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 | |
parent | 98b203fe691ec1ea9d6d19e916827185b575b05a (diff) |
Make user notifications pluggable
Diffstat (limited to 'app/Controller')
-rw-r--r-- | app/Controller/App.php | 2 | ||||
-rw-r--r-- | app/Controller/User.php | 10 | ||||
-rw-r--r-- | app/Controller/WebNotification.php (renamed from app/Controller/Webnotification.php) | 21 |
3 files changed, 22 insertions, 11 deletions
diff --git a/app/Controller/App.php b/app/Controller/App.php index 50ac1d32..3f3f0176 100644 --- a/app/Controller/App.php +++ b/app/Controller/App.php @@ -198,7 +198,7 @@ class App extends Base $this->response->html($this->layout('app/notifications', array( 'title' => t('My notifications'), - 'notifications' => $this->webNotification->getAll($user['id']), + 'notifications' => $this->userUnreadNotification->getAll($user['id']), 'user' => $user, ))); } diff --git a/app/Controller/User.php b/app/Controller/User.php index 15e9a0ee..7444ed82 100644 --- a/app/Controller/User.php +++ b/app/Controller/User.php @@ -96,7 +96,7 @@ class User extends Base $this->projectPermission->addMember($project_id, $user_id); if (! empty($values['notifications_enabled'])) { - $this->notificationType->saveUserSelectedTypes($user_id, array(NotificationType::TYPE_EMAIL)); + $this->userNotificationType->saveSelectedTypes($user_id, array(NotificationType::TYPE_EMAIL)); } $this->session->flash(t('User created successfully.')); @@ -201,16 +201,16 @@ class User extends Base if ($this->request->isPost()) { $values = $this->request->getValues(); - $this->notification->saveSettings($user['id'], $values); + $this->userNotification->saveSettings($user['id'], $values); $this->session->flash(t('User updated successfully.')); $this->response->redirect($this->helper->url->to('user', 'notifications', array('user_id' => $user['id']))); } $this->response->html($this->layout('user/notifications', array( 'projects' => $this->projectPermission->getMemberProjects($user['id']), - 'notifications' => $this->notification->readSettings($user['id']), - 'types' => $this->notificationType->getTypes(), - 'filters' => $this->notificationFilter->getFilters(), + 'notifications' => $this->userNotification->readSettings($user['id']), + 'types' => $this->userNotificationType->getTypes(), + 'filters' => $this->userNotificationFilter->getFilters(), 'user' => $user, ))); } diff --git a/app/Controller/Webnotification.php b/app/Controller/WebNotification.php index 52e3f266..dca5cb46 100644 --- a/app/Controller/Webnotification.php +++ b/app/Controller/WebNotification.php @@ -8,7 +8,7 @@ namespace Kanboard\Controller; * @package controller * @author Frederic Guillot */ -class Webnotification extends Base +class WebNotification extends Base { /** * Mark all notifications as read @@ -17,9 +17,9 @@ class Webnotification extends Base */ public function flush() { - $user_id = $this->userSession->getId(); + $user_id = $this->getUserId(); - $this->webNotification->markAllAsRead($user_id); + $this->userUnreadNotification->markAllAsRead($user_id); $this->response->redirect($this->helper->url->to('app', 'notifications', array('user_id' => $user_id))); } @@ -30,10 +30,21 @@ class Webnotification extends Base */ public function remove() { - $user_id = $this->userSession->getId(); + $user_id = $this->getUserId(); $notification_id = $this->request->getIntegerParam('notification_id'); - $this->webNotification->markAsRead($user_id, $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; + } } |