summaryrefslogtreecommitdiff
path: root/app/Model
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-07-02 15:20:59 -0400
committerFrederic Guillot <fred@kanboard.net>2016-07-02 15:20:59 -0400
commit6d5577fa0bc108fcafa92fc4ac4b9ed621bfe33e (patch)
treebd7b71d282c66c28b3060ccfb0431428b413a139 /app/Model
parent3fcc0cb9183f9ff32ce7a3c615258bcf53c385ed (diff)
Handle project tags duplication
Diffstat (limited to 'app/Model')
-rw-r--r--app/Model/ProjectDuplicationModel.php21
-rw-r--r--app/Model/TagDuplicationModel.php20
2 files changed, 39 insertions, 2 deletions
diff --git a/app/Model/ProjectDuplicationModel.php b/app/Model/ProjectDuplicationModel.php
index b67f8302..4db8f767 100644
--- a/app/Model/ProjectDuplicationModel.php
+++ b/app/Model/ProjectDuplicationModel.php
@@ -22,7 +22,15 @@ class ProjectDuplicationModel extends Base
*/
public function getOptionalSelection()
{
- return array('categoryModel', 'projectPermissionModel', 'actionModel', 'swimlaneModel', 'taskModel', 'projectMetadataModel');
+ return array(
+ 'categoryModel',
+ 'projectPermissionModel',
+ 'actionModel',
+ 'swimlaneModel',
+ 'tagDuplicationModel',
+ 'projectMetadataModel',
+ 'taskModel',
+ );
}
/**
@@ -33,7 +41,16 @@ class ProjectDuplicationModel extends Base
*/
public function getPossibleSelection()
{
- return array('boardModel', 'categoryModel', 'projectPermissionModel', 'actionModel', 'swimlaneModel', 'taskModel', 'projectMetadataModel');
+ return array(
+ 'boardModel',
+ 'categoryModel',
+ 'projectPermissionModel',
+ 'actionModel',
+ 'swimlaneModel',
+ 'tagDuplicationModel',
+ 'projectMetadataModel',
+ 'taskModel',
+ );
}
/**
diff --git a/app/Model/TagDuplicationModel.php b/app/Model/TagDuplicationModel.php
index 1876391d..fb0d8170 100644
--- a/app/Model/TagDuplicationModel.php
+++ b/app/Model/TagDuplicationModel.php
@@ -13,6 +13,26 @@ use Kanboard\Core\Base;
class TagDuplicationModel extends Base
{
/**
+ * Duplicate project tags to another project
+ *
+ * @access public
+ * @param integer $src_project_id
+ * @param integer $dst_project_id
+ * @return bool
+ */
+ public function duplicate($src_project_id, $dst_project_id)
+ {
+ $tags = $this->tagModel->getAllByProject($src_project_id);
+ $results = array();
+
+ foreach ($tags as $tag) {
+ $results[] = $this->tagModel->create($dst_project_id, $tag['name']);
+ }
+
+ return ! in_array(false, $results, true);
+ }
+
+ /**
* Link tags to the new tasks
*
* @access public