summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFlorian <github@floyer.de>2019-07-06 06:50:54 +0200
committerfguillot <fred@kanboard.net>2019-07-05 21:50:54 -0700
commit91d703eb8dd627659712e2c87fffab6140ec9aec (patch)
tree220fc8442e380dee3049749774ae83a0b3fbe94e /app
parentb397a77794c479ed66790b99a1c6bd882c727a98 (diff)
Make sure the Project Identifier is saved when creating a project from anther one
Diffstat (limited to 'app')
-rw-r--r--app/Controller/ProjectCreationController.php3
-rw-r--r--app/Model/ProjectDuplicationModel.php13
2 files changed, 12 insertions, 4 deletions
diff --git a/app/Controller/ProjectCreationController.php b/app/Controller/ProjectCreationController.php
index b9458bdd..d07e7356 100644
--- a/app/Controller/ProjectCreationController.php
+++ b/app/Controller/ProjectCreationController.php
@@ -124,7 +124,8 @@ class ProjectCreationController extends BaseController
$selection,
$this->userSession->getId(),
$values['name'],
- $values['is_private'] == 1
+ $values['is_private'] == 1,
+ $values['identifier']
);
}
}
diff --git a/app/Model/ProjectDuplicationModel.php b/app/Model/ProjectDuplicationModel.php
index 42a4d618..a8f57709 100644
--- a/app/Model/ProjectDuplicationModel.php
+++ b/app/Model/ProjectDuplicationModel.php
@@ -82,14 +82,15 @@ class ProjectDuplicationModel extends Base
* @param integer $owner_id Owner of the project
* @param string $name Name of the project
* @param boolean $private Force the project to be private
+ * @param string $identifier Identifier of the project
* @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();
// 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) {
$this->db->cancelTransaction();
@@ -133,13 +134,18 @@ class ProjectDuplicationModel extends Base
* @param integer $owner_id
* @param string $name
* @param boolean $private
+ * @param string $identifier
* @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);
$is_private = empty($project['is_private']) ? 0 : 1;
+ if (! empty($identifier)) {
+ $identifier = strtoupper($identifier);
+ }
+
$values = array(
'name' => $name ?: $this->getClonedProjectName($project['name']),
'is_active' => 1,
@@ -151,6 +157,7 @@ class ProjectDuplicationModel extends Base
'priority_default' => $project['priority_default'],
'priority_start' => $project['priority_start'],
'priority_end' => $project['priority_end'],
+ 'identifier' => $identifier,
);
return $this->db->table(ProjectModel::TABLE)->persist($values);