summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2014-11-09 12:47:49 -0500
committerFrédéric Guillot <fred@kanboard.net>2014-11-09 12:47:49 -0500
commit3df63e051fac84cec98c912668722f87d6e8183e (patch)
tree648a92db37f3295669ae6cc59126fc003235cfa8
parente0117cb8ed6326e8c77a02ce265c2b5f195e08d8 (diff)
Add projects to the dashboard and rename some methods
-rw-r--r--app/Controller/Action.php4
-rw-r--r--app/Controller/App.php8
-rw-r--r--app/Controller/Board.php10
-rw-r--r--app/Controller/Project.php8
-rw-r--r--app/Controller/Subtask.php8
-rw-r--r--app/Controller/Task.php10
-rw-r--r--app/Locale/da_DK/translations.php4
-rw-r--r--app/Locale/de_DE/translations.php4
-rw-r--r--app/Locale/es_ES/translations.php4
-rw-r--r--app/Locale/fi_FI/translations.php4
-rw-r--r--app/Locale/fr_FR/translations.php4
-rw-r--r--app/Locale/it_IT/translations.php4
-rw-r--r--app/Locale/ja_JP/translations.php4
-rw-r--r--app/Locale/pl_PL/translations.php4
-rw-r--r--app/Locale/pt_BR/translations.php4
-rw-r--r--app/Locale/ru_RU/translations.php4
-rw-r--r--app/Locale/sv_SE/translations.php4
-rw-r--r--app/Locale/th_TH/translations.php4
-rw-r--r--app/Locale/zh_CN/translations.php4
-rw-r--r--app/Model/Project.php36
-rw-r--r--app/Model/ProjectPermission.php52
-rw-r--r--app/Template/app_forbidden.php4
-rw-r--r--app/Template/app_index.php42
-rw-r--r--app/helpers.php10
-rw-r--r--assets/css/app.css26
-rw-r--r--assets/css/dashboard.css25
-rw-r--r--jsonrpc.php2
-rw-r--r--tests/units/NotificationTest.php4
-rw-r--r--tests/units/ProjectPermissionTest.php32
-rw-r--r--tests/units/ProjectTest.php4
30 files changed, 262 insertions, 75 deletions
diff --git a/app/Controller/Action.php b/app/Controller/Action.php
index 63f72e1f..bf72f36f 100644
--- a/app/Controller/Action.php
+++ b/app/Controller/Action.php
@@ -27,7 +27,7 @@ class Action extends Base
'available_events' => $this->action->getAvailableEvents(),
'available_params' => $this->action->getAllActionParameters(),
'columns_list' => $this->board->getColumnsList($project['id']),
- 'users_list' => $this->projectPermission->getUsersList($project['id']),
+ 'users_list' => $this->projectPermission->getMemberList($project['id']),
'projects_list' => $this->project->getList(false),
'colors_list' => $this->color->getList(),
'categories_list' => $this->category->getList($project['id']),
@@ -85,7 +85,7 @@ class Action extends Base
'values' => $values,
'action_params' => $action_params,
'columns_list' => $this->board->getColumnsList($project['id']),
- 'users_list' => $this->projectPermission->getUsersList($project['id']),
+ 'users_list' => $this->projectPermission->getMemberList($project['id']),
'projects_list' => $projects_list,
'colors_list' => $this->color->getList(),
'categories_list' => $this->category->getList($project['id']),
diff --git a/app/Controller/App.php b/app/Controller/App.php
index 193c2583..7fa97d4f 100644
--- a/app/Controller/App.php
+++ b/app/Controller/App.php
@@ -20,12 +20,14 @@ class App extends Base
public function index()
{
$user_id = $this->acl->getUserId();
- $projects = $this->projectPermission->getAllowedProjects($user_id);
+ $projects = $this->projectPermission->getMemberProjects($user_id);
+ $project_ids = array_keys($projects);
$this->response->html($this->template->layout('app_index', array(
- 'board_selector' => $projects,
- 'events' => $this->projectActivity->getProjects(array_keys($projects), 10),
+ 'board_selector' => $this->projectPermission->getAllowedProjects($user_id),
+ 'events' => $this->projectActivity->getProjects($project_ids, 10),
'tasks' => $this->taskFinder->getAllTasksByUser($user_id),
+ 'projects' => $this->project->getSummary($project_ids),
'title' => t('Dashboard'),
)));
}
diff --git a/app/Controller/Board.php b/app/Controller/Board.php
index 0cd8f169..a2d6628f 100644
--- a/app/Controller/Board.php
+++ b/app/Controller/Board.php
@@ -42,12 +42,11 @@ class Board extends Base
{
$task = $this->getTask();
$project = $this->project->getById($task['project_id']);
- $projects = $this->projectPermission->getAllowedProjects($this->acl->getUserId());
+
$params = array(
'errors' => array(),
'values' => $task,
- 'users_list' => $this->projectPermission->getUsersList($project['id']),
- 'projects' => $projects,
+ 'users_list' => $this->projectPermission->getMemberList($project['id']),
'current_project_id' => $project['id'],
'current_project_name' => $project['name'],
);
@@ -95,12 +94,11 @@ class Board extends Base
{
$task = $this->getTask();
$project = $this->project->getById($task['project_id']);
- $projects = $this->projectPermission->getAllowedProjects($this->acl->getUserId());
+
$params = array(
'errors' => array(),
'values' => $task,
'categories_list' => $this->category->getList($project['id']),
- 'projects' => $projects,
'current_project_id' => $project['id'],
'current_project_name' => $project['name'],
);
@@ -213,7 +211,7 @@ class Board extends Base
$this->user->storeLastSeenProjectId($project['id']);
$this->response->html($this->template->layout('board_index', array(
- 'users' => $this->projectPermission->getUsersList($project['id'], true, true),
+ 'users' => $this->projectPermission->getMemberList($project['id'], true, true),
'filters' => array('user_id' => UserModel::EVERYBODY_ID),
'projects' => $projects,
'current_project_id' => $project['id'],
diff --git a/app/Controller/Project.php b/app/Controller/Project.php
index bdc382f7..a479b1d6 100644
--- a/app/Controller/Project.php
+++ b/app/Controller/Project.php
@@ -146,7 +146,7 @@ class Project extends Base
public function update()
{
$project = $this->getProjectManagement();
- $values = $this->request->getValues() + array('is_active' => 0);
+ $values = $this->request->getValues();
list($valid, $errors) = $this->project->validateModification($values);
if ($valid) {
@@ -527,9 +527,11 @@ class Project extends Base
if ($valid) {
- if ($this->project->create($values, $this->acl->getUserId())) {
+ $project_id = $this->project->create($values, $this->acl->getUserId());
+
+ if ($project_id) {
$this->session->flash(t('Your project have been created successfully.'));
- $this->response->redirect('?controller=project');
+ $this->response->redirect('?controller=project&action=show&project_id='.$project_id);
}
else {
$this->session->flashError(t('Unable to create your project.'));
diff --git a/app/Controller/Subtask.php b/app/Controller/Subtask.php
index 5db7471a..bc50b5e1 100644
--- a/app/Controller/Subtask.php
+++ b/app/Controller/Subtask.php
@@ -42,7 +42,7 @@ class Subtask extends Base
'another_subtask' => $this->request->getIntegerParam('another_subtask', 0)
),
'errors' => array(),
- 'users_list' => $this->projectPermission->getUsersList($task['project_id']),
+ 'users_list' => $this->projectPermission->getMemberList($task['project_id']),
'task' => $task,
)));
}
@@ -78,7 +78,7 @@ class Subtask extends Base
$this->response->html($this->taskLayout('subtask_create', array(
'values' => $values,
'errors' => $errors,
- 'users_list' => $this->projectPermission->getUsersList($task['project_id']),
+ 'users_list' => $this->projectPermission->getMemberList($task['project_id']),
'task' => $task,
)));
}
@@ -96,7 +96,7 @@ class Subtask extends Base
$this->response->html($this->taskLayout('subtask_edit', array(
'values' => $subtask,
'errors' => array(),
- 'users_list' => $this->projectPermission->getUsersList($task['project_id']),
+ 'users_list' => $this->projectPermission->getMemberList($task['project_id']),
'status_list' => $this->subTask->getStatusList(),
'subtask' => $subtask,
'task' => $task,
@@ -131,7 +131,7 @@ class Subtask extends Base
$this->response->html($this->taskLayout('subtask_edit', array(
'values' => $values,
'errors' => $errors,
- 'users_list' => $this->projectPermission->getUsersList($task['project_id']),
+ 'users_list' => $this->projectPermission->getMemberList($task['project_id']),
'status_list' => $this->subTask->getStatusList(),
'subtask' => $subtask,
'task' => $task,
diff --git a/app/Controller/Task.php b/app/Controller/Task.php
index 70fda556..d1be8e1e 100644
--- a/app/Controller/Task.php
+++ b/app/Controller/Task.php
@@ -101,7 +101,7 @@ class Task extends Base
),
'projects_list' => $this->project->getListByStatus(ProjectModel::ACTIVE),
'columns_list' => $this->board->getColumnsList($project['id']),
- 'users_list' => $this->projectPermission->getUsersList($project['id']),
+ 'users_list' => $this->projectPermission->getMemberList($project['id']),
'colors_list' => $this->color->getList(),
'categories_list' => $this->category->getList($project['id']),
'date_format' => $this->config->get('application_date_format'),
@@ -149,7 +149,7 @@ class Task extends Base
'values' => $values,
'projects_list' => $this->project->getListByStatus(ProjectModel::ACTIVE),
'columns_list' => $this->board->getColumnsList($project['id']),
- 'users_list' => $this->projectPermission->getUsersList($project['id']),
+ 'users_list' => $this->projectPermission->getMemberList($project['id']),
'colors_list' => $this->color->getList(),
'categories_list' => $this->category->getList($project['id']),
'date_format' => $this->config->get('application_date_format'),
@@ -174,7 +174,7 @@ class Task extends Base
'values' => $task,
'errors' => array(),
'task' => $task,
- 'users_list' => $this->projectPermission->getUsersList($task['project_id']),
+ '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'),
@@ -224,7 +224,7 @@ class Task extends Base
'errors' => $errors,
'task' => $task,
'columns_list' => $this->board->getColumnsList($values['project_id']),
- 'users_list' => $this->projectPermission->getUsersList($values['project_id']),
+ 'users_list' => $this->projectPermission->getMemberList($values['project_id']),
'colors_list' => $this->color->getList(),
'categories_list' => $this->category->getList($values['project_id']),
'date_format' => $this->config->get('application_date_format'),
@@ -451,7 +451,7 @@ class Task extends Base
$task = $this->getTask();
$values = $task;
$errors = array();
- $projects_list = $this->projectPermission->getAllowedProjects($this->acl->getUserId());
+ $projects_list = $this->projectPermission->getMemberProjects($this->acl->getUserId());
unset($projects_list[$task['project_id']]);
diff --git a/app/Locale/da_DK/translations.php b/app/Locale/da_DK/translations.php
index 6a403bbe..8701cf3d 100644
--- a/app/Locale/da_DK/translations.php
+++ b/app/Locale/da_DK/translations.php
@@ -561,4 +561,8 @@ return array(
// 'Github issue comment created' => '',
// 'Configure' => '',
// 'Project management' => '',
+ // 'My projects' => '',
+ // 'Columns' => '',
+ // 'Task' => '',
+ // 'Your are not member of any project.' => '',
);
diff --git a/app/Locale/de_DE/translations.php b/app/Locale/de_DE/translations.php
index 4afd7180..e47e55c1 100644
--- a/app/Locale/de_DE/translations.php
+++ b/app/Locale/de_DE/translations.php
@@ -561,4 +561,8 @@ return array(
'Github issue comment created' => 'Github Fehler Kommentar hinzugefügt',
// 'Configure' => '',
// 'Project management' => '',
+ // 'My projects' => '',
+ // 'Columns' => '',
+ // 'Task' => '',
+ // 'Your are not member of any project.' => '',
);
diff --git a/app/Locale/es_ES/translations.php b/app/Locale/es_ES/translations.php
index ed8ea5b1..72c2e32f 100644
--- a/app/Locale/es_ES/translations.php
+++ b/app/Locale/es_ES/translations.php
@@ -561,4 +561,8 @@ return array(
// 'Github issue comment created' => '',
// 'Configure' => '',
// 'Project management' => '',
+ // 'My projects' => '',
+ // 'Columns' => '',
+ // 'Task' => '',
+ // 'Your are not member of any project.' => '',
);
diff --git a/app/Locale/fi_FI/translations.php b/app/Locale/fi_FI/translations.php
index 33f3629b..7711773b 100644
--- a/app/Locale/fi_FI/translations.php
+++ b/app/Locale/fi_FI/translations.php
@@ -561,4 +561,8 @@ return array(
// 'Github issue comment created' => '',
// 'Configure' => '',
// 'Project management' => '',
+ // 'My projects' => '',
+ // 'Columns' => '',
+ // 'Task' => '',
+ // 'Your are not member of any project.' => '',
);
diff --git a/app/Locale/fr_FR/translations.php b/app/Locale/fr_FR/translations.php
index 42c03288..05756a93 100644
--- a/app/Locale/fr_FR/translations.php
+++ b/app/Locale/fr_FR/translations.php
@@ -561,4 +561,8 @@ return array(
'Github issue comment created' => 'Commentaire créé sur un ticket Github',
'Configure' => 'Configurer',
'Project management' => 'Gestion des projets',
+ 'My projects' => 'Mes projets',
+ 'Columns' => 'Colonnes',
+ 'Task' => 'Tâche',
+ 'Your are not member of any project.' => 'Vous n\'êtes membre d\'aucun projet.',
);
diff --git a/app/Locale/it_IT/translations.php b/app/Locale/it_IT/translations.php
index c3613e81..64beacab 100644
--- a/app/Locale/it_IT/translations.php
+++ b/app/Locale/it_IT/translations.php
@@ -561,4 +561,8 @@ return array(
// 'Github issue comment created' => '',
// 'Configure' => '',
// 'Project management' => '',
+ // 'My projects' => '',
+ // 'Columns' => '',
+ // 'Task' => '',
+ // 'Your are not member of any project.' => '',
);
diff --git a/app/Locale/ja_JP/translations.php b/app/Locale/ja_JP/translations.php
index 02ca8364..3d9c8440 100644
--- a/app/Locale/ja_JP/translations.php
+++ b/app/Locale/ja_JP/translations.php
@@ -561,4 +561,8 @@ return array(
// 'Github issue comment created' => '',
// 'Configure' => '',
// 'Project management' => '',
+ // 'My projects' => '',
+ // 'Columns' => '',
+ // 'Task' => '',
+ // 'Your are not member of any project.' => '',
);
diff --git a/app/Locale/pl_PL/translations.php b/app/Locale/pl_PL/translations.php
index 2637a3a6..19befac7 100644
--- a/app/Locale/pl_PL/translations.php
+++ b/app/Locale/pl_PL/translations.php
@@ -561,4 +561,8 @@ return array(
// 'Github issue comment created' => '',
// 'Configure' => '',
// 'Project management' => '',
+ // 'My projects' => '',
+ // 'Columns' => '',
+ // 'Task' => '',
+ // 'Your are not member of any project.' => '',
);
diff --git a/app/Locale/pt_BR/translations.php b/app/Locale/pt_BR/translations.php
index b3780815..62744783 100644
--- a/app/Locale/pt_BR/translations.php
+++ b/app/Locale/pt_BR/translations.php
@@ -561,4 +561,8 @@ return array(
// 'Github issue comment created' => '',
// 'Configure' => '',
// 'Project management' => '',
+ // 'My projects' => '',
+ // 'Columns' => '',
+ // 'Task' => '',
+ // 'Your are not member of any project.' => '',
);
diff --git a/app/Locale/ru_RU/translations.php b/app/Locale/ru_RU/translations.php
index b6bf887b..b5c73a8f 100644
--- a/app/Locale/ru_RU/translations.php
+++ b/app/Locale/ru_RU/translations.php
@@ -561,4 +561,8 @@ return array(
// 'Github issue comment created' => '',
// 'Configure' => '',
// 'Project management' => '',
+ // 'My projects' => '',
+ // 'Columns' => '',
+ // 'Task' => '',
+ // 'Your are not member of any project.' => '',
);
diff --git a/app/Locale/sv_SE/translations.php b/app/Locale/sv_SE/translations.php
index 8767e914..39cbff16 100644
--- a/app/Locale/sv_SE/translations.php
+++ b/app/Locale/sv_SE/translations.php
@@ -561,4 +561,8 @@ return array(
// 'Github issue comment created' => '',
// 'Configure' => '',
// 'Project management' => '',
+ // 'My projects' => '',
+ // 'Columns' => '',
+ // 'Task' => '',
+ // 'Your are not member of any project.' => '',
);
diff --git a/app/Locale/th_TH/translations.php b/app/Locale/th_TH/translations.php
index d92a7af7..eefbdcf3 100644
--- a/app/Locale/th_TH/translations.php
+++ b/app/Locale/th_TH/translations.php
@@ -561,4 +561,8 @@ return array(
// 'Github issue comment created' => '',
// 'Configure' => '',
// 'Project management' => '',
+ // 'My projects' => '',
+ // 'Columns' => '',
+ // 'Task' => '',
+ // 'Your are not member of any project.' => '',
);
diff --git a/app/Locale/zh_CN/translations.php b/app/Locale/zh_CN/translations.php
index 1464d050..7db09c59 100644
--- a/app/Locale/zh_CN/translations.php
+++ b/app/Locale/zh_CN/translations.php
@@ -561,4 +561,8 @@ return array(
// 'Github issue comment created' => '',
// 'Configure' => '',
// 'Project management' => '',
+ // 'My projects' => '',
+ // 'Columns' => '',
+ // 'Task' => '',
+ // 'Your are not member of any project.' => '',
);
diff --git a/app/Model/Project.php b/app/Model/Project.php
index 32b7fcbe..ad64edcd 100644
--- a/app/Model/Project.php
+++ b/app/Model/Project.php
@@ -96,6 +96,40 @@ class Project extends Base
}
/**
+ * Get project summary for a list of project (number of tasks for each column)
+ *
+ * @access public
+ * @param array $project_ids List of project id
+ * @param integer $status Project status
+ * @param string $order Sort on this column
+ * @param string $direction Sorting direction
+ * @return array Project properties
+ */
+ public function getSummary(array $project_ids, $status = self::ACTIVE, $order = 'last_modified', $direction = 'desc')
+ {
+ if (empty($project_ids)) {
+ return array();
+ }
+
+ $projects = $this->db->table(self::TABLE)
+ ->in('id', $project_ids)
+ ->eq('is_active', $status)
+ ->orderby($order, $direction)
+ ->findAll();
+
+ foreach ($projects as &$project) {
+
+ $project['columns'] = $this->board->getColumns($project['id']);
+
+ foreach ($project['columns'] as &$column) {
+ $column['nb_tasks'] = $this->taskFinder->countByColumnId($project['id'], $column['id']);
+ }
+ }
+
+ return $projects;
+ }
+
+ /**
* Get all projects, optionaly fetch stats for each project and can check users permissions
*
* @access public
@@ -192,7 +226,7 @@ class Project extends Base
public function getStats($project_id)
{
$stats = array();
- $columns = $this->board->getcolumns($project_id);
+ $columns = $this->board->getColumns($project_id);
$stats['nb_active_tasks'] = 0;
foreach ($columns as &$column) {
diff --git a/app/Model/ProjectPermission.php b/app/Model/ProjectPermission.php
index fb9847b5..faa4ba29 100644
--- a/app/Model/ProjectPermission.php
+++ b/app/Model/ProjectPermission.php
@@ -29,9 +29,9 @@ class ProjectPermission extends Base
* @param bool $prepend_everybody Prepend the 'Everbody' value
* @return array
*/
- public function getUsersList($project_id, $prepend_unassigned = true, $prepend_everybody = false)
+ public function getMemberList($project_id, $prepend_unassigned = true, $prepend_everybody = false)
{
- $allowed_users = $this->getAllowedUsers($project_id);
+ $allowed_users = $this->getMembers($project_id);
if ($prepend_unassigned) {
$allowed_users = array(t('Unassigned')) + $allowed_users;
@@ -51,7 +51,7 @@ class ProjectPermission extends Base
* @param integer $project_id Project id
* @return array
*/
- public function getAllowedUsers($project_id)
+ public function getMembers($project_id)
{
if ($this->isEverybodyAllowed($project_id)) {
return $this->user->getList();
@@ -96,7 +96,7 @@ class ProjectPermission extends Base
$all_users = $this->user->getList();
- $users['allowed'] = $this->getAllowedUsers($project_id);
+ $users['allowed'] = $this->getMembers($project_id);
foreach ($all_users as $user_id => $username) {
@@ -141,19 +141,15 @@ class ProjectPermission extends Base
}
/**
- * Check if a specific user is allowed to access to a given project
+ * Check if a specific user is member of a project
*
* @access public
* @param integer $project_id Project id
* @param integer $user_id User id
* @return bool
*/
- public function isUserAllowed($project_id, $user_id)
+ public function isMember($project_id, $user_id)
{
- if ($this->user->isAdmin($user_id)) {
- return true;
- }
-
if ($this->isEverybodyAllowed($project_id)) {
return true;
}
@@ -166,6 +162,19 @@ class ProjectPermission extends Base
}
/**
+ * Check if a specific user is allowed to access to a given project
+ *
+ * @access public
+ * @param integer $project_id Project id
+ * @param integer $user_id User id
+ * @return bool
+ */
+ public function isUserAllowed($project_id, $user_id)
+ {
+ return $this->user->isAdmin($user_id) || $this->isMember($project_id, $user_id);
+ }
+
+ /**
* Return true if everybody is allowed for the project
*
* @access public
@@ -204,12 +213,13 @@ class ProjectPermission extends Base
* @access public
* @param array $projects Project list: ['project_id' => 'project_name']
* @param integer $user_id User id
+ * @param string $filter Method name to apply
* @return array
*/
- public function filterProjects(array $projects, $user_id)
+ public function filterProjects(array $projects, $user_id, $filter = 'isUserAllowed')
{
foreach ($projects as $project_id => $project_name) {
- if (! $this->isUserAllowed($project_id, $user_id)) {
+ if (! $this->$filter($project_id, $user_id)) {
unset($projects[$project_id]);
}
}
@@ -218,7 +228,7 @@ class ProjectPermission extends Base
}
/**
- * Return a list of projects for a given user
+ * Return a list of allowed projects for a given user
*
* @access public
* @param integer $user_id User id
@@ -226,7 +236,19 @@ class ProjectPermission extends Base
*/
public function getAllowedProjects($user_id)
{
- return $this->filterProjects($this->project->getListByStatus(Project::ACTIVE), $user_id);
+ return $this->filterProjects($this->project->getListByStatus(Project::ACTIVE), $user_id, 'isUserAllowed');
+ }
+
+ /**
+ * Return a list of projects where the user is member
+ *
+ * @access public
+ * @param integer $user_id User id
+ * @return array
+ */
+ public function getMemberProjects($user_id)
+ {
+ return $this->filterProjects($this->project->getListByStatus(Project::ACTIVE), $user_id, 'isMember');
}
/**
@@ -239,7 +261,7 @@ class ProjectPermission extends Base
*/
public function duplicate($project_from, $project_to)
{
- $users = $this->getAllowedUsers($project_from);
+ $users = $this->getMembers($project_from);
foreach ($users as $user_id => $name) {
if (! $this->allowUser($project_to, $user_id)) {
diff --git a/app/Template/app_forbidden.php b/app/Template/app_forbidden.php
index 0c035404..96e76115 100644
--- a/app/Template/app_forbidden.php
+++ b/app/Template/app_forbidden.php
@@ -1,8 +1,4 @@
<section id="main">
- <div class="page-header">
- <h2><?= t('Forbidden') ?></h2>
- </div>
-
<p class="alert alert-error">
<?= t('Access Forbidden') ?>
</p>
diff --git a/app/Template/app_index.php b/app/Template/app_index.php
index d60638d0..1aa5819a 100644
--- a/app/Template/app_index.php
+++ b/app/Template/app_index.php
@@ -14,17 +14,48 @@
</div>
<section id="dashboard">
<div class="dashboard-left-column">
+ <h2><?= t('My projects') ?></h2>
+ <?php if (empty($projects)): ?>
+ <p class="alert"><?= t('Your are not member of any project.') ?></p>
+ <?php else: ?>
+ <table>
+ <tr>
+ <th width="5%">&nbsp;</th>
+ <th width="15%"><?= t('Project') ?></th>
+ <th width="75%"><?= t('Columns') ?></th>
+ </tr>
+ <?php foreach ($projects as $project): ?>
+ <tr>
+ <td>
+ <?= Helper\a('#'.$project['id'], 'board', 'show', array('project_id' => $project['id']), false, 'dashboard-table-link') ?>
+ </td>
+ <td>
+ <?php if (Helper\is_project_admin($project)): ?>
+ <?= Helper\a('<i class="fa fa-cog"></i>', 'project', 'show', array('project_id' => $project['id']), false, 'dashboard-table-link', t('Settings')) ?>&nbsp;
+ <?php endif ?>
+ <?= Helper\a(Helper\escape($project['name']), 'board', 'show', array('project_id' => $project['id'])) ?>
+ </td>
+ <td class="dashboard-project-stats">
+ <?php foreach ($project['columns'] as $column): ?>
+ <strong title="<?= t('Task count') ?>"><?= $column['nb_tasks'] ?></strong>
+ <span><?= Helper\escape($column['title']) ?></span>
+ <?php endforeach ?>
+ </td>
+ </tr>
+ <?php endforeach ?>
+ </table>
+ <?php endif ?>
+
<h2><?= t('My tasks') ?></h2>
<?php if (empty($tasks)): ?>
<p class="alert"><?= t('There is nothing assigned to you.') ?></p>
<?php else: ?>
<table>
<tr>
- <th>&nbsp;</th>
+ <th width="5%">&nbsp;</th>
<th width="15%"><?= t('Project') ?></th>
- <th width="40%"><?= t('Title') ?></th>
- <th><?= t('Due date') ?></th>
- <th><?= t('Date created') ?></th>
+ <th width="60%"><?= t('Task') ?></th>
+ <th width="20%"><?= t('Due date') ?></th>
</tr>
<?php foreach ($tasks as $task): ?>
<tr>
@@ -40,9 +71,6 @@
<td>
<?= dt('%B %e, %Y', $task['date_due']) ?>
</td>
- <td>
- <?= dt('%B %e, %Y', $task['date_creation']) ?>
- </td>
</tr>
<?php endforeach ?>
</table>
diff --git a/app/helpers.php b/app/helpers.php
index a2b91378..f25db0f0 100644
--- a/app/helpers.php
+++ b/app/helpers.php
@@ -78,6 +78,16 @@ function is_admin()
}
/**
+ * Return true if the user can configure the project (project are previously filtered)
+ *
+ * @return boolean
+ */
+function is_project_admin(array $project)
+{
+ return is_admin() || $project['is_private'] == 1;
+}
+
+/**
* Return the username
*
* @param array $user User properties (optional)
diff --git a/assets/css/app.css b/assets/css/app.css
index ffe2f59e..08deefb7 100644
--- a/assets/css/app.css
+++ b/assets/css/app.css
@@ -991,7 +991,7 @@ tr td.task-orange,
color: #555;
}/* dashboard */
#dashboard table {
- font-size: 0.95em;
+ font-size: 0.9em;
}
.dashboard-left-column {
@@ -1003,7 +1003,29 @@ tr td.task-orange,
margin-left: 5%;
width: 40%;
float: left;
-}/* datepicker */
+}
+
+.dashboard-project-stats span {
+ font-size: 0.75em;
+ margin-right: 10px;
+ color: #999;
+}
+
+.dashboard-project-stats strong {
+ font-size: 1.1em;
+}
+
+.dashboard-table-link {
+ font-weight: bold;
+ color: #444;
+ text-decoration: none;
+}
+
+.dashboard-table-link:focus,
+.dashboard-table-link:hover {
+ color: #999;
+}
+/* datepicker */
#ui-datepicker-div {
font-size: 0.8em;
}
diff --git a/assets/css/dashboard.css b/assets/css/dashboard.css
index bb9e99bb..dc077180 100644
--- a/assets/css/dashboard.css
+++ b/assets/css/dashboard.css
@@ -1,6 +1,6 @@
/* dashboard */
#dashboard table {
- font-size: 0.95em;
+ font-size: 0.9em;
}
.dashboard-left-column {
@@ -12,4 +12,25 @@
margin-left: 5%;
width: 40%;
float: left;
-} \ No newline at end of file
+}
+
+.dashboard-project-stats span {
+ font-size: 0.75em;
+ margin-right: 10px;
+ color: #999;
+}
+
+.dashboard-project-stats strong {
+ font-size: 1.1em;
+}
+
+.dashboard-table-link {
+ font-weight: bold;
+ color: #444;
+ text-decoration: none;
+}
+
+.dashboard-table-link:focus,
+.dashboard-table-link:hover {
+ color: #999;
+}
diff --git a/jsonrpc.php b/jsonrpc.php
index 99d14806..b81a96e7 100644
--- a/jsonrpc.php
+++ b/jsonrpc.php
@@ -146,7 +146,7 @@ $server->register('removeColumn', function($column_id) use ($board) {
* Project permissions procedures
*/
$server->register('getAllowedUsers', function($project_id) use ($projectPermission) {
- return $projectPermission->getUsersList($project_id, false, false);
+ return $projectPermission->getMemberList($project_id, false, false);
});
$server->register('revokeUser', function($project_id, $user_id) use ($project, $projectPermission) {
diff --git a/tests/units/NotificationTest.php b/tests/units/NotificationTest.php
index 1c8fb6e5..6c0539c2 100644
--- a/tests/units/NotificationTest.php
+++ b/tests/units/NotificationTest.php
@@ -31,7 +31,7 @@ class NotificationTest extends Base
$this->assertTrue($u->create(array('username' => 'user4')));
// Nobody is member of any projects
- $this->assertEmpty($pp->getAllowedUsers(1));
+ $this->assertEmpty($pp->getMembers(1));
$this->assertEmpty($n->getUsersWithNotification(1));
// We allow all users to be member of our projects
@@ -40,7 +40,7 @@ class NotificationTest extends Base
$this->assertTrue($pp->allowUser(1, 3));
$this->assertTrue($pp->allowUser(1, 4));
- $this->assertNotEmpty($pp->getAllowedUsers(1));
+ $this->assertNotEmpty($pp->getMembers(1));
$users = $n->getUsersWithNotification(1);
$this->assertNotEmpty($users);
diff --git a/tests/units/ProjectPermissionTest.php b/tests/units/ProjectPermissionTest.php
index ee608d03..fd0c7331 100644
--- a/tests/units/ProjectPermissionTest.php
+++ b/tests/units/ProjectPermissionTest.php
@@ -22,16 +22,16 @@ class ProjectPermissionTest extends Base
$this->assertTrue($pp->isUserAllowed(1, 1));
$this->assertFalse($pp->isUserAllowed(1, 2));
$this->assertFalse($pp->isUserAllowed(1, 3));
- $this->assertEquals(array(), $pp->getAllowedUsers(1));
- $this->assertEquals(array('Unassigned'), $pp->getUsersList(1));
+ $this->assertEquals(array(), $pp->getMembers(1));
+ $this->assertEquals(array('Unassigned'), $pp->getMemberList(1));
$this->assertTrue($p->update(array('id' => 1, 'is_everybody_allowed' => 1)));
$this->assertTrue($pp->isEverybodyAllowed(1));
$this->assertTrue($pp->isUserAllowed(1, 1));
$this->assertTrue($pp->isUserAllowed(1, 2));
$this->assertTrue($pp->isUserAllowed(1, 3));
- $this->assertEquals(array('1' => 'admin', '2' => 'unittest#1', '3' => 'unittest#2'), $pp->getAllowedUsers(1));
- $this->assertEquals(array('Unassigned', '1' => 'admin', '2' => 'unittest#1', '3' => 'unittest#2'), $pp->getUsersList(1));
+ $this->assertEquals(array('1' => 'admin', '2' => 'unittest#1', '3' => 'unittest#2'), $pp->getMembers(1));
+ $this->assertEquals(array('Unassigned', '1' => 'admin', '2' => 'unittest#1', '3' => 'unittest#2'), $pp->getMemberList(1));
}
public function testDisallowEverybody()
@@ -45,7 +45,7 @@ class ProjectPermissionTest extends Base
$this->assertEquals(1, $p->create(array('name' => 'UnitTest')));
- $this->assertEmpty($pp->getAllowedUsers(1)); // Nobody is specified for the given project
+ $this->assertEmpty($pp->getMembers(1)); // Nobody is specified for the given project
$this->assertTrue($pp->isUserAllowed(1, 1)); // Admin should be allowed
$this->assertFalse($pp->isUserAllowed(1, 2)); // Regular user should be denied
}
@@ -72,7 +72,7 @@ class ProjectPermissionTest extends Base
$this->assertFalse($pp->allowUser(1, 50));
// Both users should be allowed
- $this->assertEquals(array('1' => 'admin', '2' => 'unittest'), $pp->getAllowedUsers(1));
+ $this->assertEquals(array('1' => 'admin', '2' => 'unittest'), $pp->getMembers(1));
$this->assertTrue($pp->isUserAllowed(1, 1));
$this->assertTrue($pp->isUserAllowed(1, 2));
}
@@ -92,7 +92,7 @@ class ProjectPermissionTest extends Base
$this->assertFalse($pp->revokeUser(1, 1));
// We should have nobody in the users list
- $this->assertEmpty($pp->getAllowedUsers(1));
+ $this->assertEmpty($pp->getMembers(1));
// Only admin is allowed
$this->assertTrue($pp->isUserAllowed(1, 1));
@@ -106,11 +106,11 @@ class ProjectPermissionTest extends Base
$this->assertTrue($pp->isUserAllowed(1, 2));
// However, we should have only our regular user in the list
- $this->assertEquals(array('2' => 'unittest'), $pp->getAllowedUsers(1));
+ $this->assertEquals(array('2' => 'unittest'), $pp->getMembers(1));
// We allow our admin, we should have both in the list
$this->assertTrue($pp->allowUser(1, 1));
- $this->assertEquals(array('1' => 'admin', '2' => 'unittest'), $pp->getAllowedUsers(1));
+ $this->assertEquals(array('1' => 'admin', '2' => 'unittest'), $pp->getMembers(1));
$this->assertTrue($pp->isUserAllowed(1, 1));
$this->assertTrue($pp->isUserAllowed(1, 2));
@@ -122,11 +122,11 @@ class ProjectPermissionTest extends Base
$this->assertFalse($pp->isUserAllowed(1, 2));
// We should have only admin in the list
- $this->assertEquals(array('1' => 'admin'), $pp->getAllowedUsers(1));
+ $this->assertEquals(array('1' => 'admin'), $pp->getMembers(1));
// We revoke the admin user
$this->assertTrue($pp->revokeUser(1, 1));
- $this->assertEmpty($pp->getAllowedUsers(1));
+ $this->assertEmpty($pp->getMembers(1));
// Only admin should be allowed again
$this->assertTrue($pp->isUserAllowed(1, 1));
@@ -147,7 +147,7 @@ class ProjectPermissionTest extends Base
// No restriction, we should have no body
$this->assertEquals(
array('Unassigned'),
- $pp->getUsersList(1)
+ $pp->getMemberList(1)
);
// We allow only the regular user
@@ -155,7 +155,7 @@ class ProjectPermissionTest extends Base
$this->assertEquals(
array(0 => 'Unassigned', 2 => 'unittest'),
- $pp->getUsersList(1)
+ $pp->getMemberList(1)
);
// We allow the admin user
@@ -163,7 +163,7 @@ class ProjectPermissionTest extends Base
$this->assertEquals(
array(0 => 'Unassigned', 1 => 'admin', 2 => 'unittest'),
- $pp->getUsersList(1)
+ $pp->getMemberList(1)
);
// We revoke only the regular user
@@ -171,7 +171,7 @@ class ProjectPermissionTest extends Base
$this->assertEquals(
array(0 => 'Unassigned', 1 => 'admin'),
- $pp->getUsersList(1)
+ $pp->getMemberList(1)
);
// We revoke only the admin user, we should have everybody
@@ -179,7 +179,7 @@ class ProjectPermissionTest extends Base
$this->assertEquals(
array(0 => 'Unassigned'),
- $pp->getUsersList(1)
+ $pp->getMemberList(1)
);
}
}
diff --git a/tests/units/ProjectTest.php b/tests/units/ProjectTest.php
index cec8d93d..c507739b 100644
--- a/tests/units/ProjectTest.php
+++ b/tests/units/ProjectTest.php
@@ -167,7 +167,7 @@ class ProjectTest extends Base
$pp = new ProjectPermission($this->registry);
- $this->assertEquals(array(1 => 'admin'), $pp->getAllowedUsers(3));
- $this->assertEquals(array(1 => 'admin'), $pp->getAllowedUsers(4));
+ $this->assertEquals(array(1 => 'admin'), $pp->getMembers(3));
+ $this->assertEquals(array(1 => 'admin'), $pp->getMembers(4));
}
}