From 7cd35ad1855e2e34459d4f6bfe7faa1be7c219ce Mon Sep 17 00:00:00 2001 From: Yagami <976204163@qq.com> Date: Wed, 14 Jul 2021 16:51:56 +0800 Subject: [PATCH] * Finish task #40118. --- module/stakeholder/model.php | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/module/stakeholder/model.php b/module/stakeholder/model.php index 259898f433..afdd39b99b 100644 --- a/module/stakeholder/model.php +++ b/module/stakeholder/model.php @@ -112,6 +112,19 @@ class stakeholderModel extends model } } + if($stakeholder->objectType == 'program' and $stakeholder->objectID) + { + $programID = $stakeholder->objectID; + /* Update children user view. */ + $childPrograms = $this->dao->select('id')->from(TABLE_PROJECT)->where('path')->like("%,$programID,%")->andWhere('type')->eq('program')->fetchPairs(); + $childProjects = $this->dao->select('id')->from(TABLE_PROJECT)->where('path')->like("%,$programID,%")->andWhere('type')->eq('project')->fetchPairs(); + $childProducts = $this->dao->select('id')->from(TABLE_PRODUCT)->where('program')->eq($programID)->fetchPairs(); + + if(!empty($childPrograms)) $this->user->updateUserView($childPrograms, 'program', $stakeholder->user); + if(!empty($childProjects)) $this->user->updateUserView($childProjects, 'project', $stakeholder->user); + if(!empty($childProducts)) $this->user->updateUserView($childProducts, 'product', $stakeholder->user); + } + return $stakeholderID; } return false; @@ -168,6 +181,19 @@ class stakeholderModel extends model foreach($products as $productID => $productName) $this->user->updateUserView($productID, 'product', $changedAccounts); } + if($stakeholder->objectType == 'program' and $stakeholder->objectID) + { + $programID = $stakeholder->objectID; + /* Update children user view. */ + $childPrograms = $this->dao->select('id')->from(TABLE_PROJECT)->where('path')->like("%,$programID,%")->andWhere('type')->eq('program')->fetchPairs(); + $childProjects = $this->dao->select('id')->from(TABLE_PROJECT)->where('path')->like("%,$programID,%")->andWhere('type')->eq('project')->fetchPairs(); + $childProducts = $this->dao->select('id')->from(TABLE_PRODUCT)->where('program')->eq($programID)->fetchPairs(); + + if(!empty($childPrograms)) $this->user->updateUserView($childPrograms, 'program', $stakeholder->user); + if(!empty($childProjects)) $this->user->updateUserView($childProjects, 'project', $stakeholder->user); + if(!empty($childProducts)) $this->user->updateUserView($childProducts, 'product', $stakeholder->user); + } + return $stakeholderList; }