From 6fdcc5f82668a47f37bac08f51cfb01136252b22 Mon Sep 17 00:00:00 2001 From: xieqiyu Date: Wed, 1 Jun 2022 23:34:48 +0800 Subject: [PATCH] * Modify review code for bug#23185. --- module/program/model.php | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/module/program/model.php b/module/program/model.php index bd46f84c27..13bf06b7cf 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -139,35 +139,26 @@ class programModel extends model { $userViewIdList = trim($this->app->user->view->programs, ',') . ',' . trim($this->app->user->view->projects, ','); $userViewIdList = array_filter(explode(',', $userViewIdList)); - asort($userViewIdList); $objectIdList = array(); if($this->app->rawMethod == 'browse') { - if(!$this->app->user->admin) - { - $pathList = $this->dao->select('id,path')->from(TABLE_PROJECT) - ->where('id')->in($userViewIdList) - ->andWhere('deleted')->eq(0) - ->fetchPairs('id'); + $pathList = $this->dao->select('id,path')->from(TABLE_PROJECT) + ->where('type')->in('program,project') + ->beginIF(!$this->app->user->admin)->andWhere('id')->in($userViewIdList)->fi() + ->andWhere('deleted')->eq(0) + ->orderBy('id_asc') + ->fetchPairs('id'); - foreach($pathList as $path) - { - if($type == 'child' and !empty($topIdList)) - { - $topID = $this->getTopByPath($path); - if(!in_array($topID, $topIdList)) continue; - } - - foreach(explode(',', trim($path, ',')) as $pathID) $objectIdList[$pathID] = $pathID; - } - } - else + foreach($pathList as $path) { - foreach($topIdList as $topID) + if($type == 'child' and !empty($topIdList)) { - $objectIdList += $this->dao->select('id')->from(TABLE_PROGRAM)->where('path')->like(",$topID,%")->fetchPairs('id'); + $topID = $this->getTopByPath($path); + if(!in_array($topID, $topIdList)) continue; } + + foreach(explode(',', trim($path, ',')) as $pathID) $objectIdList[$pathID] = $pathID; } }