Make sure the Project Identifier is saved when creating a project from anther one
This commit is contained in:
@@ -124,7 +124,8 @@ class ProjectCreationController extends BaseController
|
|||||||
$selection,
|
$selection,
|
||||||
$this->userSession->getId(),
|
$this->userSession->getId(),
|
||||||
$values['name'],
|
$values['name'],
|
||||||
$values['is_private'] == 1
|
$values['is_private'] == 1,
|
||||||
|
$values['identifier']
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,14 +82,15 @@ class ProjectDuplicationModel extends Base
|
|||||||
* @param integer $owner_id Owner of the project
|
* @param integer $owner_id Owner of the project
|
||||||
* @param string $name Name of the project
|
* @param string $name Name of the project
|
||||||
* @param boolean $private Force the project to be private
|
* @param boolean $private Force the project to be private
|
||||||
|
* @param string $identifier Identifier of the project
|
||||||
* @return integer Cloned Project Id
|
* @return integer Cloned Project Id
|
||||||
*/
|
*/
|
||||||
public function duplicate($src_project_id, $selection = array('projectPermissionModel', 'categoryModel', 'actionModel'), $owner_id = 0, $name = null, $private = null)
|
public function duplicate($src_project_id, $selection = array('projectPermissionModel', 'categoryModel', 'actionModel'), $owner_id = 0, $name = null, $private = null, $identifier = null)
|
||||||
{
|
{
|
||||||
$this->db->startTransaction();
|
$this->db->startTransaction();
|
||||||
|
|
||||||
// Get the cloned project Id
|
// Get the cloned project Id
|
||||||
$dst_project_id = $this->copy($src_project_id, $owner_id, $name, $private);
|
$dst_project_id = $this->copy($src_project_id, $owner_id, $name, $private, $identifier);
|
||||||
|
|
||||||
if ($dst_project_id === false) {
|
if ($dst_project_id === false) {
|
||||||
$this->db->cancelTransaction();
|
$this->db->cancelTransaction();
|
||||||
@@ -133,13 +134,18 @@ class ProjectDuplicationModel extends Base
|
|||||||
* @param integer $owner_id
|
* @param integer $owner_id
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @param boolean $private
|
* @param boolean $private
|
||||||
|
* @param string $identifier
|
||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
private function copy($src_project_id, $owner_id = 0, $name = null, $private = null)
|
private function copy($src_project_id, $owner_id = 0, $name = null, $private = null, $identifier = null)
|
||||||
{
|
{
|
||||||
$project = $this->projectModel->getById($src_project_id);
|
$project = $this->projectModel->getById($src_project_id);
|
||||||
$is_private = empty($project['is_private']) ? 0 : 1;
|
$is_private = empty($project['is_private']) ? 0 : 1;
|
||||||
|
|
||||||
|
if (! empty($identifier)) {
|
||||||
|
$identifier = strtoupper($identifier);
|
||||||
|
}
|
||||||
|
|
||||||
$values = array(
|
$values = array(
|
||||||
'name' => $name ?: $this->getClonedProjectName($project['name']),
|
'name' => $name ?: $this->getClonedProjectName($project['name']),
|
||||||
'is_active' => 1,
|
'is_active' => 1,
|
||||||
@@ -151,6 +157,7 @@ class ProjectDuplicationModel extends Base
|
|||||||
'priority_default' => $project['priority_default'],
|
'priority_default' => $project['priority_default'],
|
||||||
'priority_start' => $project['priority_start'],
|
'priority_start' => $project['priority_start'],
|
||||||
'priority_end' => $project['priority_end'],
|
'priority_end' => $project['priority_end'],
|
||||||
|
'identifier' => $identifier,
|
||||||
);
|
);
|
||||||
|
|
||||||
return $this->db->table(ProjectModel::TABLE)->persist($values);
|
return $this->db->table(ProjectModel::TABLE)->persist($values);
|
||||||
|
|||||||
Reference in New Issue
Block a user