summaryrefslogtreecommitdiff
path: root/app/Controller/GroupCreationController.php
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-05-16 20:19:07 -0400
committerFrederic Guillot <fred@kanboard.net>2016-05-16 20:19:07 -0400
commitabdf6f97800e7e838b5841820815385b183bab67 (patch)
tree75576da4a975561d0b93c7bcc7be94a385a4cd75 /app/Controller/GroupCreationController.php
parentde8ce875f4295e0b3bef20fcca051401f96816ef (diff)
Improve group controllers and views
Diffstat (limited to 'app/Controller/GroupCreationController.php')
-rw-r--r--app/Controller/GroupCreationController.php49
1 files changed, 49 insertions, 0 deletions
diff --git a/app/Controller/GroupCreationController.php b/app/Controller/GroupCreationController.php
new file mode 100644
index 00000000..7d0bb93c
--- /dev/null
+++ b/app/Controller/GroupCreationController.php
@@ -0,0 +1,49 @@
+<?php
+
+namespace Kanboard\Controller;
+
+/**
+ * Class GroupCreationController
+ *
+ * @package Kanboard\Controller
+ * @author Frederic Guillot
+ */
+class GroupCreationController extends BaseController
+{
+ /**
+ * Display a form to create a new group
+ *
+ * @access public
+ * @param array $values
+ * @param array $errors
+ */
+ public function show(array $values = array(), array $errors = array())
+ {
+ $this->response->html($this->template->render('group_creation/show', array(
+ 'errors' => $errors,
+ 'values' => $values,
+ )));
+ }
+
+ /**
+ * Validate and save a new group
+ *
+ * @access public
+ */
+ public function save()
+ {
+ $values = $this->request->getValues();
+ list($valid, $errors) = $this->groupValidator->validateCreation($values);
+
+ if ($valid) {
+ if ($this->group->create($values['name']) !== false) {
+ $this->flash->success(t('Group created successfully.'));
+ return $this->response->redirect($this->helper->url->to('GroupListController', 'index'), true);
+ } else {
+ $this->flash->failure(t('Unable to create your group.'));
+ }
+ }
+
+ return $this->show($values, $errors);
+ }
+}