summaryrefslogtreecommitdiff
path: root/app/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'app/Controller')
-rw-r--r--app/Controller/Action.php10
-rw-r--r--app/Controller/Activity.php45
-rw-r--r--app/Controller/Analytic.php58
-rw-r--r--app/Controller/Auth.php8
-rw-r--r--app/Controller/Base.php48
-rw-r--r--app/Controller/Board.php111
-rw-r--r--app/Controller/Calendar.php23
-rw-r--r--app/Controller/Category.php8
-rw-r--r--app/Controller/Comment.php8
-rw-r--r--app/Controller/Config.php7
-rw-r--r--app/Controller/Export.php2
-rw-r--r--app/Controller/Ical.php4
-rw-r--r--app/Controller/Listing.php37
-rw-r--r--app/Controller/Oauth.php123
-rw-r--r--app/Controller/Project.php25
-rw-r--r--app/Controller/Projectinfo.php95
-rw-r--r--app/Controller/Search.php2
-rw-r--r--app/Controller/Subtask.php12
-rw-r--r--app/Controller/Swimlane.php18
-rw-r--r--app/Controller/Task.php494
-rw-r--r--app/Controller/Taskcreation.php86
-rw-r--r--app/Controller/Taskduplication.php143
-rw-r--r--app/Controller/Taskmodification.php212
-rw-r--r--app/Controller/Taskstatus.php79
-rw-r--r--app/Controller/User.php168
25 files changed, 1003 insertions, 823 deletions
diff --git a/app/Controller/Action.php b/app/Controller/Action.php
index cd24453a..140c47d3 100644
--- a/app/Controller/Action.php
+++ b/app/Controller/Action.php
@@ -46,7 +46,7 @@ class Action extends Base
$values = $this->request->getValues();
if (empty($values['action_name']) || empty($values['project_id'])) {
- $this->response->redirect('?controller=action&action=index&project_id='.$project['id']);
+ $this->response->redirect($this->helper->url->to('action', 'index', array('project_id' => $project['id'])));
}
$this->response->html($this->projectLayout('action/event', array(
@@ -68,7 +68,7 @@ class Action extends Base
$values = $this->request->getValues();
if (empty($values['action_name']) || empty($values['project_id']) || empty($values['event_name'])) {
- $this->response->redirect('?controller=action&action=index&project_id='.$project['id']);
+ $this->response->redirect($this->helper->url->to('action', 'index', array('project_id' => $project['id'])));
}
$action = $this->action->load($values['action_name'], $values['project_id'], $values['event_name']);
@@ -117,7 +117,7 @@ class Action extends Base
if ($valid) {
- if ($this->action->create($values)) {
+ if ($this->action->create($values) !== false) {
$this->session->flash(t('Your automatic action have been created successfully.'));
}
else {
@@ -125,7 +125,7 @@ class Action extends Base
}
}
- $this->response->redirect('?controller=action&action=index&project_id='.$project['id']);
+ $this->response->redirect($this->helper->url->to('action', 'index', array('project_id' => $project['id'])));
}
/**
@@ -163,6 +163,6 @@ class Action extends Base
$this->session->flashError(t('Unable to remove this action.'));
}
- $this->response->redirect('?controller=action&action=index&project_id='.$project['id']);
+ $this->response->redirect($this->helper->url->to('action', 'index', array('project_id' => $project['id'])));
}
}
diff --git a/app/Controller/Activity.php b/app/Controller/Activity.php
new file mode 100644
index 00000000..234e4be4
--- /dev/null
+++ b/app/Controller/Activity.php
@@ -0,0 +1,45 @@
+<?php
+
+namespace Controller;
+
+/**
+ * Activity stream
+ *
+ * @package controller
+ * @author Frederic Guillot
+ */
+class Activity extends Base
+{
+ /**
+ * Activity page for a project
+ *
+ * @access public
+ */
+ public function project()
+ {
+ $project = $this->getProject();
+
+ $this->response->html($this->template->layout('activity/project', array(
+ 'board_selector' => $this->projectPermission->getAllowedProjects($this->userSession->getId()),
+ 'events' => $this->projectActivity->getProject($project['id']),
+ 'project' => $project,
+ 'title' => t('%s\'s activity', $project['name'])
+ )));
+ }
+
+ /**
+ * Display task activities
+ *
+ * @access public
+ */
+ public function task()
+ {
+ $task = $this->getTask();
+
+ $this->response->html($this->taskLayout('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 2413ba92..ca2146ed 100644
--- a/app/Controller/Analytic.php
+++ b/app/Controller/Analytic.php
@@ -3,7 +3,7 @@
namespace Controller;
/**
- * Project Anaytic controller
+ * Project Analytic controller
*
* @package controller
* @author Frederic Guillot
@@ -27,6 +27,56 @@ class Analytic extends Base
}
/**
+ * Show average Lead and Cycle time
+ *
+ * @access public
+ */
+ public function leadAndCycleTime()
+ {
+ $project = $this->getProject();
+ $values = $this->request->getValues();
+
+ $this->projectDailyStats->updateTotals($project['id'], date('Y-m-d'));
+
+ $from = $this->request->getStringParam('from', date('Y-m-d', strtotime('-1week')));
+ $to = $this->request->getStringParam('to', date('Y-m-d'));
+
+ if (! empty($values)) {
+ $from = $values['from'];
+ $to = $values['to'];
+ }
+
+ $this->response->html($this->layout('analytic/lead_cycle_time', array(
+ 'values' => array(
+ 'from' => $from,
+ 'to' => $to,
+ ),
+ 'project' => $project,
+ 'average' => $this->projectAnalytic->getAverageLeadAndCycleTime($project['id']),
+ 'metrics' => $this->projectDailyStats->getRawMetrics($project['id'], $from, $to),
+ 'date_format' => $this->config->get('application_date_format'),
+ 'date_formats' => $this->dateParser->getAvailableFormats(),
+ 'title' => t('Lead and Cycle time for "%s"', $project['name']),
+ )));
+ }
+
+ /**
+ * Show average time spent by column
+ *
+ * @access public
+ */
+ public function averageTimeByColumn()
+ {
+ $project = $this->getProject();
+
+ $this->response->html($this->layout('analytic/avg_time_columns', array(
+ 'project' => $project,
+ 'metrics' => $this->projectAnalytic->getAverageTimeSpentByColumn($project['id']),
+ 'title' => t('Average time spent into each column for "%s"', $project['name']),
+ )));
+ }
+
+ /**
* Show tasks distribution graph
*
* @access public
@@ -88,6 +138,8 @@ class Analytic extends Base
$project = $this->getProject();
$values = $this->request->getValues();
+ $this->projectDailyColumnStats->updateTotals($project['id'], date('Y-m-d'));
+
$from = $this->request->getStringParam('from', date('Y-m-d', strtotime('-1week')));
$to = $this->request->getStringParam('to', date('Y-m-d'));
@@ -96,7 +148,7 @@ class Analytic extends Base
$to = $values['to'];
}
- $display_graph = $this->projectDailySummary->countDays($project['id'], $from, $to) >= 2;
+ $display_graph = $this->projectDailyColumnStats->countDays($project['id'], $from, $to) >= 2;
$this->response->html($this->layout($template, array(
'values' => array(
@@ -104,7 +156,7 @@ class Analytic extends Base
'to' => $to,
),
'display_graph' => $display_graph,
- 'metrics' => $display_graph ? $this->projectDailySummary->getAggregatedMetrics($project['id'], $from, $to, $column) : array(),
+ 'metrics' => $display_graph ? $this->projectDailyColumnStats->getAggregatedMetrics($project['id'], $from, $to, $column) : array(),
'project' => $project,
'date_format' => $this->config->get('application_date_format'),
'date_formats' => $this->dateParser->getAvailableFormats(),
diff --git a/app/Controller/Auth.php b/app/Controller/Auth.php
index 24e6e242..e8889b7f 100644
--- a/app/Controller/Auth.php
+++ b/app/Controller/Auth.php
@@ -25,7 +25,6 @@ class Auth extends Base
'errors' => $errors,
'values' => $values,
'no_layout' => true,
- 'redirect_query' => $this->request->getStringParam('redirect_query'),
'title' => t('Login')
)));
}
@@ -37,14 +36,15 @@ class Auth extends Base
*/
public function check()
{
- $redirect_query = $this->request->getStringParam('redirect_query');
$values = $this->request->getValues();
list($valid, $errors) = $this->authentication->validateForm($values);
if ($valid) {
- if ($redirect_query !== '') {
- $this->response->redirect('?'.urldecode($redirect_query));
+ if (! empty($this->session['login_redirect']) && ! filter_var($this->session['login_redirect'], FILTER_VALIDATE_URL)) {
+ $redirect = $this->session['login_redirect'];
+ unset($this->session['login_redirect']);
+ $this->response->redirect($redirect);
}
$this->response->redirect($this->helper->url->to('app', 'index'));
diff --git a/app/Controller/Base.php b/app/Controller/Base.php
index b7ee431f..f68c4755 100644
--- a/app/Controller/Base.php
+++ b/app/Controller/Base.php
@@ -67,6 +67,7 @@ abstract class Base extends \Core\Base
$this->container['logger']->debug('SQL_QUERIES={nb}', array('nb' => $this->container['db']->nbQueries));
$this->container['logger']->debug('RENDERING={time}', array('time' => microtime(true) - @$_SERVER['REQUEST_TIME_FLOAT']));
+ $this->container['logger']->debug('MEMORY='.$this->helper->text->bytes(memory_get_usage()));
$this->container['logger']->debug('END_REQUEST='.$_SERVER['REQUEST_URI']);
}
}
@@ -101,7 +102,7 @@ abstract class Base extends \Core\Base
public function beforeAction($controller, $action)
{
// Start the session
- $this->session->open(BASE_URL_DIRECTORY);
+ $this->session->open($this->helper->url->dir());
$this->sendHeaders($action);
$this->container['dispatcher']->dispatch('session.bootstrap', new Event);
@@ -127,7 +128,8 @@ abstract class Base extends \Core\Base
$this->response->text('Not Authorized', 401);
}
- $this->response->redirect($this->helper->url->to('auth', 'login', array('redirect_query' => urlencode($this->request->getQueryString()))));
+ $this->session['login_redirect'] = $this->request->getUri();
+ $this->response->redirect($this->helper->url->to('auth', 'login'));
}
}
@@ -223,17 +225,6 @@ abstract class Base extends \Core\Base
}
/**
- * Redirection when there is no project in the database
- *
- * @access protected
- */
- protected function redirectNoProject()
- {
- $this->session->flash(t('There is no active project, the first step is to create a new project.'));
- $this->response->redirect('?controller=project&action=create');
- }
-
- /**
* Common layout for task views
*
* @access protected
@@ -301,7 +292,7 @@ abstract class Base extends \Core\Base
if (empty($project)) {
$this->session->flashError(t('Project not found.'));
- $this->response->redirect('?controller=project');
+ $this->response->redirect($this->helper->url->to('project', 'index'));
}
return $project;
@@ -327,4 +318,33 @@ abstract class Base extends \Core\Base
return $user;
}
+
+ /**
+ * Common method to get project filters
+ *
+ * @access protected
+ */
+ protected function getProjectFilters($controller, $action)
+ {
+ $project = $this->getProject();
+ $search = $this->request->getStringParam('search', $this->userSession->getFilters($project['id']));
+ $board_selector = $this->projectPermission->getAllowedProjects($this->userSession->getId());
+ unset($board_selector[$project['id']]);
+
+ $filters = array(
+ 'controller' => $controller,
+ 'action' => $action,
+ 'project_id' => $project['id'],
+ 'search' => urldecode($search),
+ );
+
+ $this->userSession->setFilters($project['id'], $filters['search']);
+
+ return array(
+ 'project' => $project,
+ 'board_selector' => $board_selector,
+ 'filters' => $filters,
+ 'title' => $project['name'],
+ );
+ }
}
diff --git a/app/Controller/Board.php b/app/Controller/Board.php
index 0f38f910..50d9c62e 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/public', array(
+ $this->response->html($this->template->layout('board/public_view', array(
'project' => $project,
'swimlanes' => $this->board->getBoard($project['id']),
'title' => $project['name'],
@@ -44,28 +44,17 @@ class Board extends Base
* Show a board for a given project
*
* @access public
- * @param integer $project_id Default project id
*/
- public function show($project_id = 0)
+ public function show()
{
- $project = $this->getProject($project_id);
- $projects = $this->projectPermission->getAllowedProjects($this->userSession->getId());
+ $params = $this->getProjectFilters('board', 'show');
- $board_selector = $projects;
- unset($board_selector[$project['id']]);
-
- $this->response->html($this->template->layout('board/index', array(
- 'users' => $this->projectPermission->getMemberList($project['id'], true, true),
- 'projects' => $projects,
- 'project' => $project,
- 'swimlanes' => $this->board->getBoard($project['id']),
- 'categories_listing' => $this->category->getList($project['id'], true, true),
- 'title' => $project['name'],
- 'description' => $project['description'],
- 'board_selector' => $board_selector,
+ $this->response->html($this->template->layout('board/private_view', array(
+ 'swimlanes' => $this->taskFilter->search($params['filters']['search'])->getBoard($params['project']['id']),
+ 'description' => $params['project']['description'],
'board_private_refresh_interval' => $this->config->get('board_private_refresh_interval'),
'board_highlight_period' => $this->config->get('board_highlight_period'),
- )));
+ ) + $params));
}
/**
@@ -99,15 +88,7 @@ class Board extends Base
return $this->response->status(400);
}
- $this->response->html(
- $this->template->render('board/show', array(
- 'project' => $this->project->getById($project_id),
- 'swimlanes' => $this->board->getBoard($project_id),
- 'board_private_refresh_interval' => $this->config->get('board_private_refresh_interval'),
- 'board_highlight_period' => $this->config->get('board_highlight_period'),
- )),
- 201
- );
+ $this->response->html($this->renderBoard($project_id), 201);
}
/**
@@ -132,14 +113,7 @@ class Board extends Base
return $this->response->status(304);
}
- $this->response->html(
- $this->template->render('board/show', array(
- 'project' => $this->project->getById($project_id),
- 'swimlanes' => $this->board->getBoard($project_id),
- 'board_private_refresh_interval' => $this->config->get('board_private_refresh_interval'),
- 'board_highlight_period' => $this->config->get('board_highlight_period'),
- ))
- );
+ $this->response->html($this->renderBoard($project_id));
}
/**
@@ -150,7 +124,7 @@ class Board extends Base
public function tasklinks()
{
$task = $this->getTask();
- $this->response->html($this->template->render('board/tasklinks', array(
+ $this->response->html($this->template->render('board/tooltip_tasklinks', array(
'links' => $this->taskLink->getAll($task['id']),
'task' => $task,
)));
@@ -164,7 +138,7 @@ class Board extends Base
public function subtasks()
{
$task = $this->getTask();
- $this->response->html($this->template->render('board/subtasks', array(
+ $this->response->html($this->template->render('board/tooltip_subtasks', array(
'subtasks' => $this->subtask->getAll($task['id']),
'task' => $task,
)));
@@ -179,7 +153,7 @@ class Board extends Base
{
$task = $this->getTask();
- $this->response->html($this->template->render('board/files', array(
+ $this->response->html($this->template->render('board/tooltip_files', array(
'files' => $this->file->getAllDocuments($task['id']),
'images' => $this->file->getAllImages($task['id']),
'task' => $task,
@@ -195,7 +169,7 @@ class Board extends Base
{
$task = $this->getTask();
- $this->response->html($this->template->render('board/comments', array(
+ $this->response->html($this->template->render('board/tooltip_comments', array(
'comments' => $this->comment->getAll($task['id'])
)));
}
@@ -209,7 +183,7 @@ class Board extends Base
{
$task = $this->getTask();
- $this->response->html($this->template->render('board/description', array(
+ $this->response->html($this->template->render('board/tooltip_description', array(
'task' => $task
)));
}
@@ -224,7 +198,7 @@ class Board extends Base
$task = $this->getTask();
$project = $this->project->getById($task['project_id']);
- $this->response->html($this->template->render('board/assignee', array(
+ $this->response->html($this->template->render('board/popover_assignee', array(
'values' => $task,
'users_list' => $this->projectPermission->getMemberList($project['id']),
'project' => $project,
@@ -262,7 +236,7 @@ class Board extends Base
$task = $this->getTask();
$project = $this->project->getById($task['project_id']);
- $this->response->html($this->template->render('board/category', array(
+ $this->response->html($this->template->render('board/popover_category', array(
'values' => $task,
'categories_list' => $this->category->getList($project['id']),
'project' => $project,
@@ -321,4 +295,57 @@ class Board extends Base
'recurrence_basedate_list' => $this->task->getRecurrenceBasedateList(),
)));
}
+
+ /**
+ * Enable collapsed mode
+ *
+ * @access public
+ */
+ public function collapse()
+ {
+ $this->changeDisplayMode(true);
+ }
+
+ /**
+ * Enable expanded mode
+ *
+ * @access public
+ */
+ public function expand()
+ {
+ $this->changeDisplayMode(false);
+ }
+
+ /**
+ * Change display mode
+ *
+ * @access private
+ */
+ private function changeDisplayMode($mode)
+ {
+ $project_id = $this->request->getIntegerParam('project_id');
+ $this->userSession->setBoardDisplayMode($project_id, $mode);
+
+ if ($this->request->isAjax()) {
+ $this->response->html($this->renderBoard($project_id));
+ }
+ else {
+ $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $project_id)));
+ }
+ }
+
+ /**
+ * Render board
+ *
+ * @access private
+ */
+ private function renderBoard($project_id)
+ {
+ return $this->template->render('board/table_container', array(
+ 'project' => $this->project->getById($project_id),
+ 'swimlanes' => $this->taskFilter->search($this->userSession->getFilters($project_id))->getBoard($project_id),
+ 'board_private_refresh_interval' => $this->config->get('board_private_refresh_interval'),
+ 'board_highlight_period' => $this->config->get('board_highlight_period'),
+ ));
+ }
}
diff --git a/app/Controller/Calendar.php b/app/Controller/Calendar.php
index 41642a59..8a24d705 100644
--- a/app/Controller/Calendar.php
+++ b/app/Controller/Calendar.php
@@ -20,20 +20,9 @@ class Calendar extends Base
*/
public function show()
{
- $project = $this->getProject();
-
$this->response->html($this->template->layout('calendar/show', array(
'check_interval' => $this->config->get('board_private_refresh_interval'),
- 'users_list' => $this->projectPermission->getMemberList($project['id'], true, true),
- 'categories_list' => $this->category->getList($project['id'], true, true),
- 'columns_list' => $this->board->getColumnsList($project['id'], true),
- 'swimlanes_list' => $this->swimlane->getList($project['id'], true),
- 'colors_list' => $this->color->getList(true),
- 'status_list' => $this->taskStatus->getList(true),
- 'project' => $project,
- 'title' => t('Calendar for "%s"', $project['name']),
- 'board_selector' => $this->projectPermission->getAllowedProjects($this->userSession->getId()),
- )));
+ ) + $this->getProjectFilters('calendar', 'show')));
}
/**
@@ -49,14 +38,8 @@ class Calendar extends Base
// Common filter
$filter = $this->taskFilter
- ->create()
- ->filterByProject($project_id)
- ->filterByCategory($this->request->getIntegerParam('category_id', -1))
- ->filterByOwner($this->request->getIntegerParam('owner_id', -1))
- ->filterByColumn($this->request->getIntegerParam('column_id', -1))
- ->filterBySwimlane($this->request->getIntegerParam('swimlane_id', -1))
- ->filterByColor($this->request->getStringParam('color_id'))
- ->filterByStatus($this->request->getIntegerParam('is_active', -1));
+ ->search($this->userSession->getFilters($project_id))
+ ->filterByProject($project_id);
// Tasks
if ($this->config->get('calendar_project_tasks', 'date_started') === 'date_creation') {
diff --git a/app/Controller/Category.php b/app/Controller/Category.php
index 515cc9c8..e8d83f2d 100644
--- a/app/Controller/Category.php
+++ b/app/Controller/Category.php
@@ -23,7 +23,7 @@ class Category extends Base
if (empty($category)) {
$this->session->flashError(t('Category not found.'));
- $this->response->redirect('?controller=category&action=index&project_id='.$project_id);
+ $this->response->redirect($this->helper->url->to('category', 'index', array('project_id' => $project_id)));
}
return $category;
@@ -63,7 +63,7 @@ class Category extends Base
if ($this->category->create($values)) {
$this->session->flash(t('Your category have been created successfully.'));
- $this->response->redirect('?controller=category&action=index&project_id='.$project['id']);
+ $this->response->redirect($this->helper->url->to('category', 'index', array('project_id' => $project['id'])));
}
else {
$this->session->flashError(t('Unable to create your category.'));
@@ -107,7 +107,7 @@ class Category extends Base
if ($this->category->update($values)) {
$this->session->flash(t('Your category have been updated successfully.'));
- $this->response->redirect('?controller=category&action=index&project_id='.$project['id']);
+ $this->response->redirect($this->helper->url->to('category', 'index', array('project_id' => $project['id'])));
}
else {
$this->session->flashError(t('Unable to update your category.'));
@@ -151,6 +151,6 @@ class Category extends Base
$this->session->flashError(t('Unable to remove this category.'));
}
- $this->response->redirect('?controller=category&action=index&project_id='.$project['id']);
+ $this->response->redirect($this->helper->url->to('category', 'index', array('project_id' => $project['id'])));
}
}
diff --git a/app/Controller/Comment.php b/app/Controller/Comment.php
index a5f6b1f8..7b9d4aee 100644
--- a/app/Controller/Comment.php
+++ b/app/Controller/Comment.php
@@ -90,10 +90,10 @@ class Comment extends Base
}
if ($ajax) {
- $this->response->redirect('?controller=board&action=show&project_id='.$task['project_id']);
+ $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])));
}
- $this->response->redirect('?controller=task&action=show&task_id='.$task['id'].'&project_id='.$task['project_id'].'#comments');
+ $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id']), 'comments'));
}
$this->create($values, $errors);
@@ -140,7 +140,7 @@ class Comment extends Base
$this->session->flashError(t('Unable to update your comment.'));
}
- $this->response->redirect('?controller=task&action=show&task_id='.$task['id'].'&project_id='.$task['project_id'].'#comment-'.$comment['id']);
+ $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), 'comment-'.$comment['id']);
}
$this->edit($values, $errors);
@@ -181,6 +181,6 @@ class Comment extends Base
$this->session->flashError(t('Unable to remove this comment.'));
}
- $this->response->redirect('?controller=task&action=show&task_id='.$task['id'].'&project_id='.$task['project_id'].'#comments');
+ $this->response->redirect($this->helper->url->to('task', 'show', array('task_id' => $task['id'], 'project_id' => $task['project_id'])), 'comments');
}
}
diff --git a/app/Controller/Config.php b/app/Controller/Config.php
index 19bc2767..206237c0 100644
--- a/app/Controller/Config.php
+++ b/app/Controller/Config.php
@@ -60,7 +60,7 @@ class Config extends Base
$this->session->flashError(t('Unable to save your settings.'));
}
- $this->response->redirect('?controller=config&action='.$redirect);
+ $this->response->redirect($this->helper->url->to('config', $redirect));
}
}
@@ -104,6 +104,7 @@ class Config extends Base
$this->common('project');
$this->response->html($this->layout('config/project', array(
+ 'colors' => $this->color->getList(),
'default_columns' => implode(', ', $this->board->getDefaultColumns()),
'title' => t('Settings').' &gt; '.t('Project settings'),
)));
@@ -199,7 +200,7 @@ class Config extends Base
$this->checkCSRFParam();
$this->config->optimizeDatabase();
$this->session->flash(t('Database optimization done.'));
- $this->response->redirect('?controller=config');
+ $this->response->redirect($this->helper->url->to('config', 'index'));
}
/**
@@ -215,6 +216,6 @@ class Config extends Base
$this->config->regenerateToken($type.'_token');
$this->session->flash(t('Token regenerated.'));
- $this->response->redirect('?controller=config&action='.$type);
+ $this->response->redirect($this->helper->url->to('config', $type));
}
}
diff --git a/app/Controller/Export.php b/app/Controller/Export.php
index 117fb5ee..8b558c0a 100644
--- a/app/Controller/Export.php
+++ b/app/Controller/Export.php
@@ -70,7 +70,7 @@ class Export extends Base
*/
public function summary()
{
- $this->common('projectDailySummary', 'getAggregatedMetrics', t('Summary'), 'summary', t('Daily project summary export'));
+ $this->common('ProjectDailyColumnStats', 'getAggregatedMetrics', t('Summary'), 'summary', t('Daily project summary export'));
}
/**
diff --git a/app/Controller/Ical.php b/app/Controller/Ical.php
index 8a7ed8b5..0129915e 100644
--- a/app/Controller/Ical.php
+++ b/app/Controller/Ical.php
@@ -78,8 +78,8 @@ class Ical extends Base
*/
private function renderCalendar(TaskFilter $filter, iCalendar $calendar)
{
- $start = $this->request->getStringParam('start', strtotime('-1 month'));
- $end = $this->request->getStringParam('end', strtotime('+2 months'));
+ $start = $this->request->getStringParam('start', strtotime('-2 month'));
+ $end = $this->request->getStringParam('end', strtotime('+6 months'));
// Tasks
if ($this->config->get('calendar_project_tasks', 'date_started') === 'date_creation') {
diff --git a/app/Controller/Listing.php b/app/Controller/Listing.php
new file mode 100644
index 00000000..2c197e3e
--- /dev/null
+++ b/app/Controller/Listing.php
@@ -0,0 +1,37 @@
+<?php
+
+namespace Controller;
+
+use Model\Task as TaskModel;
+
+/**
+ * List view controller
+ *
+ * @package controller
+ * @author Frederic Guillot
+ */
+class Listing extends Base
+{
+ /**
+ * Show list view for projects
+ *
+ * @access public
+ */
+ public function show()
+ {
+ $params = $this->getProjectFilters('listing', 'show');
+ $query = $this->taskFilter->search($params['filters']['search'])->filterByProject($params['project']['id'])->getQuery();
+
+ $paginator = $this->paginator
+ ->setUrl('listing', 'show', array('project_id' => $params['project']['id']))
+ ->setMax(30)
+ ->setOrder(TaskModel::TABLE.'.id')
+ ->setDirection('DESC')
+ ->setQuery($query)
+ ->calculate();
+
+ $this->response->html($this->template->layout('listing/show', $params + array(
+ 'paginator' => $paginator,
+ )));
+ }
+}
diff --git a/app/Controller/Oauth.php b/app/Controller/Oauth.php
new file mode 100644
index 00000000..8ba5b252
--- /dev/null
+++ b/app/Controller/Oauth.php
@@ -0,0 +1,123 @@
+<?php
+
+namespace Controller;
+
+/**
+ * OAuth controller
+ *
+ * @package controller
+ * @author Frederic Guillot
+ */
+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');
+ }
+
+ /**
+ * Unlink external account
+ *
+ * @access public
+ */
+ public function unlink($backend = '')
+ {
+ $backend = $this->request->getStringParam('backend', $backend);
+ $this->checkCSRFParam();
+
+ if ($this->authentication->backend($backend)->unlink($this->userSession->getId())) {
+ $this->session->flash(t('Your external account is not linked anymore to your profile.'));
+ }
+ else {
+ $this->session->flashError(t('Unable to unlink your external account.'));
+ }
+
+ $this->response->redirect($this->helper->url->to('user', 'external', array('user_id' => $this->userSession->getId())));
+ }
+
+ /**
+ * Redirect to the provider if no code received
+ *
+ * @access private
+ */
+ private function step1($backend)
+ {
+ $code = $this->request->getStringParam('code');
+
+ if (! empty($code)) {
+ $this->step2($backend, $code);
+ }
+ else {
+ $this->response->redirect($this->authentication->backend($backend)->getService()->getAuthorizationUrl());
+ }
+ }
+
+ /**
+ * Link or authenticate the user
+ *
+ * @access private
+ */
+ private function step2($backend, $code)
+ {
+ $profile = $this->authentication->backend($backend)->getProfile($code);
+
+ if ($this->userSession->isLogged()) {
+ $this->link($backend, $profile);
+ }
+
+ $this->authenticate($backend, $profile);
+ }
+
+ /**
+ * Link the account
+ *
+ * @access private
+ */
+ private function link($backend, $profile)
+ {
+ if (empty($profile)) {
+ $this->session->flashError(t('External authentication failed'));
+ }
+ else {
+ $this->session->flash(t('Your external account is linked to your profile successfully.'));
+ $this->authentication->backend($backend)->updateUser($this->userSession->getId(), $profile);
+ }
+
+ $this->response->redirect($this->helper->url->to('user', 'external', array('user_id' => $this->userSession->getId())));
+ }
+
+ /**
+ * Authenticate the account
+ *
+ * @access private
+ */
+ private function authenticate($backend, $profile)
+ {
+ if (! empty($profile) && $this->authentication->backend($backend)->authenticate($profile['id'])) {
+ $this->response->redirect($this->helper->url->to('app', 'index'));
+ }
+ else {
+ $this->response->html($this->template->layout('auth/index', array(
+ 'errors' => array('login' => t('External authentication failed')),
+ 'values' => array(),
+ 'no_layout' => true,
+ 'title' => t('Login')
+ )));
+ }
+ }
+}
diff --git a/app/Controller/Project.php b/app/Controller/Project.php
index faebac38..45bc2a46 100644
--- a/app/Controller/Project.php
+++ b/app/Controller/Project.php
@@ -73,11 +73,12 @@ class Project extends Base
if ($this->project->{$switch.'PublicAccess'}($project['id'])) {
$this->session->flash(t('Project updated successfully.'));
- } else {
+ }
+ else {
$this->session->flashError(t('Unable to update this project.'));
}
- $this->response->redirect('?controller=project&action=share&project_id='.$project['id']);
+ $this->response->redirect($this->helper->url->to('project', 'share', array('project_id' => $project['id'])));
}
$this->response->html($this->projectLayout('project/share', array(
@@ -150,7 +151,7 @@ class Project extends Base
if ($this->project->update($values)) {
$this->session->flash(t('Project updated successfully.'));
- $this->response->redirect('?controller=project&action=edit&project_id='.$project['id']);
+ $this->response->redirect($this->helper->url->to('project', 'edit', array('project_id' => $project['id'])));
}
else {
$this->session->flashError(t('Unable to update this project.'));
@@ -197,7 +198,7 @@ class Project extends Base
}
}
- $this->response->redirect('?controller=project&action=users&project_id='.$project['id']);
+ $this->response->redirect($this->helper->url->to('project', 'users', array('project_id' => $project['id'])));
}
/**
@@ -220,7 +221,7 @@ class Project extends Base
}
}
- $this->response->redirect('?controller=project&action=users&project_id='.$values['project_id']);
+ $this->response->redirect($this->helper->url->to('project', 'users', array('project_id' => $values['project_id'])));
}
/**
@@ -250,7 +251,7 @@ class Project extends Base
}
}
- $this->response->redirect('?controller=project&action=users&project_id='.$values['project_id']);
+ $this->response->redirect($this->helper->url->to('project', 'users', array('project_id' => $values['project_id'])));
}
/**
@@ -279,7 +280,7 @@ class Project extends Base
}
}
- $this->response->redirect('?controller=project&action=users&project_id='.$values['project_id']);
+ $this->response->redirect($this->helper->url->to('project', 'users', array('project_id' => $values['project_id'])));
}
/**
@@ -301,7 +302,7 @@ class Project extends Base
$this->session->flashError(t('Unable to remove this project.'));
}
- $this->response->redirect('?controller=project');
+ $this->response->redirect($this->helper->url->to('project', 'index'));
}
$this->response->html($this->projectLayout('project/remove', array(
@@ -329,7 +330,7 @@ class Project extends Base
$this->session->flashError(t('Unable to clone this project.'));
}
- $this->response->redirect('?controller=project');
+ $this->response->redirect($this->helper->url->to('project', 'index'));
}
$this->response->html($this->projectLayout('project/duplicate', array(
@@ -357,7 +358,7 @@ class Project extends Base
$this->session->flashError(t('Unable to disable this project.'));
}
- $this->response->redirect('?controller=project&action=show&project_id='.$project['id']);
+ $this->response->redirect($this->helper->url->to('project', 'show', array('project_id' => $project['id'])));
}
$this->response->html($this->projectLayout('project/disable', array(
@@ -385,7 +386,7 @@ class Project extends Base
$this->session->flashError(t('Unable to activate this project.'));
}
- $this->response->redirect('?controller=project&action=show&project_id='.$project['id']);
+ $this->response->redirect($this->helper->url->to('project', 'show', array('project_id' => $project['id'])));
}
$this->response->html($this->projectLayout('project/enable', array(
@@ -428,7 +429,7 @@ class Project extends Base
if ($project_id > 0) {
$this->session->flash(t('Your project have been created successfully.'));
- $this->response->redirect('?controller=project&action=show&project_id='.$project_id);
+ $this->response->redirect($this->helper->url->to('project', 'show', array('project_id' => $project_id)));
}
$this->session->flashError(t('Unable to create your project.'));
diff --git a/app/Controller/Projectinfo.php b/app/Controller/Projectinfo.php
deleted file mode 100644
index 22b9861c..00000000
--- a/app/Controller/Projectinfo.php
+++ /dev/null
@@ -1,95 +0,0 @@
-<?php
-
-namespace Controller;
-
-/**
- * Project Info controller (ActivityStream + completed tasks)
- *
- * @package controller
- * @author Frederic Guillot
- */
-class Projectinfo extends Base
-{
- /**
- * Activity page for a project
- *
- * @access public
- */
- public function activity()
- {
- $project = $this->getProject();
-
- $this->response->html($this->template->layout('projectinfo/activity', array(
- 'board_selector' => $this->projectPermission->getAllowedProjects($this->userSession->getId()),
- 'events' => $this->projectActivity->getProject($project['id']),
- 'project' => $project,
- 'title' => t('%s\'s activity', $project['name'])
- )));
- }
-
- /**
- * Task search for a given project
- *
- * @access public
- */
- public function search()
- {
- $project = $this->getProject();
- $search = $this->request->getStringParam('search');
- $nb_tasks = 0;
-
- $paginator = $this->paginator
- ->setUrl('projectinfo', 'search', array('search' => $search, 'project_id' => $project['id']))
- ->setMax(30)
- ->setOrder('tasks.id')
- ->setDirection('DESC');
-
- if ($search !== '') {
- $paginator->setQuery($this->taskFilter->search($search)->filterByProject($project['id'])->getQuery())
- ->calculate();
-
- $nb_tasks = $paginator->getTotal();
- }
-
- $this->response->html($this->template->layout('projectinfo/search', array(
- 'board_selector' => $this->projectPermission->getAllowedProjects($this->userSession->getId()),
- 'values' => array(
- 'search' => $search,
- 'controller' => 'projectinfo',
- 'action' => 'search',
- 'project_id' => $project['id'],
- ),
- 'paginator' => $paginator,
- 'project' => $project,
- 'columns' => $this->board->getColumnsList($project['id']),
- 'categories' => $this->category->getList($project['id'], false),
- 'title' => t('Search in the project "%s"', $project['name']).($nb_tasks > 0 ? ' ('.$nb_tasks.')' : '')
- )));
- }
-
- /**
- * List of completed tasks for a given project
- *
- * @access public
- */
- public function tasks()
- {
- $project = $this->getProject();
- $paginator = $this->paginator
- ->setUrl('projectinfo', 'tasks', array('project_id' => $project['id']))
- ->setMax(30)
- ->setOrder('tasks.id')
- ->setDirection('DESC')
- ->setQuery($this->taskFinder->getClosedTaskQuery($project['id']))
- ->calculate();
-
- $this->response->html($this->template->layout('projectinfo/tasks', array(
- 'board_selector' => $this->projectPermission->getAllowedProjects($this->userSession->getId()),
- 'project' => $project,
- 'columns' => $this->board->getColumnsList($project['id']),
- 'categories' => $this->category->getList($project['id'], false),
- 'paginator' => $paginator,
- 'title' => t('Completed tasks for "%s"', $project['name']).' ('.$paginator->getTotal().')'
- )));
- }
-}
diff --git a/app/Controller/Search.php b/app/Controller/Search.php
index 519f9ce4..f6dc7a32 100644
--- a/app/Controller/Search.php
+++ b/app/Controller/Search.php
@@ -13,7 +13,7 @@ class Search extends Base
public function index()
{
$projects = $this->projectPermission->getAllowedProjects($this->userSession->getId());
- $search = $this->request->getStringParam('search');
+ $search = urldecode($this->request->getStringParam('search'));
$nb_tasks = 0;
$paginator = $this->paginator
diff --git a/app/Controller/Subtask.php b/app/Controller/Subtask.php
index 6ee94333..87f3fcb4 100644
--- a/app/Controller/Subtask.php
+++ b/app/Controller/Subtask.php
@@ -75,10 +75,10 @@ class Subtask extends Base
}
if (isset($values['another_subtask']) && $values['another_subtask'] == 1) {
- $this->response->redirect('?controller=subtask&action=create&task_id='.$task['id'].'&another_subtask=1&project_id='.$task['project_id']);
+ $this->response->redirect($this->helper->url->to('subtask', 'create', array('project_id' => $task['project_id'], 'task_id' => $task['id'], 'another_subtask' => 1)));
}
- $this->response->redirect('?controller=task&action=show&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']), 'subtasks'));
}
$this->create($values, $errors);
@@ -126,7 +126,7 @@ class Subtask extends Base
$this->session->flashError(t('Unable to update your sub-task.'));
}
- $this->response->redirect('?controller=task&action=show&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']), 'subtasks'));
}
$this->edit($values, $errors);
@@ -166,7 +166,7 @@ class Subtask extends Base
$this->session->flashError(t('Unable to remove this sub-task.'));
}
- $this->response->redirect('?controller=task&action=show&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']), 'subtasks'));
}
/**
@@ -256,7 +256,7 @@ class Subtask extends Base
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('task_id' => $task['id'], 'project_id' => $task['project_id']), 'subtasks'));
}
}
@@ -275,6 +275,6 @@ class Subtask extends Base
$method = $direction === 'up' ? 'moveUp' : 'moveDown';
$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('task', 'show', array('project_id' => $project_id, 'task_id' => $task_id), 'subtasks'));
}
}
diff --git a/app/Controller/Swimlane.php b/app/Controller/Swimlane.php
index c6862d47..054fa4ba 100644
--- a/app/Controller/Swimlane.php
+++ b/app/Controller/Swimlane.php
@@ -25,7 +25,7 @@ class Swimlane extends Base
if (empty($swimlane)) {
$this->session->flashError(t('Swimlane not found.'));
- $this->response->redirect('?controller=swimlane&action=index&project_id='.$project_id);
+ $this->response->redirect($this->helper->url->to('swimlane', 'index', array('project_id' => $project_id)));
}
return $swimlane;
@@ -67,7 +67,7 @@ class Swimlane extends Base
if ($this->swimlane->create($project['id'], $values['name'])) {
$this->session->flash(t('Your swimlane have been created successfully.'));
- $this->response->redirect('?controller=swimlane&action=index&project_id='.$project['id']);
+ $this->response->redirect($this->helper->url->to('swimlane', 'index', array('project_id' => $project['id'])));
}
else {
$this->session->flashError(t('Unable to create your swimlane.'));
@@ -93,7 +93,7 @@ class Swimlane extends Base
if ($this->swimlane->updateDefault($values)) {
$this->session->flash(t('The default swimlane have been updated successfully.'));
- $this->response->redirect('?controller=swimlane&action=index&project_id='.$project['id']);
+ $this->response->redirect($this->helper->url->to('swimlane', 'index', array('project_id' => $project['id'])));
}
else {
$this->session->flashError(t('Unable to update this swimlane.'));
@@ -137,7 +137,7 @@ class Swimlane extends Base
if ($this->swimlane->rename($values['id'], $values['name'])) {
$this->session->flash(t('Swimlane updated successfully.'));
- $this->response->redirect('?controller=swimlane&action=index&project_id='.$project['id']);
+ $this->response->redirect($this->helper->url->to('swimlane', 'index', array('project_id' => $project['id'])));
}
else {
$this->session->flashError(t('Unable to update this swimlane.'));
@@ -181,7 +181,7 @@ class Swimlane extends Base
$this->session->flashError(t('Unable to remove this swimlane.'));
}
- $this->response->redirect('?controller=swimlane&action=index&project_id='.$project['id']);
+ $this->response->redirect($this->helper->url->to('swimlane', 'index', array('project_id' => $project['id'])));
}
/**
@@ -201,7 +201,7 @@ class Swimlane extends Base
$this->session->flashError(t('Unable to update this swimlane.'));
}
- $this->response->redirect('?controller=swimlane&action=index&project_id='.$project['id']);
+ $this->response->redirect($this->helper->url->to('swimlane', 'index', array('project_id' => $project['id'])));
}
/**
@@ -221,7 +221,7 @@ class Swimlane extends Base
$this->session->flashError(t('Unable to update this swimlane.'));
}
- $this->response->redirect('?controller=swimlane&action=index&project_id='.$project['id']);
+ $this->response->redirect($this->helper->url->to('swimlane', 'index', array('project_id' => $project['id'])));
}
/**
@@ -236,7 +236,7 @@ class Swimlane extends Base
$swimlane_id = $this->request->getIntegerParam('swimlane_id');
$this->swimlane->moveUp($project['id'], $swimlane_id);
- $this->response->redirect('?controller=swimlane&action=index&project_id='.$project['id']);
+ $this->response->redirect($this->helper->url->to('swimlane', 'index', array('project_id' => $project['id'])));
}
/**
@@ -251,6 +251,6 @@ class Swimlane extends Base
$swimlane_id = $this->request->getIntegerParam('swimlane_id');
$this->swimlane->moveDown($project['id'], $swimlane_id);
- $this->response->redirect('?controller=swimlane&action=index&project_id='.$project['id']);
+ $this->response->redirect($this->helper->url->to('swimlane', 'index', array('project_id' => $project['id'])));
}
}
diff --git a/app/Controller/Task.php b/app/Controller/Task.php
index dc83f7b1..0770fcd1 100644
--- a/app/Controller/Task.php
+++ b/app/Controller/Task.php
@@ -2,8 +2,6 @@
namespace Controller;
-use Model\Project as ProjectModel;
-
/**
* Task controller
*
@@ -64,7 +62,7 @@ class Task extends Base
'time_spent' => $task['time_spent'] ?: '',
);
- $this->dateParser->format($values, array('date_started'));
+ $this->dateParser->format($values, array('date_started'), 'Y-m-d H:i');
$this->response->html($this->taskLayout('task/show', array(
'project' => $this->project->getById($task['project_id']),
@@ -78,6 +76,7 @@ class Task extends Base
'link_label_list' => $this->link->getList(0, false),
'columns_list' => $this->board->getColumnsList($task['project_id']),
'colors_list' => $this->color->getList(),
+ 'users_list' => $this->projectPermission->getMemberList($task['project_id'], true, false, false),
'date_format' => $this->config->get('application_date_format'),
'date_formats' => $this->dateParser->getAvailableFormats(),
'title' => $task['project_name'].' &gt; '.$task['title'],
@@ -88,249 +87,58 @@ class Task extends Base
}
/**
- * Display task activities
+ * Display task analytics
*
* @access public
*/
- public function activites()
+ public function analytics()
{
$task = $this->getTask();
- $this->response->html($this->taskLayout('task/activity', array(
+ $this->response->html($this->taskLayout('task/analytics', array(
'title' => $task['title'],
'task' => $task,
- 'ajax' => $this->request->isAjax(),
- 'events' => $this->projectActivity->getTask($task['id']),
+ 'lead_time' => $this->taskAnalytic->getLeadTime($task),
+ 'cycle_time' => $this->taskAnalytic->getCycleTime($task),
+ 'time_spent_columns' => $this->taskAnalytic->getTimeSpentByColumn($task),
)));
}
/**
- * Display a form to create a new task
- *
- * @access public
- */
- 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'),
- 'owner_id' => $this->request->getIntegerParam('owner_id'),
- 'another_task' => $this->request->getIntegerParam('another_task'),
- );
- }
-
- $this->response->html($this->template->$method('task/new', array(
- 'ajax' => $this->request->isAjax(),
- 'errors' => $errors,
- 'values' => $values + array('project_id' => $project['id']),
- 'projects_list' => $this->project->getListByStatus(ProjectModel::ACTIVE),
- 'columns_list' => $this->board->getColumnsList($project['id']),
- 'users_list' => $this->projectPermission->getMemberList($project['id'], true, false, true),
- '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')
- )));
- }
-
- /**
- * Validate and save a new task
- *
- * @access public
- */
- public function save()
- {
- $project = $this->getProject();
- $values = $this->request->getValues();
- $values['creator_id'] = $this->userSession->getId();
-
- list($valid, $errors) = $this->taskValidator->validateCreation($values);
-
- if ($valid) {
-
- if ($this->taskCreation->create($values)) {
- $this->session->flash(t('Task created successfully.'));
-
- if (isset($values['another_task']) && $values['another_task'] == 1) {
- unset($values['title']);
- unset($values['description']);
- $this->response->redirect('?controller=task&action=create&'.http_build_query($values));
- }
- else {
- $this->response->redirect('?controller=board&action=show&project_id='.$project['id']);
- }
- }
- else {
- $this->session->flashError(t('Unable to create your task.'));
- }
- }
-
- $this->create($values, $errors);
- }
-
- /**
- * Display a form to edit a task
- *
- * @access public
- */
- public function edit(array $values = array(), array $errors = array())
- {
- $task = $this->getTask();
- $ajax = $this->request->isAjax();
-
- if (empty($values)) {
- $values = $task;
- }
-
- $this->dateParser->format($values, array('date_due'));
-
- $params = array(
- 'values' => $values,
- 'errors' => $errors,
- 'task' => $task,
- 'users_list' => $this->projectPermission->getMemberList($task['project_id']),
- 'colors_list' => $this->color->getList(),
- '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) {
- $this->response->html($this->template->render('task/edit', $params));
- }
- else {
- $this->response->html($this->taskLayout('task/edit', $params));
- }
- }
-
- /**
- * Validate and update a task
- *
- * @access public
- */
- public function update()
- {
- $task = $this->getTask();
- $values = $this->request->getValues();
-
- list($valid, $errors) = $this->taskValidator->validateModification($values);
-
- if ($valid) {
-
- if ($this->taskModification->update($values)) {
- $this->session->flash(t('Task updated successfully.'));
-
- if ($this->request->getIntegerParam('ajax')) {
- $this->response->redirect('?controller=board&action=show&project_id='.$task['project_id']);
- }
- else {
- $this->response->redirect('?controller=task&action=show&task_id='.$task['id'].'&project_id='.$task['project_id']);
- }
- }
- else {
- $this->session->flashError(t('Unable to update your task.'));
- }
- }
-
- $this->edit($values, $errors);
- }
-
- /**
- * Update time tracking information
- *
- * @access public
- */
- public function time()
- {
- $task = $this->getTask();
- $values = $this->request->getValues();
-
- list($valid,) = $this->taskValidator->validateTimeModification($values);
-
- if ($valid && $this->taskModification->update($values)) {
- $this->session->flash(t('Task updated successfully.'));
- }
- else {
- $this->session->flashError(t('Unable to update your task.'));
- }
-
- $this->response->redirect('?controller=task&action=show&task_id='.$task['id'].'&project_id='.$task['project_id']);
- }
-
- /**
- * Hide a task
+ * Display the time tracking details
*
* @access public
*/
- public function close()
+ public function timetracking()
{
$task = $this->getTask();
- $redirect = $this->request->getStringParam('redirect');
-
- if ($this->request->getStringParam('confirmation') === 'yes') {
-
- $this->checkCSRFParam();
-
- if ($this->taskStatus->close($task['id'])) {
- $this->session->flash(t('Task closed successfully.'));
- } else {
- $this->session->flashError(t('Unable to close this task.'));
- }
- if ($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'])));
- }
-
- if ($this->request->isAjax()) {
- $this->response->html($this->template->render('task/close', array(
- 'task' => $task,
- 'redirect' => $redirect,
- )));
- }
+ $subtask_paginator = $this->paginator
+ ->setUrl('task', 'timesheet', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'pagination' => 'subtasks'))
+ ->setMax(15)
+ ->setOrder('start')
+ ->setDirection('DESC')
+ ->setQuery($this->subtaskTimeTracking->getTaskQuery($task['id']))
+ ->calculateOnlyIf($this->request->getStringParam('pagination') === 'subtasks');
- $this->response->html($this->taskLayout('task/close', array(
+ $this->response->html($this->taskLayout('task/time_tracking_details', array(
'task' => $task,
- 'redirect' => $redirect,
+ 'subtask_paginator' => $subtask_paginator,
)));
}
/**
- * Open a task
+ * Display the task transitions
*
* @access public
*/
- public function open()
+ public function transitions()
{
$task = $this->getTask();
- if ($this->request->getStringParam('confirmation') === 'yes') {
-
- $this->checkCSRFParam();
-
- if ($this->taskStatus->open($task['id'])) {
- $this->session->flash(t('Task opened successfully.'));
- } else {
- $this->session->flashError(t('Unable to open this task.'));
- }
-
- $this->response->redirect('?controller=task&action=show&task_id='.$task['id'].'&project_id='.$task['project_id']);
- }
-
- $this->response->html($this->taskLayout('task/open', array(
+ $this->response->html($this->taskLayout('task/transitions', array(
'task' => $task,
+ 'transitions' => $this->transition->getAllByTask($task['id']),
)));
}
@@ -357,265 +165,11 @@ class Task extends Base
$this->session->flashError(t('Unable to remove this task.'));
}
- $this->response->redirect('?controller=board&action=show&project_id='.$task['project_id']);
+ $this->response->redirect($this->helper->url->to('board', 'show', array('project_id' => $task['project_id'])));
}
$this->response->html($this->taskLayout('task/remove', array(
'task' => $task,
)));
}
-
- /**
- * Duplicate a task
- *
- * @access public
- */
- public function duplicate()
- {
- $task = $this->getTask();
-
- if ($this->request->getStringParam('confirmation') === 'yes') {
-
- $this->checkCSRFParam();
- $task_id = $this->taskDuplication->duplicate($task['id']);
-
- if ($task_id) {
- $this->session->flash(t('Task created successfully.'));
- $this->response->redirect('?controller=task&action=show&task_id='.$task_id.'&project_id='.$task['project_id']);
- } else {
- $this->session->flashError(t('Unable to create this task.'));
- $this->response->redirect('?controller=task&action=duplicate&task_id='.$task['id'].'&project_id='.$task['project_id']);
- }
- }
-
- $this->response->html($this->taskLayout('task/duplicate', array(
- 'task' => $task,
- )));
- }
-
- /**
- * Edit description form
- *
- * @access public
- */
- public function description()
- {
- $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->session->flash(t('Task updated successfully.'));
- }
- else {
- $this->session->flashError(t('Unable to update your task.'));
- }
-
- if ($ajax) {
- $this->response->redirect('?controller=board&action=show&project_id='.$task['project_id']);
- }
- else {
- $this->response->redirect('?controller=task&action=show&task_id='.$task['id'].'&project_id='.$task['project_id']);
- }
- }
- }
- else {
- $values = $task;
- $errors = array();
- }
-
- $params = array(
- 'values' => $values,
- 'errors' => $errors,
- 'task' => $task,
- 'ajax' => $ajax,
- );
-
- if ($ajax) {
- $this->response->html($this->template->render('task/edit_description', $params));
- }
- else {
- $this->response->html($this->taskLayout('task/edit_description', $params));
- }
- }
-
- /**
- * Edit recurrence form
- *
- * @access public
- */
- public function recurrence()
- {
- $task = $this->getTask();
- $ajax = $this->request->isAjax() || $this->request->getIntegerParam('ajax');
-
- if ($this->request->isPost()) {
-
- $values = $this->request->getValues();
-
- list($valid, $errors) = $this->taskValidator->validateEditRecurrence($values);
-
- if ($valid) {
-
- if ($this->taskModification->update($values)) {
- $this->session->flash(t('Task updated successfully.'));
- }
- else {
- $this->session->flashError(t('Unable to update your task.'));
- }
-
- if ($ajax) {
- $this->response->redirect('?controller=board&action=show&project_id='.$task['project_id']);
- }
- else {
- $this->response->redirect('?controller=task&action=show&task_id='.$task['id'].'&project_id='.$task['project_id']);
- }
- }
- }
- else {
- $values = $task;
- $errors = array();
- }
-
- $params = array(
- 'values' => $values,
- 'errors' => $errors,
- 'task' => $task,
- 'ajax' => $ajax,
- 'recurrence_status_list' => $this->task->getRecurrenceStatusList(),
- 'recurrence_trigger_list' => $this->task->getRecurrenceTriggerList(),
- 'recurrence_timeframe_list' => $this->task->getRecurrenceTimeframeList(),
- 'recurrence_basedate_list' => $this->task->getRecurrenceBasedateList(),
- );
-
- if ($ajax) {
- $this->response->html($this->template->render('task/edit_recurrence', $params));
- }
- else {
- $this->response->html($this->taskLayout('task/edit_recurrence', $params));
- }
- }
-
- /**
- * Move a task to another project
- *
- * @access public
- */
- public function move()
- {
- $task = $this->getTask();
- $values = $task;
- $errors = array();
- $projects_list = $this->projectPermission->getActiveMemberProjects($this->userSession->getId());
-
- unset($projects_list[$task['project_id']]);
-
- if ($this->request->isPost()) {
-
- $values = $this->request->getValues();
- list($valid, $errors) = $this->taskValidator->validateProjectModification($values);
-
- if ($valid) {
-
- if ($this->taskDuplication->moveToProject($task['id'], $values['project_id'])) {
- $this->session->flash(t('Task updated successfully.'));
- $this->response->redirect('?controller=task&action=show&task_id='.$task['id'].'&project_id='.$values['project_id']);
- }
- else {
- $this->session->flashError(t('Unable to update your task.'));
- }
- }
- }
-
- $this->response->html($this->taskLayout('task/move_project', array(
- 'values' => $values,
- 'errors' => $errors,
- 'task' => $task,
- 'projects_list' => $projects_list,
- )));
- }
-
- /**
- * Duplicate a task to another project
- *
- * @access public
- */
- public function copy()
- {
- $task = $this->getTask();
- $values = $task;
- $errors = array();
- $projects_list = $this->projectPermission->getActiveMemberProjects($this->userSession->getId());
-
- unset($projects_list[$task['project_id']]);
-
- if ($this->request->isPost()) {
-
- $values = $this->request->getValues();
- list($valid, $errors) = $this->taskValidator->validateProjectModification($values);
-
- if ($valid) {
- $task_id = $this->taskDuplication->duplicateToProject($task['id'], $values['project_id']);
- if ($task_id) {
- $this->session->flash(t('Task created successfully.'));
- $this->response->redirect('?controller=task&action=show&task_id='.$task_id.'&project_id='.$values['project_id']);
- }
- else {
- $this->session->flashError(t('Unable to create your task.'));
- }
- }
- }
-
- $this->response->html($this->taskLayout('task/duplicate_project', array(
- 'values' => $values,
- 'errors' => $errors,
- 'task' => $task,
- 'projects_list' => $projects_list,
- )));
- }
-
- /**
- * Display the time tracking details
- *
- * @access public
- */
- public function timesheet()
- {
- $task = $this->getTask();
-
- $subtask_paginator = $this->paginator
- ->setUrl('task', 'timesheet', array('task_id' => $task['id'], 'project_id' => $task['project_id'], 'pagination' => 'subtasks'))
- ->setMax(15)
- ->setOrder('start')
- ->setDirection('DESC')
- ->setQuery($this->subtaskTimeTracking->getTaskQuery($task['id']))
- ->calculateOnlyIf($this->request->getStringParam('pagination') === 'subtasks');
-
- $this->response->html($this->taskLayout('task/time_tracking', array(
- 'task' => $task,
- 'subtask_paginator' => $subtask_paginator,
- )));
- }
-
- /**
- * Display the task transitions
- *
- * @access public
- */
- public function transitions()
- {
- $task = $this->getTask();
-
- $this->response->html($this->taskLayout('task/transitions', array(
- 'task' => $task,
- 'transitions' => $this->transition->getAllByTask($task['id']),
- )));
- }
}
diff --git a/app/Controller/Taskcreation.php b/app/Controller/Taskcreation.php
new file mode 100644
index 00000000..7c841e10
--- /dev/null
+++ b/app/Controller/Taskcreation.php
@@ -0,0 +1,86 @@
+<?php
+
+namespace Controller;
+
+use Model\Project as ProjectModel;
+
+/**
+ * Task Creation controller
+ *
+ * @package controller
+ * @author Frederic Guillot
+ */
+class Taskcreation extends Base
+{
+ /**
+ * Display a form to create a new task
+ *
+ * @access public
+ */
+ 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'),
+ );
+ }
+
+ $this->response->html($this->template->$method('task_creation/form', array(
+ 'ajax' => $this->request->isAjax(),
+ 'errors' => $errors,
+ 'values' => $values + array('project_id' => $project['id']),
+ 'projects_list' => $this->project->getListByStatus(ProjectModel::ACTIVE),
+ 'columns_list' => $this->board->getColumnsList($project['id']),
+ 'users_list' => $this->projectPermission->getMemberList($project['id'], true, false, true),
+ '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')
+ )));
+ }
+
+ /**
+ * Validate and save a new task
+ *
+ * @access public
+ */
+ public function save()
+ {
+ $project = $this->getProject();
+ $values = $this->request->getValues();
+
+ list($valid, $errors) = $this->taskValidator->validateCreation($values);
+
+ if ($valid) {
+
+ if ($this->taskCreation->create($values)) {
+ $this->session->flash(t('Task created successfully.'));
+
+ if (isset($values['another_task']) && $values['another_task'] == 1) {
+ unset($values['title']);
+ unset($values['description']);
+ $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'])));
+ }
+ }
+ else {
+ $this->session->flashError(t('Unable to create your task.'));
+ }
+ }
+
+ $this->create($values, $errors);
+ }
+}
diff --git a/app/Controller/Taskduplication.php b/app/Controller/Taskduplication.php
new file mode 100644
index 00000000..91291b0d
--- /dev/null
+++ b/app/Controller/Taskduplication.php
@@ -0,0 +1,143 @@
+<?php
+
+namespace Controller;
+
+/**
+ * Task Duplication controller
+ *
+ * @package controller
+ * @author Frederic Guillot
+ */
+class Taskduplication extends Base
+{
+ /**
+ * Duplicate a task
+ *
+ * @access public
+ */
+ public function duplicate()
+ {
+ $task = $this->getTask();
+
+ if ($this->request->getStringParam('confirmation') === 'yes') {
+
+ $this->checkCSRFParam();
+ $task_id = $this->taskDuplication->duplicate($task['id']);
+
+ if ($task_id > 0) {
+ $this->session->flash(t('Task created successfully.'));
+ $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])));
+ } else {
+ $this->session->flashError(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->html($this->taskLayout('task_duplication/duplicate', array(
+ 'task' => $task,
+ )));
+ }
+
+ /**
+ * Move a task to another project
+ *
+ * @access public
+ */
+ public function move()
+ {
+ $task = $this->getTask();
+
+ if ($this->request->isPost()) {
+
+ $values = $this->request->getValues();
+ list($valid, $errors) = $this->taskValidator->validateProjectModification($values);
+
+ if ($valid && $this->taskDuplication->moveToProject($task['id'],
+ $values['project_id'],
+ $values['swimlane_id'],
+ $values['column_id'],
+ $values['category_id'],
+ $values['owner_id'])) {
+
+ $this->session->flash(t('Task updated successfully.'));
+ $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $values['project_id'], 'task_id' => $task['id'])));
+ }
+
+ $this->session->flashError(t('Unable to update your task.'));
+ }
+
+ $this->chooseDestination($task, 'task_duplication/move');
+ }
+
+ /**
+ * Duplicate a task to another project
+ *
+ * @access public
+ */
+ public function copy()
+ {
+ $task = $this->getTask();
+
+ if ($this->request->isPost()) {
+
+ $values = $this->request->getValues();
+ list($valid, $errors) = $this->taskValidator->validateProjectModification($values);
+
+ if ($valid && $this->taskDuplication->duplicateToProject($task['id'],
+ $values['project_id'],
+ $values['swimlane_id'],
+ $values['column_id'],
+ $values['category_id'],
+ $values['owner_id'])) {
+
+ $this->session->flash(t('Task created successfully.'));
+ $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])));
+ }
+
+ $this->session->flashError(t('Unable to create your task.'));
+ }
+
+ $this->chooseDestination($task, 'task_duplication/copy');
+ }
+
+ /**
+ * Choose destination when move/copy task to another project
+ *
+ * @access private
+ */
+ private function chooseDestination(array $task, $template)
+ {
+ $values = array();
+ $projects_list = $this->projectPermission->getActiveMemberProjects($this->userSession->getId());
+
+ unset($projects_list[$task['project_id']]);
+
+ if (! empty($projects_list)) {
+ $dst_project_id = $this->request->getIntegerParam('dst_project_id', key($projects_list));
+
+ $swimlanes_list = $this->swimlane->getList($dst_project_id, false, true);
+ $columns_list = $this->board->getColumnsList($dst_project_id);
+ $categories_list = $this->category->getList($dst_project_id);
+ $users_list = $this->projectPermission->getMemberList($dst_project_id);
+
+ $values = $this->taskDuplication->checkDestinationProjectValues($task);
+ $values['project_id'] = $dst_project_id;
+ }
+ else {
+ $swimlanes_list = array();
+ $columns_list = array();
+ $categories_list = array();
+ $users_list = array();
+ }
+
+ $this->response->html($this->taskLayout($template, array(
+ 'values' => $values,
+ 'task' => $task,
+ 'projects_list' => $projects_list,
+ 'swimlanes_list' => $swimlanes_list,
+ 'columns_list' => $columns_list,
+ 'categories_list' => $categories_list,
+ 'users_list' => $users_list,
+ )));
+ }
+}
diff --git a/app/Controller/Taskmodification.php b/app/Controller/Taskmodification.php
new file mode 100644
index 00000000..56d2b9f9
--- /dev/null
+++ b/app/Controller/Taskmodification.php
@@ -0,0 +1,212 @@
+<?php
+
+namespace Controller;
+
+/**
+ * Task Modification controller
+ *
+ * @package controller
+ * @author Frederic Guillot
+ */
+class Taskmodification extends Base
+{
+ /**
+ * Set automatically the start date
+ *
+ * @access public
+ */
+ public function start()
+ {
+ $task = $this->getTask();
+ $this->taskModification->update(array('id' => $task['id'], 'date_started' => time()));
+ $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])));
+ }
+
+ /**
+ * Update time tracking information
+ *
+ * @access public
+ */
+ public function time()
+ {
+ $task = $this->getTask();
+ $values = $this->request->getValues();
+
+ list($valid,) = $this->taskValidator->validateTimeModification($values);
+
+ if ($valid && $this->taskModification->update($values)) {
+ $this->session->flash(t('Task updated successfully.'));
+ }
+ else {
+ $this->session->flashError(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'])));
+ }
+
+ /**
+ * Edit description form
+ *
+ * @access public
+ */
+ public function description()
+ {
+ $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->session->flash(t('Task updated successfully.'));
+ }
+ else {
+ $this->session->flashError(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();
+ }
+
+ $params = 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));
+ }
+ }
+
+ /**
+ * Display a form to edit a task
+ *
+ * @access public
+ */
+ public function edit(array $values = array(), array $errors = array())
+ {
+ $task = $this->getTask();
+ $ajax = $this->request->isAjax();
+
+ if (empty($values)) {
+ $values = $task;
+ }
+
+ $this->dateParser->format($values, array('date_due'));
+
+ $params = array(
+ 'values' => $values,
+ 'errors' => $errors,
+ 'task' => $task,
+ 'users_list' => $this->projectPermission->getMemberList($task['project_id']),
+ 'colors_list' => $this->color->getList(),
+ '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) {
+ $this->response->html($this->template->render('task_modification/edit_task', $params));
+ }
+ else {
+ $this->response->html($this->taskLayout('task_modification/edit_task', $params));
+ }
+ }
+
+ /**
+ * Validate and update a task
+ *
+ * @access public
+ */
+ public function update()
+ {
+ $task = $this->getTask();
+ $values = $this->request->getValues();
+
+ list($valid, $errors) = $this->taskValidator->validateModification($values);
+
+ if ($valid) {
+
+ if ($this->taskModification->update($values)) {
+ $this->session->flash(t('Task updated successfully.'));
+
+ if ($this->request->getIntegerParam('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 {
+ $this->session->flashError(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->session->flash(t('Task updated successfully.'));
+ }
+ else {
+ $this->session->flashError(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
new file mode 100644
index 00000000..a47d9da3
--- /dev/null
+++ b/app/Controller/Taskstatus.php
@@ -0,0 +1,79 @@
+<?php
+
+namespace Controller;
+
+/**
+ * Task Status controller
+ *
+ * @package controller
+ * @author Frederic Guillot
+ */
+class Taskstatus extends Base
+{
+ /**
+ * Close a task
+ *
+ * @access public
+ */
+ public function close()
+ {
+ $task = $this->getTask();
+ $redirect = $this->request->getStringParam('redirect');
+
+ if ($this->request->getStringParam('confirmation') === 'yes') {
+
+ $this->checkCSRFParam();
+
+ if ($this->taskStatus->close($task['id'])) {
+ $this->session->flash(t('Task closed successfully.'));
+ } else {
+ $this->session->flashError(t('Unable to close this task.'));
+ }
+
+ if ($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'])));
+ }
+
+ if ($this->request->isAjax()) {
+ $this->response->html($this->template->render('task_status/close', array(
+ 'task' => $task,
+ 'redirect' => $redirect,
+ )));
+ }
+
+ $this->response->html($this->taskLayout('task_status/close', array(
+ 'task' => $task,
+ 'redirect' => $redirect,
+ )));
+ }
+
+ /**
+ * Open a task
+ *
+ * @access public
+ */
+ public function open()
+ {
+ $task = $this->getTask();
+
+ if ($this->request->getStringParam('confirmation') === 'yes') {
+
+ $this->checkCSRFParam();
+
+ if ($this->taskStatus->open($task['id'])) {
+ $this->session->flash(t('Task opened successfully.'));
+ } else {
+ $this->session->flashError(t('Unable to open this task.'));
+ }
+
+ $this->response->redirect($this->helper->url->to('task', 'show', array('project_id' => $task['project_id'], 'task_id' => $task['id'])));
+ }
+
+ $this->response->html($this->taskLayout('task_status/open', array(
+ 'task' => $task,
+ )));
+ }
+}
diff --git a/app/Controller/User.php b/app/Controller/User.php
index 119041e5..10a3a931 100644
--- a/app/Controller/User.php
+++ b/app/Controller/User.php
@@ -60,7 +60,9 @@ class User extends Base
*/
public function create(array $values = array(), array $errors = array())
{
- $this->response->html($this->template->layout('user/new', array(
+ $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(
'timezones' => $this->config->getTimezones(true),
'languages' => $this->config->getLanguages(true),
'board_selector' => $this->projectPermission->getAllowedProjects($this->userSession->getId()),
@@ -178,7 +180,7 @@ class User extends Base
$this->checkCSRFParam();
$user = $this->getUser();
$this->authentication->backend('rememberMe')->remove($this->request->getIntegerParam('id'));
- $this->response->redirect('?controller=user&action=sessions&user_id='.$user['id']);
+ $this->response->redirect($this->helper->url->to('user', 'session', array('user_id' => $user['id'])));
}
/**
@@ -194,7 +196,7 @@ class User extends Base
$values = $this->request->getValues();
$this->notification->saveSettings($user['id'], $values);
$this->session->flash(t('User updated successfully.'));
- $this->response->redirect('?controller=user&action=notifications&user_id='.$user['id']);
+ $this->response->redirect($this->helper->url->to('user', 'notifications', array('user_id' => $user['id'])));
}
$this->response->html($this->layout('user/notifications', array(
@@ -272,7 +274,7 @@ class User extends Base
$this->session->flashError(t('Unable to change the password.'));
}
- $this->response->redirect('?controller=user&action=show&user_id='.$user['id']);
+ $this->response->redirect($this->helper->url->to('user', 'show', array('user_id' => $user['id'])));
}
}
@@ -298,7 +300,7 @@ class User extends Base
if ($this->request->isPost()) {
- $values = $this->request->getValues() + array('disable_login_form' => 0);
+ $values = $this->request->getValues();
if ($this->userSession->isAdmin()) {
$values += array('is_admin' => 0);
@@ -321,7 +323,7 @@ class User extends Base
$this->session->flashError(t('Unable to update your user.'));
}
- $this->response->redirect('?controller=user&action=show&user_id='.$user['id']);
+ $this->response->redirect($this->helper->url->to('user', 'show', array('user_id' => $user['id'])));
}
}
@@ -335,157 +337,67 @@ class User extends Base
}
/**
- * Remove a user
+ * Display a form to edit authentication
*
* @access public
*/
- public function remove()
+ public function authentication()
{
$user = $this->getUser();
+ $values = $user;
+ $errors = array();
- if ($this->request->getStringParam('confirmation') === 'yes') {
-
- $this->checkCSRFParam();
-
- if ($this->user->remove($user['id'])) {
- $this->session->flash(t('User removed successfully.'));
- } else {
- $this->session->flashError(t('Unable to remove this user.'));
- }
-
- $this->response->redirect('?controller=user');
- }
-
- $this->response->html($this->layout('user/remove', array(
- 'user' => $user,
- )));
- }
-
- /**
- * Google authentication
- *
- * @access public
- */
- public function google()
- {
- $code = $this->request->getStringParam('code');
-
- if ($code) {
-
- $profile = $this->authentication->backend('google')->getGoogleProfile($code);
+ unset($values['password']);
- if (is_array($profile)) {
+ if ($this->request->isPost()) {
- // If the user is already logged, link the account otherwise authenticate
- if ($this->userSession->isLogged()) {
+ $values = $this->request->getValues() + array('disable_login_form' => 0, 'is_ldap_user' => 0);
+ list($valid, $errors) = $this->user->validateModification($values);
- if ($this->authentication->backend('google')->updateUser($this->userSession->getId(), $profile)) {
- $this->session->flash(t('Your Google Account is linked to your profile successfully.'));
- }
- else {
- $this->session->flashError(t('Unable to link your Google Account.'));
- }
+ if ($valid) {
- $this->response->redirect('?controller=user&action=external&user_id='.$this->userSession->getId());
- }
- else if ($this->authentication->backend('google')->authenticate($profile['id'])) {
- $this->response->redirect('?controller=app');
+ if ($this->user->update($values)) {
+ $this->session->flash(t('User updated successfully.'));
}
else {
- $this->response->html($this->template->layout('auth/index', array(
- 'errors' => array('login' => t('Google authentication failed')),
- 'values' => array(),
- 'no_layout' => true,
- 'redirect_query' => '',
- 'title' => t('Login')
- )));
+ $this->session->flashError(t('Unable to update your user.'));
}
- }
- }
-
- $this->response->redirect($this->authentication->backend('google')->getAuthorizationUrl());
- }
- /**
- * Unlink a Google account
- *
- * @access public
- */
- public function unlinkGoogle()
- {
- $this->checkCSRFParam();
- if ($this->authentication->backend('google')->unlink($this->userSession->getId())) {
- $this->session->flash(t('Your Google Account is not linked anymore to your profile.'));
- }
- else {
- $this->session->flashError(t('Unable to unlink your Google Account.'));
+ $this->response->redirect($this->helper->url->to('user', 'authentication', array('user_id' => $user['id'])));
+ }
}
- $this->response->redirect('?controller=user&action=external&user_id='.$this->userSession->getId());
+ $this->response->html($this->layout('user/authentication', array(
+ 'values' => $values,
+ 'errors' => $errors,
+ 'user' => $user,
+ )));
}
/**
- * GitHub authentication
+ * Remove a user
*
* @access public
*/
- public function github()
+ public function remove()
{
- $code = $this->request->getStringParam('code');
-
- if ($code) {
- $profile = $this->authentication->backend('gitHub')->getGitHubProfile($code);
-
- if (is_array($profile)) {
+ $user = $this->getUser();
- // If the user is already logged, link the account otherwise authenticate
- if ($this->userSession->isLogged()) {
+ if ($this->request->getStringParam('confirmation') === 'yes') {
- if ($this->authentication->backend('gitHub')->updateUser($this->userSession->getId(), $profile)) {
- $this->session->flash(t('Your GitHub account was successfully linked to your profile.'));
- }
- else {
- $this->session->flashError(t('Unable to link your GitHub Account.'));
- }
+ $this->checkCSRFParam();
- $this->response->redirect('?controller=user&action=external&user_id='.$this->userSession->getId());
- }
- else if ($this->authentication->backend('gitHub')->authenticate($profile['id'])) {
- $this->response->redirect('?controller=app');
- }
- else {
- $this->response->html($this->template->layout('auth/index', array(
- 'errors' => array('login' => t('GitHub authentication failed')),
- 'values' => array(),
- 'no_layout' => true,
- 'redirect_query' => '',
- 'title' => t('Login')
- )));
- }
+ if ($this->user->remove($user['id'])) {
+ $this->session->flash(t('User removed successfully.'));
+ } else {
+ $this->session->flashError(t('Unable to remove this user.'));
}
- }
-
- $this->response->redirect($this->authentication->backend('gitHub')->getAuthorizationUrl());
- }
- /**
- * Unlink a GitHub account
- *
- * @access public
- */
- public function unlinkGithub()
- {
- $this->checkCSRFParam();
-
- $this->authentication->backend('gitHub')->revokeGitHubAccess();
-
- if ($this->authentication->backend('gitHub')->unlink($this->userSession->getId())) {
- $this->session->flash(t('Your GitHub account is no longer linked to your profile.'));
- }
- else {
- $this->session->flashError(t('Unable to unlink your GitHub Account.'));
+ $this->response->redirect($this->helper->url->to('user', 'index'));
}
- $this->response->redirect('?controller=user&action=external&user_id='.$this->userSession->getId());
+ $this->response->html($this->layout('user/remove', array(
+ 'user' => $user,
+ )));
}
}