Allow project managers to remove tasks

This commit is contained in:
Frédéric Guillot 2015-01-02 22:14:28 -05:00
parent 0ebdd4ddfd
commit 5c6b67bd76
7 changed files with 6 additions and 11 deletions

View File

@ -244,10 +244,6 @@ abstract class Base
*/
protected function taskLayout($template, array $params)
{
if (isset($params['task']) && $this->taskPermission->canRemoveTask($params['task']) === false) {
$params['hide_remove_menu'] = true;
}
$content = $this->template->render($template, $params);
$params['task_content_for_layout'] = $content;
$params['title'] = $params['task']['project_name'].' > '.$params['task']['title'];

View File

@ -52,7 +52,6 @@ class Acl extends Base
'category' => '*',
'project' => array('edit', 'update', 'exporttasks', 'exportdailyprojectsummary', 'share', 'integration', 'users', 'alloweverybody', 'allow', 'setowner', 'revoke', 'duplicate', 'disable', 'enable'),
'swimlane' => '*',
'task' => array('remove'),
);
/**

View File

@ -198,7 +198,7 @@ class ProjectPermission extends Base
->table(self::TABLE)
->eq('project_id', $project_id)
->eq('user_id', $user_id)
->update(array('is_owner' => $is_owner));
->update(array('is_owner' => (int) $is_owner));
}
/**

View File

@ -20,7 +20,7 @@ class TaskPermission extends Base
*/
public function canRemoveTask(array $task)
{
if ($this->userSession->isAdmin()) {
if ($this->userSession->isAdmin() || $this->projectPermission->isManager($task['project_id'], $this->userSession->getId())) {
return true;
}
else if (isset($task['creator_id']) && $task['creator_id'] == $this->userSession->getId()) {

View File

@ -6,7 +6,7 @@
</div>
<section class="sidebar-container" id="task-section">
<?= $this->render('task/sidebar', array('task' => $task, 'hide_remove_menu' => isset($hide_remove_menu))) ?>
<?= $this->render('task/sidebar', array('task' => $task)) ?>
<div class="sidebar-content">
<?= $task_content_for_layout ?>

View File

@ -35,7 +35,7 @@
<?= $this->a(t('Open this task'), 'task', 'open', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
<?php endif ?>
</li>
<?php if (! $hide_remove_menu): ?>
<?php if ($this->taskPermission->canRemoveTask($task)): ?>
<li>
<?= $this->a(t('Remove'), 'task', 'remove', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
</li>

View File

@ -59,7 +59,6 @@ class AclTest extends Base
$this->assertTrue($acl->isManagerAction('project', 'disable'));
$this->assertTrue($acl->isManagerAction('category', 'index'));
$this->assertTrue($acl->isManagerAction('project', 'users'));
$this->assertTrue($acl->isManagerAction('task', 'remove'));
$this->assertFalse($acl->isManagerAction('app', 'index'));
}
@ -183,7 +182,8 @@ class AclTest extends Base
$this->assertTrue($acl->isAllowed('project', 'show', 1));
$this->assertFalse($acl->isAllowed('config', 'application', 1));
$this->assertFalse($acl->isAllowed('project', 'users', 1));
$this->assertFalse($acl->isAllowed('task', 'remove', 1));
$this->assertTrue($acl->isAllowed('task', 'remove', 1));
$this->assertFalse($acl->isAllowed('task', 'remove', 2));
$this->assertTrue($acl->isAllowed('app', 'index', 1));
}