Make user notifications pluggable

This commit is contained in:
Frederic Guillot
2015-10-17 09:51:15 -04:00
parent 98b203fe69
commit 73a5b9bc75
25 changed files with 407 additions and 258 deletions

View File

@@ -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,
)));
}

View File

@@ -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,
)));
}

View File

@@ -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;
}
}