From ea9b26e581947d17d1eb5a132035317497100109 Mon Sep 17 00:00:00 2001 From: daitingting Date: Fri, 21 Oct 2022 00:52:14 +0000 Subject: [PATCH 1/3] * Finish task #71574. --- module/action/lang/de.php | 1 + module/action/lang/en.php | 1 + module/action/lang/fr.php | 1 + module/action/lang/zh-cn.php | 1 + module/project/control.php | 19 ++++++++++++++----- module/project/model.php | 7 +++++++ 6 files changed, 25 insertions(+), 5 deletions(-) diff --git a/module/action/lang/de.php b/module/action/lang/de.php index a3337c3963..f9d0489931 100644 --- a/module/action/lang/de.php +++ b/module/action/lang/de.php @@ -224,6 +224,7 @@ $lang->action->desc->merged = '$date, merged by $actoraction->desc->submitreview = '$date, submitted for review by $actor.' . "\n"; $lang->action->desc->ganttmove = '$date, sort by $actor .' . "\n"; $lang->action->desc->switchtolean = '$date, Switch from new mode to lean mode by '. $lang->admin->system .'.' . "\n"; +$lang->action->desc->unlinkproduct = '$date, the project is disassociated from the $extra, synchronization disassociates the sprints of the project from the $extra.' . "\n"; /* Used to describe the history of operations related to parent-child tasks. */ $lang->action->desc->createchildren = '$date, $actor created a child task $extra。' . "\n"; diff --git a/module/action/lang/en.php b/module/action/lang/en.php index 0753f1e972..d95d187fd9 100755 --- a/module/action/lang/en.php +++ b/module/action/lang/en.php @@ -224,6 +224,7 @@ $lang->action->desc->merged = '$date, merged by $actoraction->desc->submitreview = '$date, submitted for review by $actor.' . "\n"; $lang->action->desc->ganttmove = '$date, sort by $actor .' . "\n"; $lang->action->desc->switchtolean = '$date, Switch from new mode to lean mode by '. $lang->admin->system .'.' . "\n"; +$lang->action->desc->unlinkproduct = '$date, the project is disassociated from the $extra, synchronization disassociates the sprints of the project from the $extra.' . "\n"; /* Used to describe the history of operations related to parent-child tasks. */ $lang->action->desc->createchildren = '$date, $actor created a child task $extra。' . "\n"; diff --git a/module/action/lang/fr.php b/module/action/lang/fr.php index 888be01906..6b7c42fb78 100644 --- a/module/action/lang/fr.php +++ b/module/action/lang/fr.php @@ -224,6 +224,7 @@ $lang->action->desc->merged = '$date, merged by $actoraction->desc->submitreview = '$date, submitted for review by $actor.' . "\n"; $lang->action->desc->ganttmove = '$date, sort by $actor .' . "\n"; $lang->action->desc->switchtolean = '$date, Switch from new mode to lean mode by '. $lang->admin->system .'.' . "\n"; +$lang->action->desc->unlinkproduct = '$date, the project is disassociated from the $extra, synchronization disassociates the sprints of the project from the $extra.' . "\n"; /* Used to describe the history of operations related to parent-child tasks. */ $lang->action->desc->createchildren = '$date, $actor a créé un sous-tâche $extra。' . "\n"; diff --git a/module/action/lang/zh-cn.php b/module/action/lang/zh-cn.php index 4496c9373c..cb09fda2c1 100755 --- a/module/action/lang/zh-cn.php +++ b/module/action/lang/zh-cn.php @@ -224,6 +224,7 @@ $lang->action->desc->merged = '$date, 由 $actor $lang->action->desc->submitreview = '$date, 由 $actor 提交评审。' . "\n"; $lang->action->desc->ganttmove = '$date, 由 $actor 排序。' . "\n"; $lang->action->desc->switchtolean = '$date, 由 '. $lang->admin->system .' 从综合模式切换为迅捷模式。' . "\n"; +$lang->action->desc->unlinkproduct = '$date, 系统判断由于迭代所属项目与$extra取消关联,同步将迭代与$extra取消关联。' . "\n"; /* 用来描述和父子任务相关的操作历史记录。*/ $lang->action->desc->createchildren = '$date, 由 $actor 创建子任务 $extra。' . "\n"; diff --git a/module/project/control.php b/module/project/control.php index 0a5e8fe913..53b3c53a92 100755 --- a/module/project/control.php +++ b/module/project/control.php @@ -2145,11 +2145,20 @@ class project extends control if($executionID) $this->execution->updateProducts($executionID); } - $oldProducts = array_keys($oldProducts); - $newProducts = $this->product->getProducts($projectID); - $newProducts = array_keys($newProducts); - $diffProducts = array_merge(array_diff($oldProducts, $newProducts), array_diff($newProducts, $oldProducts)); - if($diffProducts) $this->loadModel('action')->create('project', $projectID, 'Managed', '', !empty($_POST['products']) ? join(',', $_POST['products']) : ''); + $newProducts = $this->product->getProducts($projectID); + $oldProductIDs = array_keys($oldProducts); + $newProductIDs = array_keys($newProducts); + $diffProductIDs = array_merge(array_diff($oldProductIDs, $newProductIDs), array_diff($newProductIDs, $oldProductIDs)); + if($diffProductIDs) $this->loadModel('action')->create('project', $projectID, 'Managed', '', !empty($_POST['products']) ? join(',', $_POST['products']) : ''); + + $unlinkedProducts = array_diff($oldProductIDs, $newProductIDs); + if(!empty($unlinkedProducts)) + { + $unlinkedProductPairs = array(); + foreach($unlinkedProducts as $unlinkedProduct) $unlinkedProductPairs[$unlinkedProduct] = $oldProducts[$unlinkedProduct]->name; + + $this->action->create('project', $projectID, 'unlinkproduct', '', implode(',', $unlinkedProductPairs)); + } $locateLink = inLink('manageProducts', "projectID=$projectID"); if($from == 'program') $locateLink = $this->session->projectList; diff --git a/module/project/model.php b/module/project/model.php index af615515ae..dd8a5cd557 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -1599,6 +1599,13 @@ class projectModel extends model $oldProject->linkedProducts = implode(',', $linkedProducts); $project->linkedProducts = implode(',', $_POST['products']); + $unlinkedProducts = array_diff($linkedProducts, $_POST['products']); + if(!empty($unlinkedProducts)) + { + $products = $this->dao->select('name')->from(TABLE_PRODUCT)->where('id')->in($unlinkedProducts)->fetchPairs(); + $this->action->create('project', $projectID, 'unlinkproduct', '', implode(',', $products)); + } + /* Activate or close the shadow product of the project. */ if(!$oldProject->hasProduct && $oldProject->status != $project->status && strpos('doing,closed', $project->status) !== false) { From b09405cdef0ace27ca446ef12e9f6954f662733c Mon Sep 17 00:00:00 2001 From: daitingting Date: Fri, 21 Oct 2022 01:07:48 +0000 Subject: [PATCH 2/3] * Adjust codes. --- module/project/model.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/project/model.php b/module/project/model.php index dd8a5cd557..2f823bea97 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -1528,7 +1528,7 @@ class projectModel extends model ->checkIF($project->begin != '', 'begin', 'date') ->checkIF($project->end != '', 'end', 'date') ->checkIF($project->end != '', 'end', 'gt', $project->begin) - ->checkIF(!empty($project->name), 'name', 'unique', "id != $projectID and `type` = 'project' and `parent` = '$project->parent' and `model` = '{$project->model}' and `deleted` = '0'") + ->checkIF(!empty($project->name), 'name', 'unique', "id != $projectID and `type` = 'project' and `parent` = '$oldProject->parent' and `model` = '{$project->model}' and `deleted` = '0'") ->checkIF(!empty($project->code), 'code', 'unique', "id != $projectID and `type` = 'project' and `model` = '{$project->model}' and `deleted` = '0'") ->checkFlow() ->where('id')->eq($projectID) @@ -1603,7 +1603,7 @@ class projectModel extends model if(!empty($unlinkedProducts)) { $products = $this->dao->select('name')->from(TABLE_PRODUCT)->where('id')->in($unlinkedProducts)->fetchPairs(); - $this->action->create('project', $projectID, 'unlinkproduct', '', implode(',', $products)); + $this->loadModel('action')->create('project', $projectID, 'unlinkproduct', '', implode(',', $products)); } /* Activate or close the shadow product of the project. */ From dc4865c9d16bc5cec2aa09e7fb81a7b052d24692 Mon Sep 17 00:00:00 2001 From: daitingting Date: Fri, 21 Oct 2022 01:22:22 +0000 Subject: [PATCH 3/3] * Unlink execution with product. --- module/project/model.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/module/project/model.php b/module/project/model.php index 2f823bea97..94a800b36d 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -1595,6 +1595,7 @@ class projectModel extends model $oldWhitelist = explode(',', $oldProject->whitelist) and $oldWhitelist = array_filter($oldWhitelist); $newWhitelist = explode(',', $project->whitelist) and $newWhitelist = array_filter($newWhitelist); if(count($oldWhitelist) == count($newWhitelist) and count(array_diff($oldWhitelist, $newWhitelist)) == 0) unset($project->whitelist); + /* Add linkedproducts changes. */ $oldProject->linkedProducts = implode(',', $linkedProducts); $project->linkedProducts = implode(',', $_POST['products']); @@ -2308,9 +2309,12 @@ class projectModel extends model public function updateProducts($projectID, $products = '') { $this->loadModel('user'); + $products = isset($_POST['products']) ? $_POST['products'] : $products; $oldProjectProducts = $this->dao->select('*')->from(TABLE_PROJECTPRODUCT)->where('project')->eq((int)$projectID)->fetchGroup('product', 'branch'); + $this->dao->delete()->from(TABLE_PROJECTPRODUCT)->where('project')->eq((int)$projectID)->exec(); + $members = array_keys($this->getTeamMembers($projectID)); if(empty($products)) { @@ -2351,6 +2355,10 @@ class projectModel extends model $existedProducts[$productID][$branch] = true; } + /* Delete the execution linked products that is not linked with the execution. */ + $executions = $this->dao->select('id')->from(TABLE_EXECUTION)->where('project')->eq((int)$projectID)->fetchPairs('id'); + $this->dao->delete()->from(TABLE_PROJECTPRODUCT)->where('project')->in($executions)->andWhere('product')->notin($products)->exec(); + $oldProductKeys = array_keys($oldProjectProducts); $needUpdate = array_merge(array_diff($oldProductKeys, $products), array_diff($products, $oldProductKeys)); if($needUpdate) $this->user->updateUserView($needUpdate, 'product', $members);