From a18eff2a3c34f4e38f65d7693b18297107af33c4 Mon Sep 17 00:00:00 2001 From: Yagami <976204163@qq.com> Date: Thu, 22 Oct 2020 09:34:40 +0800 Subject: [PATCH] * Fix bug. --- module/program/control.php | 2 +- module/program/model.php | 2 +- module/project/model.php | 3 +++ module/user/model.php | 19 ++++++++++--------- 4 files changed, 15 insertions(+), 11 deletions(-) diff --git a/module/program/control.php b/module/program/control.php index accd1e924c..907722fe1e 100644 --- a/module/program/control.php +++ b/module/program/control.php @@ -510,7 +510,7 @@ class program extends control $this->loadModel('user')->updateUserView($programID, 'program', array($account)); /* Update children user view. */ - $childPgmList = $this->dao->select('id')->from(TABLE_PROJECT)->where('path')->like("%,$programID,%")->andWhere('type')->eq('program')->fetchPairs(); + $childPGMList = $this->dao->select('id')->from(TABLE_PROJECT)->where('path')->like("%,$programID,%")->andWhere('type')->eq('program')->fetchPairs(); $childPRJList = $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(); diff --git a/module/program/model.php b/module/program/model.php index 60e76d484b..193421e694 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -598,7 +598,7 @@ class programModel extends model $this->loadModel('user')->updateUserView($programID, 'program', $changedAccounts); /* Update children user view. */ - $childPgmList = $this->dao->select('id')->from(TABLE_PROJECT)->where('path')->like("%,$programID,%")->andWhere('type')->eq('program')->fetchPairs(); + $childPGMList = $this->dao->select('id')->from(TABLE_PROJECT)->where('path')->like("%,$programID,%")->andWhere('type')->eq('program')->fetchPairs(); $childPRJList = $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(); diff --git a/module/project/model.php b/module/project/model.php index 7c119ffaa5..2fc28e8908 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -1996,6 +1996,9 @@ class projectModel extends model $this->loadModel('user')->updateUserView($projectID, $projectType, $changedAccounts); + $childSprints = $this->dao->select('id')->from(TABLE_PROJECT)->where('path')->like("%,$projectID,%")->andWhere('type')->in('sprint,stage')->fetchPairs(); + if($childSprints) $this->user->updateUserView($childSprints, 'sprint', $changedAccounts); + $products = $this->getProducts($projectID, false); if($products) $this->user->updateUserView(array_keys($products), 'product', $changedAccounts); } diff --git a/module/user/model.php b/module/user/model.php index 7e41b6261d..2f89f8797a 100644 --- a/module/user/model.php +++ b/module/user/model.php @@ -1838,20 +1838,19 @@ class userModel extends model ->fetchAll('id'); if(empty($sprints)) return true; + $parentIdList = array(); + foreach($sprints as $sprint) $parentIdList[$sprint->project] = $sprint->project; + $teamGroups = array(); $stmt = $this->dao->select('root,account')->from(TABLE_TEAM) - ->where('type')->eq('sprint') - ->andWhere('root')->in($sprintIdList) + ->where('type')->in('project,sprint,stage') + ->andWhere('root')->in(array_merge($sprintIdList, $parentIdList)) ->query(); while($team = $stmt->fetch()) $teamGroups[$team->root][$team->account] = $team->account; $projectIdList = array(); - foreach($sprints as $sprintID => $sprint) - { - $projectIdList[$sprint->parent] = $sprint->parent; - $sprint->project = $sprint->project; - } + foreach($sprints as $sprintID => $sprint) $projectIdList[$sprint->parent] = $sprint->parent; /* Get parent project stakeholders. */ $stakeholderGroup = $this->loadModel('stakeholder')->getStakeholderGroup($projectIdList); @@ -1865,8 +1864,9 @@ class userModel extends model { $stakeholders = zget($stakeholderGroup, $sprint->project, array()); $teams = zget($teamGroups, $sprint->id, array()); + $parentTeams = zget($teamGroups, $sprint->project, array()); - $authedUsers += $this->getSprintAuthedUsers($sprint, $stakeholders, $teams); + $authedUsers += $this->getSprintAuthedUsers($sprint, $stakeholders, array_merge($teams, $parentTeams)); } } @@ -1885,8 +1885,9 @@ class userModel extends model { $stakeholders = zget($stakeholderGroup, $sprint->project, array()); $teams = zget($teamGroups, $sprint->id, array()); + $parentTeams = zget($teamGroups, $sprint->project, array()); - $hasPriv = $this->checkSprintPriv($sprint, $account, $stakeholders, $teams); + $hasPriv = $this->checkSprintPriv($sprint, $account, $stakeholders, array_merge($teams, $parentTeams)); if($hasPriv and strpos(",{$view},", ",{$sprintID},") === false) $view .= ",{$sprintID}"; if(!$hasPriv and strpos(",{$view},", ",{$sprintID},") !== false) $view = trim(str_replace(",{$sprintID},", ',', ",{$view},"), ','); }