Allow a project owner to manage his own public project
This commit is contained in:
@@ -27,6 +27,7 @@ Improvements:
|
|||||||
|
|
||||||
Bug fixes:
|
Bug fixes:
|
||||||
|
|
||||||
|
* Allow a project owner to manage his own public project
|
||||||
* Fixed PHP warning when removing a user with no Avatar image
|
* Fixed PHP warning when removing a user with no Avatar image
|
||||||
* Fixed improper Markdown escaping for some tooltips
|
* Fixed improper Markdown escaping for some tooltips
|
||||||
* Closing all tasks by column, also update closed tasks
|
* Closing all tasks by column, also update closed tasks
|
||||||
|
|||||||
@@ -69,8 +69,13 @@ class ProjectUserRole extends Base
|
|||||||
*/
|
*/
|
||||||
public function getUserRole($project_id, $user_id)
|
public function getUserRole($project_id, $user_id)
|
||||||
{
|
{
|
||||||
if ($this->projectPermission->isEverybodyAllowed($project_id)) {
|
$projectInfo = $this->db->table(Project::TABLE)
|
||||||
return Role::PROJECT_MEMBER;
|
->eq('id', $project_id)
|
||||||
|
->columns('owner_id', 'is_everybody_allowed')
|
||||||
|
->findOne();
|
||||||
|
|
||||||
|
if ($projectInfo['is_everybody_allowed'] == 1) {
|
||||||
|
return $projectInfo['owner_id'] == $user_id ? Role::PROJECT_MANAGER : Role::PROJECT_MEMBER;
|
||||||
}
|
}
|
||||||
|
|
||||||
$role = $this->db->table(self::TABLE)->eq('user_id', $user_id)->eq('project_id', $project_id)->findOneColumn('role');
|
$role = $this->db->table(self::TABLE)->eq('user_id', $user_id)->eq('project_id', $project_id)->findOneColumn('role');
|
||||||
|
|||||||
@@ -101,6 +101,26 @@ class ProjectUserRoleTest extends Base
|
|||||||
$this->assertEquals('', $userRoleModel->getUserRole(1, 2));
|
$this->assertEquals('', $userRoleModel->getUserRole(1, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testGetRoleWithPublicProject()
|
||||||
|
{
|
||||||
|
$projectModel = new Project($this->container);
|
||||||
|
$userRoleModel = new ProjectUserRole($this->container);
|
||||||
|
$userModel = new User($this->container);
|
||||||
|
|
||||||
|
$this->assertEquals(2, $userModel->create(array('username' => 'user1', 'name' => 'User1')));
|
||||||
|
$this->assertEquals(3, $userModel->create(array('username' => 'user2', 'name' => 'User2')));
|
||||||
|
|
||||||
|
$this->assertEquals(1, $projectModel->create(array('name' => 'Test'), 2, true));
|
||||||
|
|
||||||
|
$this->assertEquals(Role::PROJECT_MANAGER, $userRoleModel->getUserRole(1, 2));
|
||||||
|
$this->assertEquals(null, $userRoleModel->getUserRole(1, 3));
|
||||||
|
|
||||||
|
$this->assertTrue($projectModel->update(array('id' => 1, 'is_everybody_allowed' => 1)));
|
||||||
|
|
||||||
|
$this->assertEquals(Role::PROJECT_MANAGER, $userRoleModel->getUserRole(1, 2));
|
||||||
|
$this->assertEquals(Role::PROJECT_MEMBER, $userRoleModel->getUserRole(1, 3));
|
||||||
|
}
|
||||||
|
|
||||||
public function testGetAssignableUsersWithDisabledUsers()
|
public function testGetAssignableUsersWithDisabledUsers()
|
||||||
{
|
{
|
||||||
$projectModel = new Project($this->container);
|
$projectModel = new Project($this->container);
|
||||||
|
|||||||
Reference in New Issue
Block a user