summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog1
-rw-r--r--app/Controller/ProjectListController.php2
-rw-r--r--app/Model/ProjectPermissionModel.php12
-rw-r--r--tests/units/Model/ProjectPermissionTest.php23
4 files changed, 37 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 36f40461..d5c1c10d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -28,6 +28,7 @@ Improvements:
Bug fixes:
+* Allow users to see inactive projects
* Fixed typo in template that prevent project permissions to be duplicated
* Fixed search query with multiple assignees (nested OR conditions)
* Fixed Markdown editor auto-grow on the task form (Safari)
diff --git a/app/Controller/ProjectListController.php b/app/Controller/ProjectListController.php
index e1172400..4de73c97 100644
--- a/app/Controller/ProjectListController.php
+++ b/app/Controller/ProjectListController.php
@@ -20,7 +20,7 @@ class ProjectListController extends BaseController
if ($this->userSession->isAdmin()) {
$project_ids = $this->projectModel->getAllIds();
} else {
- $project_ids = $this->projectPermissionModel->getActiveProjectIds($this->userSession->getId());
+ $project_ids = $this->projectPermissionModel->getProjectIds($this->userSession->getId());
}
$nb_projects = count($project_ids);
diff --git a/app/Model/ProjectPermissionModel.php b/app/Model/ProjectPermissionModel.php
index a7c1857c..4882343d 100644
--- a/app/Model/ProjectPermissionModel.php
+++ b/app/Model/ProjectPermissionModel.php
@@ -152,6 +152,18 @@ class ProjectPermissionModel extends Base
}
/**
+ * 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
*
* @param integer $project_src_id Project Template
diff --git a/tests/units/Model/ProjectPermissionTest.php b/tests/units/Model/ProjectPermissionTest.php
index c9e0a481..a9f8ab04 100644
--- a/tests/units/Model/ProjectPermissionTest.php
+++ b/tests/units/Model/ProjectPermissionTest.php
@@ -267,6 +267,29 @@ class ProjectPermissionTest extends Base
$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()
{
$userModel = new UserModel($this->container);