From c9721cd0ce64c540ad96dd328fa43c69d7c11407 Mon Sep 17 00:00:00 2001 From: Yagami <976204163@qq.com> Date: Thu, 14 Jan 2021 16:26:38 +0800 Subject: [PATCH] * Fix project drop menu. --- module/program/control.php | 4 ++-- module/program/model.php | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/module/program/control.php b/module/program/control.php index 7cb8ca4c95..73b89b73b4 100644 --- a/module/program/control.php +++ b/module/program/control.php @@ -673,7 +673,7 @@ class program extends control $this->view->module = $module; $this->view->method = $method; - $this->view->normalProjectsHtml = $this->program->getPRJTreeMenu(0, array('programmodel', 'createPRJManageLink')); + $this->view->normalProjectsHtml = $this->program->getPRJTreeMenu(0, array('programmodel', 'createPRJManageLink'), 0, 'dropmenu'); $this->view->closedProjectsHtml = $closedProjectsHtml; $this->display(); @@ -782,7 +782,7 @@ class program extends control $this->view->pager = $pager; $this->view->programID = $programID; $this->view->program = $this->program->getPRJByID($programID); - $this->view->PRJTree = $this->program->getPRJTreeMenu(0, array('programmodel', 'createPRJManageLink')); + $this->view->PRJTree = $this->program->getPRJTreeMenu(0, array('programmodel', 'createPRJManageLink'), 0, 'list'); $this->view->users = $this->loadModel('user')->getPairs('noletter|pofirst|nodeleted'); $this->view->browseType = $browseType; $this->view->param = $param; diff --git a/module/program/model.php b/module/program/model.php index bde892e3d9..3dd4199e5a 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -1214,19 +1214,21 @@ class programModel extends model * Build the query. * * @param int $projectID + * @param string $type list|dropmenu * @access public * @return object */ - public function buildPRJMenuQuery($projectID = 0) + public function buildPRJMenuQuery($projectID = 0, $type = 'list') { $path = ''; $program = $this->getPRJByID($projectID); if($program) $path = $program->path; return $this->dao->select('*')->from(TABLE_PROJECT) - ->where('type')->eq('program') + ->where('deleted')->eq('0') + ->beginIF($type == 'list')->andWhere('type')->eq('program')->fi() + ->beginIF($type == 'dropmenu')->andWhere('type')->in('program,project')->fi() ->andWhere('status')->ne('closed') - ->andWhere('deleted')->eq('0') ->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->programs)->fi() ->beginIF($projectID > 0)->andWhere('path')->like($path . '%')->fi() ->orderBy('grade desc, `order`') @@ -1259,13 +1261,14 @@ class programModel extends model * @param int $projectID * @param string $userFunc * @param int $param + * @param string $type list|dropmenu * @access public * @return string */ - public function getPRJTreeMenu($projectID = 0, $userFunc, $param = 0) + public function getPRJTreeMenu($projectID = 0, $userFunc, $param = 0, $type = 'list') { $projectMenu = array(); - $stmt = $this->dbh->query($this->buildPRJMenuQuery($projectID)); + $stmt = $this->dbh->query($this->buildPRJMenuQuery($projectID, $type)); while($project = $stmt->fetch()) {