summaryrefslogtreecommitdiff
path: root/app/Controller
diff options
context:
space:
mode:
author85pando <85pando@googlemail.com>2016-02-05 10:28:40 +0100
committer85pando <85pando@googlemail.com>2016-02-05 10:28:40 +0100
commit791d13c87bf510d913973b77a5f6d152311a1d87 (patch)
tree81412e8dbd3ac4fa0047030a6068afafd975687e /app/Controller
parent2074aaaa9a75455097e4e77ca09f4fba3e567052 (diff)
parent12aaec03b19a07635f59b00f532c92c37ac1df5f (diff)
Merge remote-tracking branch 'refs/remotes/upstream/master'
Conflicts: app/Locale/de_DE/translations.php
Diffstat (limited to 'app/Controller')
-rw-r--r--app/Controller/Action.php8
-rw-r--r--app/Controller/Activity.php5
-rw-r--r--app/Controller/Analytic.php29
-rw-r--r--app/Controller/App.php30
-rw-r--r--app/Controller/Auth.php2
-rw-r--r--app/Controller/Base.php64
-rw-r--r--app/Controller/Board.php4
-rw-r--r--app/Controller/BoardTooltip.php16
-rw-r--r--app/Controller/Calendar.php2
-rw-r--r--app/Controller/Category.php6
-rw-r--r--app/Controller/Column.php6
-rw-r--r--app/Controller/Comment.php33
-rw-r--r--app/Controller/Config.php36
-rw-r--r--app/Controller/Currency.php18
-rw-r--r--app/Controller/Customfilter.php4
-rw-r--r--app/Controller/Doc.php4
-rw-r--r--app/Controller/Export.php2
-rw-r--r--app/Controller/File.php16
-rw-r--r--app/Controller/Gantt.php22
-rw-r--r--app/Controller/Group.php19
-rw-r--r--app/Controller/Link.php22
-rw-r--r--app/Controller/Listing.php2
-rw-r--r--app/Controller/Oauth.php46
-rw-r--r--app/Controller/PasswordReset.php4
-rw-r--r--app/Controller/Project.php79
-rw-r--r--app/Controller/ProjectCreation.php125
-rw-r--r--app/Controller/ProjectEdit.php6
-rw-r--r--app/Controller/ProjectPermission.php58
-rw-r--r--app/Controller/Projectuser.php21
-rw-r--r--app/Controller/Search.php3
-rw-r--r--app/Controller/Subtask.php131
-rw-r--r--app/Controller/SubtaskRestriction.php61
-rw-r--r--app/Controller/SubtaskStatus.php28
-rw-r--r--app/Controller/Swimlane.php6
-rw-r--r--app/Controller/Task.php12
-rw-r--r--app/Controller/TaskExternalLink.php185
-rw-r--r--app/Controller/TaskImport.php2
-rw-r--r--app/Controller/TaskRecurrence.php61
-rw-r--r--app/Controller/Taskcreation.php36
-rw-r--r--app/Controller/Taskduplication.php10
-rw-r--r--app/Controller/Tasklink.php49
-rw-r--r--app/Controller/Taskmodification.php121
-rw-r--r--app/Controller/Taskstatus.php42
-rw-r--r--app/Controller/Twofactor.php8
-rw-r--r--app/Controller/User.php56
-rw-r--r--app/Controller/UserImport.php2
46 files changed, 787 insertions, 715 deletions
diff --git a/app/Controller/Action.php b/app/Controller/Action.php
index 645b53b7..482a210b 100644
--- a/app/Controller/Action.php
+++ b/app/Controller/Action.php
@@ -20,7 +20,7 @@ class Action extends Base
$project = $this->getProject();
$actions = $this->action->getAllByProject($project['id']);
- $this->response->html($this->projectLayout('action/index', array(
+ $this->response->html($this->helper->layout->project('action/index', array(
'values' => array('project_id' => $project['id']),
'project' => $project,
'actions' => $actions,
@@ -51,7 +51,7 @@ class Action extends Base
$this->response->redirect($this->helper->url->to('action', 'index', array('project_id' => $project['id'])));
}
- $this->response->html($this->projectLayout('action/event', array(
+ $this->response->html($this->helper->layout->project('action/event', array(
'values' => $values,
'project' => $project,
'events' => $this->actionManager->getCompatibleEvents($values['action_name']),
@@ -83,7 +83,7 @@ class Action extends Base
$projects_list = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
unset($projects_list[$project['id']]);
- $this->response->html($this->projectLayout('action/params', array(
+ $this->response->html($this->helper->layout->project('action/params', array(
'values' => $values,
'action_params' => $action_params,
'columns_list' => $this->board->getColumnsList($project['id']),
@@ -138,7 +138,7 @@ class Action extends Base
{
$project = $this->getProject();
- $this->response->html($this->projectLayout('action/remove', array(
+ $this->response->html($this->helper->layout->project('action/remove', array(
'action' => $this->action->getById($this->request->getIntegerParam('action_id')),
'available_events' => $this->eventManager->getAll(),
'available_actions' => $this->actionManager->getAvailableActions(),
diff --git a/app/Controller/Activity.php b/app/Controller/Activity.php
index 38658345..db520ebe 100644
--- a/app/Controller/Activity.php
+++ b/app/Controller/Activity.php
@@ -19,8 +19,7 @@ class Activity extends Base
{
$project = $this->getProject();
- $this->response->html($this->template->layout('activity/project', array(
- 'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
+ $this->response->html($this->helper->layout->app('activity/project', array(
'events' => $this->projectActivity->getProject($project['id']),
'project' => $project,
'title' => t('%s\'s activity', $project['name'])
@@ -36,7 +35,7 @@ class Activity extends Base
{
$task = $this->getTask();
- $this->response->html($this->taskLayout('activity/task', array(
+ $this->response->html($this->helper->layout->task('activity/task', array(
'title' => $task['title'],
'task' => $task,
'events' => $this->projectActivity->getTask($task['id']),
diff --git a/app/Controller/Analytic.php b/app/Controller/Analytic.php
index d203fb8e..e7ab9ebc 100644
--- a/app/Controller/Analytic.php
+++ b/app/Controller/Analytic.php
@@ -1,6 +1,7 @@
<?php
namespace Kanboard\Controller;
+
use Kanboard\Model\Task as TaskModel;
/**
@@ -12,22 +13,6 @@ use Kanboard\Model\Task as TaskModel;
class Analytic extends Base
{
/**
- * Common layout for analytic views
- *
- * @access private
- * @param string $template Template name
- * @param array $params Template parameters
- * @return string
- */
- private function layout($template, array $params)
- {
- $params['board_selector'] = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
- $params['content_for_sublayout'] = $this->template->render($template, $params);
-
- return $this->template->layout('analytic/layout', $params);
- }
-
- /**
* Show average Lead and Cycle time
*
* @access public
@@ -37,7 +22,7 @@ class Analytic extends Base
$project = $this->getProject();
list($from, $to) = $this->getDates();
- $this->response->html($this->layout('analytic/lead_cycle_time', array(
+ $this->response->html($this->helper->layout->analytic('analytic/lead_cycle_time', array(
'values' => array(
'from' => $from,
'to' => $to,
@@ -69,7 +54,7 @@ class Analytic extends Base
->setQuery($query)
->calculate();
- $this->response->html($this->layout('analytic/compare_hours', array(
+ $this->response->html($this->helper->layout->analytic('analytic/compare_hours', array(
'project' => $project,
'paginator' => $paginator,
'metrics' => $this->estimatedTimeComparisonAnalytic->build($project['id']),
@@ -86,7 +71,7 @@ class Analytic extends Base
{
$project = $this->getProject();
- $this->response->html($this->layout('analytic/avg_time_columns', array(
+ $this->response->html($this->helper->layout->analytic('analytic/avg_time_columns', array(
'project' => $project,
'metrics' => $this->averageTimeSpentColumnAnalytic->build($project['id']),
'title' => t('Average time spent into each column for "%s"', $project['name']),
@@ -102,7 +87,7 @@ class Analytic extends Base
{
$project = $this->getProject();
- $this->response->html($this->layout('analytic/tasks', array(
+ $this->response->html($this->helper->layout->analytic('analytic/tasks', array(
'project' => $project,
'metrics' => $this->taskDistributionAnalytic->build($project['id']),
'title' => t('Task repartition for "%s"', $project['name']),
@@ -118,7 +103,7 @@ class Analytic extends Base
{
$project = $this->getProject();
- $this->response->html($this->layout('analytic/users', array(
+ $this->response->html($this->helper->layout->analytic('analytic/users', array(
'project' => $project,
'metrics' => $this->userDistributionAnalytic->build($project['id']),
'title' => t('User repartition for "%s"', $project['name']),
@@ -160,7 +145,7 @@ class Analytic extends Base
$display_graph = $this->projectDailyColumnStats->countDays($project['id'], $from, $to) >= 2;
- $this->response->html($this->layout($template, array(
+ $this->response->html($this->helper->layout->analytic($template, array(
'values' => array(
'from' => $from,
'to' => $to,
diff --git a/app/Controller/App.php b/app/Controller/App.php
index bdd7fbcf..1ce74506 100644
--- a/app/Controller/App.php
+++ b/app/Controller/App.php
@@ -13,22 +13,6 @@ use Kanboard\Model\Subtask as SubtaskModel;
class App extends Base
{
/**
- * Common layout for dashboard views
- *
- * @access private
- * @param string $template Template name
- * @param array $params Template parameters
- * @return string
- */
- private function layout($template, array $params)
- {
- $params['board_selector'] = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
- $params['content_for_sublayout'] = $this->template->render($template, $params);
-
- return $this->template->layout('app/layout', $params);
- }
-
- /**
* Get project pagination
*
* @access private
@@ -101,7 +85,7 @@ class App extends Base
{
$user = $this->getUser();
- $this->response->html($this->layout('app/overview', array(
+ $this->response->html($this->helper->layout->dashboard('app/overview', array(
'title' => t('Dashboard'),
'project_paginator' => $this->getProjectPaginator($user['id'], 'index', 10),
'task_paginator' => $this->getTaskPaginator($user['id'], 'index', 10),
@@ -119,7 +103,7 @@ class App extends Base
{
$user = $this->getUser();
- $this->response->html($this->layout('app/tasks', array(
+ $this->response->html($this->helper->layout->dashboard('app/tasks', array(
'title' => t('My tasks'),
'paginator' => $this->getTaskPaginator($user['id'], 'tasks', 50),
'user' => $user,
@@ -135,7 +119,7 @@ class App extends Base
{
$user = $this->getUser();
- $this->response->html($this->layout('app/subtasks', array(
+ $this->response->html($this->helper->layout->dashboard('app/subtasks', array(
'title' => t('My subtasks'),
'paginator' => $this->getSubtaskPaginator($user['id'], 'subtasks', 50),
'user' => $user,
@@ -151,7 +135,7 @@ class App extends Base
{
$user = $this->getUser();
- $this->response->html($this->layout('app/projects', array(
+ $this->response->html($this->helper->layout->dashboard('app/projects', array(
'title' => t('My projects'),
'paginator' => $this->getProjectPaginator($user['id'], 'projects', 25),
'user' => $user,
@@ -167,7 +151,7 @@ class App extends Base
{
$user = $this->getUser();
- $this->response->html($this->layout('app/activity', array(
+ $this->response->html($this->helper->layout->dashboard('app/activity', array(
'title' => t('My activity stream'),
'events' => $this->projectActivity->getProjects($this->projectPermission->getActiveProjectIds($user['id']), 100),
'user' => $user,
@@ -181,7 +165,7 @@ class App extends Base
*/
public function calendar()
{
- $this->response->html($this->layout('app/calendar', array(
+ $this->response->html($this->helper->layout->dashboard('app/calendar', array(
'title' => t('My calendar'),
'user' => $this->getUser(),
)));
@@ -196,7 +180,7 @@ class App extends Base
{
$user = $this->getUser();
- $this->response->html($this->layout('app/notifications', array(
+ $this->response->html($this->helper->layout->dashboard('app/notifications', array(
'title' => t('My notifications'),
'notifications' => $this->userUnreadNotification->getAll($user['id']),
'user' => $user,
diff --git a/app/Controller/Auth.php b/app/Controller/Auth.php
index 5284e126..fef7f0e3 100644
--- a/app/Controller/Auth.php
+++ b/app/Controller/Auth.php
@@ -21,7 +21,7 @@ class Auth extends Base
$this->response->redirect($this->helper->url->to('app', 'index'));
}
- $this->response->html($this->template->layout('auth/index', array(
+ $this->response->html($this->helper->layout->app('auth/index', array(
'captcha' => ! empty($values['username']) && $this->userLocking->hasCaptcha($values['username']),
'errors' => $errors,
'values' => $values,
diff --git a/app/Controller/Base.php b/app/Controller/Base.php
index efeab31e..c55ad9ad 100644
--- a/app/Controller/Base.php
+++ b/app/Controller/Base.php
@@ -131,7 +131,7 @@ abstract class Base extends \Kanboard\Core\Base
*/
protected function notfound($no_layout = false)
{
- $this->response->html($this->template->layout('app/notfound', array(
+ $this->response->html($this->helper->layout->app('app/notfound', array(
'title' => t('Page not found'),
'no_layout' => $no_layout,
)));
@@ -149,7 +149,7 @@ abstract class Base extends \Kanboard\Core\Base
$this->response->text('Access Forbidden', 403);
}
- $this->response->html($this->template->layout('app/forbidden', array(
+ $this->response->html($this->helper->layout->app('app/forbidden', array(
'title' => t('Access Forbidden'),
'no_layout' => $no_layout,
)));
@@ -180,43 +180,6 @@ abstract class Base extends \Kanboard\Core\Base
}
/**
- * Common layout for task views
- *
- * @access protected
- * @param string $template Template name
- * @param array $params Template parameters
- * @return string
- */
- protected function taskLayout($template, array $params)
- {
- $content = $this->template->render($template, $params);
- $params['task_content_for_layout'] = $content;
- $params['title'] = $params['task']['project_name'].' &gt; '.$params['task']['title'];
- $params['board_selector'] = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
-
- return $this->template->layout('task/layout', $params);
- }
-
- /**
- * Common layout for project views
- *
- * @access protected
- * @param string $template Template name
- * @param array $params Template parameters
- * @return string
- */
- protected function projectLayout($template, array $params, $sidebar_template = 'project/sidebar')
- {
- $content = $this->template->render($template, $params);
- $params['project_content_for_layout'] = $content;
- $params['title'] = $params['project']['name'] === $params['title'] ? $params['title'] : $params['project']['name'].' &gt; '.$params['title'];
- $params['board_selector'] = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
- $params['sidebar_template'] = $sidebar_template;
-
- return $this->template->layout('project/layout', $params);
- }
-
- /**
* Common method to get a task for task views
*
* @access protected
@@ -251,8 +214,7 @@ abstract class Base extends \Kanboard\Core\Base
$project = $this->project->getByIdWithOwner($project_id);
if (empty($project)) {
- $this->flash->failure(t('Project not found.'));
- $this->response->redirect($this->helper->url->to('project', 'index'));
+ $this->notfound();
}
return $project;
@@ -280,6 +242,23 @@ abstract class Base extends \Kanboard\Core\Base
}
/**
+ * Get the current subtask
+ *
+ * @access protected
+ * @return array
+ */
+ protected function getSubtask()
+ {
+ $subtask = $this->subtask->getById($this->request->getIntegerParam('subtask_id'));
+
+ if (empty($subtask)) {
+ $this->notfound();
+ }
+
+ return $subtask;
+ }
+
+ /**
* Common method to get project filters
*
* @access protected
@@ -319,7 +298,8 @@ abstract class Base extends \Kanboard\Core\Base
* @param array &$project
* @return string
*/
- protected function getProjectDescription(array &$project) {
+ protected function getProjectDescription(array &$project)
+ {
if ($project['owner_id'] > 0) {
$description = t('Project owner: ').'**'.$this->template->e($project['owner_name'] ?: $project['owner_username']).'**'.PHP_EOL.PHP_EOL;
diff --git a/app/Controller/Board.php b/app/Controller/Board.php
index f64de69a..199f1703 100644
--- a/app/Controller/Board.php
+++ b/app/Controller/Board.php
@@ -27,7 +27,7 @@ class Board extends Base
}
// Display the board with a specific layout
- $this->response->html($this->template->layout('board/view_public', array(
+ $this->response->html($this->helper->layout->app('board/view_public', array(
'project' => $project,
'swimlanes' => $this->board->getBoard($project['id']),
'title' => $project['name'],
@@ -49,7 +49,7 @@ class Board extends Base
{
$params = $this->getProjectFilters('board', 'show');
- $this->response->html($this->template->layout('board/view_private', array(
+ $this->response->html($this->helper->layout->app('board/view_private', array(
'categories_list' => $this->category->getList($params['project']['id'], false),
'users_list' => $this->projectUserRole->getAssignableUsersList($params['project']['id'], false),
'custom_filters_list' => $this->customFilter->getAll($params['project']['id'], $this->userSession->getId()),
diff --git a/app/Controller/BoardTooltip.php b/app/Controller/BoardTooltip.php
index ed58a2f2..06f4d729 100644
--- a/app/Controller/BoardTooltip.php
+++ b/app/Controller/BoardTooltip.php
@@ -19,7 +19,21 @@ class BoardTooltip extends Base
{
$task = $this->getTask();
$this->response->html($this->template->render('board/tooltip_tasklinks', array(
- 'links' => $this->taskLink->getAll($task['id']),
+ 'links' => $this->taskLink->getAllGroupedByLabel($task['id']),
+ 'task' => $task,
+ )));
+ }
+
+ /**
+ * Get links on mouseover
+ *
+ * @access public
+ */
+ public function externallinks()
+ {
+ $task = $this->getTask();
+ $this->response->html($this->template->render('board/tooltip_external_links', array(
+ 'links' => $this->taskExternalLink->getAll($task['id']),
'task' => $task,
)));
}
diff --git a/app/Controller/Calendar.php b/app/Controller/Calendar.php
index 67a402d3..a0a25e41 100644
--- a/app/Controller/Calendar.php
+++ b/app/Controller/Calendar.php
@@ -20,7 +20,7 @@ class Calendar extends Base
*/
public function show()
{
- $this->response->html($this->template->layout('calendar/show', array(
+ $this->response->html($this->helper->layout->app('calendar/show', array(
'check_interval' => $this->config->get('board_private_refresh_interval'),
) + $this->getProjectFilters('calendar', 'show')));
}
diff --git a/app/Controller/Category.php b/app/Controller/Category.php
index a0af4139..258a3b78 100644
--- a/app/Controller/Category.php
+++ b/app/Controller/Category.php
@@ -38,7 +38,7 @@ class Category extends Base
{
$project = $this->getProject();
- $this->response->html($this->projectLayout('category/index', array(
+ $this->response->html($this->helper->layout->project('category/index', array(
'categories' => $this->category->getList($project['id'], false),
'values' => $values + array('project_id' => $project['id']),
'errors' => $errors,
@@ -81,7 +81,7 @@ class Category extends Base
$project = $this->getProject();
$category = $this->getCategory($project['id']);
- $this->response->html($this->projectLayout('category/edit', array(
+ $this->response->html($this->helper->layout->project('category/edit', array(
'values' => empty($values) ? $category : $values,
'errors' => $errors,
'project' => $project,
@@ -123,7 +123,7 @@ class Category extends Base
$project = $this->getProject();
$category = $this->getCategory($project['id']);
- $this->response->html($this->projectLayout('category/remove', array(
+ $this->response->html($this->helper->layout->project('category/remove', array(
'project' => $project,
'category' => $category,
'title' => t('Remove a category')
diff --git a/app/Controller/Column.php b/app/Controller/Column.php
index 1ce575d7..3201c549 100644
--- a/app/Controller/Column.php
+++ b/app/Controller/Column.php
@@ -26,7 +26,7 @@ class Column extends Base
$values['task_limit['.$column['id'].']'] = $column['task_limit'] ?: null;
}
- $this->response->html($this->projectLayout('column/index', array(
+ $this->response->html($this->helper->layout->project('column/index', array(
'errors' => $errors,
'values' => $values + array('project_id' => $project['id']),
'columns' => $columns,
@@ -75,7 +75,7 @@ class Column extends Base
$project = $this->getProject();
$column = $this->board->getColumn($this->request->getIntegerParam('column_id'));
- $this->response->html($this->projectLayout('column/edit', array(
+ $this->response->html($this->helper->layout->project('column/edit', array(
'errors' => $errors,
'values' => $values ?: $column,
'project' => $project,
@@ -136,7 +136,7 @@ class Column extends Base
{
$project = $this->getProject();
- $this->response->html($this->projectLayout('column/remove', array(
+ $this->response->html($this->helper->layout->project('column/remove', array(
'column' => $this->board->getColumn($this->request->getIntegerParam('column_id')),
'project' => $project,
'title' => t('Remove a column from a board')
diff --git a/app/Controller/Comment.php b/app/Controller/Comment.php
index a608dd1c..da3213e0 100644
--- a/app/Controller/Comment.php
+++ b/app/Controller/Comment.php
@@ -21,13 +21,11 @@ class Comment extends Base
$comment = $this->comment->getById($this->request->getIntegerParam('comment_id'));
if (empty($comment)) {
- $this->notfound();
+ return $this->notfound();
}
if (! $this->userSession->isAdmin() && $comment['user_id'] != $this->userSession->getId()) {
- $this->response->html($this->template->layout('comment/forbidden', array(
- 'title' => t('Access Forbidden')
- )));
+ return $this->forbidden();
}
return $comment;
@@ -41,7 +39,6 @@ class Comment extends Base
public function create(array $values = array(), array $errors = array())
{
$task = $this->getTask();
- $ajax = $this->request->isAjax() || $this->request->getIntegerParam('ajax');
if (empty($values)) {
$values = array(
@@ -50,16 +47,7 @@ class Comment extends Base
);
}
- if ($ajax) {
- $this->response->html($this->template->render('comment/create', array(
- 'values' => $values,
- 'errors' => $errors,
- 'task' => $task,
- 'ajax' => $ajax,
- )));
- }
-
- $this->response->html($this->taskLayout('comment/create', array(
+ $this->response->html($this->helper->layout->task('comment/create', array(
'values' => $values,
'errors' => $errors,
'task' => $task,
@@ -76,7 +64,6 @@ class Comment extends Base
{
$task = $this->getTask();
$values = $this->request->getValues();
- $ajax = $this->request->isAjax() || $this->request->getIntegerParam('ajax');
list($valid, $errors) = $this->commentValidator->validateCreation($values);
@@ -87,11 +74,7 @@ class Comment extends Base
$this->flash->failure(t('Unable to create your comment.'));
}
- if ($ajax) {
- $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])));
- }
-
- $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comments'));
+ return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comments'), true);
}
$this->create($values, $errors);
@@ -107,7 +90,7 @@ class Comment extends Base
$task = $this->getTask();
$comment = $this->getComment();
- $this->response->html($this->taskLayout('comment/edit', array(
+ $this->response->html($this->helper->layout->task('comment/edit', array(
'values' => empty($values) ? $comment : $values,
'errors' => $errors,
'comment' => $comment,
@@ -124,7 +107,7 @@ class Comment extends Base
public function update()
{
$task = $this->getTask();
- $comment = $this->getComment();
+ $this->getComment();
$values = $this->request->getValues();
list($valid, $errors) = $this->commentValidator->validateModification($values);
@@ -136,7 +119,7 @@ class Comment extends Base
$this->flash->failure(t('Unable to update your comment.'));
}
- $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comment-'.$comment['id']));
+ return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), false);
}
$this->edit($values, $errors);
@@ -152,7 +135,7 @@ class Comment extends Base
$task = $this->getTask();
$comment = $this->getComment();
- $this->response->html($this->taskLayout('comment/remove', array(
+ $this->response->html($this->helper->layout->task('comment/remove', array(
'comment' => $comment,
'task' => $task,
'title' => t('Remove a comment')
diff --git a/app/Controller/Config.php b/app/Controller/Config.php
index 4aee8553..53f7cdb6 100644
--- a/app/Controller/Config.php
+++ b/app/Controller/Config.php
@@ -11,24 +11,6 @@ namespace Kanboard\Controller;
class Config extends Base
{
/**
- * Common layout for config views
- *
- * @access private
- * @param string $template Template name
- * @param array $params Template parameters
- * @return string
- */
- private function layout($template, array $params)
- {
- $params['board_selector'] = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
- $params['values'] = $this->config->getAll();
- $params['errors'] = array();
- $params['config_content_for_layout'] = $this->template->render($template, $params);
-
- return $this->template->layout('config/layout', $params);
- }
-
- /**
* Common method between pages
*
* @access private
@@ -72,7 +54,7 @@ class Config extends Base
*/
public function index()
{
- $this->response->html($this->layout('config/about', array(
+ $this->response->html($this->helper->layout->config('config/about', array(
'db_size' => $this->config->getDatabaseSize(),
'title' => t('Settings').' &gt; '.t('About'),
)));
@@ -85,7 +67,7 @@ class Config extends Base
*/
public function plugins()
{
- $this->response->html($this->layout('config/plugins', array(
+ $this->response->html($this->helper->layout->config('config/plugins', array(
'plugins' => $this->pluginLoader->plugins,
'title' => t('Settings').' &gt; '.t('Plugins'),
)));
@@ -100,7 +82,7 @@ class Config extends Base
{
$this->common('application');
- $this->response->html($this->layout('config/application', array(
+ $this->response->html($this->helper->layout->config('config/application', array(
'languages' => $this->config->getLanguages(),
'timezones' => $this->config->getTimezones(),
'date_formats' => $this->dateParser->getAvailableFormats(),
@@ -117,7 +99,7 @@ class Config extends Base
{
$this->common('project');
- $this->response->html($this->layout('config/project', array(
+ $this->response->html($this->helper->layout->config('config/project', array(
'colors' => $this->color->getList(),
'default_columns' => implode(', ', $this->board->getDefaultColumns()),
'title' => t('Settings').' &gt; '.t('Project settings'),
@@ -133,7 +115,7 @@ class Config extends Base
{
$this->common('board');
- $this->response->html($this->layout('config/board', array(
+ $this->response->html($this->helper->layout->config('config/board', array(
'title' => t('Settings').' &gt; '.t('Board settings'),
)));
}
@@ -147,7 +129,7 @@ class Config extends Base
{
$this->common('calendar');
- $this->response->html($this->layout('config/calendar', array(
+ $this->response->html($this->helper->layout->config('config/calendar', array(
'title' => t('Settings').' &gt; '.t('Calendar settings'),
)));
}
@@ -161,7 +143,7 @@ class Config extends Base
{
$this->common('integrations');
- $this->response->html($this->layout('config/integrations', array(
+ $this->response->html($this->helper->layout->config('config/integrations', array(
'title' => t('Settings').' &gt; '.t('Integrations'),
)));
}
@@ -175,7 +157,7 @@ class Config extends Base
{
$this->common('webhook');
- $this->response->html($this->layout('config/webhook', array(
+ $this->response->html($this->helper->layout->config('config/webhook', array(
'title' => t('Settings').' &gt; '.t('Webhook settings'),
)));
}
@@ -187,7 +169,7 @@ class Config extends Base
*/
public function api()
{
- $this->response->html($this->layout('config/api', array(
+ $this->response->html($this->helper->layout->config('config/api', array(
'title' => t('Settings').' &gt; '.t('API'),
)));
}
diff --git a/app/Controller/Currency.php b/app/Controller/Currency.php
index 42e404f8..ecaa9834 100644
--- a/app/Controller/Currency.php
+++ b/app/Controller/Currency.php
@@ -11,29 +11,13 @@ namespace Kanboard\Controller;
class Currency extends Base
{
/**
- * Common layout for config views
- *
- * @access private
- * @param string $template Template name
- * @param array $params Template parameters
- * @return string
- */
- private function layout($template, array $params)
- {
- $params['board_selector'] = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
- $params['config_content_for_layout'] = $this->template->render($template, $params);
-
- return $this->template->layout('config/layout', $params);
- }
-
- /**
* Display all currency rates and form
*
* @access public
*/
public function index(array $values = array(), array $errors = array())
{
- $this->response->html($this->layout('currency/index', array(
+ $this->response->html($this->helper->layout->config('currency/index', array(
'config_values' => array('application_currency' => $this->config->get('application_currency')),
'values' => $values,
'errors' => $errors,
diff --git a/app/Controller/Customfilter.php b/app/Controller/Customfilter.php
index 1b43f1d0..da7eb77b 100644
--- a/app/Controller/Customfilter.php
+++ b/app/Controller/Customfilter.php
@@ -21,7 +21,7 @@ class Customfilter extends Base
{
$project = $this->getProject();
- $this->response->html($this->projectLayout('custom_filter/index', array(
+ $this->response->html($this->helper->layout->project('custom_filter/index', array(
'values' => $values + array('project_id' => $project['id']),
'errors' => $errors,
'project' => $project,
@@ -90,7 +90,7 @@ class Customfilter extends Base
$this->checkPermission($project, $filter);
- $this->response->html($this->projectLayout('custom_filter/edit', array(
+ $this->response->html($this->helper->layout->project('custom_filter/edit', array(
'values' => empty($values) ? $filter : $values,
'errors' => $errors,
'project' => $project,
diff --git a/app/Controller/Doc.php b/app/Controller/Doc.php
index a233b120..6f309d48 100644
--- a/app/Controller/Doc.php
+++ b/app/Controller/Doc.php
@@ -52,8 +52,6 @@ class Doc extends Base
}
}
- $this->response->html($this->template->layout('doc/show', $this->readFile($filename) + array(
- 'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
- )));
+ $this->response->html($this->helper->layout->app('doc/show', $this->readFile($filename)));
}
}
diff --git a/app/Controller/Export.php b/app/Controller/Export.php
index c39f58a1..977a4107 100644
--- a/app/Controller/Export.php
+++ b/app/Controller/Export.php
@@ -27,7 +27,7 @@ class Export extends Base
$this->response->csv($data);
}
- $this->response->html($this->projectLayout('export/'.$action, array(
+ $this->response->html($this->helper->layout->project('export/'.$action, array(
'values' => array(
'controller' => 'export',
'action' => $action,
diff --git a/app/Controller/File.php b/app/Controller/File.php
index b46f7d19..50db3865 100644
--- a/app/Controller/File.php
+++ b/app/Controller/File.php
@@ -23,17 +23,11 @@ class File extends Base
if ($this->request->isPost() && $this->file->uploadScreenshot($task['project_id'], $task['id'], $this->request->getValue('screenshot')) !== false) {
$this->flash->success(t('Screenshot uploaded successfully.'));
-
- if ($this->request->getStringParam('redirect') === 'board') {
- $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])));
- }
-
- $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])));
+ return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true);
}
- $this->response->html($this->taskLayout('file/screenshot', array(
+ $this->response->html($this->helper->layout->task('file/screenshot', array(
'task' => $task,
- 'redirect' => 'task',
)));
}
@@ -46,7 +40,7 @@ class File extends Base
{
$task = $this->getTask();
- $this->response->html($this->taskLayout('file/new', array(
+ $this->response->html($this->helper->layout->task('file/new', array(
'task' => $task,
'max_size' => ini_get('upload_max_filesize'),
)));
@@ -65,7 +59,7 @@ class File extends Base
$this->flash->failure(t('Unable to upload the file.'));
}
- $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])));
+ $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true);
}
/**
@@ -184,7 +178,7 @@ class File extends Base
$task = $this->getTask();
$file = $this->file->getById($this->request->getIntegerParam('file_id'));
- $this->response->html($this->taskLayout('file/remove', array(
+ $this->response->html($this->helper->layout->task('file/remove', array(
'task' => $task,
'file' => $file,
)));
diff --git a/app/Controller/Gantt.php b/app/Controller/Gantt.php
index ac0e6fad..2d1edc08 100644
--- a/app/Controller/Gantt.php
+++ b/app/Controller/Gantt.php
@@ -23,10 +23,9 @@ class Gantt extends Base
$project_ids = $this->projectPermission->getActiveProjectIds($this->userSession->getId());
}
- $this->response->html($this->template->layout('gantt/projects', array(
+ $this->response->html($this->helper->layout->app('gantt/projects', array(
'projects' => $this->projectGanttFormatter->filter($project_ids)->format(),
'title' => t('Gantt chart for all projects'),
- 'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
)));
}
@@ -65,7 +64,7 @@ class Gantt extends Base
$filter->getQuery()->asc('column_position')->asc(TaskModel::TABLE.'.position');
}
- $this->response->html($this->template->layout('gantt/project', $params + array(
+ $this->response->html($this->helper->layout->app('gantt/project', $params + array(
'users_list' => $this->projectUserRole->getAssignableUsersList($params['project']['id'], false),
'sorting' => $sorting,
'tasks' => $filter->format(),
@@ -102,19 +101,22 @@ class Gantt extends Base
{
$project = $this->getProject();
+ $values = $values + array(
+ 'project_id' => $project['id'],
+ 'column_id' => $this->board->getFirstColumn($project['id']),
+ 'position' => 1
+ );
+
+ $values = $this->hook->merge('controller:task:form:default', $values, array('default_values' => $values));
+
$this->response->html($this->template->render('gantt/task_creation', array(
+ 'project' => $project,
'errors' => $errors,
- 'values' => $values + array(
- 'project_id' => $project['id'],
- 'column_id' => $this->board->getFirstColumn($project['id']),
- 'position' => 1
- ),
+ 'values' => $values,
'users_list' => $this->projectUserRole->getAssignableUsersList($project['id'], true, false, true),
'colors_list' => $this->color->getList(),
'categories_list' => $this->category->getList($project['id']),
'swimlanes_list' => $this->swimlane->getList($project['id'], false, true),
- 'date_format' => $this->config->get('application_date_format'),
- 'date_formats' => $this->dateParser->getAvailableFormats(),
'title' => $project['name'].' &gt; '.t('New task')
)));
}
diff --git a/app/Controller/Group.php b/app/Controller/Group.php
index e952c0e5..fa47f428 100644
--- a/app/Controller/Group.php
+++ b/app/Controller/Group.php
@@ -24,8 +24,7 @@ class Group extends Base
->setQuery($this->group->getQuery())
->calculate();
- $this->response->html($this->template->layout('group/index', array(
- 'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
+ $this->response->html($this->helper->layout->app('group/index', array(
'title' => t('Groups').' ('.$paginator->getTotal().')',
'paginator' => $paginator,
)));
@@ -48,8 +47,7 @@ class Group extends Base
->setQuery($this->groupMember->getQuery($group_id))
->calculate();
- $this->response->html($this->template->layout('group/users', array(
- 'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
+ $this->response->html($this->helper->layout->app('group/users', array(
'title' => t('Members of %s', $group['name']).' ('.$paginator->getTotal().')',
'paginator' => $paginator,
'group' => $group,
@@ -63,8 +61,7 @@ class Group extends Base
*/
public function create(array $values = array(), array $errors = array())
{
- $this->response->html($this->template->layout('group/create', array(
- 'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
+ $this->response->html($this->helper->layout->app('group/create', array(
'errors' => $errors,
'values' => $values,
'title' => t('New group')
@@ -104,8 +101,7 @@ class Group extends Base
$values = $this->group->getById($this->request->getIntegerParam('group_id'));
}
- $this->response->html($this->template->layout('group/edit', array(
- 'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
+ $this->response->html($this->helper->layout->app('group/edit', array(
'errors' => $errors,
'values' => $values,
'title' => t('Edit group')
@@ -148,8 +144,7 @@ class Group extends Base
$values['group_id'] = $group_id;
}
- $this->response->html($this->template->layout('group/associate', array(
- 'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
+ $this->response->html($this->helper->layout->app('group/associate', array(
'users' => $this->user->prepareList($this->groupMember->getNotMembers($group_id)),
'group' => $group,
'errors' => $errors,
@@ -191,7 +186,7 @@ class Group extends Base
$group = $this->group->getById($group_id);
$user = $this->user->getById($user_id);
- $this->response->html($this->template->layout('group/dissociate', array(
+ $this->response->html($this->helper->layout->app('group/dissociate', array(
'group' => $group,
'user' => $user,
'title' => t('Remove user from group "%s"', $group['name']),
@@ -228,7 +223,7 @@ class Group extends Base
$group_id = $this->request->getIntegerParam('group_id');
$group = $this->group->getById($group_id);
- $this->response->html($this->template->layout('group/remove', array(
+ $this->response->html($this->helper->layout->app('group/remove', array(
'group' => $group,
'title' => t('Remove group'),
)));
diff --git a/app/Controller/Link.php b/app/Controller/Link.php
index d52d1f91..ec7ab1af 100644
--- a/app/Controller/Link.php
+++ b/app/Controller/Link.php
@@ -12,22 +12,6 @@ namespace Kanboard\Controller;
class Link extends Base
{
/**
- * Common layout for config views
- *
- * @access private
- * @param string $template Template name
- * @param array $params Template parameters
- * @return string
- */
- private function layout($template, array $params)
- {
- $params['board_selector'] = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
- $params['config_content_for_layout'] = $this->template->render($template, $params);
-
- return $this->template->layout('config/layout', $params);
- }
-
- /**
* Get the current link
*
* @access private
@@ -51,7 +35,7 @@ class Link extends Base
*/
public function index(array $values = array(), array $errors = array())
{
- $this->response->html($this->layout('link/index', array(
+ $this->response->html($this->helper->layout->config('link/index', array(
'links' => $this->link->getMergedList(),
'values' => $values,
'errors' => $errors,
@@ -91,7 +75,7 @@ class Link extends Base
$link = $this->getLink();
$link['label'] = t($link['label']);
- $this->response->html($this->layout('link/edit', array(
+ $this->response->html($this->helper->layout->config('link/edit', array(
'values' => $values ?: $link,
'errors' => $errors,
'labels' => $this->link->getList($link['id']),
@@ -131,7 +115,7 @@ class Link extends Base
{
$link = $this->getLink();
- $this->response->html($this->layout('link/remove', array(
+ $this->response->html($this->helper->layout->config('link/remove', array(
'link' => $link,
'title' => t('Remove a link')
)));
diff --git a/app/Controller/Listing.php b/app/Controller/Listing.php
index b9c851f5..c7d3d9a8 100644
--- a/app/Controller/Listing.php
+++ b/app/Controller/Listing.php
@@ -30,7 +30,7 @@ class Listing extends Base
->setQuery($query)
->calculate();
- $this->response->html($this->template->layout('listing/show', $params + array(
+ $this->response->html($this->helper->layout->app('listing/show', $params + array(
'paginator' => $paginator,
)));
}
diff --git a/app/Controller/Oauth.php b/app/Controller/Oauth.php
index ed901def..452faecd 100644
--- a/app/Controller/Oauth.php
+++ b/app/Controller/Oauth.php
@@ -11,36 +11,6 @@ namespace Kanboard\Controller;
class Oauth extends Base
{
/**
- * Link or authenticate a Google account
- *
- * @access public
- */
- public function google()
- {
- $this->step1('Google');
- }
-
- /**
- * Link or authenticate a Github account
- *
- * @access public
- */
- public function github()
- {
- $this->step1('Github');
- }
-
- /**
- * Link or authenticate a Gitlab account
- *
- * @access public
- */
- public function gitlab()
- {
- $this->step1('Gitlab');
- }
-
- /**
* Unlink external account
*
* @access public
@@ -65,7 +35,7 @@ class Oauth extends Base
* @access private
* @param string $provider
*/
- private function step1($provider)
+ protected function step1($provider)
{
$code = $this->request->getStringParam('code');
@@ -79,11 +49,11 @@ class Oauth extends Base
/**
* Link or authenticate the user
*
- * @access private
+ * @access protected
* @param string $provider
* @param string $code
*/
- private function step2($provider, $code)
+ protected function step2($provider, $code)
{
$this->authenticationManager->getProvider($provider)->setCode($code);
@@ -97,10 +67,10 @@ class Oauth extends Base
/**
* Link the account
*
- * @access private
+ * @access protected
* @param string $provider
*/
- private function link($provider)
+ protected function link($provider)
{
$authProvider = $this->authenticationManager->getProvider($provider);
@@ -117,15 +87,15 @@ class Oauth extends Base
/**
* Authenticate the account
*
- * @access private
+ * @access protected
* @param string $provider
*/
- private function authenticate($provider)
+ protected function authenticate($provider)
{
if ($this->authenticationManager->oauthAuthentication($provider)) {
$this->response->redirect($this->helper->url->to('app', 'index'));
} else {
- $this->response->html($this->template->layout('auth/index', array(
+ $this->response->html($this->helper->layout->app('auth/index', array(
'errors' => array('login' => t('External authentication failed')),
'values' => array(),
'no_layout' => true,
diff --git a/app/Controller/PasswordReset.php b/app/Controller/PasswordReset.php
index 23567c9c..f6a0eb8e 100644
--- a/app/Controller/PasswordReset.php
+++ b/app/Controller/PasswordReset.php
@@ -17,7 +17,7 @@ class PasswordReset extends Base
{
$this->checkActivation();
- $this->response->html($this->template->layout('password_reset/create', array(
+ $this->response->html($this->helper->layout->app('password_reset/create', array(
'errors' => $errors,
'values' => $values,
'no_layout' => true,
@@ -53,7 +53,7 @@ class PasswordReset extends Base
$user_id = $this->passwordReset->getUserIdByToken($token);
if ($user_id !== false) {
- $this->response->html($this->template->layout('password_reset/change', array(
+ $this->response->html($this->helper->layout->app('password_reset/change', array(
'token' => $token,
'errors' => $errors,
'values' => $values,
diff --git a/app/Controller/Project.php b/app/Controller/Project.php
index ffd62b09..cdfbd94a 100644
--- a/app/Controller/Project.php
+++ b/app/Controller/Project.php
@@ -32,8 +32,7 @@ class Project extends Base
->setQuery($this->project->getQueryColumnStats($project_ids))
->calculate();
- $this->response->html($this->template->layout('project/index', array(
- 'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
+ $this->response->html($this->helper->layout->app('project/index', array(
'paginator' => $paginator,
'nb_projects' => $nb_projects,
'title' => t('Projects').' ('.$nb_projects.')'
@@ -49,7 +48,7 @@ class Project extends Base
{
$project = $this->getProject();
- $this->response->html($this->projectLayout('project/show', array(
+ $this->response->html($this->helper->layout->project('project/show', array(
'project' => $project,
'stats' => $this->project->getTaskStats($project['id']),
'title' => $project['name'],
@@ -78,7 +77,7 @@ class Project extends Base
$this->response->redirect($this->helper->url->to('project', 'share', array('project_id' => $project['id'])));
}
- $this->response->html($this->projectLayout('project/share', array(
+ $this->response->html($this->helper->layout->project('project/share', array(
'project' => $project,
'title' => t('Public access'),
)));
@@ -99,7 +98,7 @@ class Project extends Base
$this->response->redirect($this->helper->url->to('project', 'integrations', array('project_id' => $project['id'])));
}
- $this->response->html($this->projectLayout('project/integrations', array(
+ $this->response->html($this->helper->layout->project('project/integrations', array(
'project' => $project,
'title' => t('Integrations'),
'webhook_token' => $this->config->get('webhook_token'),
@@ -124,7 +123,7 @@ class Project extends Base
$this->response->redirect($this->helper->url->to('project', 'notifications', array('project_id' => $project['id'])));
}
- $this->response->html($this->projectLayout('project/notifications', array(
+ $this->response->html($this->helper->layout->project('project/notifications', array(
'notifications' => $this->projectNotification->readSettings($project['id']),
'types' => $this->projectNotificationType->getTypes(),
'project' => $project,
@@ -153,7 +152,7 @@ class Project extends Base
$this->response->redirect($this->helper->url->to('project', 'index'));
}
- $this->response->html($this->projectLayout('project/remove', array(
+ $this->response->html($this->helper->layout->project('project/remove', array(
'project' => $project,
'title' => t('Remove project')
)));
@@ -171,17 +170,18 @@ class Project extends Base
$project = $this->getProject();
if ($this->request->getStringParam('duplicate') === 'yes') {
- $values = array_keys($this->request->getValues());
- if ($this->projectDuplication->duplicate($project['id'], $values) !== false) {
+ $project_id = $this->projectDuplication->duplicate($project['id'], array_keys($this->request->getValues()), $this->userSession->getId());
+
+ if ($project_id !== false) {
$this->flash->success(t('Project cloned successfully.'));
} else {
$this->flash->failure(t('Unable to clone this project.'));
}
- $this->response->redirect($this->helper->url->to('project', 'index'));
+ $this->response->redirect($this->helper->url->to('project', 'show', array('project_id' => $project_id)));
}
- $this->response->html($this->projectLayout('project/duplicate', array(
+ $this->response->html($this->helper->layout->project('project/duplicate', array(
'project' => $project,
'title' => t('Clone this project')
)));
@@ -208,7 +208,7 @@ class Project extends Base
$this->response->redirect($this->helper->url->to('project', 'show', array('project_id' => $project['id'])));
}
- $this->response->html($this->projectLayout('project/disable', array(
+ $this->response->html($this->helper->layout->project('project/disable', array(
'project' => $project,
'title' => t('Project activation')
)));
@@ -235,62 +235,9 @@ class Project extends Base
$this->response->redirect($this->helper->url->to('project', 'show', array('project_id' => $project['id'])));
}
- $this->response->html($this->projectLayout('project/enable', array(
+ $this->response->html($this->helper->layout->project('project/enable', array(
'project' => $project,
'title' => t('Project activation')
)));
}
-
- /**
- * Display a form to create a new project
- *
- * @access public
- */
- public function create(array $values = array(), array $errors = array())
- {
- $is_private = isset($values['is_private']) && $values['is_private'] == 1;
-
- $this->response->html($this->template->layout('project/new', array(
- 'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
- 'values' => $values,
- 'errors' => $errors,
- 'is_private' => $is_private,
- 'title' => $is_private ? t('New private project') : t('New project'),
- )));
- }
-
- /**
- * Display a form to create a private project
- *
- * @access public
- */
- public function createPrivate(array $values = array(), array $errors = array())
- {
- $values['is_private'] = 1;
- $this->create($values, $errors);
- }
-
- /**
- * Validate and save a new project
- *
- * @access public
- */
- public function save()
- {
- $values = $this->request->getValues();
- list($valid, $errors) = $this->projectValidator->validateCreation($values);
-
- if ($valid) {
- $project_id = $this->project->create($values, $this->userSession->getId(), true);
-
- if ($project_id > 0) {
- $this->flash->success(t('Your project have been created successfully.'));
- $this->response->redirect($this->helper->url->to('project', 'show', array('project_id' => $project_id)));
- }
-
- $this->flash->failure(t('Unable to create your project.'));
- }
-
- $this->create($values, $errors);
- }
}
diff --git a/app/Controller/ProjectCreation.php b/app/Controller/ProjectCreation.php
new file mode 100644
index 00000000..61ea2586
--- /dev/null
+++ b/app/Controller/ProjectCreation.php
@@ -0,0 +1,125 @@
+<?php
+
+namespace Kanboard\Controller;
+
+/**
+ * Project Creation Controller
+ *
+ * @package controller
+ * @author Frederic Guillot
+ */
+class ProjectCreation extends Base
+{
+ /**
+ * Display a form to create a new project
+ *
+ * @access public
+ */
+ public function create(array $values = array(), array $errors = array())
+ {
+ $is_private = isset($values['is_private']) && $values['is_private'] == 1;
+ $projects_list = array(0 => t('Do not duplicate anything')) + $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
+
+ $this->response->html($this->helper->layout->app('project_creation/create', array(
+ 'values' => $values,
+ 'errors' => $errors,
+ 'is_private' => $is_private,
+ 'projects_list' => $projects_list,
+ 'title' => $is_private ? t('New private project') : t('New project'),
+ )));
+ }
+
+ /**
+ * Display a form to create a private project
+ *
+ * @access public
+ */
+ public function createPrivate(array $values = array(), array $errors = array())
+ {
+ $values['is_private'] = 1;
+ $this->create($values, $errors);
+ }
+
+ /**
+ * Validate and save a new project
+ *
+ * @access public
+ */
+ public function save()
+ {
+ $values = $this->request->getValues();
+ list($valid, $errors) = $this->projectValidator->validateCreation($values);
+
+ if ($valid) {
+ $project_id = $this->createOrDuplicate($values);
+
+ if ($project_id > 0) {
+ $this->flash->success(t('Your project have been created successfully.'));
+ return $this->response->redirect($this->helper->url->to('project', 'show', array('project_id' => $project_id)));
+ }
+
+ $this->flash->failure(t('Unable to create your project.'));
+ }
+
+ $this->create($values, $errors);
+ }
+
+ /**
+ * Create or duplicate a project
+ *
+ * @access private
+ * @param array $values
+ * @return boolean|integer
+ */
+ private function createOrDuplicate(array $values)
+ {
+ if ($values['src_project_id'] == 0) {
+ return $this->createNewProject($values);
+ }
+
+ return $this->duplicateNewProject($values);
+ }
+
+ /**
+ * Save a new project
+ *
+ * @access private
+ * @param array $values
+ * @return boolean|integer
+ */
+ private function createNewProject(array $values)
+ {
+ $project = array(
+ 'name' => $values['name'],
+ 'is_private' => $values['is_private'],
+ );
+
+ return $this->project->create($project, $this->userSession->getId(), true);
+ }
+
+ /**
+ * Creatte from another project
+ *
+ * @access private
+ * @param array $values
+ * @return boolean|integer
+ */
+ private function duplicateNewProject(array $values)
+ {
+ $selection = array();
+
+ foreach ($this->projectDuplication->getOptionalSelection() as $item) {
+ if (isset($values[$item]) && $values[$item] == 1) {
+ $selection[] = $item;
+ }
+ }
+
+ return $this->projectDuplication->duplicate(
+ $values['src_project_id'],
+ $selection,
+ $this->userSession->getId(),
+ $values['name'],
+ $values['is_private'] == 1
+ );
+ }
+}
diff --git a/app/Controller/ProjectEdit.php b/app/Controller/ProjectEdit.php
index 0dfc7de3..f4a3a7cb 100644
--- a/app/Controller/ProjectEdit.php
+++ b/app/Controller/ProjectEdit.php
@@ -89,11 +89,11 @@ class ProjectEdit extends Base
{
if ($redirect === 'edit') {
if (isset($values['is_private'])) {
- if (! $this->helper->user->hasProjectAccess('project', 'create', $project['id'])) {
+ if (! $this->helper->user->hasProjectAccess('ProjectCreation', 'create', $project['id'])) {
unset($values['is_private']);
}
} elseif ($project['is_private'] == 1 && ! isset($values['is_private'])) {
- if ($this->helper->user->hasProjectAccess('project', 'create', $project['id'])) {
+ if ($this->helper->user->hasProjectAccess('ProjectCreation', 'create', $project['id'])) {
$values += array('is_private' => 0);
}
}
@@ -114,7 +114,7 @@ class ProjectEdit extends Base
{
$project = $this->getProject();
- $this->response->html($this->projectLayout($template, array(
+ $this->response->html($this->helper->layout->project($template, array(
'owners' => $this->projectUserRole->getAssignableUsersList($project['id'], true),
'values' => empty($values) ? $project : $values,
'errors' => $errors,
diff --git a/app/Controller/ProjectPermission.php b/app/Controller/ProjectPermission.php
index 4434d017..800da02f 100644
--- a/app/Controller/ProjectPermission.php
+++ b/app/Controller/ProjectPermission.php
@@ -13,6 +13,24 @@ use Kanboard\Core\Security\Role;
class ProjectPermission extends Base
{
/**
+ * Permissions are only available for team projects
+ *
+ * @access protected
+ * @param integer $project_id Default project id
+ * @return array
+ */
+ protected function getProject($project_id = 0)
+ {
+ $project = parent::getProject($project_id);
+
+ if ($project['is_private'] == 1) {
+ $this->forbidden();
+ }
+
+ return $project;
+ }
+
+ /**
* Show all permissions
*
* @access public
@@ -25,7 +43,7 @@ class ProjectPermission extends Base
$values['role'] = Role::PROJECT_MEMBER;
}
- $this->response->html($this->projectLayout('project_permission/index', array(
+ $this->response->html($this->helper->layout->project('project_permission/index', array(
'project' => $project,
'users' => $this->projectUserRole->getUsers($project['id']),
'groups' => $this->projectGroupRole->getGroups($project['id']),
@@ -62,6 +80,7 @@ class ProjectPermission extends Base
*/
public function addUser()
{
+ $project = $this->getProject();
$values = $this->request->getValues();
if ($this->projectUserRole->addUser($values['project_id'], $values['user_id'], $values['role'])) {
@@ -70,7 +89,7 @@ class ProjectPermission extends Base
$this->flash->failure(t('Unable to update this project.'));
}
- $this->response->redirect($this->helper->url->to('ProjectPermission', 'index', array('project_id' => $values['project_id'])));
+ $this->response->redirect($this->helper->url->to('ProjectPermission', 'index', array('project_id' => $project['id'])));
}
/**
@@ -81,19 +100,16 @@ class ProjectPermission extends Base
public function removeUser()
{
$this->checkCSRFParam();
+ $project = $this->getProject();
+ $user_id = $this->request->getIntegerParam('user_id');
- $values = array(
- 'project_id' => $this->request->getIntegerParam('project_id'),
- 'user_id' => $this->request->getIntegerParam('user_id'),
- );
-
- if ($this->projectUserRole->removeUser($values['project_id'], $values['user_id'])) {
+ if ($this->projectUserRole->removeUser($project['id'], $user_id)) {
$this->flash->success(t('Project updated successfully.'));
} else {
$this->flash->failure(t('Unable to update this project.'));
}
- $this->response->redirect($this->helper->url->to('ProjectPermission', 'index', array('project_id' => $values['project_id'])));
+ $this->response->redirect($this->helper->url->to('ProjectPermission', 'index', array('project_id' => $project['id'])));
}
/**
@@ -103,10 +119,10 @@ class ProjectPermission extends Base
*/
public function changeUserRole()
{
- $project_id = $this->request->getIntegerParam('project_id');
+ $project = $this->getProject();
$values = $this->request->getJson();
- if (! empty($project_id) && ! empty($values) && $this->projectUserRole->changeUserRole($project_id, $values['id'], $values['role'])) {
+ if (! empty($project) && ! empty($values) && $this->projectUserRole->changeUserRole($project['id'], $values['id'], $values['role'])) {
$this->response->json(array('status' => 'ok'));
} else {
$this->response->json(array('status' => 'error'));
@@ -120,19 +136,20 @@ class ProjectPermission extends Base
*/
public function addGroup()
{
+ $project = $this->getProject();
$values = $this->request->getValues();
if (empty($values['group_id']) && ! empty($values['external_id'])) {
$values['group_id'] = $this->group->create($values['name'], $values['external_id']);
}
- if ($this->projectGroupRole->addGroup($values['project_id'], $values['group_id'], $values['role'])) {
+ if ($this->projectGroupRole->addGroup($project['id'], $values['group_id'], $values['role'])) {
$this->flash->success(t('Project updated successfully.'));
} else {
$this->flash->failure(t('Unable to update this project.'));
}
- $this->response->redirect($this->helper->url->to('ProjectPermission', 'index', array('project_id' => $values['project_id'])));
+ $this->response->redirect($this->helper->url->to('ProjectPermission', 'index', array('project_id' => $project['id'])));
}
/**
@@ -143,19 +160,16 @@ class ProjectPermission extends Base
public function removeGroup()
{
$this->checkCSRFParam();
+ $project = $this->getProject();
+ $group_id = $this->request->getIntegerParam('group_id');
- $values = array(
- 'project_id' => $this->request->getIntegerParam('project_id'),
- 'group_id' => $this->request->getIntegerParam('group_id'),
- );
-
- if ($this->projectGroupRole->removeGroup($values['project_id'], $values['group_id'])) {
+ if ($this->projectGroupRole->removeGroup($project['id'], $group_id)) {
$this->flash->success(t('Project updated successfully.'));
} else {
$this->flash->failure(t('Unable to update this project.'));
}
- $this->response->redirect($this->helper->url->to('ProjectPermission', 'index', array('project_id' => $values['project_id'])));
+ $this->response->redirect($this->helper->url->to('ProjectPermission', 'index', array('project_id' => $project['id'])));
}
/**
@@ -165,10 +179,10 @@ class ProjectPermission extends Base
*/
public function changeGroupRole()
{
- $project_id = $this->request->getIntegerParam('project_id');
+ $project = $this->getProject();
$values = $this->request->getJson();
- if (! empty($project_id) && ! empty($values) && $this->projectGroupRole->changeGroupRole($project_id, $values['id'], $values['role'])) {
+ if (! empty($project) && ! empty($values) && $this->projectGroupRole->changeGroupRole($project['id'], $values['id'], $values['role'])) {
$this->response->json(array('status' => 'ok'));
} else {
$this->response->json(array('status' => 'error'));
diff --git a/app/Controller/Projectuser.php b/app/Controller/Projectuser.php
index 78b93ab6..9cd21021 100644
--- a/app/Controller/Projectuser.php
+++ b/app/Controller/Projectuser.php
@@ -14,23 +14,6 @@ use Kanboard\Core\Security\Role;
*/
class Projectuser extends Base
{
- /**
- * Common layout for users overview views
- *
- * @access private
- * @param string $template Template name
- * @param array $params Template parameters
- * @return string
- */
- private function layout($template, array $params)
- {
- $params['board_selector'] = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
- $params['content_for_sublayout'] = $this->template->render($template, $params);
- $params['filter'] = array('user_id' => $params['user_id']);
-
- return $this->template->layout('project_user/layout', $params);
- }
-
private function common()
{
$user_id = $this->request->getIntegerParam('user_id', UserModel::EVERYBODY_ID);
@@ -62,7 +45,7 @@ class Projectuser extends Base
->setQuery($query)
->calculate();
- $this->response->html($this->layout('project_user/roles', array(
+ $this->response->html($this->helper->layout->projectUser('project_user/roles', array(
'paginator' => $paginator,
'title' => $title,
'user_id' => $user_id,
@@ -88,7 +71,7 @@ class Projectuser extends Base
->setQuery($query)
->calculate();
- $this->response->html($this->layout('project_user/tasks', array(
+ $this->response->html($this->helper->layout->projectUser('project_user/tasks', array(
'paginator' => $paginator,
'title' => $title,
'user_id' => $user_id,
diff --git a/app/Controller/Search.php b/app/Controller/Search.php
index 390210c0..9b9b9e65 100644
--- a/app/Controller/Search.php
+++ b/app/Controller/Search.php
@@ -36,8 +36,7 @@ class Search extends Base
$nb_tasks = $paginator->getTotal();
}
- $this->response->html($this->template->layout('search/index', array(
- 'board_selector' => $projects,
+ $this->response->html($this->helper->layout->app('search/index', array(
'values' => array(
'search' => $search,
'controller' => 'search',
diff --git a/app/Controller/Subtask.php b/app/Controller/Subtask.php
index caaaa85e..f8798906 100644
--- a/app/Controller/Subtask.php
+++ b/app/Controller/Subtask.php
@@ -2,8 +2,6 @@
namespace Kanboard\Controller;
-use Kanboard\Model\Subtask as SubtaskModel;
-
/**
* Subtask controller
*
@@ -13,20 +11,20 @@ use Kanboard\Model\Subtask as SubtaskModel;
class Subtask extends Base
{
/**
- * Get the current subtask
- *
- * @access private
- * @return array
+ * Show list of subtasks
*/
- private function getSubtask()
+ public function show()
{
- $subtask = $this->subtask->getById($this->request->getIntegerParam('subtask_id'));
-
- if (empty($subtask)) {
- $this->notfound();
- }
+ $task = $this->getTask();
- return $subtask;
+ $this->response->html($this->helper->layout->task('subtask/show', array(
+ 'users_list' => $this->projectUserRole->getAssignableUsersList($task['project_id']),
+ 'task' => $task,
+ 'project' => $this->getProject(),
+ 'subtasks' => $this->subtask->getAll($task['id']),
+ 'editable' => true,
+ 'redirect' => 'subtask',
+ )));
}
/**
@@ -45,7 +43,7 @@ class Subtask extends Base
);
}
- $this->response->html($this->taskLayout('subtask/create', array(
+ $this->response->html($this->helper->layout->task('subtask/create', array(
'values' => $values,
'errors' => $errors,
'users_list' => $this->projectUserRole->getAssignableUsersList($task['project_id']),
@@ -73,10 +71,10 @@ class Subtask extends Base
}
if (isset($values['another_subtask']) && $values['another_subtask'] == 1) {
- $this->response->redirect($this->helper->url->to('subtask', 'create', array('project_id' => $task['project_id'], 'task_id' => $task['id'], 'another_subtask' => 1)));
+ return $this->create(array('project_id' => $task['project_id'], 'task_id' => $task['id'], 'another_subtask' => 1));
}
- $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id']), 'subtasks'));
+ return $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id']), 'subtasks'), true);
}
$this->create($values, $errors);
@@ -92,7 +90,7 @@ class Subtask extends Base
$task = $this->getTask();
$subtask = $this->getSubTask();
- $this->response->html($this->taskLayout('subtask/edit', array(
+ $this->response->html($this->helper->layout->task('subtask/edit', array(
'values' => empty($values) ? $subtask : $values,
'errors' => $errors,
'users_list' => $this->projectUserRole->getAssignableUsersList($task['project_id']),
@@ -122,7 +120,7 @@ class Subtask extends Base
$this->flash->failure(t('Unable to update your sub-task.'));
}
- $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id']), 'subtasks'));
+ return $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true);
}
$this->edit($values, $errors);
@@ -138,7 +136,7 @@ class Subtask extends Base
$task = $this->getTask();
$subtask = $this->getSubtask();
- $this->response->html($this->taskLayout('subtask/remove', array(
+ $this->response->html($this->helper->layout->task('subtask/remove', array(
'subtask' => $subtask,
'task' => $task,
)));
@@ -161,97 +159,7 @@ class Subtask extends Base
$this->flash->failure(t('Unable to remove this sub-task.'));
}
- $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id']), 'subtasks'));
- }
-
- /**
- * Change status to the next status: Toto -> In Progress -> Done
- *
- * @access public
- */
- public function toggleStatus()
- {
- $task = $this->getTask();
- $subtask = $this->getSubtask();
- $redirect = $this->request->getStringParam('redirect', 'task');
-
- $this->subtask->toggleStatus($subtask['id']);
-
- if ($redirect === 'board') {
- $this->sessionStorage->hasSubtaskInProgress = $this->subtask->hasSubtaskInProgress($this->userSession->getId());
-
- $this->response->html($this->template->render('board/tooltip_subtasks', array(
- 'subtasks' => $this->subtask->getAll($task['id']),
- 'task' => $task,
- )));
- }
-
- $this->toggleRedirect($task, $redirect);
- }
-
- /**
- * Handle subtask restriction (popover)
- *
- * @access public
- */
- public function subtaskRestriction()
- {
- $task = $this->getTask();
- $subtask = $this->getSubtask();
-
- $this->response->html($this->template->render('subtask/restriction_change_status', array(
- 'status_list' => array(
- SubtaskModel::STATUS_TODO => t('Todo'),
- SubtaskModel::STATUS_DONE => t('Done'),
- ),
- 'subtask_inprogress' => $this->subtask->getSubtaskInProgress($this->userSession->getId()),
- 'subtask' => $subtask,
- 'task' => $task,
- 'redirect' => $this->request->getStringParam('redirect'),
- )));
- }
-
- /**
- * Change status of the in progress subtask and the other subtask
- *
- * @access public
- */
- public function changeRestrictionStatus()
- {
- $task = $this->getTask();
- $subtask = $this->getSubtask();
- $values = $this->request->getValues();
-
- // Change status of the previous in progress subtask
- $this->subtask->update(array(
- 'id' => $values['id'],
- 'status' => $values['status'],
- ));
-
- // Set the current subtask to in pogress
- $this->subtask->update(array(
- 'id' => $subtask['id'],
- 'status' => SubtaskModel::STATUS_INPROGRESS,
- ));
-
- $this->toggleRedirect($task, $values['redirect']);
- }
-
- /**
- * Redirect to the right page
- *
- * @access private
- */
- private function toggleRedirect(array $task, $redirect)
- {
- switch ($redirect) {
- case 'board':
- $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])));
- case 'dashboard':
- $this->response->redirect($this->helper->url->to('app', 'index'));
- default:
- $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'subtasks'));
- }
+ $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true);
}
/**
@@ -267,8 +175,9 @@ class Subtask extends Base
$subtask_id = $this->request->getIntegerParam('subtask_id');
$direction = $this->request->getStringParam('direction');
$method = $direction === 'up' ? 'moveUp' : 'moveDown';
+ $redirect = $this->request->getStringParam('redirect', 'task');
$this->subtask->$method($task_id, $subtask_id);
- $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $project_id, 'task_id' => $task_id), 'subtasks'));
+ $this->response->redirect($this->helper->url->to($redirect, 'show', array('project_id' => $project_id, 'task_id' => $task_id), 'subtasks'));
}
}
diff --git a/app/Controller/SubtaskRestriction.php b/app/Controller/SubtaskRestriction.php
new file mode 100644
index 00000000..56024867
--- /dev/null
+++ b/app/Controller/SubtaskRestriction.php
@@ -0,0 +1,61 @@
+<?php
+
+namespace Kanboard\Controller;
+
+use Kanboard\Model\Subtask as SubtaskModel;
+
+/**
+ * Subtask Restriction
+ *
+ * @package controller
+ * @author Frederic Guillot
+ */
+class SubtaskRestriction extends Base
+{
+ /**
+ * Show popup
+ *
+ * @access public
+ */
+ public function popover()
+ {
+ $task = $this->getTask();
+ $subtask = $this->getSubtask();
+
+ $this->response->html($this->template->render('subtask_restriction/popover', array(
+ 'status_list' => array(
+ SubtaskModel::STATUS_TODO => t('Todo'),
+ SubtaskModel::STATUS_DONE => t('Done'),
+ ),
+ 'subtask_inprogress' => $this->subtask->getSubtaskInProgress($this->userSession->getId()),
+ 'subtask' => $subtask,
+ 'task' => $task,
+ )));
+ }
+
+ /**
+ * Change status of the in progress subtask and the other subtask
+ *
+ * @access public
+ */
+ public function update()
+ {
+ $task = $this->getTask();
+ $subtask = $this->getSubtask();
+ $values = $this->request->getValues();
+
+ // Change status of the previous "in progress" subtask
+ $this->subtask->update(array(
+ 'id' => $values['id'],
+ 'status' => $values['status'],
+ ));
+
+ // Set the current subtask to "in progress"
+ $this->subtask->update(array(
+ 'id' => $subtask['id'],
+ 'status' => SubtaskModel::STATUS_INPROGRESS,
+ ));
+
+ $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true);
+ }
+}
diff --git a/app/Controller/SubtaskStatus.php b/app/Controller/SubtaskStatus.php
new file mode 100644
index 00000000..efe8a974
--- /dev/null
+++ b/app/Controller/SubtaskStatus.php
@@ -0,0 +1,28 @@
+<?php
+
+namespace Kanboard\Controller;
+
+/**
+ * Subtask Status
+ *
+ * @package controller
+ * @author Frederic Guillot
+ */
+class SubtaskStatus extends Base
+{
+ /**
+ * Change status to the next status: Toto -> In Progress -> Done
+ *
+ * @access public
+ */
+ public function change()
+ {
+ $task = $this->getTask();
+ $subtask = $this->getSubtask();
+
+ $status = $this->subtask->toggleStatus($subtask['id']);
+ $subtask['status'] = $status;
+
+ $this->response->html($this->helper->subtask->toggleStatus($subtask, $task['project_id']));
+ }
+}
diff --git a/app/Controller/Swimlane.php b/app/Controller/Swimlane.php
index 66410888..4e8c2863 100644
--- a/app/Controller/Swimlane.php
+++ b/app/Controller/Swimlane.php
@@ -40,7 +40,7 @@ class Swimlane extends Base
{
$project = $this->getProject();
- $this->response->html($this->projectLayout('swimlane/index', array(
+ $this->response->html($this->helper->layout->project('swimlane/index', array(
'default_swimlane' => $this->swimlane->getDefault($project['id']),
'active_swimlanes' => $this->swimlane->getAllByStatus($project['id'], SwimlaneModel::ACTIVE),
'inactive_swimlanes' => $this->swimlane->getAllByStatus($project['id'], SwimlaneModel::INACTIVE),
@@ -108,7 +108,7 @@ class Swimlane extends Base
$project = $this->getProject();
$swimlane = $this->getSwimlane($project['id']);
- $this->response->html($this->projectLayout('swimlane/edit', array(
+ $this->response->html($this->helper->layout->project('swimlane/edit', array(
'values' => empty($values) ? $swimlane : $values,
'errors' => $errors,
'project' => $project,
@@ -150,7 +150,7 @@ class Swimlane extends Base
$project = $this->getProject();
$swimlane = $this->getSwimlane($project['id']);
- $this->response->html($this->projectLayout('swimlane/remove', array(
+ $this->response->html($this->helper->layout->project('swimlane/remove', array(
'project' => $project,
'swimlane' => $swimlane,
'title' => t('Remove a swimlane')
diff --git a/app/Controller/Task.php b/app/Controller/Task.php
index 1811dcb7..0d463725 100644
--- a/app/Controller/Task.php
+++ b/app/Controller/Task.php
@@ -30,7 +30,7 @@ class Task extends Base
$this->notfound(true);
}
- $this->response->html($this->template->layout('task/public', array(
+ $this->response->html($this->helper->layout->app('task/public', array(
'project' => $project,
'comments' => $this->comment->getAll($task['id']),
'subtasks' => $this->subtask->getAll($task['id']),
@@ -64,7 +64,7 @@ class Task extends Base
$this->dateParser->format($values, array('date_started'), 'Y-m-d H:i');
- $this->response->html($this->taskLayout('task/show', array(
+ $this->response->html($this->helper->layout->task('task/show', array(
'project' => $this->project->getById($task['project_id']),
'files' => $this->file->getAllDocuments($task['id']),
'images' => $this->file->getAllImages($task['id']),
@@ -95,7 +95,7 @@ class Task extends Base
{
$task = $this->getTask();
- $this->response->html($this->taskLayout('task/analytics', array(
+ $this->response->html($this->helper->layout->task('task/analytics', array(
'title' => $task['title'],
'task' => $task,
'lead_time' => $this->taskAnalytic->getLeadTime($task),
@@ -121,7 +121,7 @@ class Task extends Base
->setQuery($this->subtaskTimeTracking->getTaskQuery($task['id']))
->calculateOnlyIf($this->request->getStringParam('pagination') === 'subtasks');
- $this->response->html($this->taskLayout('task/time_tracking_details', array(
+ $this->response->html($this->helper->layout->task('task/time_tracking_details', array(
'task' => $task,
'subtask_paginator' => $subtask_paginator,
)));
@@ -136,7 +136,7 @@ class Task extends Base
{
$task = $this->getTask();
- $this->response->html($this->taskLayout('task/transitions', array(
+ $this->response->html($this->helper->layout->task('task/transitions', array(
'task' => $task,
'transitions' => $this->transition->getAllByTask($task['id']),
)));
@@ -167,7 +167,7 @@ class Task extends Base
$this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])));
}
- $this->response->html($this->taskLayout('task/remove', array(
+ $this->response->html($this->helper->layout->task('task/remove', array(
'task' => $task,
)));
}
diff --git a/app/Controller/TaskExternalLink.php b/app/Controller/TaskExternalLink.php
new file mode 100644
index 00000000..f26922dd
--- /dev/null
+++ b/app/Controller/TaskExternalLink.php
@@ -0,0 +1,185 @@
+<?php
+
+namespace Kanboard\Controller;
+
+use Kanboard\Core\ExternalLink\ExternalLinkProviderNotFound;
+
+/**
+ * Task External Link Controller
+ *
+ * @package controller
+ * @author Frederic Guillot
+ */
+class TaskExternalLink extends Base
+{
+ /**
+ * Creation form
+ *
+ * @access public
+ */
+ public function show()
+ {
+ $task = $this->getTask();
+
+ $this->response->html($this->helper->layout->task('task_external_link/show', array(
+ 'links' => $this->taskExternalLink->getAll($task['id']),
+ 'task' => $task,
+ 'title' => t('List of external links'),
+ )));
+ }
+
+ /**
+ * First creation form
+ *
+ * @access public
+ */
+ public function find(array $values = array(), array $errors = array())
+ {
+ $task = $this->getTask();
+
+ $this->response->html($this->helper->layout->task('task_external_link/find', array(
+ 'values' => $values,
+ 'errors' => $errors,
+ 'task' => $task,
+ 'types' => $this->externalLinkManager->getTypes(),
+ )));
+ }
+
+ /**
+ * Second creation form
+ *
+ * @access public
+ */
+ public function create()
+ {
+ try {
+
+ $task = $this->getTask();
+ $values = $this->request->getValues();
+
+ $provider = $this->externalLinkManager->setUserInput($values)->find();
+ $link = $provider->getLink();
+
+ $this->response->html($this->helper->layout->task('task_external_link/create', array(
+ 'values' => array(
+ 'title' => $link->getTitle(),
+ 'url' => $link->getUrl(),
+ 'link_type' => $provider->getType(),
+ ),
+ 'dependencies' => $provider->getDependencies(),
+ 'errors' => array(),
+ 'task' => $task,
+ )));
+
+ } catch (ExternalLinkProviderNotFound $e) {
+ $errors = array('text' => array(t('Unable to fetch link information.')));
+ $this->find($values, $errors);
+ }
+ }
+
+ /**
+ * Save link
+ *
+ * @access public
+ */
+ public function save()
+ {
+ $task = $this->getTask();
+ $values = $this->request->getValues();
+ list($valid, $errors) = $this->externalLinkValidator->validateCreation($values);
+
+ if ($valid && $this->taskExternalLink->create($values)) {
+ $this->flash->success(t('Link added successfully.'));
+ return $this->response->redirect($this->helper->url->to('TaskExternalLink', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true);
+ }
+
+ $this->edit($values, $errors);
+ }
+
+ /**
+ * Edit form
+ *
+ * @access public
+ */
+ public function edit(array $values = array(), array $errors = array())
+ {
+ $task = $this->getTask();
+ $link_id = $this->request->getIntegerParam('link_id');
+
+ if ($link_id > 0) {
+ $values = $this->taskExternalLink->getById($link_id);
+ }
+
+ if (empty($values)) {
+ return $this->notfound();
+ }
+
+ $provider = $this->externalLinkManager->getProvider($values['link_type']);
+
+ $this->response->html($this->helper->layout->task('task_external_link/edit', array(
+ 'values' => $values,
+ 'errors' => $errors,
+ 'task' => $task,
+ 'dependencies' => $provider->getDependencies(),
+ )));
+ }
+
+ /**
+ * Update link
+ *
+ * @access public
+ */
+ public function update()
+ {
+ $task = $this->getTask();
+ $values = $this->request->getValues();
+ list($valid, $errors) = $this->externalLinkValidator->validateModification($values);
+
+ if ($valid && $this->taskExternalLink->update($values)) {
+ $this->flash->success(t('Link updated successfully.'));
+ return $this->response->redirect($this->helper->url->to('TaskExternalLink', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true);
+ }
+
+ $this->edit($values, $errors);
+ }
+
+ /**
+ * Confirmation dialog before removing a link
+ *
+ * @access public
+ */
+ public function confirm()
+ {
+ $task = $this->getTask();
+ $link_id = $this->request->getIntegerParam('link_id');
+ $link = $this->taskExternalLink->getById($link_id);
+
+ if (empty($link)) {
+ return $this->notfound();
+ }
+
+ $this->response->html($this->helper->layout->task('task_external_link/remove', array(
+ 'link' => $link,
+ 'task' => $task,
+ )));
+ }
+
+ /**
+ * Remove a link
+ *
+ * @access public
+ */
+ public function remove()
+ {
+ $this->checkCSRFParam();
+ $task = $this->getTask();
+
+ if ($this->taskExternalLink->remove($this->request->getIntegerParam('link_id'))) {
+ $this->flash->success(t('Link removed successfully.'));
+ } else {
+ $this->flash->failure(t('Unable to remove this link.'));
+ }
+
+ $this->response->redirect($this->helper->url->to('TaskExternalLink', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])));
+ }
+}
diff --git a/app/Controller/TaskImport.php b/app/Controller/TaskImport.php
index f09c14ce..460c608c 100644
--- a/app/Controller/TaskImport.php
+++ b/app/Controller/TaskImport.php
@@ -20,7 +20,7 @@ class TaskImport extends Base
{
$project = $this->getProject();
- $this->response->html($this->projectLayout('task_import/step1', array(
+ $this->response->html($this->helper->layout->project('task_import/step1', array(
'project' => $project,
'values' => $values,
'errors' => $errors,
diff --git a/app/Controller/TaskRecurrence.php b/app/Controller/TaskRecurrence.php
new file mode 100644
index 00000000..f02f3cdc
--- /dev/null
+++ b/app/Controller/TaskRecurrence.php
@@ -0,0 +1,61 @@
+<?php
+
+namespace Kanboard\Controller;
+
+/**
+ * Task Recurrence controller
+ *
+ * @package controller
+ * @author Frederic Guillot
+ */
+class TaskRecurrence extends Base
+{
+ /**
+ * Edit recurrence form
+ *
+ * @access public
+ */
+ public function edit(array $values = array(), array $errors = array())
+ {
+ $task = $this->getTask();
+
+ if (empty($values)) {
+ $values = $task;
+ }
+
+ $this->response->html($this->helper->layout->task('task_recurrence/edit', array(
+ 'values' => $values,
+ 'errors' => $errors,
+ 'task' => $task,
+ 'recurrence_status_list' => $this->task->getRecurrenceStatusList(),
+ 'recurrence_trigger_list' => $this->task->getRecurrenceTriggerList(),
+ 'recurrence_timeframe_list' => $this->task->getRecurrenceTimeframeList(),
+ 'recurrence_basedate_list' => $this->task->getRecurrenceBasedateList(),
+ )));
+ }
+
+ /**
+ * Update recurrence form
+ *
+ * @access public
+ */
+ public function update()
+ {
+ $task = $this->getTask();
+ $values = $this->request->getValues();
+
+ list($valid, $errors) = $this->taskValidator->validateEditRecurrence($values);
+
+ if ($valid) {
+ if ($this->taskModification->update($values)) {
+ $this->flash->success(t('Task updated successfully.'));
+ } else {
+ $this->flash->failure(t('Unable to update your task.'));
+ }
+
+ $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true);
+ }
+
+ $this->edit($values, $errors);
+ }
+}
diff --git a/app/Controller/Taskcreation.php b/app/Controller/Taskcreation.php
index 49ccea7f..e661587c 100644
--- a/app/Controller/Taskcreation.php
+++ b/app/Controller/Taskcreation.php
@@ -18,22 +18,21 @@ class Taskcreation extends Base
public function create(array $values = array(), array $errors = array())
{
$project = $this->getProject();
- $method = $this->request->isAjax() ? 'render' : 'layout';
$swimlanes_list = $this->swimlane->getList($project['id'], false, true);
if (empty($values)) {
$values = array(
'swimlane_id' => $this->request->getIntegerParam('swimlane_id', key($swimlanes_list)),
'column_id' => $this->request->getIntegerParam('column_id'),
- 'color_id' => $this->request->getStringParam('color_id', $this->color->getDefaultColor()),
- 'owner_id' => $this->request->getIntegerParam('owner_id'),
- 'another_task' => $this->request->getIntegerParam('another_task'),
+ 'color_id' => $this->color->getDefaultColor(),
+ 'owner_id' => $this->userSession->getId(),
);
+
+ $values = $this->hook->merge('controller:task:form:default', $values, array('default_values' => $values));
}
- $this->response->html($this->template->$method('task_creation/form', array(
+ $this->response->html($this->template->render('task_creation/form', array(
'project' => $project,
- 'ajax' => $this->request->isAjax(),
'errors' => $errors,
'values' => $values + array('project_id' => $project['id']),
'columns_list' => $this->board->getColumnsList($project['id']),
@@ -41,8 +40,6 @@ class Taskcreation extends Base
'colors_list' => $this->color->getList(),
'categories_list' => $this->category->getList($project['id']),
'swimlanes_list' => $swimlanes_list,
- 'date_format' => $this->config->get('application_date_format'),
- 'date_formats' => $this->dateParser->getAvailableFormats(),
'title' => $project['name'].' &gt; '.t('New task')
)));
}
@@ -61,25 +58,26 @@ class Taskcreation extends Base
if ($valid && $this->taskCreation->create($values)) {
$this->flash->success(t('Task created successfully.'));
- $this->afterSave($project, $values);
- } else {
- $this->flash->failure(t('Unable to create your task.'));
+ return $this->afterSave($project, $values);
}
+ $this->flash->failure(t('Unable to create your task.'));
$this->create($values, $errors);
}
private function afterSave(array $project, array &$values)
{
if (isset($values['another_task']) && $values['another_task'] == 1) {
- unset($values['title']);
- unset($values['description']);
-
- if (! $this->request->isAjax()) {
- $this->response->redirect($this->helper->url->to('taskcreation', 'create', $values));
- }
- } else {
- $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $project['id'])));
+ return $this->create(array(
+ 'owner_id' => $values['owner_id'],
+ 'color_id' => $values['color_id'],
+ 'category_id' => isset($values['category_id']) ? $values['category_id'] : 0,
+ 'column_id' => $values['column_id'],
+ 'swimlane_id' => isset($values['swimlane_id']) ? $values['swimlane_id'] : 0,
+ 'another_task' => 1,
+ ));
}
+
+ $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $project['id'])));
}
}
diff --git a/app/Controller/Taskduplication.php b/app/Controller/Taskduplication.php
index ae8bfcbc..7e7fccd6 100644
--- a/app/Controller/Taskduplication.php
+++ b/app/Controller/Taskduplication.php
@@ -2,8 +2,6 @@
namespace Kanboard\Controller;
-use Kanboard\Model\Project as ProjectModel;
-
/**
* Task Duplication controller
*
@@ -30,11 +28,11 @@ class Taskduplication extends Base
$this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task_id)));
} else {
$this->flash->failure(t('Unable to create this task.'));
- $this->response->redirect($this->helper->url->to('taskduplication', 'duplicate', array('project_id' => $task['project_id'], 'task_id' => $task['id'])));
+ $this->response->redirect($this->helper->url->to('taskduplication', 'duplicate', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true);
}
}
- $this->response->html($this->taskLayout('task_duplication/duplicate', array(
+ $this->response->html($this->helper->layout->task('task_duplication/duplicate', array(
'task' => $task,
)));
}
@@ -109,7 +107,7 @@ class Taskduplication extends Base
private function chooseDestination(array $task, $template)
{
$values = array();
- $projects_list = $this->projectUserRole->getProjectsByUser($this->userSession->getId(), array(ProjectModel::ACTIVE));
+ $projects_list = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
unset($projects_list[$task['project_id']]);
@@ -130,7 +128,7 @@ class Taskduplication extends Base
$users_list = array();
}
- $this->response->html($this->taskLayout($template, array(
+ $this->response->html($this->helper->layout->task($template, array(
'values' => $values,
'task' => $task,
'projects_list' => $projects_list,
diff --git a/app/Controller/Tasklink.php b/app/Controller/Tasklink.php
index a81d3ee5..fdb4fada 100644
--- a/app/Controller/Tasklink.php
+++ b/app/Controller/Tasklink.php
@@ -22,13 +22,32 @@ class Tasklink extends Base
$link = $this->taskLink->getById($this->request->getIntegerParam('link_id'));
if (empty($link)) {
- $this->notfound();
+ return $this->notfound();
}
return $link;
}
/**
+ * Show links
+ *
+ * @access public
+ */
+ public function show()
+ {
+ $task = $this->getTask();
+ $project = $this->project->getById($task['project_id']);
+
+ $this->response->html($this->helper->layout->task('tasklink/show', array(
+ 'links' => $this->taskLink->getAllGroupedByLabel($task['id']),
+ 'task' => $task,
+ 'project' => $project,
+ 'editable' => true,
+ 'is_public' => false,
+ )));
+ }
+
+ /**
* Creation form
*
* @access public
@@ -36,20 +55,8 @@ class Tasklink extends Base
public function create(array $values = array(), array $errors = array())
{
$task = $this->getTask();
- $ajax = $this->request->isAjax() || $this->request->getIntegerParam('ajax');
-
- if ($ajax && empty($errors)) {
- $this->response->html($this->template->render('tasklink/create', array(
- 'values' => $values,
- 'errors' => $errors,
- 'task' => $task,
- 'labels' => $this->link->getList(0, false),
- 'title' => t('Add a new link'),
- 'ajax' => $ajax,
- )));
- }
- $this->response->html($this->taskLayout('tasklink/create', array(
+ $this->response->html($this->helper->layout->task('tasklink/create', array(
'values' => $values,
'errors' => $errors,
'task' => $task,
@@ -67,19 +74,13 @@ class Tasklink extends Base
{
$task = $this->getTask();
$values = $this->request->getValues();
- $ajax = $this->request->isAjax() || $this->request->getIntegerParam('ajax');
list($valid, $errors) = $this->taskLinkValidator->validateCreation($values);
if ($valid) {
if ($this->taskLink->create($values['task_id'], $values['opposite_task_id'], $values['link_id'])) {
$this->flash->success(t('Link added successfully.'));
-
- if ($ajax) {
- $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])));
- }
-
- $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])).'#links');
+ return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])).'#links', true);
}
$errors = array('title' => array(t('The exact same link already exists')));
@@ -105,7 +106,7 @@ class Tasklink extends Base
$values['title'] = '#'.$opposite_task['id'].' - '.$opposite_task['title'];
}
- $this->response->html($this->taskLayout('tasklink/edit', array(
+ $this->response->html($this->helper->layout->task('tasklink/edit', array(
'values' => $values,
'errors' => $errors,
'task_link' => $task_link,
@@ -130,7 +131,7 @@ class Tasklink extends Base
if ($valid) {
if ($this->taskLink->update($values['id'], $values['task_id'], $values['opposite_task_id'], $values['link_id'])) {
$this->flash->success(t('Link updated successfully.'));
- $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])).'#links');
+ return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])).'#links');
}
$this->flash->failure(t('Unable to update your link.'));
@@ -149,7 +150,7 @@ class Tasklink extends Base
$task = $this->getTask();
$link = $this->getTaskLink();
- $this->response->html($this->taskLayout('tasklink/remove', array(
+ $this->response->html($this->helper->layout->task('tasklink/remove', array(
'link' => $link,
'task' => $task,
)));
diff --git a/app/Controller/Taskmodification.php b/app/Controller/Taskmodification.php
index 2c97970b..0e9316b2 100644
--- a/app/Controller/Taskmodification.php
+++ b/app/Controller/Taskmodification.php
@@ -48,46 +48,44 @@ class Taskmodification extends Base
*
* @access public
*/
- public function description()
+ public function description(array $values = array(), array $errors = array())
{
$task = $this->getTask();
- $ajax = $this->request->isAjax() || $this->request->getIntegerParam('ajax');
- if ($this->request->isPost()) {
- $values = $this->request->getValues();
-
- list($valid, $errors) = $this->taskValidator->validateDescriptionCreation($values);
-
- if ($valid) {
- if ($this->taskModification->update($values)) {
- $this->flash->success(t('Task updated successfully.'));
- } else {
- $this->flash->failure(t('Unable to update your task.'));
- }
-
- if ($ajax) {
- $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])));
- } else {
- $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])));
- }
- }
- } else {
- $values = $task;
- $errors = array();
+ if (empty($values)) {
+ $values = array('id' => $task['id'], 'description' => $task['description']);
}
- $params = array(
+ $this->response->html($this->helper->layout->task('task_modification/edit_description', array(
'values' => $values,
'errors' => $errors,
'task' => $task,
- 'ajax' => $ajax,
- );
+ )));
+ }
- if ($ajax) {
- $this->response->html($this->template->render('task_modification/edit_description', $params));
- } else {
- $this->response->html($this->taskLayout('task_modification/edit_description', $params));
+ /**
+ * Update description
+ *
+ * @access public
+ */
+ public function updateDescription()
+ {
+ $task = $this->getTask();
+ $values = $this->request->getValues();
+
+ list($valid, $errors) = $this->taskValidator->validateDescriptionCreation($values);
+
+ if ($valid) {
+ if ($this->taskModification->update($values)) {
+ $this->flash->success(t('Task updated successfully.'));
+ } else {
+ $this->flash->failure(t('Unable to update your task.'));
+ }
+
+ return $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true);
}
+
+ $this->description($values, $errors);
}
/**
@@ -99,15 +97,15 @@ class Taskmodification extends Base
{
$task = $this->getTask();
$project = $this->project->getById($task['project_id']);
- $ajax = $this->request->isAjax();
if (empty($values)) {
$values = $task;
+ $values = $this->hook->merge('controller:task:form:default', $values, array('default_values' => $values));
}
$this->dateParser->format($values, array('date_due'));
- $params = array(
+ $this->response->html($this->helper->layout->task('task_modification/edit_task', array(
'project' => $project,
'values' => $values,
'errors' => $errors,
@@ -117,16 +115,7 @@ class Taskmodification extends Base
'categories_list' => $this->category->getList($task['project_id']),
'date_format' => $this->config->get('application_date_format'),
'date_formats' => $this->dateParser->getAvailableFormats(),
- 'ajax' => $ajax,
- );
-
- if ($ajax) {
- $html = $this->template->render('task_modification/edit_task', $params);
- } else {
- $html = $this->taskLayout('task_modification/edit_task', $params);
- }
-
- $this->response->html($html);
+ )));
}
/**
@@ -143,56 +132,10 @@ class Taskmodification extends Base
if ($valid && $this->taskModification->update($values)) {
$this->flash->success(t('Task updated successfully.'));
-
- if ($this->request->isAjax()) {
- $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])));
- } else {
- $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])));
- }
+ return $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])), true);
} else {
$this->flash->failure(t('Unable to update your task.'));
$this->edit($values, $errors);
}
}
-
- /**
- * Edit recurrence form
- *
- * @access public
- */
- public function recurrence()
- {
- $task = $this->getTask();
-
- if ($this->request->isPost()) {
- $values = $this->request->getValues();
-
- list($valid, $errors) = $this->taskValidator->validateEditRecurrence($values);
-
- if ($valid) {
- if ($this->taskModification->update($values)) {
- $this->flash->success(t('Task updated successfully.'));
- } else {
- $this->flash->failure(t('Unable to update your task.'));
- }
-
- $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])));
- }
- } else {
- $values = $task;
- $errors = array();
- }
-
- $params = array(
- 'values' => $values,
- 'errors' => $errors,
- 'task' => $task,
- 'recurrence_status_list' => $this->task->getRecurrenceStatusList(),
- 'recurrence_trigger_list' => $this->task->getRecurrenceTriggerList(),
- 'recurrence_timeframe_list' => $this->task->getRecurrenceTimeframeList(),
- 'recurrence_basedate_list' => $this->task->getRecurrenceBasedateList(),
- );
-
- $this->response->html($this->taskLayout('task_modification/edit_recurrence', $params));
- }
}
diff --git a/app/Controller/Taskstatus.php b/app/Controller/Taskstatus.php
index b03baebf..c07f2cc5 100644
--- a/app/Controller/Taskstatus.php
+++ b/app/Controller/Taskstatus.php
@@ -17,9 +17,7 @@ class Taskstatus extends Base
*/
public function close()
{
- $task = $this->getTask();
- $this->changeStatus($task, 'close', t('Task closed successfully.'), t('Unable to close this task.'));
- $this->renderTemplate($task, 'task_status/close');
+ $this->changeStatus('close', 'task_status/close', t('Task closed successfully.'), t('Unable to close this task.'));
}
/**
@@ -29,13 +27,22 @@ class Taskstatus extends Base
*/
public function open()
{
- $task = $this->getTask();
- $this->changeStatus($task, 'open', t('Task opened successfully.'), t('Unable to open this task.'));
- $this->renderTemplate($task, 'task_status/open');
+ $this->changeStatus('open', 'task_status/open', t('Task opened successfully.'), t('Unable to open this task.'));
}
- private function changeStatus(array $task, $method, $success_message, $failure_message)
+ /**
+ * Common method to change status
+ *
+ * @access private
+ * @param string $method
+ * @param string $template
+ * @param string $success_message
+ * @param string $failure_message
+ */
+ private function changeStatus($method, $template, $success_message, $failure_message)
{
+ $task = $this->getTask();
+
if ($this->request->getStringParam('confirmation') === 'yes') {
$this->checkCSRFParam();
@@ -45,28 +52,11 @@ class Taskstatus extends Base
$this->flash->failure($failure_message);
}
- if ($this->request->getStringParam('redirect') === 'board') {
- $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])));
- }
-
- $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])));
- }
- }
-
- private function renderTemplate(array $task, $template)
- {
- $redirect = $this->request->getStringParam('redirect');
-
- if ($this->request->isAjax()) {
- $this->response->html($this->template->render($template, array(
- 'task' => $task,
- 'redirect' => $redirect,
- )));
+ return $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), true);
}
- $this->response->html($this->taskLayout($template, array(
+ $this->response->html($this->helper->layout->task($template, array(
'task' => $task,
- 'redirect' => $redirect,
)));
}
}
diff --git a/app/Controller/Twofactor.php b/app/Controller/Twofactor.php
index 8dbfcf66..10292261 100644
--- a/app/Controller/Twofactor.php
+++ b/app/Controller/Twofactor.php
@@ -33,7 +33,7 @@ class Twofactor extends User
$this->checkCurrentUser($user);
unset($this->sessionStorage->twoFactorSecret);
- $this->response->html($this->layout('twofactor/index', array(
+ $this->response->html($this->helper->layout->user('twofactor/index', array(
'user' => $user,
'provider' => $this->authenticationManager->getPostAuthenticationProvider()->getName(),
)));
@@ -60,7 +60,7 @@ class Twofactor extends User
$provider->setSecret($this->sessionStorage->twoFactorSecret);
}
- $this->response->html($this->layout('twofactor/show', array(
+ $this->response->html($this->helper->layout->user('twofactor/show', array(
'user' => $user,
'secret' => $this->sessionStorage->twoFactorSecret,
'qrcode_url' => $provider->getQrCodeUrl($label),
@@ -165,7 +165,7 @@ class Twofactor extends User
$this->sessionStorage->twoFactorBeforeCodeCalled = true;
}
- $this->response->html($this->template->layout('twofactor/check', array(
+ $this->response->html($this->helper->layout->app('twofactor/check', array(
'title' => t('Check two factor authentication code'),
)));
}
@@ -191,7 +191,7 @@ class Twofactor extends User
$this->response->redirect($this->helper->url->to('user', 'show', array('user_id' => $user['id'])));
}
- $this->response->html($this->layout('twofactor/disable', array(
+ $this->response->html($this->helper->layout->user('twofactor/disable', array(
'user' => $user,
)));
}
diff --git a/app/Controller/User.php b/app/Controller/User.php
index 97e01553..881266d4 100644
--- a/app/Controller/User.php
+++ b/app/Controller/User.php
@@ -15,27 +15,6 @@ use Kanboard\Core\Security\Role;
class User extends Base
{
/**
- * Common layout for user views
- *
- * @access protected
- * @param string $template Template name
- * @param array $params Template parameters
- * @return string
- */
- protected function layout($template, array $params)
- {
- $content = $this->template->render($template, $params);
- $params['user_content_for_layout'] = $content;
- $params['board_selector'] = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
-
- if (isset($params['user'])) {
- $params['title'] = ($params['user']['name'] ?: $params['user']['username']).' (#'.$params['user']['id'].')';
- }
-
- return $this->template->layout('user/layout', $params);
- }
-
- /**
* List all users
*
* @access public
@@ -50,8 +29,7 @@ class User extends Base
->calculate();
$this->response->html(
- $this->template->layout('user/index', array(
- 'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
+ $this->helper->layout->app('user/index', array(
'title' => t('Users').' ('.$paginator->getTotal().')',
'paginator' => $paginator,
)));
@@ -71,8 +49,7 @@ class User extends Base
}
$this->response->html(
- $this->template->layout('user/profile', array(
- 'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
+ $this->helper->layout->app('user/profile', array(
'title' => $user['name'] ?: $user['username'],
'user' => $user,
)
@@ -88,11 +65,10 @@ class User extends Base
{
$is_remote = $this->request->getIntegerParam('remote') == 1 || (isset($values['is_ldap_user']) && $values['is_ldap_user'] == 1);
- $this->response->html($this->template->layout($is_remote ? 'user/create_remote' : 'user/create_local', array(
+ $this->response->html($this->helper->layout->app($is_remote ? 'user/create_remote' : 'user/create_local', array(
'timezones' => $this->config->getTimezones(true),
'languages' => $this->config->getLanguages(true),
'roles' => $this->role->getApplicationRoles(),
- 'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
'projects' => $this->project->getList(),
'errors' => $errors,
'values' => $values + array('role' => Role::APP_USER),
@@ -142,7 +118,7 @@ class User extends Base
public function show()
{
$user = $this->getUser();
- $this->response->html($this->layout('user/show', array(
+ $this->response->html($this->helper->layout->user('user/show', array(
'user' => $user,
'timezones' => $this->config->getTimezones(true),
'languages' => $this->config->getLanguages(true),
@@ -166,7 +142,7 @@ class User extends Base
->setQuery($this->subtaskTimeTracking->getUserQuery($user['id']))
->calculateOnlyIf($this->request->getStringParam('pagination') === 'subtasks');
- $this->response->html($this->layout('user/timesheet', array(
+ $this->response->html($this->helper->layout->user('user/timesheet', array(
'subtask_paginator' => $subtask_paginator,
'user' => $user,
)));
@@ -180,7 +156,7 @@ class User extends Base
public function passwordReset()
{
$user = $this->getUser();
- $this->response->html($this->layout('user/password_reset', array(
+ $this->response->html($this->helper->layout->user('user/password_reset', array(
'tokens' => $this->passwordReset->getAll($user['id']),
'user' => $user,
)));
@@ -194,7 +170,7 @@ class User extends Base
public function last()
{
$user = $this->getUser();
- $this->response->html($this->layout('user/last', array(
+ $this->response->html($this->helper->layout->user('user/last', array(
'last_logins' => $this->lastLogin->getAll($user['id']),
'user' => $user,
)));
@@ -208,7 +184,7 @@ class User extends Base
public function sessions()
{
$user = $this->getUser();
- $this->response->html($this->layout('user/sessions', array(
+ $this->response->html($this->helper->layout->user('user/sessions', array(
'sessions' => $this->rememberMeSession->getAll($user['id']),
'user' => $user,
)));
@@ -243,7 +219,7 @@ class User extends Base
$this->response->redirect($this->helper->url->to('user', 'notifications', array('user_id' => $user['id'])));
}
- $this->response->html($this->layout('user/notifications', array(
+ $this->response->html($this->helper->layout->user('user/notifications', array(
'projects' => $this->projectUserRole->getProjectsByUser($user['id'], array(ProjectModel::ACTIVE)),
'notifications' => $this->userNotification->readSettings($user['id']),
'types' => $this->userNotificationType->getTypes(),
@@ -268,7 +244,7 @@ class User extends Base
$this->response->redirect($this->helper->url->to('user', 'integrations', array('user_id' => $user['id'])));
}
- $this->response->html($this->layout('user/integrations', array(
+ $this->response->html($this->helper->layout->user('user/integrations', array(
'user' => $user,
'values' => $this->userMetadata->getall($user['id']),
)));
@@ -282,7 +258,7 @@ class User extends Base
public function external()
{
$user = $this->getUser();
- $this->response->html($this->layout('user/external', array(
+ $this->response->html($this->helper->layout->user('user/external', array(
'last_logins' => $this->lastLogin->getAll($user['id']),
'user' => $user,
)));
@@ -310,7 +286,7 @@ class User extends Base
$this->response->redirect($this->helper->url->to('user', 'share', array('user_id' => $user['id'])));
}
- $this->response->html($this->layout('user/share', array(
+ $this->response->html($this->helper->layout->user('user/share', array(
'user' => $user,
'title' => t('Public access'),
)));
@@ -342,7 +318,7 @@ class User extends Base
}
}
- $this->response->html($this->layout('user/password', array(
+ $this->response->html($this->helper->layout->user('user/password', array(
'values' => $values,
'errors' => $errors,
'user' => $user,
@@ -384,7 +360,7 @@ class User extends Base
}
}
- $this->response->html($this->layout('user/edit', array(
+ $this->response->html($this->helper->layout->user('user/edit', array(
'values' => $values,
'errors' => $errors,
'user' => $user,
@@ -422,7 +398,7 @@ class User extends Base
}
}
- $this->response->html($this->layout('user/authentication', array(
+ $this->response->html($this->helper->layout->user('user/authentication', array(
'values' => $values,
'errors' => $errors,
'user' => $user,
@@ -450,7 +426,7 @@ class User extends Base
$this->response->redirect($this->helper->url->to('user', 'index'));
}
- $this->response->html($this->layout('user/remove', array(
+ $this->response->html($this->helper->layout->user('user/remove', array(
'user' => $user,
)));
}
diff --git a/app/Controller/UserImport.php b/app/Controller/UserImport.php
index cbc5aa14..debd69e5 100644
--- a/app/Controller/UserImport.php
+++ b/app/Controller/UserImport.php
@@ -18,7 +18,7 @@ class UserImport extends Base
*/
public function step1(array $values = array(), array $errors = array())
{
- $this->response->html($this->template->layout('user_import/step1', array(
+ $this->response->html($this->helper->layout->app('user_import/step1', array(
'values' => $values,
'errors' => $errors,
'max_size' => ini_get('upload_max_filesize'),