From 73f3a6d80a947b5fca97d005daf049b02f7ea497 Mon Sep 17 00:00:00 2001 From: tianshujie Date: Tue, 13 Sep 2022 16:53:52 +0800 Subject: [PATCH] * Finish task #68925. --- module/product/lang/de.php | 2 +- module/product/lang/en.php | 2 +- module/product/lang/fr.php | 2 +- module/product/lang/zh-cn.php | 2 +- module/program/model.php | 9 +++++++-- module/upgrade/model.php | 32 ++++++++++++++++++++++++++++++++ module/user/model.php | 11 +++++++++++ 7 files changed, 54 insertions(+), 6 deletions(-) diff --git a/module/product/lang/de.php b/module/product/lang/de.php index a9adf7e665..2d2dd903e8 100644 --- a/module/product/lang/de.php +++ b/module/product/lang/de.php @@ -186,7 +186,7 @@ $lang->product->statusList['closed'] = 'Geschlossen'; global $config; if($config->systemMode == 'new') { - $lang->product->aclList['private'] = "Privat {$lang->productCommon} ({$lang->executionCommon} Nur Teammitglieder)"; + $lang->product->aclList['private'] = "Private {$lang->productCommon} (Stakeholders and owner of the respective program, team members and stakeholders of the associated project can access)"; } else { diff --git a/module/product/lang/en.php b/module/product/lang/en.php index 5f07eb8736..78f79cae43 100644 --- a/module/product/lang/en.php +++ b/module/product/lang/en.php @@ -186,7 +186,7 @@ $lang->product->statusList['closed'] = 'Closed'; global $config; if($config->systemMode == 'new') { - $lang->product->aclList['private'] = "Private {$lang->productCommon} (Stakeholders of the respective program, team members and stakeholders of the associated project can access)"; + $lang->product->aclList['private'] = "Private {$lang->productCommon} (Stakeholders and owner of the respective program, team members and stakeholders of the associated project can access)"; } else { diff --git a/module/product/lang/fr.php b/module/product/lang/fr.php index fc9b29549d..a7e23ce195 100644 --- a/module/product/lang/fr.php +++ b/module/product/lang/fr.php @@ -186,7 +186,7 @@ $lang->product->statusList['closed'] = 'Fermé'; global $config; if($config->systemMode == 'new') { - $lang->product->aclList['private'] = "{$lang->productCommon} Privé (seuls les membres de l'équipe {$lang->executionCommon} ont les droits)"; + $lang->product->aclList['private'] = "Private {$lang->productCommon} (Stakeholders and owner of the respective program, team members and stakeholders of the associated project can access)"; } else { diff --git a/module/product/lang/zh-cn.php b/module/product/lang/zh-cn.php index e5c1184c44..6bed7d52d0 100644 --- a/module/product/lang/zh-cn.php +++ b/module/product/lang/zh-cn.php @@ -186,7 +186,7 @@ $lang->product->statusList['closed'] = '结束'; global $config; if($config->systemMode == 'new') { - $lang->product->aclList['private'] = "私有({$lang->productCommon}相关负责人、所属项目集的干系人、相关联项目的团队成员和干系人可访问)"; + $lang->product->aclList['private'] = "私有({$lang->productCommon}相关负责人、所属项目集的负责人及干系人、相关联项目的团队成员和干系人可访问)"; } else { diff --git a/module/program/model.php b/module/program/model.php index c2d23738b1..4f5063f43e 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -841,12 +841,17 @@ class programModel extends model $this->file->updateObjectID($this->post->uid, $programID, 'project'); $whitelist = explode(',', $program->whitelist); $this->loadModel('personnel')->updateWhitelist($whitelist, 'program', $programID); - if($program->acl != 'open') $this->loadModel('user')->updateUserView($programID, 'program'); + $this->loadModel('user'); + if($program->acl != 'open') $this->user->updateUserView($programID, 'program'); /* If the program changes, the authorities of programs and projects under the program should be refreshed. */ $children = $this->dao->select('id, type')->from(TABLE_PROGRAM)->where('path')->like("%,{$programID},%")->andWhere('id')->ne($programID)->andWhere('acl')->eq('program')->fetchPairs('id', 'type'); - $this->loadModel('user'); foreach($children as $id => $type) $this->user->updateUserView($id, $type); + if($program->PM != $oldProgram->PM) + { + $productIdList = $this->dao->select('id')->from(TABLE_PRODUCT)->where('program')->eq($programID)->fetchPairs('id'); + foreach($productIdList as $productID) $this->user->updateUserView($productID, 'product'); + } if($oldProgram->parent != $program->parent) { diff --git a/module/upgrade/model.php b/module/upgrade/model.php index c0fd3dd323..c6be9dbc5a 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -557,6 +557,9 @@ class upgradeModel extends model $this->xuanRecoverCreatedDates(); $this->xuanSetPartitionedMessageIndex(); break; + case '17_6_1': + $this->updateProductView(); + break; } $this->deletePatch(); @@ -7528,4 +7531,33 @@ class upgradeModel extends model } return true; } + + /** + * Update the owner of the program into the product view. + * + * @access public + * @return bool + */ + public function updateProductView() + { + $programs = $this->dao->select('id,PM')->from(TABLE_PROGRAM)->where('type')->eq('program')->andWhere('PM')->ne('')->fetchPairs('id', 'PM'); + if(empty($programs)) return true; + + $productGroup = $this->dao->select('id,program')->from(TABLE_PRODUCT)->where('program')->in(array_keys($programs))->andWhere('acl')->ne('open')->fetchGroup('program', 'id'); + if(empty($productGroup)) return true; + + $userView = $this->dao->select('*')->from(TABLE_USERVIEW)->where('account')->in(array_values($programs))->fetchAll('account'); + foreach($programs as $programID => $programPM) + { + if(empty($productGroup[$programID])) continue; + $canViewProducts = zget($productGroup, $programID); + $view = $userView[$programPM]->products; + foreach($canViewProducts as $productID => $product) + { + if(strpos(",$view,", ",$productID,") === false) $view .= ',' . $productID; + } + $this->dao->update(TABLE_USERVIEW)->set('products')->eq($view)->where('account')->eq($programPM)->exec(); + } + return true; + } } diff --git a/module/user/model.php b/module/user/model.php index e779699ede..4b5222b35f 100644 --- a/module/user/model.php +++ b/module/user/model.php @@ -1983,6 +1983,17 @@ class userModel extends model $productIdList = zget($programProduct, $programStakeholder->objectID, array()); foreach($productIdList as $productID) $stakeholderGroups[$productID][$programStakeholder->user] = $programStakeholder->user; } + + $sql = $this->dao->select('id,PM')->from(TABLE_PROGRAM) + ->where('type')->eq('program') + ->andWhere('id')->in(array_keys($programProduct)) + ->query(); + + while($programOwner = $sql->fetch()) + { + $productIdList = zget($programProduct, $programOwner->id, array()); + foreach($productIdList as $productID) $stakeholderGroups[$productID][$programOwner->PM] = $programOwner->PM; + } } return array($teamGroups, $stakeholderGroups);