Automatically add the logged user during project creation
This commit is contained in:
@@ -560,7 +560,7 @@ class Project extends Base
|
|||||||
|
|
||||||
if ($valid) {
|
if ($valid) {
|
||||||
|
|
||||||
$project_id = $this->project->create($values, $this->acl->getUserId());
|
$project_id = $this->project->create($values, $this->acl->getUserId(), true);
|
||||||
|
|
||||||
if ($project_id) {
|
if ($project_id) {
|
||||||
$this->session->flash(t('Your project have been created successfully.'));
|
$this->session->flash(t('Your project have been created successfully.'));
|
||||||
|
|||||||
@@ -270,11 +270,12 @@ class Project extends Base
|
|||||||
* Create a project
|
* Create a project
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param array $values Form values
|
* @param array $values Form values
|
||||||
* @param integer $user_id User who create the project
|
* @param integer $user_id User who create the project
|
||||||
* @return integer Project id
|
* @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();
|
$this->db->startTransaction();
|
||||||
|
|
||||||
@@ -294,7 +295,7 @@ class Project extends Base
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($values['is_private'] && $user_id) {
|
if ($add_user && $user_id) {
|
||||||
$this->projectPermission->allowUser($project_id, $user_id);
|
$this->projectPermission->allowUser($project_id, $user_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ class ProjectTest extends Base
|
|||||||
$this->assertEmpty($project['token']);
|
$this->assertEmpty($project['token']);
|
||||||
|
|
||||||
// Clone private project
|
// 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));
|
$this->assertEquals(4, $p->duplicate(3));
|
||||||
|
|
||||||
$project = $p->getById(4);
|
$project = $p->getById(4);
|
||||||
|
|||||||
Reference in New Issue
Block a user