Add projects to the dashboard and rename some methods
This commit is contained in:
parent
e0117cb8ed
commit
3df63e051f
|
|
@ -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']),
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
)));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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'],
|
||||
|
|
|
|||
|
|
@ -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.'));
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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']]);
|
||||
|
||||
|
|
|
|||
|
|
@ -561,4 +561,8 @@ return array(
|
|||
// 'Github issue comment created' => '',
|
||||
// 'Configure' => '',
|
||||
// 'Project management' => '',
|
||||
// 'My projects' => '',
|
||||
// 'Columns' => '',
|
||||
// 'Task' => '',
|
||||
// 'Your are not member of any project.' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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.' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -561,4 +561,8 @@ return array(
|
|||
// 'Github issue comment created' => '',
|
||||
// 'Configure' => '',
|
||||
// 'Project management' => '',
|
||||
// 'My projects' => '',
|
||||
// 'Columns' => '',
|
||||
// 'Task' => '',
|
||||
// 'Your are not member of any project.' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -561,4 +561,8 @@ return array(
|
|||
// 'Github issue comment created' => '',
|
||||
// 'Configure' => '',
|
||||
// 'Project management' => '',
|
||||
// 'My projects' => '',
|
||||
// 'Columns' => '',
|
||||
// 'Task' => '',
|
||||
// 'Your are not member of any project.' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -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.',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -561,4 +561,8 @@ return array(
|
|||
// 'Github issue comment created' => '',
|
||||
// 'Configure' => '',
|
||||
// 'Project management' => '',
|
||||
// 'My projects' => '',
|
||||
// 'Columns' => '',
|
||||
// 'Task' => '',
|
||||
// 'Your are not member of any project.' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -561,4 +561,8 @@ return array(
|
|||
// 'Github issue comment created' => '',
|
||||
// 'Configure' => '',
|
||||
// 'Project management' => '',
|
||||
// 'My projects' => '',
|
||||
// 'Columns' => '',
|
||||
// 'Task' => '',
|
||||
// 'Your are not member of any project.' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -561,4 +561,8 @@ return array(
|
|||
// 'Github issue comment created' => '',
|
||||
// 'Configure' => '',
|
||||
// 'Project management' => '',
|
||||
// 'My projects' => '',
|
||||
// 'Columns' => '',
|
||||
// 'Task' => '',
|
||||
// 'Your are not member of any project.' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -561,4 +561,8 @@ return array(
|
|||
// 'Github issue comment created' => '',
|
||||
// 'Configure' => '',
|
||||
// 'Project management' => '',
|
||||
// 'My projects' => '',
|
||||
// 'Columns' => '',
|
||||
// 'Task' => '',
|
||||
// 'Your are not member of any project.' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -561,4 +561,8 @@ return array(
|
|||
// 'Github issue comment created' => '',
|
||||
// 'Configure' => '',
|
||||
// 'Project management' => '',
|
||||
// 'My projects' => '',
|
||||
// 'Columns' => '',
|
||||
// 'Task' => '',
|
||||
// 'Your are not member of any project.' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -561,4 +561,8 @@ return array(
|
|||
// 'Github issue comment created' => '',
|
||||
// 'Configure' => '',
|
||||
// 'Project management' => '',
|
||||
// 'My projects' => '',
|
||||
// 'Columns' => '',
|
||||
// 'Task' => '',
|
||||
// 'Your are not member of any project.' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -561,4 +561,8 @@ return array(
|
|||
// 'Github issue comment created' => '',
|
||||
// 'Configure' => '',
|
||||
// 'Project management' => '',
|
||||
// 'My projects' => '',
|
||||
// 'Columns' => '',
|
||||
// 'Task' => '',
|
||||
// 'Your are not member of any project.' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -561,4 +561,8 @@ return array(
|
|||
// 'Github issue comment created' => '',
|
||||
// 'Configure' => '',
|
||||
// 'Project management' => '',
|
||||
// 'My projects' => '',
|
||||
// 'Columns' => '',
|
||||
// 'Task' => '',
|
||||
// 'Your are not member of any project.' => '',
|
||||
);
|
||||
|
|
|
|||
|
|
@ -95,6 +95,40 @@ class Project extends Base
|
|||
return (bool) $this->db->table(self::TABLE)->eq('id', $project_id)->eq('is_private', 1)->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -165,6 +161,19 @@ class ProjectPermission extends Base
|
|||
->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
|
@ -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)) {
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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%"> </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')) ?>
|
||||
<?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> </th>
|
||||
<th width="5%"> </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>
|
||||
|
|
|
|||
|
|
@ -77,6 +77,16 @@ function is_admin()
|
|||
return $_SESSION['user']['is_admin'] == 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
.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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue