summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-07-01 12:33:18 -0400
committerFrederic Guillot <fred@kanboard.net>2016-07-01 12:33:18 -0400
commitabdfa46cfcc06175dea10b5e285fe5b2331b6ead (patch)
tree0303dc234f542acd4273e9b8b304577ea21ba19e /app
parent662506941f6ad00be535c3d854f3500bc12676de (diff)
Fixed empty title for web notification with only one overdue task
Diffstat (limited to 'app')
-rw-r--r--app/Console/TaskOverdueNotificationCommand.php2
-rw-r--r--app/Controller/WebNotificationController.php4
-rw-r--r--app/Model/NotificationModel.php37
-rw-r--r--app/Template/dashboard/notifications.php6
4 files changed, 42 insertions, 7 deletions
diff --git a/app/Console/TaskOverdueNotificationCommand.php b/app/Console/TaskOverdueNotificationCommand.php
index 225a6a1a..36276615 100644
--- a/app/Console/TaskOverdueNotificationCommand.php
+++ b/app/Console/TaskOverdueNotificationCommand.php
@@ -149,7 +149,7 @@ class TaskOverdueNotificationCommand extends BaseCommand
$this->userNotificationModel->sendUserNotification(
$user,
TaskModel::EVENT_OVERDUE,
- array('tasks' => $user_tasks, 'project_name' => implode(", ", $project_names))
+ array('tasks' => $user_tasks, 'project_name' => implode(', ', $project_names))
);
}
}
diff --git a/app/Controller/WebNotificationController.php b/app/Controller/WebNotificationController.php
index 46a42063..30e317f8 100644
--- a/app/Controller/WebNotificationController.php
+++ b/app/Controller/WebNotificationController.php
@@ -54,14 +54,14 @@ class WebNotificationController extends BaseController
$this->response->redirect($this->helper->url->to(
'TaskViewController',
'show',
- array('task_id' => $notification['event_data']['task']['id'], 'project_id' => $notification['event_data']['task']['project_id']),
+ array('task_id' => $this->notificationModel->getTaskIdFromEvent($notification['event_name'], $notification['event_data'])),
'comment-'.$notification['event_data']['comment']['id']
));
} else {
$this->response->redirect($this->helper->url->to(
'TaskViewController',
'show',
- array('task_id' => $notification['event_data']['task']['id'], 'project_id' => $notification['event_data']['task']['project_id'])
+ array('task_id' => $this->notificationModel->getTaskIdFromEvent($notification['event_name'], $notification['event_data']))
));
}
}
diff --git a/app/Model/NotificationModel.php b/app/Model/NotificationModel.php
index 8937b77e..4d697b5e 100644
--- a/app/Model/NotificationModel.php
+++ b/app/Model/NotificationModel.php
@@ -133,4 +133,41 @@ class NotificationModel extends Base
return e('Notification');
}
}
+
+ /**
+ * Get task id from event
+ *
+ * @access public
+ * @param string $event_name
+ * @param array $event_data
+ * @return integer
+ */
+ public function getTaskIdFromEvent($event_name, array $event_data)
+ {
+ switch ($event_name) {
+ case TaskFileModel::EVENT_CREATE:
+ return $event_data['file']['task_id'];
+ case CommentModel::EVENT_CREATE:
+ case CommentModel::EVENT_UPDATE:
+ return $event_data['comment']['task_id'];
+ case SubtaskModel::EVENT_CREATE:
+ case SubtaskModel::EVENT_UPDATE:
+ return $event_data['subtask']['task_id'];
+ case TaskModel::EVENT_CREATE:
+ case TaskModel::EVENT_UPDATE:
+ case TaskModel::EVENT_CLOSE:
+ case TaskModel::EVENT_OPEN:
+ case TaskModel::EVENT_MOVE_COLUMN:
+ case TaskModel::EVENT_MOVE_POSITION:
+ case TaskModel::EVENT_MOVE_SWIMLANE:
+ case TaskModel::EVENT_ASSIGNEE_CHANGE:
+ case CommentModel::EVENT_USER_MENTION:
+ case TaskModel::EVENT_USER_MENTION:
+ return $event_data['task']['id'];
+ case TaskModel::EVENT_OVERDUE:
+ return $event_data['tasks'][0]['id'];
+ default:
+ return 0;
+ }
+ }
}
diff --git a/app/Template/dashboard/notifications.php b/app/Template/dashboard/notifications.php
index e0e9b878..3b70b49f 100644
--- a/app/Template/dashboard/notifications.php
+++ b/app/Template/dashboard/notifications.php
@@ -36,10 +36,8 @@
<i class="fa fa-file-o fa-fw"></i>
<?php endif ?>
- <?php if ($this->text->contains($notification['event_name'], 'task.overdue')): ?>
- <?php if (count($notification['event_data']['tasks']) > 1): ?>
- <?= $notification['title'] ?>
- <?php endif ?>
+ <?php if ($this->text->contains($notification['event_name'], 'task.overdue') && count($notification['event_data']['tasks']) > 1): ?>
+ <?= $notification['title'] ?>
<?php else: ?>
<?= $this->url->link($notification['title'], 'WebNotificationController', 'redirect', array('notification_id' => $notification['id'], 'user_id' => $user['id'])) ?>
<?php endif ?>