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; }