summaryrefslogtreecommitdiff
path: root/app/Controller
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2017-02-18 20:21:48 -0500
committerFrederic Guillot <fred@kanboard.net>2017-02-18 20:21:48 -0500
commit11a774e555786182dd634676811e3c58f316dad0 (patch)
tree4dd0092b45d15d1c6ae1db613e37eb9bb009c0ec /app/Controller
parent93c05371a882b3c07d16457479129e42a2999492 (diff)
Send tasks by email
Diffstat (limited to 'app/Controller')
-rw-r--r--app/Controller/TaskMailController.php55
1 files changed, 55 insertions, 0 deletions
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 @@
+<?php
+
+namespace Kanboard\Controller;
+
+/**
+ * Class TaskMailController
+ *
+ * @package Kanboard\Controller
+ * @author Frederic Guillot
+ */
+class TaskMailController extends BaseController
+{
+ public function create(array $values = array(), array $errors = array())
+ {
+ $project = $this->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
+ );
+ }
+}