From d67d7c54e65e80d1b484490e42dbecb969aa7686 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 3 Oct 2015 12:09:27 -0400 Subject: Add web notifications --- app/Template/app/notifications.php | 61 +++++++++++++++++++++++++++++++++++++ app/Template/app/sidebar.php | 3 ++ app/Template/header.php | 4 +++ app/Template/user/create_local.php | 2 +- app/Template/user/create_remote.php | 2 +- app/Template/user/notifications.php | 27 ++++++---------- app/Template/user/sidebar.php | 2 +- 7 files changed, 80 insertions(+), 21 deletions(-) create mode 100644 app/Template/app/notifications.php (limited to 'app/Template') diff --git a/app/Template/app/notifications.php b/app/Template/app/notifications.php new file mode 100644 index 00000000..4f7dd353 --- /dev/null +++ b/app/Template/app/notifications.php @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + +
+ text->contains($notification['event_name'], 'subtask')): ?> + + text->contains($notification['event_name'], 'task.move')): ?> + + text->contains($notification['event_name'], 'task.overdue')): ?> + + text->contains($notification['event_name'], 'task')): ?> + + text->contains($notification['event_name'], 'comment')): ?> + + text->contains($notification['event_name'], 'file')): ?> + + + + text->contains($notification['event_name'], 'comment')): ?> + url->link($notification['title'], 'task', 'show', array('task_id' => $notification['event_data']['task']['id'], 'project_id' => $notification['event_data']['task']['project_id']), false, '', '', false, 'comment-'.$notification['event_data']['comment']['id']) ?> + text->contains($notification['event_name'], 'task.overdue')): ?> + 1): ?> + + + url->link($notification['title'], 'task', 'show', array('task_id' => $notification['event_data']['tasks'][0]['id'], 'project_id' => $notification['event_data']['tasks'][0]['project_id'])) ?> + + + url->link($notification['title'], 'task', 'show', array('task_id' => $notification['event_data']['task']['id'], 'project_id' => $notification['event_data']['task']['project_id'])) ?> + + + + + + url->link(t('Mark as read'), 'webnotification', 'remove', array('user_id' => $user['id'], 'notification_id' => $notification['id'])) ?> +
+ \ No newline at end of file diff --git a/app/Template/app/sidebar.php b/app/Template/app/sidebar.php index c1de0dbe..552a9c27 100644 --- a/app/Template/app/sidebar.php +++ b/app/Template/app/sidebar.php @@ -19,6 +19,9 @@
  • app->getRouterAction() === 'activity' ? 'class="active"' : '' ?>> url->link(t('My activity stream'), 'app', 'activity', array('user_id' => $user['id'])) ?>
  • +
  • app->getRouterAction() === 'notifications' ? 'class="active"' : '' ?>> + url->link(t('My notifications'), 'app', 'notifications', array('user_id' => $user['id'])) ?> +
  • hook->render('template:dashboard:sidebar') ?> diff --git a/app/Template/header.php b/app/Template/header.php index 0bcfdbbc..19ffbbf5 100644 --- a/app/Template/header.php +++ b/app/Template/header.php @@ -25,6 +25,10 @@
  • + user->hasNotifications()): ?> + url->link('', 'app', 'notifications', array('user_id' => $this->user->getId()), false, '', t('Unread notifications')) ?> + + url->link(t('Logout'), 'auth', 'logout') ?> (user->getProfileLink() ?>)
  • diff --git a/app/Template/user/create_local.php b/app/Template/user/create_local.php index 3c8b43b0..98c38f0d 100644 --- a/app/Template/user/create_local.php +++ b/app/Template/user/create_local.php @@ -37,7 +37,7 @@ form->label(t('Language'), 'language') ?> form->select('language', $languages, $values, $errors) ?>
    - form->checkbox('notifications_enabled', t('Enable notifications'), 1, isset($values['notifications_enabled']) && $values['notifications_enabled'] == 1 ? true : false) ?> + form->checkbox('notifications_enabled', t('Enable email notifications'), 1, isset($values['notifications_enabled']) && $values['notifications_enabled'] == 1 ? true : false) ?> form->checkbox('is_admin', t('Administrator'), 1, isset($values['is_admin']) && $values['is_admin'] == 1 ? true : false) ?> form->checkbox('is_project_admin', t('Project Administrator'), 1, isset($values['is_project_admin']) && $values['is_project_admin'] == 1 ? true : false) ?> diff --git a/app/Template/user/create_remote.php b/app/Template/user/create_remote.php index 559d3d72..49d1548c 100644 --- a/app/Template/user/create_remote.php +++ b/app/Template/user/create_remote.php @@ -40,7 +40,7 @@ form->label(t('Language'), 'language') ?> form->select('language', $languages, $values, $errors) ?>
    - form->checkbox('notifications_enabled', t('Enable notifications'), 1, isset($values['notifications_enabled']) && $values['notifications_enabled'] == 1 ? true : false) ?> + form->checkbox('notifications_enabled', t('Enable email notifications'), 1, isset($values['notifications_enabled']) && $values['notifications_enabled'] == 1 ? true : false) ?> form->checkbox('is_admin', t('Administrator'), 1, isset($values['is_admin']) && $values['is_admin'] == 1 ? true : false) ?> form->checkbox('is_project_admin', t('Project Administrator'), 1, isset($values['is_project_admin']) && $values['is_project_admin'] == 1 ? true : false) ?> form->checkbox('disable_login_form', t('Disallow login form'), 1, isset($values['disable_login_form']) && $values['disable_login_form'] == 1) ?> diff --git a/app/Template/user/notifications.php b/app/Template/user/notifications.php index a425705d..7223013c 100644 --- a/app/Template/user/notifications.php +++ b/app/Template/user/notifications.php @@ -1,33 +1,24 @@
    form->csrf() ?> - form->checkbox('notifications_enabled', t('Enable email notifications'), '1', $notifications['notifications_enabled'] == 1) ?>
    + form->checkbox('notifications_enabled', t('Enable notifications'), '1', $notifications['notifications_enabled'] == 1) ?>

    - - - - form->radios('notifications_filter', array( - \Model\Notification::FILTER_NONE => t('All tasks'), - \Model\Notification::FILTER_ASSIGNEE => t('Only for tasks assigned to me'), - \Model\Notification::FILTER_CREATOR => t('Only for tasks created by me'), - \Model\Notification::FILTER_BOTH => t('Only for tasks created by me and assigned to me'), - ), $notifications) ?>
    +

    + form->checkboxes('notification_types', $types, $notifications) ?>
    +

    + form->radios('notifications_filter', $filters, $notifications) ?> +
    -



    - -
    - $project_name): ?> - form->checkbox('projects['.$project_id.']', $project_name, '1', isset($notifications['project_'.$project_id])) ?>
    - -
    +

    + form->checkboxes('notification_projects', $projects, $notifications) ?>
    diff --git a/app/Template/user/sidebar.php b/app/Template/user/sidebar.php index 640c8b80..ca1e0621 100644 --- a/app/Template/user/sidebar.php +++ b/app/Template/user/sidebar.php @@ -51,7 +51,7 @@ url->link(t('Public access'), 'user', 'share', array('user_id' => $user['id'])) ?>
  • app->getRouterController() === 'user' && $this->app->getRouterAction() === 'notifications' ? 'class="active"' : '' ?>> - url->link(t('Email notifications'), 'user', 'notifications', array('user_id' => $user['id'])) ?> + url->link(t('Notifications'), 'user', 'notifications', array('user_id' => $user['id'])) ?>
  • app->getRouterController() === 'user' && $this->app->getRouterAction() === 'external' ? 'class="active"' : '' ?>> url->link(t('External accounts'), 'user', 'external', array('user_id' => $user['id'])) ?> -- cgit v1.2.3