From 35bd85a24339d53d57dc78bd48f361e5f5c195cc Mon Sep 17 00:00:00 2001 From: hufangzhou Date: Fri, 10 Feb 2023 05:41:06 +0000 Subject: [PATCH 1/2] * Modifying the access control of the parent phase does not synchronize the child phase's. --- module/programplan/model.php | 14 +++++++------- module/user/model.php | 8 ++++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/module/programplan/model.php b/module/programplan/model.php index 031f29a143..e9287a1cc6 100755 --- a/module/programplan/model.php +++ b/module/programplan/model.php @@ -927,20 +927,20 @@ class programplanModel extends model $members = array($this->app->user->account, $data->PM); $roles = $this->user->getUserRoles(array_values($members)); $team = $this->user->getTeamMemberPairs($stageID, 'execution'); - foreach($members as $account) + foreach($members as $teamMember) { - if(empty($account) or isset($team[$account]) or isset($teamMembers[$account])) continue; + if(empty($teamMember) or isset($team[$teamMember]) or isset($teamMembers[$teamMember])) continue; $member = new stdclass(); $member->root = $stageID; - $member->account = $account; - $member->role = zget($roles, $account, ''); + $member->account = $teamMember; + $member->role = zget($roles, $teamMember, ''); $member->join = $now; $member->type = 'execution'; $member->days = $data->days; $member->hours = $this->config->execution->defaultWorkhours; $this->dao->insert(TABLE_TEAM)->data($member)->exec(); - $teamMembers[$account] = $member; + $teamMembers[$teamMember] = $member; } $this->execution->addProjectMembers($data->project, $teamMembers); @@ -1077,8 +1077,8 @@ class programplanModel extends model else { /* Synchronously update sub-phase permissions. */ - $childrenIDList = $this->dao->select('*')->from(TABLE_PROJECT)->where('parent')->eq($oldPlan->id)->fetch('id'); - if(!empty($childrenIDList)) $this->dao->update(TABLE_PROJECT)->set('acl')->eq($plan->acl)->where('id')->in($childrenIDList)->exec(); + $childrenIDList = $this->dao->select('id')->from(TABLE_PROJECT)->where('parent')->eq($oldPlan->id)->fetchAll('id'); + if(!empty($childrenIDList)) $this->dao->update(TABLE_PROJECT)->set('acl')->eq($plan->acl)->where('id')->in(array_keys($childrenIDList))->exec(); /* The workload of the parent plan cannot exceed 100%. */ $oldPlan->parent = $plan->parent; diff --git a/module/user/model.php b/module/user/model.php index eea5c31733..ff2aa02a62 100644 --- a/module/user/model.php +++ b/module/user/model.php @@ -2417,6 +2417,14 @@ class userModel extends model $parentIdList = array(); foreach($sprints as $sprint) $parentIdList[$sprint->project] = $sprint->project; + $childList = array(); + foreach($sprints as $sprint) + { + $children = $this->dao->select('id, project, PM, PO, QD, RD, openedBy, acl, parent, path, grade, type')->from(TABLE_EXECUTION)->where('path')->like("%,$sprint->id,%")->fetchAll('id'); + $childList = $childList + $children; + } + $sprints = $sprints + $childList; + /* Get team group. */ $teamGroups = array(); $stmt = $this->dao->select('root,account')->from(TABLE_TEAM) From 17bbda6505604d0e5ec3e465b1ce0c1e91c7fc27 Mon Sep 17 00:00:00 2001 From: hufangzhou Date: Fri, 10 Feb 2023 06:09:44 +0000 Subject: [PATCH 2/2] * Format the code. --- module/programplan/model.php | 6 +++++- module/user/model.php | 8 -------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/module/programplan/model.php b/module/programplan/model.php index e9287a1cc6..777f1afad4 100755 --- a/module/programplan/model.php +++ b/module/programplan/model.php @@ -1118,7 +1118,11 @@ class programplanModel extends model if(dao::isError()) return false; $this->setTreePath($planID); - if($plan->acl != 'open') $this->loadModel('user')->updateUserView($planID, 'sprint'); + if($plan->acl != 'open') + { + $planIdList = $this->dao->select('id')->from(TABLE_EXECUTION)->where('path')->like("%,$planID,%")->andWhere('type')->eq('stage')->fetchAll('id'); + $this->loadModel('user')->updateUserView(array_keys($planIdList), 'sprint'); + } if($planChanged) { diff --git a/module/user/model.php b/module/user/model.php index ff2aa02a62..eea5c31733 100644 --- a/module/user/model.php +++ b/module/user/model.php @@ -2417,14 +2417,6 @@ class userModel extends model $parentIdList = array(); foreach($sprints as $sprint) $parentIdList[$sprint->project] = $sprint->project; - $childList = array(); - foreach($sprints as $sprint) - { - $children = $this->dao->select('id, project, PM, PO, QD, RD, openedBy, acl, parent, path, grade, type')->from(TABLE_EXECUTION)->where('path')->like("%,$sprint->id,%")->fetchAll('id'); - $childList = $childList + $children; - } - $sprints = $sprints + $childList; - /* Get team group. */ $teamGroups = array(); $stmt = $this->dao->select('root,account')->from(TABLE_TEAM)