summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-12-17 21:38:13 -0500
committerFrederic Guillot <fred@kanboard.net>2015-12-17 21:38:13 -0500
commitc83f589b22cd548c6de10bfb0c18f767ba7dffd8 (patch)
treea5842339000632f2270f7732bfd67d46fe88b4cd /app
parentd0af39170c2c53cf7aa5178a0563bd0d2c667d46 (diff)
Show only active projects in board selector
Diffstat (limited to 'app')
-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/Model/ProjectPermission.php2
-rw-r--r--app/Model/ProjectUserRole.php14
15 files changed, 37 insertions, 25 deletions
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/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