summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorBusfreak <Busfreak@users.noreply.github.com>2015-12-23 00:18:32 +0100
committerBusfreak <Busfreak@users.noreply.github.com>2015-12-23 00:18:32 +0100
commit050d69091822641dabd0ded1b6023b7ef9f90311 (patch)
tree7a6698152aafc9f1eece503f5fa4d4a772782fcd /app
parentbe2fde7cc01228ad4526e05d77a3d4865e550357 (diff)
parent8ff2032ea3fa49972fe076166c831719131e829d (diff)
Merge pull request #1 from fguillot/master
please merge
Diffstat (limited to 'app')
-rw-r--r--app/Api/Comment.php3
-rw-r--r--app/Controller/Activity.php2
-rw-r--r--app/Controller/Analytic.php2
-rw-r--r--app/Controller/App.php2
-rw-r--r--app/Controller/Base.php6
-rw-r--r--app/Controller/Config.php2
-rw-r--r--app/Controller/Currency.php2
-rw-r--r--app/Controller/Doc.php2
-rw-r--r--app/Controller/Gantt.php2
-rw-r--r--app/Controller/Group.php10
-rw-r--r--app/Controller/Link.php2
-rw-r--r--app/Controller/Project.php4
-rw-r--r--app/Controller/Projectuser.php2
-rw-r--r--app/Controller/User.php8
-rw-r--r--app/Core/Base.php1
-rw-r--r--app/Core/Http/Request.php49
-rw-r--r--app/Core/Http/Route.php188
-rw-r--r--app/Core/Http/Router.php199
-rw-r--r--app/Group/LdapBackendGroupProvider.php2
-rw-r--r--app/Helper/App.php15
-rw-r--r--app/Helper/Url.php14
-rw-r--r--app/Model/Comment.php1
-rw-r--r--app/Model/ProjectPermission.php2
-rw-r--r--app/Model/ProjectUserRole.php14
-rw-r--r--app/ServiceProvider/RouteProvider.php268
25 files changed, 498 insertions, 304 deletions
diff --git a/app/Api/Comment.php b/app/Api/Comment.php
index 26b632e9..4c4027c0 100644
--- a/app/Api/Comment.php
+++ b/app/Api/Comment.php
@@ -25,12 +25,13 @@ class Comment extends \Kanboard\Core\Base
return $this->comment->remove($comment_id);
}
- public function createComment($task_id, $user_id, $content)
+ public function createComment($task_id, $user_id, $content, $reference = '')
{
$values = array(
'task_id' => $task_id,
'user_id' => $user_id,
'comment' => $content,
+ 'reference' => $reference,
);
list($valid, ) = $this->comment->validateCreation($values);
diff --git a/app/Controller/Activity.php b/app/Controller/Activity.php
index 71d5e94f..38658345 100644
--- a/app/Controller/Activity.php
+++ b/app/Controller/Activity.php
@@ -20,7 +20,7 @@ class Activity extends Base
$project = $this->getProject();
$this->response->html($this->template->layout('activity/project', array(
- 'board_selector' => $this->projectUserRole->getProjectsByUser($this->userSession->getId()),
+ 'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
'events' => $this->projectActivity->getProject($project['id']),
'project' => $project,
'title' => t('%s\'s activity', $project['name'])
diff --git a/app/Controller/Analytic.php b/app/Controller/Analytic.php
index bebb13fa..b2e27c58 100644
--- a/app/Controller/Analytic.php
+++ b/app/Controller/Analytic.php
@@ -21,7 +21,7 @@ class Analytic extends Base
*/
private function layout($template, array $params)
{
- $params['board_selector'] = $this->projectUserRole->getProjectsByUser($this->userSession->getId());
+ $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);
diff --git a/app/Controller/App.php b/app/Controller/App.php
index c596b4a8..bdd7fbcf 100644
--- a/app/Controller/App.php
+++ b/app/Controller/App.php
@@ -22,7 +22,7 @@ class App extends Base
*/
private function layout($template, array $params)
{
- $params['board_selector'] = $this->projectUserRole->getProjectsByUser($this->userSession->getId());
+ $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);
diff --git a/app/Controller/Base.php b/app/Controller/Base.php
index 35ceee09..6d0ecae9 100644
--- a/app/Controller/Base.php
+++ b/app/Controller/Base.php
@@ -190,7 +190,7 @@ abstract class Base extends \Kanboard\Core\Base
$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->getProjectsByUser($this->userSession->getId());
+ $params['board_selector'] = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
return $this->template->layout('task/layout', $params);
}
@@ -208,7 +208,7 @@ abstract class Base extends \Kanboard\Core\Base
$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->getProjectsByUser($this->userSession->getId());
+ $params['board_selector'] = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
$params['sidebar_template'] = $sidebar_template;
return $this->template->layout('project/layout', $params);
@@ -289,7 +289,7 @@ abstract class Base extends \Kanboard\Core\Base
{
$project = $this->getProject();
$search = $this->request->getStringParam('search', $this->userSession->getFilters($project['id']));
- $board_selector = $this->projectUserRole->getProjectsByUser($this->userSession->getId());
+ $board_selector = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
unset($board_selector[$project['id']]);
$filters = array(
diff --git a/app/Controller/Config.php b/app/Controller/Config.php
index c813c795..c7097da3 100644
--- a/app/Controller/Config.php
+++ b/app/Controller/Config.php
@@ -20,7 +20,7 @@ class Config extends Base
*/
private function layout($template, array $params)
{
- $params['board_selector'] = $this->projectUserRole->getProjectsByUser($this->userSession->getId());
+ $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);
diff --git a/app/Controller/Currency.php b/app/Controller/Currency.php
index 89e38569..4c5b8ee8 100644
--- a/app/Controller/Currency.php
+++ b/app/Controller/Currency.php
@@ -20,7 +20,7 @@ class Currency extends Base
*/
private function layout($template, array $params)
{
- $params['board_selector'] = $this->projectUserRole->getProjectsByUser($this->userSession->getId());
+ $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);
diff --git a/app/Controller/Doc.php b/app/Controller/Doc.php
index 08561aa1..a233b120 100644
--- a/app/Controller/Doc.php
+++ b/app/Controller/Doc.php
@@ -53,7 +53,7 @@ class Doc extends Base
}
$this->response->html($this->template->layout('doc/show', $this->readFile($filename) + array(
- 'board_selector' => $this->projectUserRole->getProjectsByUser($this->userSession->getId()),
+ 'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
)));
}
}
diff --git a/app/Controller/Gantt.php b/app/Controller/Gantt.php
index f3954a25..ac0e6fad 100644
--- a/app/Controller/Gantt.php
+++ b/app/Controller/Gantt.php
@@ -26,7 +26,7 @@ class Gantt extends Base
$this->response->html($this->template->layout('gantt/projects', array(
'projects' => $this->projectGanttFormatter->filter($project_ids)->format(),
'title' => t('Gantt chart for all projects'),
- 'board_selector' => $this->projectUserRole->getProjectsByUser($this->userSession->getId()),
+ 'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
)));
}
diff --git a/app/Controller/Group.php b/app/Controller/Group.php
index 3e6505e9..3c9c4a07 100644
--- a/app/Controller/Group.php
+++ b/app/Controller/Group.php
@@ -25,7 +25,7 @@ class Group extends Base
->calculate();
$this->response->html($this->template->layout('group/index', array(
- 'board_selector' => $this->projectUserRole->getProjectsByUser($this->userSession->getId()),
+ 'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
'title' => t('Groups').' ('.$paginator->getTotal().')',
'paginator' => $paginator,
)));
@@ -49,7 +49,7 @@ class Group extends Base
->calculate();
$this->response->html($this->template->layout('group/users', array(
- 'board_selector' => $this->projectUserRole->getProjectsByUser($this->userSession->getId()),
+ 'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
'title' => t('Members of %s', $group['name']).' ('.$paginator->getTotal().')',
'paginator' => $paginator,
'group' => $group,
@@ -64,7 +64,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->getProjectsByUser($this->userSession->getId()),
+ 'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
'errors' => $errors,
'values' => $values,
'title' => t('New group')
@@ -105,7 +105,7 @@ class Group extends Base
}
$this->response->html($this->template->layout('group/edit', array(
- 'board_selector' => $this->projectUserRole->getProjectsByUser($this->userSession->getId()),
+ 'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
'errors' => $errors,
'values' => $values,
'title' => t('Edit group')
@@ -149,7 +149,7 @@ class Group extends Base
}
$this->response->html($this->template->layout('group/associate', array(
- 'board_selector' => $this->projectUserRole->getProjectsByUser($this->userSession->getId()),
+ 'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
'users' => $this->user->prepareList($this->groupMember->getNotMembers($group_id)),
'group' => $group,
'errors' => $errors,
diff --git a/app/Controller/Link.php b/app/Controller/Link.php
index 33ec6688..2ae57b1a 100644
--- a/app/Controller/Link.php
+++ b/app/Controller/Link.php
@@ -21,7 +21,7 @@ class Link extends Base
*/
private function layout($template, array $params)
{
- $params['board_selector'] = $this->projectUserRole->getProjectsByUser($this->userSession->getId());
+ $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);
diff --git a/app/Controller/Project.php b/app/Controller/Project.php
index 80c95aa2..5e75db4e 100644
--- a/app/Controller/Project.php
+++ b/app/Controller/Project.php
@@ -33,7 +33,7 @@ class Project extends Base
->calculate();
$this->response->html($this->template->layout('project/index', array(
- 'board_selector' => $this->projectUserRole->getProjectsByUser($this->userSession->getId()),
+ 'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
'paginator' => $paginator,
'nb_projects' => $nb_projects,
'title' => t('Projects').' ('.$nb_projects.')'
@@ -302,7 +302,7 @@ class Project extends Base
$is_private = isset($values['is_private']) && $values['is_private'] == 1;
$this->response->html($this->template->layout('project/new', array(
- 'board_selector' => $this->projectUserRole->getProjectsByUser($this->userSession->getId()),
+ 'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
'values' => $values,
'errors' => $errors,
'is_private' => $is_private,
diff --git a/app/Controller/Projectuser.php b/app/Controller/Projectuser.php
index 34595764..806ede77 100644
--- a/app/Controller/Projectuser.php
+++ b/app/Controller/Projectuser.php
@@ -24,7 +24,7 @@ class Projectuser extends Base
*/
private function layout($template, array $params)
{
- $params['board_selector'] = $this->projectUserRole->getProjectsByUser($this->userSession->getId());
+ $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']);
diff --git a/app/Controller/User.php b/app/Controller/User.php
index 0968d5a5..8b6df44c 100644
--- a/app/Controller/User.php
+++ b/app/Controller/User.php
@@ -26,7 +26,7 @@ class User extends Base
{
$content = $this->template->render($template, $params);
$params['user_content_for_layout'] = $content;
- $params['board_selector'] = $this->projectUserRole->getProjectsByUser($this->userSession->getId());
+ $params['board_selector'] = $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId());
if (isset($params['user'])) {
$params['title'] = ($params['user']['name'] ?: $params['user']['username']).' (#'.$params['user']['id'].')';
@@ -51,7 +51,7 @@ class User extends Base
$this->response->html(
$this->template->layout('user/index', array(
- 'board_selector' => $this->projectUserRole->getProjectsByUser($this->userSession->getId()),
+ 'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
'title' => t('Users').' ('.$paginator->getTotal().')',
'paginator' => $paginator,
)));
@@ -72,7 +72,7 @@ class User extends Base
$this->response->html(
$this->template->layout('user/profile', array(
- 'board_selector' => $this->projectUserRole->getProjectsByUser($this->userSession->getId()),
+ 'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
'title' => $user['name'] ?: $user['username'],
'user' => $user,
)
@@ -92,7 +92,7 @@ class User extends Base
'timezones' => $this->config->getTimezones(true),
'languages' => $this->config->getLanguages(true),
'roles' => $this->role->getApplicationRoles(),
- 'board_selector' => $this->projectUserRole->getProjectsByUser($this->userSession->getId()),
+ 'board_selector' => $this->projectUserRole->getActiveProjectsByUser($this->userSession->getId()),
'projects' => $this->project->getList(),
'errors' => $errors,
'values' => $values + array('role' => Role::APP_USER),
diff --git a/app/Core/Base.php b/app/Core/Base.php
index 2d00e52a..a4cf787a 100644
--- a/app/Core/Base.php
+++ b/app/Core/Base.php
@@ -18,6 +18,7 @@ use Pimple\Container;
* @property \Kanboard\Core\Http\Request $request
* @property \Kanboard\Core\Http\Response $response
* @property \Kanboard\Core\Http\Router $router
+ * @property \Kanboard\Core\Http\Route $route
* @property \Kanboard\Core\Mail\Client $emailClient
* @property \Kanboard\Core\ObjectStorage\ObjectStorageInterface $objectStorage
* @property \Kanboard\Core\Plugin\Hook $hook
diff --git a/app/Core/Http/Request.php b/app/Core/Http/Request.php
index c626f5b2..da95f2d4 100644
--- a/app/Core/Http/Request.php
+++ b/app/Core/Http/Request.php
@@ -42,6 +42,16 @@ class Request extends Base
}
/**
+ * Set GET parameters
+ *
+ * @param array $params
+ */
+ public function setParams(array $params)
+ {
+ $this->get = array_merge($this->get, $params);
+ }
+
+ /**
* Get query string string parameter
*
* @access public
@@ -147,6 +157,17 @@ class Request extends Base
}
/**
+ * Return HTTP method
+ *
+ * @access public
+ * @return bool
+ */
+ public function getMethod()
+ {
+ return $this->getServerVariable('REQUEST_METHOD');
+ }
+
+ /**
* Return true if the HTTP request is sent with the POST method
*
* @access public
@@ -154,7 +175,7 @@ class Request extends Base
*/
public function isPost()
{
- return isset($this->server['REQUEST_METHOD']) && $this->server['REQUEST_METHOD'] === 'POST';
+ return $this->getServerVariable('REQUEST_METHOD') === 'POST';
}
/**
@@ -203,7 +224,7 @@ class Request extends Base
public function getHeader($name)
{
$name = 'HTTP_'.str_replace('-', '_', strtoupper($name));
- return isset($this->server[$name]) ? $this->server[$name] : '';
+ return $this->getServerVariable($name);
}
/**
@@ -214,18 +235,18 @@ class Request extends Base
*/
public function getRemoteUser()
{
- return isset($this->server[REVERSE_PROXY_USER_HEADER]) ? $this->server[REVERSE_PROXY_USER_HEADER] : '';
+ return $this->getServerVariable(REVERSE_PROXY_USER_HEADER);
}
/**
- * Returns current request's query string, useful for redirecting
+ * Returns query string
*
* @access public
* @return string
*/
public function getQueryString()
{
- return isset($this->server['QUERY_STRING']) ? $this->server['QUERY_STRING'] : '';
+ return $this->getServerVariable('QUERY_STRING');
}
/**
@@ -236,7 +257,7 @@ class Request extends Base
*/
public function getUri()
{
- return isset($this->server['REQUEST_URI']) ? $this->server['REQUEST_URI'] : '';
+ return $this->getServerVariable('REQUEST_URI');
}
/**
@@ -269,7 +290,7 @@ class Request extends Base
);
foreach ($keys as $key) {
- if (! empty($this->server[$key])) {
+ if ($this->getServerVariable($key) !== '') {
foreach (explode(',', $this->server[$key]) as $ipAddress) {
return trim($ipAddress);
}
@@ -287,6 +308,18 @@ class Request extends Base
*/
public function getStartTime()
{
- return isset($this->server['REQUEST_TIME_FLOAT']) ? $this->server['REQUEST_TIME_FLOAT'] : 0;
+ return $this->getServerVariable('REQUEST_TIME_FLOAT') ?: 0;
+ }
+
+ /**
+ * Get server variable
+ *
+ * @access public
+ * @param string $variable
+ * @return string
+ */
+ public function getServerVariable($variable)
+ {
+ return isset($this->server[$variable]) ? $this->server[$variable] : '';
}
}
diff --git a/app/Core/Http/Route.php b/app/Core/Http/Route.php
new file mode 100644
index 00000000..ed831467
--- /dev/null
+++ b/app/Core/Http/Route.php
@@ -0,0 +1,188 @@
+<?php
+
+namespace Kanboard\Core\Http;
+
+use RuntimeException;
+use Kanboard\Core\Base;
+
+/**
+ * Route Handler
+ *
+ * @package http
+ * @author Frederic Guillot
+ */
+class Route extends Base
+{
+ /**
+ * Flag that enable the routing table
+ *
+ * @access private
+ * @var boolean
+ */
+ private $activated = false;
+
+ /**
+ * Store routes for path lookup
+ *
+ * @access private
+ * @var array
+ */
+ private $paths = array();
+
+ /**
+ * Store routes for url lookup
+ *
+ * @access private
+ * @var array
+ */
+ private $urls = array();
+
+ /**
+ * Enable routing table
+ *
+ * @access public
+ * @return Route
+ */
+ public function enable()
+ {
+ $this->activated = true;
+ return $this;
+ }
+
+ /**
+ * Add route
+ *
+ * @access public
+ * @param string $path
+ * @param string $controller
+ * @param string $action
+ * @param string $plugin
+ * @return Route
+ */
+ public function addRoute($path, $controller, $action, $plugin = '')
+ {
+ if ($this->activated) {
+ $path = ltrim($path, '/');
+ $items = explode('/', $path);
+ $params = $this->findParams($items);
+
+ $this->paths[] = array(
+ 'items' => $items,
+ 'count' => count($items),
+ 'controller' => $controller,
+ 'action' => $action,
+ 'plugin' => $plugin,
+ );
+
+ $this->urls[$plugin][$controller][$action][] = array(
+ 'path' => $path,
+ 'params' => $params,
+ 'count' => count($params),
+ );
+ }
+
+ return $this;
+ }
+
+ /**
+ * Find a route according to the given path
+ *
+ * @access public
+ * @param string $path
+ * @return array
+ */
+ public function findRoute($path)
+ {
+ $items = explode('/', ltrim($path, '/'));
+ $count = count($items);
+
+ foreach ($this->paths as $route) {
+ if ($count === $route['count']) {
+ $params = array();
+
+ for ($i = 0; $i < $count; $i++) {
+ if ($route['items'][$i]{0} === ':') {
+ $params[substr($route['items'][$i], 1)] = $items[$i];
+ } elseif ($route['items'][$i] !== $items[$i]) {
+ break;
+ }
+ }
+
+ if ($i === $count) {
+ $this->request->setParams($params);
+ return array(
+ 'controller' => $route['controller'],
+ 'action' => $route['action'],
+ 'plugin' => $route['plugin'],
+ );
+ }
+ }
+ }
+
+ return array(
+ 'controller' => 'app',
+ 'action' => 'index',
+ 'plugin' => '',
+ );
+ }
+
+ /**
+ * Find route url
+ *
+ * @access public
+ * @param string $controller
+ * @param string $action
+ * @param array $params
+ * @param string $plugin
+ * @return string
+ */
+ public function findUrl($controller, $action, array $params = array(), $plugin = '')
+ {
+ if ($plugin === '' && isset($params['plugin'])) {
+ $plugin = $params['plugin'];
+ unset($params['plugin']);
+ }
+
+ if (! isset($this->urls[$plugin][$controller][$action])) {
+ return '';
+ }
+
+ foreach ($this->urls[$plugin][$controller][$action] as $route) {
+ if (array_diff_key($params, $route['params']) === array()) {
+ $url = $route['path'];
+ $i = 0;
+
+ foreach ($params as $variable => $value) {
+ $url = str_replace(':'.$variable, $value, $url);
+ $i++;
+ }
+
+ if ($i === $route['count']) {
+ return $url;
+ }
+ }
+ }
+
+ return '';
+ }
+
+ /**
+ * Find url params
+ *
+ * @access public
+ * @param array $items
+ * @return array
+ */
+ public function findParams(array $items)
+ {
+ $params = array();
+
+ foreach ($items as $item) {
+ if ($item !== '' && $item{0} === ':') {
+ $params[substr($item, 1)] = true;
+ }
+ }
+
+ return $params;
+ }
+}
diff --git a/app/Core/Http/Router.php b/app/Core/Http/Router.php
index 0080b23a..8b58a947 100644
--- a/app/Core/Http/Router.php
+++ b/app/Core/Http/Router.php
@@ -6,7 +6,7 @@ use RuntimeException;
use Kanboard\Core\Base;
/**
- * Router class
+ * Route Dispatcher
*
* @package http
* @author Frederic Guillot
@@ -14,46 +14,38 @@ use Kanboard\Core\Base;
class Router extends Base
{
/**
- * Controller
+ * Plugin name
*
* @access private
* @var string
*/
- private $controller = '';
+ private $plugin = '';
/**
- * Action
+ * Controller
*
* @access private
* @var string
*/
- private $action = '';
-
- /**
- * Store routes for path lookup
- *
- * @access private
- * @var array
- */
- private $paths = array();
+ private $controller = '';
/**
- * Store routes for url lookup
+ * Action
*
* @access private
- * @var array
+ * @var string
*/
- private $urls = array();
+ private $action = '';
/**
- * Get action
+ * Get plugin name
*
* @access public
* @return string
*/
- public function getAction()
+ public function getPlugin()
{
- return $this->action;
+ return $this->plugin;
}
/**
@@ -68,163 +60,110 @@ class Router extends Base
}
/**
- * Get the path to compare patterns
+ * Get action
*
* @access public
- * @param string $uri
- * @param string $query_string
* @return string
*/
- public function getPath($uri, $query_string = '')
+ public function getAction()
{
- $path = substr($uri, strlen($this->helper->url->dir()));
-
- if (! empty($query_string)) {
- $path = substr($path, 0, - strlen($query_string) - 1);
- }
-
- if (! empty($path) && $path{0} === '/') {
- $path = substr($path, 1);
- }
-
- return $path;
+ return $this->action;
}
/**
- * Add route
+ * Get the path to compare patterns
*
* @access public
- * @param string $path
- * @param string $controller
- * @param string $action
- * @param array $params
+ * @return string
*/
- public function addRoute($path, $controller, $action, array $params = array())
+ public function getPath()
{
- $pattern = explode('/', $path);
-
- $this->paths[] = array(
- 'pattern' => $pattern,
- 'count' => count($pattern),
- 'controller' => $controller,
- 'action' => $action,
- );
-
- $this->urls[$controller][$action][] = array(
- 'path' => $path,
- 'params' => array_flip($params),
- 'count' => count($params),
- );
- }
+ $path = substr($this->request->getUri(), strlen($this->helper->url->dir()));
- /**
- * Find a route according to the given path
- *
- * @access public
- * @param string $path
- * @return array
- */
- public function findRoute($path)
- {
- $parts = explode('/', $path);
- $count = count($parts);
-
- foreach ($this->paths as $route) {
- if ($count === $route['count']) {
- $params = array();
-
- for ($i = 0; $i < $count; $i++) {
- if ($route['pattern'][$i]{0} === ':') {
- $params[substr($route['pattern'][$i], 1)] = $parts[$i];
- } elseif ($route['pattern'][$i] !== $parts[$i]) {
- break;
- }
- }
-
- if ($i === $count) {
- $_GET = array_merge($_GET, $params);
- return array($route['controller'], $route['action']);
- }
- }
+ if ($this->request->getQueryString() !== '') {
+ $path = substr($path, 0, - strlen($this->request->getQueryString()) - 1);
}
- return array('app', 'index');
+ if ($path !== '' && $path{0} === '/') {
+ $path = substr($path, 1);
+ }
+
+ return $path;
}
/**
- * Find route url
+ * Find controller/action from the route table or from get arguments
*
* @access public
- * @param string $controller
- * @param string $action
- * @param array $params
- * @return string
*/
- public function findUrl($controller, $action, array $params = array())
+ public function dispatch()
{
- if (! isset($this->urls[$controller][$action])) {
- return '';
+ $controller = $this->request->getStringParam('controller');
+ $action = $this->request->getStringParam('action');
+ $plugin = $this->request->getStringParam('plugin');
+
+ if ($controller === '') {
+ $route = $this->route->findRoute($this->getPath());
+ $controller = $route['controller'];
+ $action = $route['action'];
+ $plugin = $route['plugin'];
}
- foreach ($this->urls[$controller][$action] as $pattern) {
- if (array_diff_key($params, $pattern['params']) === array()) {
- $url = $pattern['path'];
- $i = 0;
-
- foreach ($params as $variable => $value) {
- $url = str_replace(':'.$variable, $value, $url);
- $i++;
- }
-
- if ($i === $pattern['count']) {
- return $url;
- }
- }
- }
+ $this->controller = ucfirst($this->sanitize($controller, 'app'));
+ $this->action = $this->sanitize($action, 'index');
+ $this->plugin = ucfirst($this->sanitize($plugin));
- return '';
+ return $this->executeAction();
}
/**
* Check controller and action parameter
*
* @access public
- * @param string $value Controller or action name
- * @param string $default_value Default value if validation fail
+ * @param string $value
+ * @param string $default
* @return string
*/
- public function sanitize($value, $default_value)
+ public function sanitize($value, $default = '')
{
- return ! preg_match('/^[a-zA-Z_0-9]+$/', $value) ? $default_value : $value;
+ return preg_match('/^[a-zA-Z_0-9]+$/', $value) ? $value : $default;
}
/**
- * Find controller/action from the route table or from get arguments
+ * Execute controller action
*
- * @access public
- * @param string $uri
- * @param string $query_string
+ * @access private
*/
- public function dispatch($uri, $query_string = '')
+ private function executeAction()
{
- if (! empty($_GET['controller']) && ! empty($_GET['action'])) {
- $this->controller = $this->sanitize($_GET['controller'], 'app');
- $this->action = $this->sanitize($_GET['action'], 'index');
- $plugin = ! empty($_GET['plugin']) ? $this->sanitize($_GET['plugin'], '') : '';
- } else {
- list($this->controller, $this->action) = $this->findRoute($this->getPath($uri, $query_string)); // TODO: add plugin for routes
- $plugin = '';
- }
+ $class = $this->getControllerClassName();
- $class = '\Kanboard\\';
- $class .= empty($plugin) ? 'Controller\\'.ucfirst($this->controller) : 'Plugin\\'.ucfirst($plugin).'\Controller\\'.ucfirst($this->controller);
+ if (! class_exists($class)) {
+ throw new RuntimeException('Controller not found');
+ }
- if (! class_exists($class) || ! method_exists($class, $this->action)) {
- throw new RuntimeException('Controller or method not found for the given url!');
+ if (! method_exists($class, $this->action)) {
+ throw new RuntimeException('Action not implemented');
}
$instance = new $class($this->container);
$instance->beforeAction($this->controller, $this->action);
$instance->{$this->action}();
+ return $instance;
+ }
+
+ /**
+ * Get controller class name
+ *
+ * @access private
+ * @return string
+ */
+ private function getControllerClassName()
+ {
+ if ($this->plugin !== '') {
+ return '\Kanboard\Plugin\\'.$this->plugin.'\Controller\\'.$this->controller;
+ }
+
+ return '\Kanboard\Controller\\'.$this->controller;
}
}
diff --git a/app/Group/LdapBackendGroupProvider.php b/app/Group/LdapBackendGroupProvider.php
index d65a9865..cad732c4 100644
--- a/app/Group/LdapBackendGroupProvider.php
+++ b/app/Group/LdapBackendGroupProvider.php
@@ -45,7 +45,7 @@ class LdapBackendGroupProvider extends Base implements GroupBackendProviderInter
*/
public function getLdapGroupPattern($input)
{
- if (empty(LDAP_GROUP_FILTER)) {
+ if (LDAP_GROUP_FILTER === '') {
throw new LogicException('LDAP group filter empty, check the parameter LDAP_GROUP_FILTER');
}
diff --git a/app/Helper/App.php b/app/Helper/App.php
index 33729f2b..6e6028fc 100644
--- a/app/Helper/App.php
+++ b/app/Helper/App.php
@@ -2,15 +2,28 @@
namespace Kanboard\Helper;
+use Kanboard\Core\Base;
+
/**
* Application helpers
*
* @package helper
* @author Frederic Guillot
*/
-class App extends \Kanboard\Core\Base
+class App extends Base
{
/**
+ * Get plugin name from route
+ *
+ * @access public
+ * @return string
+ */
+ public function getPluginName()
+ {
+ return $this->router->getPlugin();
+ }
+
+ /**
* Get router controller
*
* @access public
diff --git a/app/Helper/Url.php b/app/Helper/Url.php
index 6ada8068..720297cf 100644
--- a/app/Helper/Url.php
+++ b/app/Helper/Url.php
@@ -103,8 +103,8 @@ class Url extends Base
*/
public function dir()
{
- if (empty($this->directory) && isset($_SERVER['REQUEST_METHOD'])) {
- $this->directory = str_replace('\\', '/', dirname($_SERVER['PHP_SELF']));
+ if ($this->directory === '' && $this->request->getMethod() !== '') {
+ $this->directory = str_replace('\\', '/', dirname($this->request->getServerVariable('PHP_SELF')));
$this->directory = $this->directory !== '/' ? $this->directory.'/' : '/';
$this->directory = str_replace('//', '/', $this->directory);
}
@@ -120,13 +120,13 @@ class Url extends Base
*/
public function server()
{
- if (empty($_SERVER['SERVER_NAME'])) {
+ if ($this->request->getServerVariable('SERVER_NAME') === '') {
return 'http://localhost/';
}
$url = $this->request->isHTTPS() ? 'https://' : 'http://';
- $url .= $_SERVER['SERVER_NAME'];
- $url .= $_SERVER['SERVER_PORT'] == 80 || $_SERVER['SERVER_PORT'] == 443 ? '' : ':'.$_SERVER['SERVER_PORT'];
+ $url .= $this->request->getServerVariable('SERVER_NAME');
+ $url .= $this->request->getServerVariable('SERVER_PORT') == 80 || $this->request->getServerVariable('SERVER_PORT') == 443 ? '' : ':'.$this->request->getServerVariable('SERVER_PORT');
$url .= $this->dir() ?: '/';
return $url;
@@ -147,13 +147,15 @@ class Url extends Base
*/
private function build($separator, $controller, $action, array $params = array(), $csrf = false, $anchor = '', $absolute = false)
{
- $path = $this->router->findUrl($controller, $action, $params);
+ $path = $this->route->findUrl($controller, $action, $params);
$qs = array();
if (empty($path)) {
$qs['controller'] = $controller;
$qs['action'] = $action;
$qs += $params;
+ } else {
+ unset($params['plugin']);
}
if ($csrf) {
diff --git a/app/Model/Comment.php b/app/Model/Comment.php
index c7125a25..f60a96e3 100644
--- a/app/Model/Comment.php
+++ b/app/Model/Comment.php
@@ -203,6 +203,7 @@ class Comment extends Base
new Validators\Integer('id', t('This value must be an integer')),
new Validators\Integer('task_id', t('This value must be an integer')),
new Validators\Integer('user_id', t('This value must be an integer')),
+ new Validators\MaxLength('reference', t('The maximum length is %d characters', 50), 50),
new Validators\Required('comment', t('Comment is required'))
);
}
diff --git a/app/Model/ProjectPermission.php b/app/Model/ProjectPermission.php
index f74b8587..4ad9bbf1 100644
--- a/app/Model/ProjectPermission.php
+++ b/app/Model/ProjectPermission.php
@@ -100,7 +100,7 @@ class ProjectPermission extends Base
*/
public function getActiveProjectIds($user_id)
{
- return array_keys($this->projectUserRole->getProjectsByUser($user_id, array(Project::ACTIVE)));
+ return array_keys($this->projectUserRole->getActiveProjectsByUser($user_id));
}
/**
diff --git a/app/Model/ProjectUserRole.php b/app/Model/ProjectUserRole.php
index 28e6c8c6..b2c38622 100644
--- a/app/Model/ProjectUserRole.php
+++ b/app/Model/ProjectUserRole.php
@@ -20,7 +20,19 @@ class ProjectUserRole extends Base
const TABLE = 'project_has_users';
/**
- * Get the list of project visible by the given user
+ * Get the list of active project for the given user
+ *
+ * @access public
+ * @param integer $user_id
+ * @return array
+ */
+ public function getActiveProjectsByUser($user_id)
+ {
+ return $this->getProjectsByUser($user_id, $status = array(Project::ACTIVE));
+ }
+
+ /**
+ * Get the list of project visible for the given user
*
* @access public
* @param integer $user_id
diff --git a/app/ServiceProvider/RouteProvider.php b/app/ServiceProvider/RouteProvider.php
index b7dba8e5..e58d50c7 100644
--- a/app/ServiceProvider/RouteProvider.php
+++ b/app/ServiceProvider/RouteProvider.php
@@ -4,6 +4,7 @@ namespace Kanboard\ServiceProvider;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
+use Kanboard\Core\Http\Route;
use Kanboard\Core\Http\Router;
/**
@@ -24,183 +25,186 @@ class RouteProvider implements ServiceProviderInterface
public function register(Container $container)
{
$container['router'] = new Router($container);
+ $container['route'] = new Route($container);
if (ENABLE_URL_REWRITE) {
+ $container['route']->enable();
+
// Dashboard
- $container['router']->addRoute('dashboard', 'app', 'index');
- $container['router']->addRoute('dashboard/:user_id', 'app', 'index', array('user_id'));
- $container['router']->addRoute('dashboard/:user_id/projects', 'app', 'projects', array('user_id'));
- $container['router']->addRoute('dashboard/:user_id/tasks', 'app', 'tasks', array('user_id'));
- $container['router']->addRoute('dashboard/:user_id/subtasks', 'app', 'subtasks', array('user_id'));
- $container['router']->addRoute('dashboard/:user_id/calendar', 'app', 'calendar', array('user_id'));
- $container['router']->addRoute('dashboard/:user_id/activity', 'app', 'activity', array('user_id'));
+ $container['route']->addRoute('dashboard', 'app', 'index');
+ $container['route']->addRoute('dashboard/:user_id', 'app', 'index');
+ $container['route']->addRoute('dashboard/:user_id/projects', 'app', 'projects');
+ $container['route']->addRoute('dashboard/:user_id/tasks', 'app', 'tasks');
+ $container['route']->addRoute('dashboard/:user_id/subtasks', 'app', 'subtasks');
+ $container['route']->addRoute('dashboard/:user_id/calendar', 'app', 'calendar');
+ $container['route']->addRoute('dashboard/:user_id/activity', 'app', 'activity');
// Search routes
- $container['router']->addRoute('search', 'search', 'index');
- $container['router']->addRoute('search/:search', 'search', 'index', array('search'));
+ $container['route']->addRoute('search', 'search', 'index');
+ $container['route']->addRoute('search/:search', 'search', 'index');
// Project routes
- $container['router']->addRoute('projects', 'project', 'index');
- $container['router']->addRoute('project/create', 'project', 'create');
- $container['router']->addRoute('project/create/private', 'project', 'createPrivate');
- $container['router']->addRoute('project/:project_id', 'project', 'show', array('project_id'));
- $container['router']->addRoute('p/:project_id', 'project', 'show', array('project_id'));
- $container['router']->addRoute('project/:project_id/customer-filter', 'customfilter', 'index', array('project_id'));
- $container['router']->addRoute('project/:project_id/share', 'project', 'share', array('project_id'));
- $container['router']->addRoute('project/:project_id/notifications', 'project', 'notifications', array('project_id'));
- $container['router']->addRoute('project/:project_id/edit', 'project', 'edit', array('project_id'));
- $container['router']->addRoute('project/:project_id/integrations', 'project', 'integrations', array('project_id'));
- $container['router']->addRoute('project/:project_id/duplicate', 'project', 'duplicate', array('project_id'));
- $container['router']->addRoute('project/:project_id/remove', 'project', 'remove', array('project_id'));
- $container['router']->addRoute('project/:project_id/disable', 'project', 'disable', array('project_id'));
- $container['router']->addRoute('project/:project_id/enable', 'project', 'enable', array('project_id'));
- $container['router']->addRoute('project/:project_id/permissions', 'ProjectPermission', 'index', array('project_id'));
- $container['router']->addRoute('project/:project_id/import', 'taskImport', 'step1', array('project_id'));
+ $container['route']->addRoute('projects', 'project', 'index');
+ $container['route']->addRoute('project/create', 'project', 'create');
+ $container['route']->addRoute('project/create/private', 'project', 'createPrivate');
+ $container['route']->addRoute('project/:project_id', 'project', 'show');
+ $container['route']->addRoute('p/:project_id', 'project', 'show');
+ $container['route']->addRoute('project/:project_id/customer-filter', 'customfilter', 'index');
+ $container['route']->addRoute('project/:project_id/share', 'project', 'share');
+ $container['route']->addRoute('project/:project_id/notifications', 'project', 'notifications');
+ $container['route']->addRoute('project/:project_id/edit', 'project', 'edit');
+ $container['route']->addRoute('project/:project_id/integrations', 'project', 'integrations');
+ $container['route']->addRoute('project/:project_id/duplicate', 'project', 'duplicate');
+ $container['route']->addRoute('project/:project_id/remove', 'project', 'remove');
+ $container['route']->addRoute('project/:project_id/disable', 'project', 'disable');
+ $container['route']->addRoute('project/:project_id/enable', 'project', 'enable');
+ $container['route']->addRoute('project/:project_id/permissions', 'ProjectPermission', 'index');
+ $container['route']->addRoute('project/:project_id/import', 'taskImport', 'step1');
// ProjectUser routes
- $container['router']->addRoute('projects/managers/:user_id', 'projectuser', 'managers', array('user_id'));
- $container['router']->addRoute('projects/members/:user_id', 'projectuser', 'members', array('user_id'));
- $container['router']->addRoute('projects/tasks/:user_id/opens', 'projectuser', 'opens', array('user_id'));
- $container['router']->addRoute('projects/tasks/:user_id/closed', 'projectuser', 'closed', array('user_id'));
- $container['router']->addRoute('projects/managers', 'projectuser', 'managers');
+ $container['route']->addRoute('projects/managers/:user_id', 'projectuser', 'managers');
+ $container['route']->addRoute('projects/members/:user_id', 'projectuser', 'members');
+ $container['route']->addRoute('projects/tasks/:user_id/opens', 'projectuser', 'opens');
+ $container['route']->addRoute('projects/tasks/:user_id/closed', 'projectuser', 'closed');
+ $container['route']->addRoute('projects/managers', 'projectuser', 'managers');
// Action routes
- $container['router']->addRoute('project/:project_id/actions', 'action', 'index', array('project_id'));
- $container['router']->addRoute('project/:project_id/action/:action_id/confirm', 'action', 'confirm', array('project_id', 'action_id'));
+ $container['route']->addRoute('project/:project_id/actions', 'action', 'index');
+ $container['route']->addRoute('project/:project_id/action/:action_id/confirm', 'action', 'confirm');
// Column routes
- $container['router']->addRoute('project/:project_id/columns', 'column', 'index', array('project_id'));
- $container['router']->addRoute('project/:project_id/column/:column_id/edit', 'column', 'edit', array('project_id', 'column_id'));
- $container['router']->addRoute('project/:project_id/column/:column_id/confirm', 'column', 'confirm', array('project_id', 'column_id'));
- $container['router']->addRoute('project/:project_id/column/:column_id/move/:direction', 'column', 'move', array('project_id', 'column_id', 'direction'));
+ $container['route']->addRoute('project/:project_id/columns', 'column', 'index');
+ $container['route']->addRoute('project/:project_id/column/:column_id/edit', 'column', 'edit');
+ $container['route']->addRoute('project/:project_id/column/:column_id/confirm', 'column', 'confirm');
+ $container['route']->addRoute('project/:project_id/column/:column_id/move/:direction', 'column', 'move');
// Swimlane routes
- $container['router']->addRoute('project/:project_id/swimlanes', 'swimlane', 'index', array('project_id'));
- $container['router']->addRoute('project/:project_id/swimlane/:swimlane_id/edit', 'swimlane', 'edit', array('project_id', 'swimlane_id'));
- $container['router']->addRoute('project/:project_id/swimlane/:swimlane_id/confirm', 'swimlane', 'confirm', array('project_id', 'swimlane_id'));
- $container['router']->addRoute('project/:project_id/swimlane/:swimlane_id/disable', 'swimlane', 'disable', array('project_id', 'swimlane_id'));
- $container['router']->addRoute('project/:project_id/swimlane/:swimlane_id/enable', 'swimlane', 'enable', array('project_id', 'swimlane_id'));
- $container['router']->addRoute('project/:project_id/swimlane/:swimlane_id/up', 'swimlane', 'moveup', array('project_id', 'swimlane_id'));
- $container['router']->addRoute('project/:project_id/swimlane/:swimlane_id/down', 'swimlane', 'movedown', array('project_id', 'swimlane_id'));
+ $container['route']->addRoute('project/:project_id/swimlanes', 'swimlane', 'index');
+ $container['route']->addRoute('project/:project_id/swimlane/:swimlane_id/edit', 'swimlane', 'edit');
+ $container['route']->addRoute('project/:project_id/swimlane/:swimlane_id/confirm', 'swimlane', 'confirm');
+ $container['route']->addRoute('project/:project_id/swimlane/:swimlane_id/disable', 'swimlane', 'disable');
+ $container['route']->addRoute('project/:project_id/swimlane/:swimlane_id/enable', 'swimlane', 'enable');
+ $container['route']->addRoute('project/:project_id/swimlane/:swimlane_id/up', 'swimlane', 'moveup');
+ $container['route']->addRoute('project/:project_id/swimlane/:swimlane_id/down', 'swimlane', 'movedown');
// Category routes
- $container['router']->addRoute('project/:project_id/categories', 'category', 'index', array('project_id'));
- $container['router']->addRoute('project/:project_id/category/:category_id/edit', 'category', 'edit', array('project_id', 'category_id'));
- $container['router']->addRoute('project/:project_id/category/:category_id/confirm', 'category', 'confirm', array('project_id', 'category_id'));
+ $container['route']->addRoute('project/:project_id/categories', 'category', 'index');
+ $container['route']->addRoute('project/:project_id/category/:category_id/edit', 'category', 'edit');
+ $container['route']->addRoute('project/:project_id/category/:category_id/confirm', 'category', 'confirm');
// Task routes
- $container['router']->addRoute('project/:project_id/task/:task_id', 'task', 'show', array('project_id', 'task_id'));
- $container['router']->addRoute('t/:task_id', 'task', 'show', array('task_id'));
- $container['router']->addRoute('public/task/:task_id/:token', 'task', 'readonly', array('task_id', 'token'));
-
- $container['router']->addRoute('project/:project_id/task/:task_id/activity', 'activity', 'task', array('project_id', 'task_id'));
- $container['router']->addRoute('project/:project_id/task/:task_id/screenshot', 'file', 'screenshot', array('project_id', 'task_id'));
- $container['router']->addRoute('project/:project_id/task/:task_id/upload', 'file', 'create', array('project_id', 'task_id'));
- $container['router']->addRoute('project/:project_id/task/:task_id/comment', 'comment', 'create', array('project_id', 'task_id'));
- $container['router']->addRoute('project/:project_id/task/:task_id/link', 'tasklink', 'create', array('project_id', 'task_id'));
- $container['router']->addRoute('project/:project_id/task/:task_id/transitions', 'task', 'transitions', array('project_id', 'task_id'));
- $container['router']->addRoute('project/:project_id/task/:task_id/analytics', 'task', 'analytics', array('project_id', 'task_id'));
- $container['router']->addRoute('project/:project_id/task/:task_id/remove', 'task', 'remove', array('project_id', 'task_id'));
-
- $container['router']->addRoute('project/:project_id/task/:task_id/edit', 'taskmodification', 'edit', array('project_id', 'task_id'));
- $container['router']->addRoute('project/:project_id/task/:task_id/description', 'taskmodification', 'description', array('project_id', 'task_id'));
- $container['router']->addRoute('project/:project_id/task/:task_id/recurrence', 'taskmodification', 'recurrence', array('project_id', 'task_id'));
-
- $container['router']->addRoute('project/:project_id/task/:task_id/close', 'taskstatus', 'close', array('task_id', 'project_id'));
- $container['router']->addRoute('project/:project_id/task/:task_id/open', 'taskstatus', 'open', array('task_id', 'project_id'));
-
- $container['router']->addRoute('project/:project_id/task/:task_id/duplicate', 'taskduplication', 'duplicate', array('task_id', 'project_id'));
- $container['router']->addRoute('project/:project_id/task/:task_id/copy', 'taskduplication', 'copy', array('task_id', 'project_id'));
- $container['router']->addRoute('project/:project_id/task/:task_id/copy/:dst_project_id', 'taskduplication', 'copy', array('task_id', 'project_id', 'dst_project_id'));
- $container['router']->addRoute('project/:project_id/task/:task_id/move', 'taskduplication', 'move', array('task_id', 'project_id'));
- $container['router']->addRoute('project/:project_id/task/:task_id/move/:dst_project_id', 'taskduplication', 'move', array('task_id', 'project_id', 'dst_project_id'));
+ $container['route']->addRoute('project/:project_id/task/:task_id', 'task', 'show');
+ $container['route']->addRoute('t/:task_id', 'task', 'show');
+ $container['route']->addRoute('public/task/:task_id/:token', 'task', 'readonly');
+
+ $container['route']->addRoute('project/:project_id/task/:task_id/activity', 'activity', 'task');
+ $container['route']->addRoute('project/:project_id/task/:task_id/screenshot', 'file', 'screenshot');
+ $container['route']->addRoute('project/:project_id/task/:task_id/upload', 'file', 'create');
+ $container['route']->addRoute('project/:project_id/task/:task_id/comment', 'comment', 'create');
+ $container['route']->addRoute('project/:project_id/task/:task_id/link', 'tasklink', 'create');
+ $container['route']->addRoute('project/:project_id/task/:task_id/transitions', 'task', 'transitions');
+ $container['route']->addRoute('project/:project_id/task/:task_id/analytics', 'task', 'analytics');
+ $container['route']->addRoute('project/:project_id/task/:task_id/remove', 'task', 'remove');
+
+ $container['route']->addRoute('project/:project_id/task/:task_id/edit', 'taskmodification', 'edit');
+ $container['route']->addRoute('project/:project_id/task/:task_id/description', 'taskmodification', 'description');
+ $container['route']->addRoute('project/:project_id/task/:task_id/recurrence', 'taskmodification', 'recurrence');
+
+ $container['route']->addRoute('project/:project_id/task/:task_id/close', 'taskstatus', 'close');
+ $container['route']->addRoute('project/:project_id/task/:task_id/open', 'taskstatus', 'open');
+
+ $container['route']->addRoute('project/:project_id/task/:task_id/duplicate', 'taskduplication', 'duplicate');
+ $container['route']->addRoute('project/:project_id/task/:task_id/copy', 'taskduplication', 'copy');
+ $container['route']->addRoute('project/:project_id/task/:task_id/copy/:dst_project_id', 'taskduplication', 'copy');
+ $container['route']->addRoute('project/:project_id/task/:task_id/move', 'taskduplication', 'move');
+ $container['route']->addRoute('project/:project_id/task/:task_id/move/:dst_project_id', 'taskduplication', 'move');
// Exports
- $container['router']->addRoute('export/tasks/:project_id', 'export', 'tasks', array('project_id'));
- $container['router']->addRoute('export/subtasks/:project_id', 'export', 'subtasks', array('project_id'));
- $container['router']->addRoute('export/transitions/:project_id', 'export', 'transitions', array('project_id'));
- $container['router']->addRoute('export/summary/:project_id', 'export', 'summary', array('project_id'));
+ $container['route']->addRoute('export/tasks/:project_id', 'export', 'tasks');
+ $container['route']->addRoute('export/subtasks/:project_id', 'export', 'subtasks');
+ $container['route']->addRoute('export/transitions/:project_id', 'export', 'transitions');
+ $container['route']->addRoute('export/summary/:project_id', 'export', 'summary');
// Board routes
- $container['router']->addRoute('board/:project_id', 'board', 'show', array('project_id'));
- $container['router']->addRoute('b/:project_id', 'board', 'show', array('project_id'));
- $container['router']->addRoute('public/board/:token', 'board', 'readonly', array('token'));
+ $container['route']->addRoute('board/:project_id', 'board', 'show');
+ $container['route']->addRoute('b/:project_id', 'board', 'show');
+ $container['route']->addRoute('public/board/:token', 'board', 'readonly');
// Calendar routes
- $container['router']->addRoute('calendar/:project_id', 'calendar', 'show', array('project_id'));
- $container['router']->addRoute('c/:project_id', 'calendar', 'show', array('project_id'));
+ $container['route']->addRoute('calendar/:project_id', 'calendar', 'show');
+ $container['route']->addRoute('c/:project_id', 'calendar', 'show');
// Listing routes
- $container['router']->addRoute('list/:project_id', 'listing', 'show', array('project_id'));
- $container['router']->addRoute('l/:project_id', 'listing', 'show', array('project_id'));
+ $container['route']->addRoute('list/:project_id', 'listing', 'show');
+ $container['route']->addRoute('l/:project_id', 'listing', 'show');
// Gantt routes
- $container['router']->addRoute('gantt/:project_id', 'gantt', 'project', array('project_id'));
- $container['router']->addRoute('gantt/:project_id/sort/:sorting', 'gantt', 'project', array('project_id', 'sorting'));
+ $container['route']->addRoute('gantt/:project_id', 'gantt', 'project');
+ $container['route']->addRoute('gantt/:project_id/sort/:sorting', 'gantt', 'project');
// Subtask routes
- $container['router']->addRoute('project/:project_id/task/:task_id/subtask/create', 'subtask', 'create', array('project_id', 'task_id'));
- $container['router']->addRoute('project/:project_id/task/:task_id/subtask/:subtask_id/remove', 'subtask', 'confirm', array('project_id', 'task_id', 'subtask_id'));
- $container['router']->addRoute('project/:project_id/task/:task_id/subtask/:subtask_id/edit', 'subtask', 'edit', array('project_id', 'task_id', 'subtask_id'));
+ $container['route']->addRoute('project/:project_id/task/:task_id/subtask/create', 'subtask', 'create');
+ $container['route']->addRoute('project/:project_id/task/:task_id/subtask/:subtask_id/remove', 'subtask', 'confirm');
+ $container['route']->addRoute('project/:project_id/task/:task_id/subtask/:subtask_id/edit', 'subtask', 'edit');
// Feed routes
- $container['router']->addRoute('feed/project/:token', 'feed', 'project', array('token'));
- $container['router']->addRoute('feed/user/:token', 'feed', 'user', array('token'));
+ $container['route']->addRoute('feed/project/:token', 'feed', 'project');
+ $container['route']->addRoute('feed/user/:token', 'feed', 'user');
// Ical routes
- $container['router']->addRoute('ical/project/:token', 'ical', 'project', array('token'));
- $container['router']->addRoute('ical/user/:token', 'ical', 'user', array('token'));
+ $container['route']->addRoute('ical/project/:token', 'ical', 'project');
+ $container['route']->addRoute('ical/user/:token', 'ical', 'user');
// Users
- $container['router']->addRoute('users', 'user', 'index');
- $container['router']->addRoute('user/profile/:user_id', 'user', 'profile', array('user_id'));
- $container['router']->addRoute('user/show/:user_id', 'user', 'show', array('user_id'));
- $container['router']->addRoute('user/show/:user_id/timesheet', 'user', 'timesheet', array('user_id'));
- $container['router']->addRoute('user/show/:user_id/last-logins', 'user', 'last', array('user_id'));
- $container['router']->addRoute('user/show/:user_id/sessions', 'user', 'sessions', array('user_id'));
- $container['router']->addRoute('user/:user_id/edit', 'user', 'edit', array('user_id'));
- $container['router']->addRoute('user/:user_id/password', 'user', 'password', array('user_id'));
- $container['router']->addRoute('user/:user_id/share', 'user', 'share', array('user_id'));
- $container['router']->addRoute('user/:user_id/notifications', 'user', 'notifications', array('user_id'));
- $container['router']->addRoute('user/:user_id/accounts', 'user', 'external', array('user_id'));
- $container['router']->addRoute('user/:user_id/integrations', 'user', 'integrations', array('user_id'));
- $container['router']->addRoute('user/:user_id/authentication', 'user', 'authentication', array('user_id'));
- $container['router']->addRoute('user/:user_id/remove', 'user', 'remove', array('user_id'));
- $container['router']->addRoute('user/:user_id/2fa', 'twofactor', 'index', array('user_id'));
+ $container['route']->addRoute('users', 'user', 'index');
+ $container['route']->addRoute('user/profile/:user_id', 'user', 'profile');
+ $container['route']->addRoute('user/show/:user_id', 'user', 'show');
+ $container['route']->addRoute('user/show/:user_id/timesheet', 'user', 'timesheet');
+ $container['route']->addRoute('user/show/:user_id/last-logins', 'user', 'last');
+ $container['route']->addRoute('user/show/:user_id/sessions', 'user', 'sessions');
+ $container['route']->addRoute('user/:user_id/edit', 'user', 'edit');
+ $container['route']->addRoute('user/:user_id/password', 'user', 'password');
+ $container['route']->addRoute('user/:user_id/share', 'user', 'share');
+ $container['route']->addRoute('user/:user_id/notifications', 'user', 'notifications');
+ $container['route']->addRoute('user/:user_id/accounts', 'user', 'external');
+ $container['route']->addRoute('user/:user_id/integrations', 'user', 'integrations');
+ $container['route']->addRoute('user/:user_id/authentication', 'user', 'authentication');
+ $container['route']->addRoute('user/:user_id/remove', 'user', 'remove');
+ $container['route']->addRoute('user/:user_id/2fa', 'twofactor', 'index');
// Groups
- $container['router']->addRoute('groups', 'group', 'index');
- $container['router']->addRoute('groups/create', 'group', 'create');
- $container['router']->addRoute('group/:group_id/associate', 'group', 'associate', array('group_id'));
- $container['router']->addRoute('group/:group_id/dissociate/:user_id', 'group', 'dissociate', array('group_id', 'user_id'));
- $container['router']->addRoute('group/:group_id/edit', 'group', 'edit', array('group_id'));
- $container['router']->addRoute('group/:group_id/members', 'group', 'users', array('group_id'));
- $container['router']->addRoute('group/:group_id/remove', 'group', 'confirm', array('group_id'));
+ $container['route']->addRoute('groups', 'group', 'index');
+ $container['route']->addRoute('groups/create', 'group', 'create');
+ $container['route']->addRoute('group/:group_id/associate', 'group', 'associate');
+ $container['route']->addRoute('group/:group_id/dissociate/:user_id', 'group', 'dissociate');
+ $container['route']->addRoute('group/:group_id/edit', 'group', 'edit');
+ $container['route']->addRoute('group/:group_id/members', 'group', 'users');
+ $container['route']->addRoute('group/:group_id/remove', 'group', 'confirm');
// Config
- $container['router']->addRoute('settings', 'config', 'index');
- $container['router']->addRoute('settings/plugins', 'config', 'plugins');
- $container['router']->addRoute('settings/application', 'config', 'application');
- $container['router']->addRoute('settings/project', 'config', 'project');
- $container['router']->addRoute('settings/project', 'config', 'project');
- $container['router']->addRoute('settings/board', 'config', 'board');
- $container['router']->addRoute('settings/calendar', 'config', 'calendar');
- $container['router']->addRoute('settings/integrations', 'config', 'integrations');
- $container['router']->addRoute('settings/webhook', 'config', 'webhook');
- $container['router']->addRoute('settings/api', 'config', 'api');
- $container['router']->addRoute('settings/links', 'link', 'index');
- $container['router']->addRoute('settings/currencies', 'currency', 'index');
+ $container['route']->addRoute('settings', 'config', 'index');
+ $container['route']->addRoute('settings/plugins', 'config', 'plugins');
+ $container['route']->addRoute('settings/application', 'config', 'application');
+ $container['route']->addRoute('settings/project', 'config', 'project');
+ $container['route']->addRoute('settings/project', 'config', 'project');
+ $container['route']->addRoute('settings/board', 'config', 'board');
+ $container['route']->addRoute('settings/calendar', 'config', 'calendar');
+ $container['route']->addRoute('settings/integrations', 'config', 'integrations');
+ $container['route']->addRoute('settings/webhook', 'config', 'webhook');
+ $container['route']->addRoute('settings/api', 'config', 'api');
+ $container['route']->addRoute('settings/links', 'link', 'index');
+ $container['route']->addRoute('settings/currencies', 'currency', 'index');
// Doc
- $container['router']->addRoute('documentation/:file', 'doc', 'show', array('file'));
- $container['router']->addRoute('documentation', 'doc', 'show');
+ $container['route']->addRoute('documentation/:file', 'doc', 'show');
+ $container['route']->addRoute('documentation', 'doc', 'show');
// Auth routes
- $container['router']->addRoute('oauth/google', 'oauth', 'google');
- $container['router']->addRoute('oauth/github', 'oauth', 'github');
- $container['router']->addRoute('oauth/gitlab', 'oauth', 'gitlab');
- $container['router']->addRoute('login', 'auth', 'login');
- $container['router']->addRoute('logout', 'auth', 'logout');
+ $container['route']->addRoute('oauth/google', 'oauth', 'google');
+ $container['route']->addRoute('oauth/github', 'oauth', 'github');
+ $container['route']->addRoute('oauth/gitlab', 'oauth', 'gitlab');
+ $container['route']->addRoute('login', 'auth', 'login');
+ $container['route']->addRoute('logout', 'auth', 'logout');
}
return $container;