From 001ca0ef8f2b372ec89f59251b6a1c9ef87574f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A1=E6=A0=8B?= Date: Tue, 26 Oct 2021 15:39:46 +0800 Subject: [PATCH] * code for task #43347. --- api/v1/entries/execution.php | 11 ++++++++++- api/v1/entries/executions.php | 3 +++ api/v1/entries/projects.php | 2 ++ framework/api/entry.class.php | 24 ++++++++++++++++++++++++ module/program/model.php | 3 ++- 5 files changed, 41 insertions(+), 2 deletions(-) diff --git a/api/v1/entries/execution.php b/api/v1/entries/execution.php index 534b70d98f..0868abf625 100644 --- a/api/v1/entries/execution.php +++ b/api/v1/entries/execution.php @@ -36,7 +36,7 @@ class executionEntry extends Entry if(!$fields) $this->send(200, $execution); /* Set other fields. */ - $fields = explode(',', $fields); + $fields = explode(',', strtolower($fields)); foreach($fields as $field) { switch($field) @@ -50,6 +50,15 @@ class executionEntry extends Entry $execution->modules = $data->data->tree; } break; + case 'moduleoptionmenu': + $execution->moduleOptionMenu = $this->loadModel('tree')->getTaskOptionMenu($executionID, 0, 0, 'allModule'); + break; + case 'members': + $execution->members = $this->loadModel('user')->getTeamMemberPairs($executionID, 'execution', 'nodeleted');; + break; + case 'stories': + $execution->stories = $this->loadModel('story')->getExecutionStoryPairs($executionID, 0, 0, '', 'full', 'unclosed'); + break; } } diff --git a/api/v1/entries/executions.php b/api/v1/entries/executions.php index 720df0e3a7..9d378362aa 100644 --- a/api/v1/entries/executions.php +++ b/api/v1/entries/executions.php @@ -20,6 +20,8 @@ class executionsEntry extends entry */ public function get($projectID = 0) { + $returnFields = explode(',', $this->param('return', '')); + $control = $this->loadController('execution', 'all'); $control->all($this->param('status', 'all'), $this->param('project', $projectID), $this->param('order', 'id_desc'), 0, 0, $this->param('limit', 20), $this->param('page', 1)); $data = $this->getData(); @@ -30,6 +32,7 @@ class executionsEntry extends entry $result = array(); foreach($data->data->executionStats as $execution) { + if($returnFields) $execution = $this->filterFields($execution, $returnFields); $result[] = $this->format($execution, 'openedDate:time,lastEditedDate:time,closedDate:time,canceledDate:time,begin:date,end:date,realBegan:date,realEnd:date,deleted:bool'); } return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'executions' => $result)); diff --git a/api/v1/entries/projects.php b/api/v1/entries/projects.php index 7a09c12e44..470731ef41 100644 --- a/api/v1/entries/projects.php +++ b/api/v1/entries/projects.php @@ -21,6 +21,7 @@ class projectsEntry extends entry public function get($programID = 0) { if(!$programID) $programID = $this->param('program', 0); + $returnFields = explode(',', $this->param('return', '')); $control = $this->loadController('project', 'browse'); $control->browse($programID, $this->param('status', 'all'), 0, $this->param('order', 'order_asc'), 0, $this->param('limit', 20), $this->param('page', 1)); @@ -32,6 +33,7 @@ class projectsEntry extends entry $result = array(); foreach($data->data->projectStats as $project) { + if($returnFields) $project = $this->filterFields($project, $returnFields); $result[] = $this->format($project, 'openedDate:time,lastEditedDate:time,closedDate:time,canceledDate:time'); } return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => (int)$pager->recPerPage, 'projects' => $result)); diff --git a/framework/api/entry.class.php b/framework/api/entry.class.php index 39f469e22a..41b6284a60 100644 --- a/framework/api/entry.class.php +++ b/framework/api/entry.class.php @@ -486,6 +486,8 @@ class baseEntry $type = $field[1]; $isArray = false; + if(!isset($object->$key)) continue; + $pos = strpos($type, ']'); if($pos !== FALSE) { @@ -519,6 +521,28 @@ class baseEntry } } + /** + * Filter fields. + * + * @param object $object + * @param array $filters + * @access public + * @return object + */ + public function filterFields($object, $allowable = '') + { + if(empty($allowable)) return $object; + + $filtered = new stdclass(); + foreach($allowable as $field) + { + if(!isset($object->$field)) continue; + $filtered->$field = $object->$field; + } + + return $filtered; + } + /** * 类型转换. * Typecasting. diff --git a/module/program/model.php b/module/program/model.php index 0ba7e0cfd4..5c1ec55921 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -443,7 +443,8 @@ class programModel extends model $projectList = $this->dao->select('*')->from(TABLE_PROJECT) ->where('deleted')->eq('0') ->beginIF($this->config->systemMode == 'new')->andWhere('type')->eq('project')->fi() - ->beginIF($browseType != 'all')->andWhere('status')->eq($browseType)->fi() + ->beginIF($browseType != 'all' and $browseType != 'undone')->andWhere('status')->eq($browseType)->fi() + ->beginIF($browseType != 'undone')->andWhere('status')->in('wait,doing')->fi() ->beginIF($path)->andWhere('path')->like($path . '%')->fi() ->beginIF(!$queryAll and !$this->app->user->admin and $this->config->systemMode == 'new')->andWhere('id')->in($this->app->user->view->projects)->fi() ->beginIF(!$queryAll and !$this->app->user->admin and $this->config->systemMode == 'classic')->andWhere('id')->in($this->app->user->view->sprints)->fi()