diff options
author | Frédéric Guillot <fred@kanboard.net> | 2014-11-25 20:30:59 -0500 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2014-11-25 20:30:59 -0500 |
commit | d68fa290bb54e12b0532c539370408435d23e639 (patch) | |
tree | 8b0fa3a21079a6aa62377ed75ae5c9998435075d | |
parent | 7731f00e29b36806af284ac2771b03e223da846a (diff) |
Automatically add the logged user during project creation
-rw-r--r-- | app/Controller/Project.php | 2 | ||||
-rw-r--r-- | app/Model/Project.php | 11 | ||||
-rw-r--r-- | tests/units/ProjectTest.php | 2 |
3 files changed, 8 insertions, 7 deletions
diff --git a/app/Controller/Project.php b/app/Controller/Project.php index 22139323..6f224406 100644 --- a/app/Controller/Project.php +++ b/app/Controller/Project.php @@ -560,7 +560,7 @@ class Project extends Base if ($valid) { - $project_id = $this->project->create($values, $this->acl->getUserId()); + $project_id = $this->project->create($values, $this->acl->getUserId(), true); if ($project_id) { $this->session->flash(t('Your project have been created successfully.')); diff --git a/app/Model/Project.php b/app/Model/Project.php index 8b842519..c657e823 100644 --- a/app/Model/Project.php +++ b/app/Model/Project.php @@ -270,11 +270,12 @@ class Project extends Base * Create a project * * @access public - * @param array $values Form values - * @param integer $user_id User who create the project - * @return integer Project id + * @param array $values Form values + * @param integer $user_id User who create the project + * @param bool $add_user Automatically add the user + * @return integer Project id */ - public function create(array $values, $user_id = 0) + public function create(array $values, $user_id = 0, $add_user = false) { $this->db->startTransaction(); @@ -294,7 +295,7 @@ class Project extends Base return false; } - if ($values['is_private'] && $user_id) { + if ($add_user && $user_id) { $this->projectPermission->allowUser($project_id, $user_id); } diff --git a/tests/units/ProjectTest.php b/tests/units/ProjectTest.php index 93cdcf6a..aab8398d 100644 --- a/tests/units/ProjectTest.php +++ b/tests/units/ProjectTest.php @@ -156,7 +156,7 @@ class ProjectTest extends Base $this->assertEmpty($project['token']); // Clone private project - $this->assertEquals(3, $p->create(array('name' => 'Private', 'is_private' => 1), 1)); + $this->assertEquals(3, $p->create(array('name' => 'Private', 'is_private' => 1), 1, true)); $this->assertEquals(4, $p->duplicate(3)); $project = $p->getById(4); |