Add web notifications
This commit is contained in:
@@ -187,6 +187,22 @@ class App extends Base
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* My notifications
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
public function notifications()
|
||||
{
|
||||
$user = $this->getUser();
|
||||
|
||||
$this->response->html($this->layout('app/notifications', array(
|
||||
'title' => t('My notifications'),
|
||||
'notifications' => $this->webNotification->getAll($user['id']),
|
||||
'user' => $user,
|
||||
)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Render Markdown text and reply with the HTML Code
|
||||
*
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
|
||||
namespace Controller;
|
||||
|
||||
use Model\NotificationType;
|
||||
|
||||
/**
|
||||
* User controller
|
||||
*
|
||||
@@ -92,6 +94,11 @@ class User extends Base
|
||||
|
||||
if ($user_id !== false) {
|
||||
$this->projectPermission->addMember($project_id, $user_id);
|
||||
|
||||
if (! empty($values['notifications_enabled'])) {
|
||||
$this->notificationType->saveUserSelectedTypes($user_id, array(NotificationType::TYPE_EMAIL));
|
||||
}
|
||||
|
||||
$this->session->flash(t('User created successfully.'));
|
||||
$this->response->redirect($this->helper->url->to('user', 'show', array('user_id' => $user_id)));
|
||||
}
|
||||
@@ -202,6 +209,8 @@ class User extends Base
|
||||
$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(),
|
||||
'user' => $user,
|
||||
)));
|
||||
}
|
||||
|
||||
39
app/Controller/Webnotification.php
Normal file
39
app/Controller/Webnotification.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace 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->userSession->getId();
|
||||
|
||||
$this->webNotification->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->userSession->getId();
|
||||
$notification_id = $this->request->getIntegerParam('notification_id');
|
||||
|
||||
$this->webNotification->markAsRead($user_id, $notification_id);
|
||||
$this->response->redirect($this->helper->url->to('app', 'notifications', array('user_id' => $user_id)));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user