From ed6e82f02f6eef07886547f5ade3c0d9198896ef Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Thu, 17 Mar 2022 10:11:35 +0800 Subject: [PATCH] *Close a story. --- api/v1/entries/storyclose.php | 39 +++++++++++++++++++++++++++++++++++ api/v1/entries/tabs.php | 1 + config/config.php | 2 +- config/routes.php | 1 + module/my/model.php | 1 + module/story/control.php | 2 +- 6 files changed, 44 insertions(+), 2 deletions(-) create mode 100644 api/v1/entries/storyclose.php diff --git a/api/v1/entries/storyclose.php b/api/v1/entries/storyclose.php new file mode 100644 index 0000000000..a83948232e --- /dev/null +++ b/api/v1/entries/storyclose.php @@ -0,0 +1,39 @@ + + * @package entries + * @version 1 + * @link http://www.zentao.net + */ +class storyCloseEntry extends Entry +{ + /** + * POST method. + * + * @param int $storyID + * @access public + * @return void + */ + public function post($storyID) + { + $story = $this->loadModel('story')->getByID($storyID); + + $fields = 'closedReason,duplicateStory,childStories,comment'; + $this->batchSetPost($fields); + + $control = $this->loadController('story', 'close'); + $control->close($storyID); + + $data = $this->getData(); + if(!$data) return $this->send400('error'); + if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message); + + $story = $this->story->getByID($storyID); + + $this->send(200, $this->format($story, 'openedBy:user,openedDate:time,assignedTo:user,assignedDate:time,reviewedBy:user,reviewedDate:time,lastEditedBy:user,lastEditedDate:time,closedBy:user,closedDate:time,deleted:bool,mailto:userList')); + } +} diff --git a/api/v1/entries/tabs.php b/api/v1/entries/tabs.php index caf7fa7ae5..71c245e10a 100644 --- a/api/v1/entries/tabs.php +++ b/api/v1/entries/tabs.php @@ -28,6 +28,7 @@ class tabsEntry extends baseEntry foreach($tabs as $menuKey) { + if(!isset($this->lang->my->$menuKey)) continue; if(!common::hasPriv('my', $menuKey)) continue; $label = $this->lang->my->$menuKey; if($menuKey == 'calendar') $label = $this->lang->my->calendarAction; diff --git a/config/config.php b/config/config.php index b6b562c975..6271d1a45d 100644 --- a/config/config.php +++ b/config/config.php @@ -23,7 +23,7 @@ $config->cookieLife = time() + 2592000; // Cookie的生存时间。The co $config->timezone = 'Asia/Shanghai'; // 时区设置。 The time zone setting, for more see http://www.php.net/manual/en/timezones.php. $config->webRoot = ''; // URL根目录。 The root path of the url. $config->customSession = false; // 是否开启自定义session的存储路径。Whether custom the session save path. -$config->edition = 'max'; // 设置系统的edition,可选值:open|biz|max。Set edition, optional: open|biz|max. +$config->edition = 'open'; // 设置系统的edition,可选值:open|biz|max。Set edition, optional: open|biz|max. /* 框架路由相关设置。Routing settings. */ $config->requestType = 'PATH_INFO'; // 请求类型:PATH_INFO|PATHINFO2|GET。 The request type: PATH_INFO|PATH_INFO2|GET. diff --git a/config/routes.php b/config/routes.php index fc96a8da72..5988f71312 100644 --- a/config/routes.php +++ b/config/routes.php @@ -45,6 +45,7 @@ $routes['/projects/:id/stories'] = 'projectStories'; $routes['/executions/:id/stories'] = 'executionStories'; $routes['/stories/:id'] = 'story'; $routes['/stories/:id/change'] = 'storyChange'; +$routes['/stories/:id/close'] = 'storyClose'; $routes['/module/:id/stories'] = 'moduleStories'; diff --git a/module/my/model.php b/module/my/model.php index 21028cfc01..3941377e1e 100644 --- a/module/my/model.php +++ b/module/my/model.php @@ -149,6 +149,7 @@ class myModel extends model } /* Sort by storyCount, get 5 records */ + $products = json_decode(json_encode($products), true); array_multisort(array_column($products, 'storyEstimateCount'), SORT_DESC, $products); $products = array_slice($products, 0, 5); diff --git a/module/story/control.php b/module/story/control.php index 691333d69a..2d83b39c95 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -1343,7 +1343,7 @@ class story extends control if(defined('RUN_MODE') && RUN_MODE == 'api') { - return print(array('status' => 'success', 'data' => $storyID)); + return $this->send(array('status' => 'success', 'data' => $storyID)); } else {