summaryrefslogtreecommitdiff
path: root/app/Controller
diff options
context:
space:
mode:
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
+ );
+ }
+}