summaryrefslogtreecommitdiff
path: root/app/Controller/ProjectPredefinedContentController.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2017-10-30 16:46:39 -0700
committerFrederic Guillot <fred@kanboard.net>2017-10-30 16:46:39 -0700
commit48b40ec7bff777ca9c4c7ec2f91c8e803baab57b (patch)
tree7681c558f97daf8f6425315a4ba6ee8dc817e36d /app/Controller/ProjectPredefinedContentController.php
parent0a3f2a6a32677e1c5a12a140d2a3a865cb71a2ac (diff)
Add section for predefined contents
Diffstat (limited to 'app/Controller/ProjectPredefinedContentController.php')
-rw-r--r--app/Controller/ProjectPredefinedContentController.php61
1 files changed, 61 insertions, 0 deletions
diff --git a/app/Controller/ProjectPredefinedContentController.php b/app/Controller/ProjectPredefinedContentController.php
new file mode 100644
index 00000000..1195dfa3
--- /dev/null
+++ b/app/Controller/ProjectPredefinedContentController.php
@@ -0,0 +1,61 @@
+<?php
+
+namespace Kanboard\Controller;
+
+/**
+ * Project Predefined Content Controller
+ *
+ * @package Kanboard\Controller
+ * @author Frederic Guillot
+ */
+class ProjectPredefinedContentController extends BaseController
+{
+ /**
+ * Edit project
+ *
+ * @access public
+ * @param array $values
+ * @param array $errors
+ */
+ public function show(array $values = array(), array $errors = array())
+ {
+ $project = $this->getProject();
+
+ $this->response->html($this->helper->layout->project('project_predefined_content/show', array(
+ 'values' => empty($values) ? $project : $values,
+ 'errors' => $errors,
+ 'project' => $project,
+ 'title' => t('Predefined Contents')
+ )));
+ }
+
+ /**
+ * Validate and update a project
+ *
+ * @access public
+ */
+ public function update()
+ {
+ $project = $this->getProject();
+ $values = $this->request->getValues();
+
+ $values = array(
+ 'id' => $project['id'],
+ 'name' => $project['name'],
+ 'predefined_email_subjects' => isset($values['predefined_email_subjects']) ? $values['predefined_email_subjects'] : '',
+ );
+
+ list($valid, $errors) = $this->projectValidator->validateModification($values);
+
+ if ($valid) {
+ if ($this->projectModel->update($values)) {
+ $this->flash->success(t('Project updated successfully.'));
+ return $this->response->redirect($this->helper->url->to('ProjectPredefinedContentController', 'show', array('project_id' => $project['id'])), true);
+ } else {
+ $this->flash->failure(t('Unable to update this project.'));
+ }
+ }
+
+ return $this->show($values, $errors);
+ }
+}