Allow project managers to remove tasks
This commit is contained in:
@@ -244,10 +244,6 @@ abstract class Base
|
|||||||
*/
|
*/
|
||||||
protected function taskLayout($template, array $params)
|
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);
|
$content = $this->template->render($template, $params);
|
||||||
$params['task_content_for_layout'] = $content;
|
$params['task_content_for_layout'] = $content;
|
||||||
$params['title'] = $params['task']['project_name'].' > '.$params['task']['title'];
|
$params['title'] = $params['task']['project_name'].' > '.$params['task']['title'];
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ class Acl extends Base
|
|||||||
'category' => '*',
|
'category' => '*',
|
||||||
'project' => array('edit', 'update', 'exporttasks', 'exportdailyprojectsummary', 'share', 'integration', 'users', 'alloweverybody', 'allow', 'setowner', 'revoke', 'duplicate', 'disable', 'enable'),
|
'project' => array('edit', 'update', 'exporttasks', 'exportdailyprojectsummary', 'share', 'integration', 'users', 'alloweverybody', 'allow', 'setowner', 'revoke', 'duplicate', 'disable', 'enable'),
|
||||||
'swimlane' => '*',
|
'swimlane' => '*',
|
||||||
'task' => array('remove'),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ class ProjectPermission extends Base
|
|||||||
->table(self::TABLE)
|
->table(self::TABLE)
|
||||||
->eq('project_id', $project_id)
|
->eq('project_id', $project_id)
|
||||||
->eq('user_id', $user_id)
|
->eq('user_id', $user_id)
|
||||||
->update(array('is_owner' => $is_owner));
|
->update(array('is_owner' => (int) $is_owner));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class TaskPermission extends Base
|
|||||||
*/
|
*/
|
||||||
public function canRemoveTask(array $task)
|
public function canRemoveTask(array $task)
|
||||||
{
|
{
|
||||||
if ($this->userSession->isAdmin()) {
|
if ($this->userSession->isAdmin() || $this->projectPermission->isManager($task['project_id'], $this->userSession->getId())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (isset($task['creator_id']) && $task['creator_id'] == $this->userSession->getId()) {
|
else if (isset($task['creator_id']) && $task['creator_id'] == $this->userSession->getId()) {
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<section class="sidebar-container" id="task-section">
|
<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">
|
<div class="sidebar-content">
|
||||||
<?= $task_content_for_layout ?>
|
<?= $task_content_for_layout ?>
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
<?= $this->a(t('Open this task'), 'task', 'open', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
|
<?= $this->a(t('Open this task'), 'task', 'open', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
|
||||||
<?php endif ?>
|
<?php endif ?>
|
||||||
</li>
|
</li>
|
||||||
<?php if (! $hide_remove_menu): ?>
|
<?php if ($this->taskPermission->canRemoveTask($task)): ?>
|
||||||
<li>
|
<li>
|
||||||
<?= $this->a(t('Remove'), 'task', 'remove', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
|
<?= $this->a(t('Remove'), 'task', 'remove', array('task_id' => $task['id'], 'project_id' => $task['project_id'])) ?>
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ class AclTest extends Base
|
|||||||
$this->assertTrue($acl->isManagerAction('project', 'disable'));
|
$this->assertTrue($acl->isManagerAction('project', 'disable'));
|
||||||
$this->assertTrue($acl->isManagerAction('category', 'index'));
|
$this->assertTrue($acl->isManagerAction('category', 'index'));
|
||||||
$this->assertTrue($acl->isManagerAction('project', 'users'));
|
$this->assertTrue($acl->isManagerAction('project', 'users'));
|
||||||
$this->assertTrue($acl->isManagerAction('task', 'remove'));
|
|
||||||
$this->assertFalse($acl->isManagerAction('app', 'index'));
|
$this->assertFalse($acl->isManagerAction('app', 'index'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -183,7 +182,8 @@ class AclTest extends Base
|
|||||||
$this->assertTrue($acl->isAllowed('project', 'show', 1));
|
$this->assertTrue($acl->isAllowed('project', 'show', 1));
|
||||||
$this->assertFalse($acl->isAllowed('config', 'application', 1));
|
$this->assertFalse($acl->isAllowed('config', 'application', 1));
|
||||||
$this->assertFalse($acl->isAllowed('project', 'users', 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));
|
$this->assertTrue($acl->isAllowed('app', 'index', 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user