From 11a774e555786182dd634676811e3c58f316dad0 Mon Sep 17 00:00:00 2001 From: Frederic Guillot Date: Sat, 18 Feb 2017 20:21:48 -0500 Subject: Send tasks by email --- app/Controller/TaskMailController.php | 55 +++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 app/Controller/TaskMailController.php (limited to 'app/Controller') diff --git a/app/Controller/TaskMailController.php b/app/Controller/TaskMailController.php new file mode 100644 index 00000000..e95ddf03 --- /dev/null +++ b/app/Controller/TaskMailController.php @@ -0,0 +1,55 @@ +getProject(); + $task = $this->getTask(); + + $this->response->html($this->helper->layout->task('task_mail/create', array( + 'values' => $values, + 'errors' => $errors, + 'task' => $task, + 'project' => $project, + ))); + } + + public function send() + { + $task = $this->getTask(); + $values = $this->request->getValues(); + + list($valid, $errors) = $this->taskValidator->validateEmailCreation($values); + + if ($valid) { + $this->sendByEmail($values, $task); + $this->flash->success(t('Task sent by email successfully.')); + $this->response->redirect($this->helper->url->to('TaskViewController', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comments'), true); + } else { + $this->create($values, $errors); + } + } + + protected function sendByEmail(array $values, array $task) + { + $html = $this->template->render('task_mail/email', array( + 'task' => $task, + )); + + $this->emailClient->send( + $values['email'], + $values['email'], + $values['subject'], + $html + ); + } +} -- cgit v1.2.3