From 9eeded33f68872515954a2fc177fcb47a9273ae9 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Fri, 15 Aug 2014 17:23:41 -0700 Subject: Add email notifications --- app/Event/BaseNotificationListener.php | 76 +++++++++++++++++++++++++++++++ app/Event/CommentNotificationListener.php | 30 ++++++++++++ app/Event/FileNotificationListener.php | 30 ++++++++++++ app/Event/SubTaskNotificationListener.php | 30 ++++++++++++ app/Event/TaskNotificationListener.php | 29 ++++++++++++ 5 files changed, 195 insertions(+) create mode 100644 app/Event/BaseNotificationListener.php create mode 100644 app/Event/CommentNotificationListener.php create mode 100644 app/Event/FileNotificationListener.php create mode 100644 app/Event/SubTaskNotificationListener.php create mode 100644 app/Event/TaskNotificationListener.php (limited to 'app/Event') diff --git a/app/Event/BaseNotificationListener.php b/app/Event/BaseNotificationListener.php new file mode 100644 index 00000000..6c1728cb --- /dev/null +++ b/app/Event/BaseNotificationListener.php @@ -0,0 +1,76 @@ +template = $template; + $this->notification = $notification; + } + + /** + * Execute the action + * + * @access public + * @param array $data Event data dictionary + * @return bool True if the action was executed or false when not executed + */ + public function execute(array $data) + { + $values = $this->getTemplateData($data); + + // Get the list of users to be notified + $users = $this->notification->getUsersList($values['task']['project_id']); + + // Send notifications + if ($users) { + $this->notification->sendEmails($this->template, $users, $values); + return true; + } + + return false; + } +} diff --git a/app/Event/CommentNotificationListener.php b/app/Event/CommentNotificationListener.php new file mode 100644 index 00000000..3771ea7e --- /dev/null +++ b/app/Event/CommentNotificationListener.php @@ -0,0 +1,30 @@ +notification->comment->getById($data['id']); + $values['task'] = $this->notification->task->getById($data['task_id'], true); + + return $values; + } +} diff --git a/app/Event/FileNotificationListener.php b/app/Event/FileNotificationListener.php new file mode 100644 index 00000000..98fc4260 --- /dev/null +++ b/app/Event/FileNotificationListener.php @@ -0,0 +1,30 @@ +notification->task->getById($data['task_id'], true); + + return $values; + } +} diff --git a/app/Event/SubTaskNotificationListener.php b/app/Event/SubTaskNotificationListener.php new file mode 100644 index 00000000..0a239421 --- /dev/null +++ b/app/Event/SubTaskNotificationListener.php @@ -0,0 +1,30 @@ +notification->subtask->getById($data['id'], true); + $values['task'] = $this->notification->task->getById($data['task_id'], true); + + return $values; + } +} diff --git a/app/Event/TaskNotificationListener.php b/app/Event/TaskNotificationListener.php new file mode 100644 index 00000000..ffbe7a8c --- /dev/null +++ b/app/Event/TaskNotificationListener.php @@ -0,0 +1,29 @@ +notification->task->getById($data['task_id'], true); + + return $values; + } +} -- cgit v1.2.3