Allow users to see inactive projects

This commit is contained in:
Frederic Guillot
2016-07-28 16:56:37 -04:00
parent 837173cf93
commit f3e16da4ac
4 changed files with 37 additions and 1 deletions

View File

@@ -28,6 +28,7 @@ Improvements:
Bug fixes: Bug fixes:
* Allow users to see inactive projects
* Fixed typo in template that prevent project permissions to be duplicated * Fixed typo in template that prevent project permissions to be duplicated
* Fixed search query with multiple assignees (nested OR conditions) * Fixed search query with multiple assignees (nested OR conditions)
* Fixed Markdown editor auto-grow on the task form (Safari) * Fixed Markdown editor auto-grow on the task form (Safari)

View File

@@ -20,7 +20,7 @@ class ProjectListController extends BaseController
if ($this->userSession->isAdmin()) { if ($this->userSession->isAdmin()) {
$project_ids = $this->projectModel->getAllIds(); $project_ids = $this->projectModel->getAllIds();
} else { } else {
$project_ids = $this->projectPermissionModel->getActiveProjectIds($this->userSession->getId()); $project_ids = $this->projectPermissionModel->getProjectIds($this->userSession->getId());
} }
$nb_projects = count($project_ids); $nb_projects = count($project_ids);

View File

@@ -151,6 +151,18 @@ class ProjectPermissionModel extends Base
return array_keys($this->projectUserRoleModel->getActiveProjectsByUser($user_id)); return array_keys($this->projectUserRoleModel->getActiveProjectsByUser($user_id));
} }
/**
* Get all project ids by user
*
* @access public
* @param integer $user_id
* @return array
*/
public function getProjectIds($user_id)
{
return array_keys($this->projectUserRoleModel->getProjectsByUser($user_id));
}
/** /**
* Copy permissions to another project * Copy permissions to another project
* *

View File

@@ -267,6 +267,29 @@ class ProjectPermissionTest extends Base
$this->assertEquals(array(1), $projectPermission->getActiveProjectIds(3)); $this->assertEquals(array(1), $projectPermission->getActiveProjectIds(3));
} }
public function testGetProjectIds()
{
$userModel = new UserModel($this->container);
$projectModel = new ProjectModel($this->container);
$userRoleModel = new ProjectUserRoleModel($this->container);
$projectPermission = new ProjectPermissionModel($this->container);
$this->assertEquals(2, $userModel->create(array('username' => 'user 1')));
$this->assertEquals(3, $userModel->create(array('username' => 'user 2')));
$this->assertEquals(1, $projectModel->create(array('name' => 'Project 1')));
$this->assertEquals(2, $projectModel->create(array('name' => 'Project 2', 'is_active' => 0)));
$this->assertTrue($userRoleModel->addUser(1, 2, Role::PROJECT_MEMBER));
$this->assertTrue($userRoleModel->addUser(2, 2, Role::PROJECT_MEMBER));
$this->assertTrue($userRoleModel->addUser(1, 3, Role::PROJECT_MEMBER));
$this->assertTrue($userRoleModel->addUser(2, 3, Role::PROJECT_MEMBER));
$this->assertEmpty($projectPermission->getProjectIds(1));
$this->assertEquals(array(1, 2), $projectPermission->getProjectIds(2));
$this->assertEquals(array(1, 2), $projectPermission->getProjectIds(3));
}
public function testDuplicate() public function testDuplicate()
{ {
$userModel = new UserModel($this->container); $userModel = new UserModel($this->container);