From 2a6f7cbc4ba80861041a27fe99b875ecf29b8b50 Mon Sep 17 00:00:00 2001 From: zhengrunyu Date: Tue, 8 Mar 2022 13:54:52 +0800 Subject: [PATCH 01/31] *fix api. --- api/v1/entries/bug.php | 2 +- framework/api/entry.class.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/api/v1/entries/bug.php b/api/v1/entries/bug.php index 6bc0243f45..f3ae69aeb4 100644 --- a/api/v1/entries/bug.php +++ b/api/v1/entries/bug.php @@ -92,7 +92,7 @@ class bugEntry extends entry $oldBug = $this->loadModel('bug')->getByID($bugID); /* Set $_POST variables. */ - $fields = 'title,project,execution,openedBuild,assignedTo,pri,severity,type,story,resolvedBy,closedBy,resolution,product,plan,task,module,steps'; + $fields = 'title,project,execution,openedBuild,assignedTo,pri,severity,type,story,resolvedBy,closedBy,resolution,product,plan,task,module,steps,mailto'; $this->batchSetPost($fields, $oldBug); $this->setPost('notifyEmail', implode(',', $this->request('notifyEmail', array()))); diff --git a/framework/api/entry.class.php b/framework/api/entry.class.php index a2c6496563..4f4843d83c 100644 --- a/framework/api/entry.class.php +++ b/framework/api/entry.class.php @@ -286,7 +286,20 @@ class baseEntry * 引入该模块的control文件。 * Include the control file of the module. **/ + $file2Included = $app->setActionExtFile() ? $app->extActionFile : $app->controlFile; + + $isExt = $app->setActionExtFile(); + if($isExt) + { + $controlFile = $app->controlFile; + spl_autoload_register(function($class) use ($moduleName, $controlFile) + { + if($class == $moduleName) include $controlFile; + }); + } + + $file2Included = $isExt ? $app->extActionFile : $app->controlFile; chdir(dirname($file2Included)); helper::import($file2Included); } From 2ccf6d9bdc71b6f6531e86b0e8f82619cf1f890d Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Tue, 8 Mar 2022 15:00:06 +0800 Subject: [PATCH 02/31] *Fix error. --- api/v1/entries/task.php | 1 + 1 file changed, 1 insertion(+) diff --git a/api/v1/entries/task.php b/api/v1/entries/task.php index c91060d76f..ad28eb410e 100644 --- a/api/v1/entries/task.php +++ b/api/v1/entries/task.php @@ -109,6 +109,7 @@ class taskEntry extends Entry $control->edit($taskID); $this->getData(); + if($data->status != 'success' and $data->data->result == 'fail') return $this->sendError(zget($data, 'code', 400), $data->data->message); $task = $this->task->getByID($taskID); $this->send(200, $this->format($task, 'deadline:date,openedBy:user,openedDate:time,assignedTo:user,assignedDate:time,realStarted:time,finishedBy:user,finishedDate:time,closedBy:user,closedDate:time,canceledBy:user,canceledDate:time,lastEditedBy:user,lastEditedDate:time,deleted:bool,mailto:userList')); } From fa97a8fcac5638fcd3ccb8a3e868b92764d96ab3 Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Tue, 8 Mar 2022 15:06:10 +0800 Subject: [PATCH 03/31] *Product history. --- api/v1/entries/product.php | 1 + 1 file changed, 1 insertion(+) diff --git a/api/v1/entries/product.php b/api/v1/entries/product.php index cedc89b2a2..1f30423a74 100644 --- a/api/v1/entries/product.php +++ b/api/v1/entries/product.php @@ -54,6 +54,7 @@ class productEntry extends Entry case 'actions': $product->addComment = common::hasPriv('action', 'comment') ? true : false; + $users = $this->loadModel('user')->getPairs(); $actions = $data->data->actions; $product->actions = $this->loadModel('action')->processActionForAPI($actions, $users, $this->lang->product); break; From 203f2921a06b3985e0e467814a812d5bbf7214cb Mon Sep 17 00:00:00 2001 From: zhengrunyu Date: Tue, 8 Mar 2022 15:29:37 +0800 Subject: [PATCH 04/31] *Fix bug. --- api/v1/entries/bugs.php | 2 +- api/v1/entries/executionstories.php | 1 + config/config.php | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/api/v1/entries/bugs.php b/api/v1/entries/bugs.php index 9e6621a61d..fae5a41a41 100644 --- a/api/v1/entries/bugs.php +++ b/api/v1/entries/bugs.php @@ -79,7 +79,7 @@ class bugsEntry extends entry if(!$productID and isset($this->requestBody->product)) $productID = $this->requestBody->product; if(!$productID) return $this->sendError(400, 'Need product id.'); - $fields = 'title,project,execution,openedBuild,assignedTo,pri,severity,type,story'; + $fields = 'title,project,execution,openedBuild,assignedTo,pri,severity,type,story,task'; $this->batchSetPost($fields); $this->setPost('product', $productID); diff --git a/api/v1/entries/executionstories.php b/api/v1/entries/executionstories.php index 4f32cb527c..d2f74e1126 100644 --- a/api/v1/entries/executionstories.php +++ b/api/v1/entries/executionstories.php @@ -34,6 +34,7 @@ class executionStoriesEntry extends entry $result = array(); foreach($stories as $story) { + $story->name =$story->title; $result[] = $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'); } return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'stories' => $result)); diff --git a/config/config.php b/config/config.php index 6271d1a45d..b6b562c975 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 = 'open'; // 设置系统的edition,可选值:open|biz|max。Set edition, optional: open|biz|max. +$config->edition = 'max'; // 设置系统的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. From c309388a68c464dc90710fd8b31883e9efbe7a99 Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Tue, 8 Mar 2022 15:40:05 +0800 Subject: [PATCH 05/31] *Kanban view data. --- module/execution/control.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/module/execution/control.php b/module/execution/control.php index 1189c8047c..fb1ee720b3 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -126,7 +126,7 @@ class execution extends control $execution = $this->commonAction($executionID, $status); $executionID = $execution->id; - if($execution->type == 'kanban' and $this->config->vision != 'lite') $this->locate($this->createLink('execution', 'kanban', "executionID=$executionID")); + if($execution->type == 'kanban' and $this->config->vision != 'lite' and defined('RUN_MODE') and RUN_MODE != 'api') $this->locate($this->createLink('execution', 'kanban', "executionID=$executionID")); /* Get products by execution. */ $products = $this->product->getProductPairsByProject($executionID); @@ -1961,7 +1961,7 @@ class execution extends control { $executionID = $this->execution->saveState((int)$executionID, $this->executions); $execution = $this->execution->getById($executionID, true); - if(empty($execution) || strpos('stage,sprint', $execution->type) === false) return print(js::error($this->lang->notFound) . js::locate('back')); + if(empty($execution) || strpos('stage,sprint', $execution->type) === false and defined('RUN_MODE') and RUN_MODE != 'api') return print(js::error($this->lang->notFound) . js::locate('back')); $this->app->loadLang('program'); From 465d3c64517425ae657202ae56841519742ea1cb Mon Sep 17 00:00:00 2001 From: zhengrunyu Date: Tue, 8 Mar 2022 16:33:46 +0800 Subject: [PATCH 06/31] *Fix bug. --- api/v1/entries/bugs.php | 2 +- api/v1/entries/productplans.php | 1 + api/v1/entries/stories.php | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/api/v1/entries/bugs.php b/api/v1/entries/bugs.php index fae5a41a41..ef00d94398 100644 --- a/api/v1/entries/bugs.php +++ b/api/v1/entries/bugs.php @@ -79,7 +79,7 @@ class bugsEntry extends entry if(!$productID and isset($this->requestBody->product)) $productID = $this->requestBody->product; if(!$productID) return $this->sendError(400, 'Need product id.'); - $fields = 'title,project,execution,openedBuild,assignedTo,pri,severity,type,story,task'; + $fields = 'title,project,execution,openedBuild,assignedTo,pri,severity,type,story,task,mailto,keywords,steps'; $this->batchSetPost($fields); $this->setPost('product', $productID); diff --git a/api/v1/entries/productplans.php b/api/v1/entries/productplans.php index f56cf3ae96..e903903f4c 100644 --- a/api/v1/entries/productplans.php +++ b/api/v1/entries/productplans.php @@ -36,6 +36,7 @@ class productplansEntry extends entry foreach($plans as $plan) { + $plan->name = $plan->title; if($plan->parent > 0 and isset($result[$plan->parent])) { $parentPlan = $result[$plan->parent]; diff --git a/api/v1/entries/stories.php b/api/v1/entries/stories.php index af5333b2bc..fcffda17ca 100644 --- a/api/v1/entries/stories.php +++ b/api/v1/entries/stories.php @@ -35,6 +35,7 @@ class storiesEntry extends entry $result = array(); foreach($stories as $story) { + $story->name =$story->title; if(isset($story->children)) $story->children = array_values((array)$story->children); $result[] = $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'); } From 5118abeaf9fb1b73d41997fb5cdcc35c5bc0cf86 Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Wed, 9 Mar 2022 14:41:01 +0800 Subject: [PATCH 07/31] *Fix API bug. --- api/v1/entries/executioncases.php | 2 +- api/v1/entries/task.php | 4 ++-- api/v1/entries/taskstart.php | 4 ++-- framework/api/entry.class.php | 12 ++++++++++++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/api/v1/entries/executioncases.php b/api/v1/entries/executioncases.php index 8cef23bee0..be10d28b97 100644 --- a/api/v1/entries/executioncases.php +++ b/api/v1/entries/executioncases.php @@ -35,7 +35,7 @@ class executionCasesEntry extends entry $result = array(); foreach($cases as $case) { - $case->statusName = 'name' => $this->lang->testcase->statusList[$case->status]; + $case->statusName = $this->lang->testcase->statusList[$case->status]; $result[] = $this->format($case, 'openedDate:time,reviewedDate:date,lastEditedDate:time,lastRunDate:time'); } diff --git a/api/v1/entries/task.php b/api/v1/entries/task.php index ad28eb410e..3afe36fafd 100644 --- a/api/v1/entries/task.php +++ b/api/v1/entries/task.php @@ -108,8 +108,8 @@ class taskEntry extends Entry $control = $this->loadController('task', 'edit'); $control->edit($taskID); - $this->getData(); - if($data->status != 'success' and $data->data->result == 'fail') return $this->sendError(zget($data, 'code', 400), $data->data->message); + $data = $this->getData(); + if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message); $task = $this->task->getByID($taskID); $this->send(200, $this->format($task, 'deadline:date,openedBy:user,openedDate:time,assignedTo:user,assignedDate:time,realStarted:time,finishedBy:user,finishedDate:time,closedBy:user,closedDate:time,canceledBy:user,canceledDate:time,lastEditedBy:user,lastEditedDate:time,deleted:bool,mailto:userList')); } diff --git a/api/v1/entries/taskstart.php b/api/v1/entries/taskstart.php index cf5adaee15..d21d4bb37a 100644 --- a/api/v1/entries/taskstart.php +++ b/api/v1/entries/taskstart.php @@ -22,7 +22,7 @@ class taskStartEntry extends Entry { $task = $this->loadModel('task')->getByID($taskID); - $fields = 'assignedTo,realStarted,comment,left'; + $fields = 'assignedTo,realStarted,consumed,left,comment'; $this->batchSetPost($fields); $control = $this->loadController('task', 'start'); @@ -30,7 +30,7 @@ class taskStartEntry extends Entry $control->start($taskID); $data = $this->getData(); - if(!$data or !isset($data->status)) return $this->send400('error'); + if(!$data) return $this->send400('error'); if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message); $task = $this->loadModel('task')->getByID($taskID); diff --git a/framework/api/entry.class.php b/framework/api/entry.class.php index 4f4843d83c..6ae1237f45 100644 --- a/framework/api/entry.class.php +++ b/framework/api/entry.class.php @@ -246,6 +246,18 @@ class baseEntry $this->send($code, $response); } + /** + * Send 400 response. + * + * @param string message + * @access public + * @return void + */ + public function send400($message = 'error') + { + $this->sendError(400, $message); + } + /** * Send 404 response. * From c2b8e2431cbc249dbe099f670deccb5408f7e461 Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Thu, 10 Mar 2022 15:33:38 +0800 Subject: [PATCH 08/31] *Finish task. --- api/v1/entries/taskfinish.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/v1/entries/taskfinish.php b/api/v1/entries/taskfinish.php index 28de8ae47e..2c12a46cc6 100644 --- a/api/v1/entries/taskfinish.php +++ b/api/v1/entries/taskfinish.php @@ -36,7 +36,7 @@ class taskFinishEntry extends Entry $control->finish($taskID); $data = $this->getData(); - if(!$data or !isset($data->status)) return $this->send400('error'); + if(!$data) return $this->send400('error'); if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message); $task = $this->loadModel('task')->getByID($taskID); From 5f7f4bc37c78b349062d0ba62eafcc9580d8caf0 Mon Sep 17 00:00:00 2001 From: zhengrunyu Date: Thu, 10 Mar 2022 15:54:55 +0800 Subject: [PATCH 09/31] *Fix API --- api/v1/entries/bug.php | 2 +- api/v1/entries/stories.php | 2 +- api/v1/entries/story.php | 9 +++++++-- config/config.php | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/api/v1/entries/bug.php b/api/v1/entries/bug.php index f3ae69aeb4..7146d2d879 100644 --- a/api/v1/entries/bug.php +++ b/api/v1/entries/bug.php @@ -92,7 +92,7 @@ class bugEntry extends entry $oldBug = $this->loadModel('bug')->getByID($bugID); /* Set $_POST variables. */ - $fields = 'title,project,execution,openedBuild,assignedTo,pri,severity,type,story,resolvedBy,closedBy,resolution,product,plan,task,module,steps,mailto'; + $fields = 'title,project,execution,openedBuild,assignedTo,pri,severity,type,story,resolvedBy,closedBy,resolution,product,plan,task,module,steps,mailto,keywords'; $this->batchSetPost($fields, $oldBug); $this->setPost('notifyEmail', implode(',', $this->request('notifyEmail', array()))); diff --git a/api/v1/entries/stories.php b/api/v1/entries/stories.php index fcffda17ca..863888aa3f 100644 --- a/api/v1/entries/stories.php +++ b/api/v1/entries/stories.php @@ -55,7 +55,7 @@ class storiesEntry extends entry if(!$productID and isset($this->requestBody->product)) $productID = $this->requestBody->product; if(!$productID) return $this->sendError(400, 'Need product id.'); - $fields = 'title,spec,verify,reviewer,type,plan,module,source,sourceNote,category,pri,estimate'; + $fields = 'title,spec,verify,reviewer,type,plan,module,source,sourceNote,category,pri,estimate,mailto,keywords'; $this->batchSetPost($fields); /* If reviewer is not post, set needNotReview. */ diff --git a/api/v1/entries/story.php b/api/v1/entries/story.php index b9ed92df75..a22703a461 100644 --- a/api/v1/entries/story.php +++ b/api/v1/entries/story.php @@ -95,14 +95,19 @@ class storyEntry extends Entry $oldStory = $this->loadModel('story')->getByID($storyID); /* Set $_POST variables. */ - $fields = 'type'; + $fields = 'title,reviewer,type,plan,module,source,sourceNote,category,pri,estimate,mailto,keywords'; $this->batchSetPost($fields, $oldStory); $this->setPost('parent', 0); $control = $this->loadController('story', 'edit'); $control->edit($storyID); - $this->getData(); + + $data = $this->getData(); + + if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message); + if(!isset($data->status)) return $this->sendError(400, 'error'); + $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/config/config.php b/config/config.php index 6271d1a45d..b6b562c975 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 = 'open'; // 设置系统的edition,可选值:open|biz|max。Set edition, optional: open|biz|max. +$config->edition = 'max'; // 设置系统的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. From bdfecb629d1929580d7154a44ae8f76290c65487 Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Fri, 11 Mar 2022 11:07:29 +0800 Subject: [PATCH 10/31] *Fix pri bug. --- api/v1/entries/task.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/v1/entries/task.php b/api/v1/entries/task.php index 3afe36fafd..7bce68f0bf 100644 --- a/api/v1/entries/task.php +++ b/api/v1/entries/task.php @@ -102,7 +102,7 @@ class taskEntry extends Entry $oldTask = $this->loadModel('task')->getByID($taskID); /* Set $_POST variables. */ - $fields = 'name,type,assignedTo,estimate,left,consumed,story,parent,execution,module,closedReason,status,estStarted,deadline'; + $fields = 'name,type,assignedTo,pri,estimate,left,consumed,story,parent,execution,module,closedReason,status,estStarted,deadline'; $this->batchSetPost($fields, $oldTask); $control = $this->loadController('task', 'edit'); From 16238b2adfbcf2f0d5bc7e0ac265745844e2d57c Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Fri, 11 Mar 2022 11:09:32 +0800 Subject: [PATCH 11/31] *Open. --- config/config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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. From 296060a91acfcdf0815d6c831b760192cedbe418 Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Fri, 11 Mar 2022 13:26:12 +0800 Subject: [PATCH 12/31] *Fix team bug. --- api/v1/entries/task.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/v1/entries/task.php b/api/v1/entries/task.php index 7bce68f0bf..b30eba505b 100644 --- a/api/v1/entries/task.php +++ b/api/v1/entries/task.php @@ -102,7 +102,7 @@ class taskEntry extends Entry $oldTask = $this->loadModel('task')->getByID($taskID); /* Set $_POST variables. */ - $fields = 'name,type,assignedTo,pri,estimate,left,consumed,story,parent,execution,module,closedReason,status,estStarted,deadline'; + $fields = 'name,type,assignedTo,pri,estimate,left,consumed,story,parent,execution,module,closedReason,status,estStarted,deadline,team,teamEstimate,multiple'; $this->batchSetPost($fields, $oldTask); $control = $this->loadController('task', 'edit'); From 255ef2ff7c80656e556cc1693c2e72e2f0c90019 Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Mon, 14 Mar 2022 09:45:16 +0800 Subject: [PATCH 13/31] *ExecutionMembers API. --- config/routes.php | 1 + 1 file changed, 1 insertion(+) diff --git a/config/routes.php b/config/routes.php index c47cd483aa..b6073b28fd 100644 --- a/config/routes.php +++ b/config/routes.php @@ -95,6 +95,7 @@ $routes['/builds/:id'] = 'build'; $routes['/products/:id/testcases'] = 'testcases'; $routes['/projects/:id/testcases'] = 'projectCases'; $routes['/executions/:id/testcases'] = 'executionCases'; +$routes['/executions/:id/members'] = 'executionMembers'; $routes['/testcases'] = 'testcases'; $routes['/testcases/:id'] = 'testcase'; From a8cb135c46e97b219dc14c886c300379e652e0ce Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Mon, 14 Mar 2022 09:46:28 +0800 Subject: [PATCH 14/31] *ExecutionMembers API. --- api/v1/entries/executionmembers.php | 25 +++++++++++++++++++++++++ api/v1/entries/task.php | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 api/v1/entries/executionmembers.php diff --git a/api/v1/entries/executionmembers.php b/api/v1/entries/executionmembers.php new file mode 100644 index 0000000000..6b7a680b93 --- /dev/null +++ b/api/v1/entries/executionmembers.php @@ -0,0 +1,25 @@ + + * @package entries + * @version 1 + * @link http://www.zentao.net + */ +class executionMembersEntry extends entry +{ + public function get($executionID = 0) + { + if(!$executionID) $executionID = $this->param('execution', 0); + if(empty($executionID)) return $this->sendError(400, 'Need execution id.'); + $members = $this->loadModel('execution')->getTeamMembers($executionID); + if(isset($members)) + { + foreach($members as $member) $result[] = $this->format($member, 'join:date'); + } + return $this->send(200, array('members' => $result)); + } +} diff --git a/api/v1/entries/task.php b/api/v1/entries/task.php index b30eba505b..9611ce7f28 100644 --- a/api/v1/entries/task.php +++ b/api/v1/entries/task.php @@ -102,7 +102,7 @@ class taskEntry extends Entry $oldTask = $this->loadModel('task')->getByID($taskID); /* Set $_POST variables. */ - $fields = 'name,type,assignedTo,pri,estimate,left,consumed,story,parent,execution,module,closedReason,status,estStarted,deadline,team,teamEstimate,multiple'; + $fields = 'name,type,desc,assignedTo,pri,estimate,left,consumed,story,parent,execution,module,closedReason,status,estStarted,deadline,team,teamEstimate,multiple'; $this->batchSetPost($fields, $oldTask); $control = $this->loadController('task', 'edit'); From f7233bc22899c43d61d864b5cc4a67731764df86 Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Mon, 14 Mar 2022 11:17:34 +0800 Subject: [PATCH 15/31] *Fix mailto edit bug. --- api/v1/entries/task.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/v1/entries/task.php b/api/v1/entries/task.php index 9611ce7f28..b06bd8f677 100644 --- a/api/v1/entries/task.php +++ b/api/v1/entries/task.php @@ -102,7 +102,7 @@ class taskEntry extends Entry $oldTask = $this->loadModel('task')->getByID($taskID); /* Set $_POST variables. */ - $fields = 'name,type,desc,assignedTo,pri,estimate,left,consumed,story,parent,execution,module,closedReason,status,estStarted,deadline,team,teamEstimate,multiple'; + $fields = 'name,type,desc,assignedTo,pri,estimate,left,consumed,story,parent,execution,module,closedReason,status,estStarted,deadline,team,teamEstimate,multiple,mailto'; $this->batchSetPost($fields, $oldTask); $control = $this->loadController('task', 'edit'); From fa09f6349e6f656f84fcb277f0ebd3e852fb36f2 Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Mon, 14 Mar 2022 16:19:56 +0800 Subject: [PATCH 16/31] *Get the execution stories under the module API. --- api/v1/entries/modulestories.php | 33 ++++++++++++++++++++++++++++++++ config/routes.php | 2 ++ 2 files changed, 35 insertions(+) create mode 100644 api/v1/entries/modulestories.php diff --git a/api/v1/entries/modulestories.php b/api/v1/entries/modulestories.php new file mode 100644 index 0000000000..ce2c95fa5d --- /dev/null +++ b/api/v1/entries/modulestories.php @@ -0,0 +1,33 @@ + + * @package entries + * @version 1 + * @link http://www.zentao.net + */ +class moduleStoriesEntry extends Entry +{ + public function get($moduleID) + { + $executionID = $this->param('executionID', 0); + if(!$executionID) $executionID = $this->param('executionID', 0); + if(empty($executionID)) return $this->sendError(400, 'Need execution id.'); + $control = $this->loadController('story', 'ajaxGetExecutionStories'); + $control->ajaxGetExecutionStories($executionID, $this->param('productID', 0), $this->param('branchID', 0), $moduleID); + + $data = $this->getData(); + $this->loadModel('story'); + $result = []; + foreach($data as $storyID => $storyName) + { + if(empty($storyID)) continue; + $story = $this->story->getById($storyID); + $result[] = $this->filterFields($story, 'id,title,module,pri,status,stage,estimate'); + } + return $this->send(200, array('stories' => $result)); + } +} diff --git a/config/routes.php b/config/routes.php index b6073b28fd..f7b8dba007 100644 --- a/config/routes.php +++ b/config/routes.php @@ -46,6 +46,8 @@ $routes['/executions/:id/stories'] = 'executionStories'; $routes['/stories/:id'] = 'story'; $routes['/stories/:id/change'] = 'storyChange'; +$routes['/module/:id/stories'] = 'moduleStories'; + $routes['/products/:id/bugs'] = 'bugs'; $routes['/projects/:id/bugs'] = 'projectBugs'; $routes['/executions/:id/bugs'] = 'executionBugs'; From 5b9270737016a2874d7f7182c4d6666b63bb8d11 Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Mon, 14 Mar 2022 17:00:41 +0800 Subject: [PATCH 17/31] *Pause a task. --- api/v1/entries/modulestories.php | 3 +-- api/v1/entries/taskpause.php | 39 ++++++++++++++++++++++++++++++++ config/routes.php | 2 ++ 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 api/v1/entries/taskpause.php diff --git a/api/v1/entries/modulestories.php b/api/v1/entries/modulestories.php index ce2c95fa5d..03a29b2f2f 100644 --- a/api/v1/entries/modulestories.php +++ b/api/v1/entries/modulestories.php @@ -1,6 +1,6 @@ param('executionID', 0); - if(!$executionID) $executionID = $this->param('executionID', 0); if(empty($executionID)) return $this->sendError(400, 'Need execution id.'); $control = $this->loadController('story', 'ajaxGetExecutionStories'); $control->ajaxGetExecutionStories($executionID, $this->param('productID', 0), $this->param('branchID', 0), $moduleID); diff --git a/api/v1/entries/taskpause.php b/api/v1/entries/taskpause.php new file mode 100644 index 0000000000..7548fa25e0 --- /dev/null +++ b/api/v1/entries/taskpause.php @@ -0,0 +1,39 @@ + + * @package entries + * @version 1 + * @link http://www.zentao.net + */ +class taskPauseEntry extends Entry +{ + /** + * POST method. + * + * @param int $taskID + * @access public + * @return void + */ + public function post($taskID) + { + $task = $this->loadModel('task')->getByID($taskID); + + $fields = 'comment'; + $this->batchSetPost($fields); + + $control = $this->loadController('task', 'pause'); + $control->pause($taskID); + + $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); + + $task = $this->loadModel('task')->getByID($taskID); + + $this->send(200, $task); + } +} diff --git a/config/routes.php b/config/routes.php index f7b8dba007..95da122a32 100644 --- a/config/routes.php +++ b/config/routes.php @@ -68,7 +68,9 @@ $routes['/tasks'] = 'tasks'; $routes['/tasks/:id'] = 'task'; $routes['/tasks/:id/assignto'] = 'taskAssignTo'; $routes['/tasks/:id/start'] = 'taskStart'; +$routes['/tasks/:id/pause'] = 'taskPause'; $routes['/tasks/:id/finish'] = 'taskFinish'; +$routes['/tasks/:id/close'] = 'taskClose'; $routes['/users'] = 'users'; $routes['/users/:id'] = 'user'; From 08c284054bc5c87e7438efdfe140cd2f3e6cdcf6 Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Tue, 15 Mar 2022 08:21:32 +0800 Subject: [PATCH 18/31] *Close a task. --- api/v1/entries/taskclose.php | 39 ++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 api/v1/entries/taskclose.php diff --git a/api/v1/entries/taskclose.php b/api/v1/entries/taskclose.php new file mode 100644 index 0000000000..774c115c53 --- /dev/null +++ b/api/v1/entries/taskclose.php @@ -0,0 +1,39 @@ + + * @package entries + * @version 1 + * @link http://www.zentao.net + */ +class taskCloseEntry extends Entry +{ + /** + * POST method. + * + * @param int $taskID + * @access public + * @return void + */ + public function post($taskID) + { + $task = $this->loadModel('task')->getByID($taskID); + + $fields = 'comment'; + $this->batchSetPost($fields); + + $control = $this->loadController('task', 'close'); + $control->close($taskID); + + $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); + + $task = $this->loadModel('task')->getByID($taskID); + + $this->send(200, $task); + } +} From e6287a4d682a23500d31ae10c5cb59704a741b85 Mon Sep 17 00:00:00 2001 From: zhengrunyu Date: Tue, 15 Mar 2022 16:12:56 +0800 Subject: [PATCH 19/31] * Fix bug. --- api/v1/entries/builds.php | 1 - api/v1/entries/stories.php | 2 +- api/v1/entries/story.php | 2 +- config/config.php | 2 +- 4 files changed, 3 insertions(+), 4 deletions(-) diff --git a/api/v1/entries/builds.php b/api/v1/entries/builds.php index e303c9a4e1..3709a0463c 100644 --- a/api/v1/entries/builds.php +++ b/api/v1/entries/builds.php @@ -21,7 +21,6 @@ class buildsEntry extends entry public function get($projectID = 0) { if(empty($projectID)) $projectID = $this->param('project', 0); - if(empty($projectID)) return $this->sendError(400, "Need project id."); $control = $this->loadController('project', 'build'); $control->build($projectID, $this->param('type', 'all'), $this->param('param', 0), $this->param('order', 't1.date_desc,t1.id_desc')); diff --git a/api/v1/entries/stories.php b/api/v1/entries/stories.php index 863888aa3f..165c27f2ef 100644 --- a/api/v1/entries/stories.php +++ b/api/v1/entries/stories.php @@ -55,7 +55,7 @@ class storiesEntry extends entry if(!$productID and isset($this->requestBody->product)) $productID = $this->requestBody->product; if(!$productID) return $this->sendError(400, 'Need product id.'); - $fields = 'title,spec,verify,reviewer,type,plan,module,source,sourceNote,category,pri,estimate,mailto,keywords'; + $fields = 'title,spec,verify,reviewer,type,assignedTo,plan,module,source,sourceNote,category,pri,estimate,mailto,keywords'; $this->batchSetPost($fields); /* If reviewer is not post, set needNotReview. */ diff --git a/api/v1/entries/story.php b/api/v1/entries/story.php index a22703a461..77889a3dbc 100644 --- a/api/v1/entries/story.php +++ b/api/v1/entries/story.php @@ -95,7 +95,7 @@ class storyEntry extends Entry $oldStory = $this->loadModel('story')->getByID($storyID); /* Set $_POST variables. */ - $fields = 'title,reviewer,type,plan,module,source,sourceNote,category,pri,estimate,mailto,keywords'; + $fields = 'title,product,reviewer,type,plan,module,source,sourceNote,category,pri,estimate,mailto,keywords'; $this->batchSetPost($fields, $oldStory); $this->setPost('parent', 0); diff --git a/config/config.php b/config/config.php index 6271d1a45d..b6b562c975 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 = 'open'; // 设置系统的edition,可选值:open|biz|max。Set edition, optional: open|biz|max. +$config->edition = 'max'; // 设置系统的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. From 459ccd36202398f1b1088f66d88782a5b35d1a8d Mon Sep 17 00:00:00 2001 From: zhengrunyu Date: Wed, 16 Mar 2022 09:01:13 +0800 Subject: [PATCH 20/31] * Fix bug. --- api/v1/entries/product.php | 3 +++ api/v1/entries/stories.php | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/api/v1/entries/product.php b/api/v1/entries/product.php index 1f30423a74..90b70743c9 100644 --- a/api/v1/entries/product.php +++ b/api/v1/entries/product.php @@ -51,6 +51,9 @@ class productEntry extends Entry $product->modules = $data->data->tree; } break; + case 'moduleoptionmenu': + $product->moduleOptionMenu = $this->loadModel('tree')->getOptionMenu($productID, 'bug', 0, 'all'); + break; case 'actions': $product->addComment = common::hasPriv('action', 'comment') ? true : false; diff --git a/api/v1/entries/stories.php b/api/v1/entries/stories.php index 165c27f2ef..d92f3ddd6e 100644 --- a/api/v1/entries/stories.php +++ b/api/v1/entries/stories.php @@ -55,7 +55,7 @@ class storiesEntry extends entry if(!$productID and isset($this->requestBody->product)) $productID = $this->requestBody->product; if(!$productID) return $this->sendError(400, 'Need product id.'); - $fields = 'title,spec,verify,reviewer,type,assignedTo,plan,module,source,sourceNote,category,pri,estimate,mailto,keywords'; + $fields = 'title,spec,verify,reviewer,type,plan,module,moduleOptionMenu,source,sourceNote,category,pri,estimate,mailto,keywords'; $this->batchSetPost($fields); /* If reviewer is not post, set needNotReview. */ From 956933c4a18002fc71628bf37ac93537436c900d Mon Sep 17 00:00:00 2001 From: zhengrunyu Date: Wed, 16 Mar 2022 09:29:05 +0800 Subject: [PATCH 21/31] * fix bug. --- api/v1/entries/product.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/v1/entries/product.php b/api/v1/entries/product.php index 90b70743c9..effecc6a9a 100644 --- a/api/v1/entries/product.php +++ b/api/v1/entries/product.php @@ -54,6 +54,9 @@ class productEntry extends Entry case 'moduleoptionmenu': $product->moduleOptionMenu = $this->loadModel('tree')->getOptionMenu($productID, 'bug', 0, 'all'); break; + case 'builds': + $product->builds = $this->loadModel('build')->getBuildPairs($productID, 'all', 'noempty,noterminate,nodone,withbranch'); + break; case 'actions': $product->addComment = common::hasPriv('action', 'comment') ? true : false; From ca8de6eea26ede859aa27627ef12711f3806204c Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Wed, 16 Mar 2022 15:15:31 +0800 Subject: [PATCH 22/31] *Create a children task. --- api/v1/entries/taskcomponent.php | 45 ++++++++++++++++++++++++++++++++ config/routes.php | 1 + 2 files changed, 46 insertions(+) create mode 100644 api/v1/entries/taskcomponent.php diff --git a/api/v1/entries/taskcomponent.php b/api/v1/entries/taskcomponent.php new file mode 100644 index 0000000000..6921b7e5b1 --- /dev/null +++ b/api/v1/entries/taskcomponent.php @@ -0,0 +1,45 @@ + + * @package entries + * @version 1 + * @link http://www.zentao.net + */ +class taskComponentEntry extends Entry +{ + /** + * POST method. + * + * @param int $taskID + * @access public + * @return void + */ + public function post($taskID) + { + $fields = 'name,type,assignedTo,parent,estimate,story,module,pri,desc,estStarted,deadline'; + $this->batchSetPost($fields); + + $fields = explode(',', $fields); + foreach($fields as $field) $this->setArrayPost($field); + $task = $this->loadModel('task')->getById($taskID); + + $control = $this->loadController('task', 'batchCreate'); + $control->batchCreate($task->execution, 0, 0, $taskID); + + $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); + + $task = $this->task->getById($data->idList[0]); + $this->send(200, $this->format($task, 'deadline:date,openedBy:user,openedDate:time,assignedTo:user,assignedDate:time,realStarted:time,finishedBy:user,finishedDate:time,closedBy:user,closedDate:time,canceledBy:user,canceledDate:time,lastEditedBy:user,lastEditedDate:time,deleted:bool,mailto:userList')); + } + + public function setArrayPost($field) + { + $_POST[$field] = array('0' => $_POST[$field]); + } +} diff --git a/config/routes.php b/config/routes.php index 95da122a32..fc96a8da72 100644 --- a/config/routes.php +++ b/config/routes.php @@ -66,6 +66,7 @@ $routes['/executions/:id'] = 'execution'; $routes['/executions/:id/tasks'] = 'tasks'; $routes['/tasks'] = 'tasks'; $routes['/tasks/:id'] = 'task'; +$routes['/tasks/:id/component'] = 'taskComponent'; $routes['/tasks/:id/assignto'] = 'taskAssignTo'; $routes['/tasks/:id/start'] = 'taskStart'; $routes['/tasks/:id/pause'] = 'taskPause'; From ed6e82f02f6eef07886547f5ade3c0d9198896ef Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Thu, 17 Mar 2022 10:11:35 +0800 Subject: [PATCH 23/31] *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 { From 500daec39d37e90a3c537f57445f0b12d1580d67 Mon Sep 17 00:00:00 2001 From: zhengrunyu Date: Thu, 17 Mar 2022 10:30:30 +0800 Subject: [PATCH 24/31] *Add API for active story. --- api/v1/entries/execution.php | 13 ++++--------- config/routes.php | 1 + 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/api/v1/entries/execution.php b/api/v1/entries/execution.php index 00ae8b68c7..306d6f374b 100644 --- a/api/v1/entries/execution.php +++ b/api/v1/entries/execution.php @@ -20,7 +20,8 @@ class executionEntry extends Entry */ public function get($executionID) { - $fields = $this->param('fields'); + $fields = $this->param('fields'); + $productID = $this->param('productID'); $control = $this->loadController('execution', 'view'); $control->view($executionID); @@ -63,14 +64,8 @@ class executionEntry extends Entry { switch($field) { - case 'modules': - $control = $this->loadController('tree', 'browsetask'); - $control->browsetask($executionID); - $data = $this->getData(); - if(isset($data->status) and $data->status == 'success') - { - $execution->modules = $data->data->tree; - } + case 'builds': + $execution->builds = $this->loadModel('build')->getBuildPairs($productID, 'all', 'noempty,noterminate,nodone', $executionID, 'execution'); break; case 'moduleoptionmenu': $execution->moduleOptionMenu = $this->loadModel('tree')->getTaskOptionMenu($executionID, 0, 0, 'allModule'); diff --git a/config/routes.php b/config/routes.php index fc96a8da72..f43e6b8e20 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/active'] = 'storyActive'; $routes['/module/:id/stories'] = 'moduleStories'; From b39a4fedee0a5bd84710142c2c1d309c9bbfa26d Mon Sep 17 00:00:00 2001 From: zhengrunyu Date: Thu, 17 Mar 2022 10:37:54 +0800 Subject: [PATCH 25/31] * Fix api. --- config/routes.php | 1 + 1 file changed, 1 insertion(+) diff --git a/config/routes.php b/config/routes.php index f43e6b8e20..6f47d9981b 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/active'] = 'storyActive'; $routes['/module/:id/stories'] = 'moduleStories'; From c3f4bda24e3ffed8704d9330daaa93adb2f0790c Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Thu, 17 Mar 2022 13:33:17 +0800 Subject: [PATCH 26/31] *Assign a story. --- api/v1/entries/storyactive.php | 42 ++++++++++++++++++++++++++++++++++ config/routes.php | 4 +++- 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 api/v1/entries/storyactive.php diff --git a/api/v1/entries/storyactive.php b/api/v1/entries/storyactive.php new file mode 100644 index 0000000000..cfaf4145bd --- /dev/null +++ b/api/v1/entries/storyactive.php @@ -0,0 +1,42 @@ + + * @package entries + * @version 1 + * @link http://www.zentao.net + **/ + +class storyActiveEntry extends Entry +{ + /** + * POST method. + * + * @param int $storyID + * @access public + * @return void + */ + public function put($storyID) + { + $oldStory = $this->loadModel('story')->getByID($storyID); + + $fields = 'assignedTo,status,comment'; + $this->batchSetPost($fields); + + $control = $this->loadController('story', 'activate'); + + $control->activate($storyID); + + $data = $this->getData(); + if(!$data or !isset($data->status)) return $this->send400('error'); + if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message); + + $story = $this->loadModel('story')->getByID($storyID); + + $this->send(200, $story); + } +} + diff --git a/config/routes.php b/config/routes.php index 2dc12543fc..d6d381440a 100644 --- a/config/routes.php +++ b/config/routes.php @@ -47,7 +47,9 @@ $routes['/stories/:id'] = 'story'; $routes['/stories/:id/change'] = 'storyChange'; $routes['/stories/:id/close'] = 'storyClose'; -$routes['/stories/:id/active'] = 'storyActive'; + + +$routes['/stories/:id/assign'] = 'storyAssignto'; $routes['/module/:id/stories'] = 'moduleStories'; From e0df7d3c1c6716307554c4301e51f5c03ffb4a2b Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Thu, 17 Mar 2022 13:49:09 +0800 Subject: [PATCH 27/31] *Add routes. --- config/routes.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/config/routes.php b/config/routes.php index d6d381440a..ceedddcfd4 100644 --- a/config/routes.php +++ b/config/routes.php @@ -46,9 +46,7 @@ $routes['/executions/:id/stories'] = 'executionStories'; $routes['/stories/:id'] = 'story'; $routes['/stories/:id/change'] = 'storyChange'; $routes['/stories/:id/close'] = 'storyClose'; - - - +$routes['/stories/:id/active'] = 'storyActive'; $routes['/stories/:id/assign'] = 'storyAssignto'; $routes['/module/:id/stories'] = 'moduleStories'; From b6e6ecf4f278746d29480d5a66847ac510722ce7 Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Fri, 18 Mar 2022 09:39:47 +0800 Subject: [PATCH 28/31] *Record task estimate. --- api/v1/entries/storyrecordestimate.php | 39 ++++++++++++++++++++++ api/v1/entries/taskrecordestimate.php | 45 ++++++++++++++++++++++++++ config/routes.php | 38 +++++++++++----------- 3 files changed, 104 insertions(+), 18 deletions(-) create mode 100644 api/v1/entries/storyrecordestimate.php create mode 100644 api/v1/entries/taskrecordestimate.php diff --git a/api/v1/entries/storyrecordestimate.php b/api/v1/entries/storyrecordestimate.php new file mode 100644 index 0000000000..389ede8726 --- /dev/null +++ b/api/v1/entries/storyrecordestimate.php @@ -0,0 +1,39 @@ + + * @package entries + * @version 1 + * @link http://www.zentao.net + */ +class storyRecordEstimateEntry 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/taskrecordestimate.php b/api/v1/entries/taskrecordestimate.php new file mode 100644 index 0000000000..178452030c --- /dev/null +++ b/api/v1/entries/taskrecordestimate.php @@ -0,0 +1,45 @@ + + * @package entries + * @version 1 + * @link http://www.zentao.net + */ +class taskRecordEstimateEntry extends Entry +{ + /** + * POST method. + * + * @param int $taskID + * @access public + * @return void + */ + public function post($taskID) + { + if($this->config->edition != 'open') + { + $fields = 'id,dates,consumed,left,objectType,objectID,work'; + $this->batchSetPost($fields); + $control = $this->loadController('effort', 'createForObject'); + $control->createForObject('task', $taskID); + } + else + { + $fields = 'id,dates,consumed,left,work'; + $this->batchSetPost($fields); + $control = $this->loadController('task', 'recordEstimate'); + $control->recordEstimate($taskID); + } + + $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); + + $task = $this->loadModel('task')->getById($taskID); + $this->send(200, $this->format($task, 'deadline:date,openedBy:user,openedDate:time,assignedTo:user,assignedDate:time,realStarted:time,finishedBy:user,finishedDate:time,closedBy:user,closedDate:time,canceledBy:user,canceledDate:time,lastEditedBy:user,lastEditedDate:time,deleted:bool,mailto:userList')); + } +} diff --git a/config/routes.php b/config/routes.php index ceedddcfd4..6f7c828f0b 100644 --- a/config/routes.php +++ b/config/routes.php @@ -39,15 +39,16 @@ $routes['/products/:id/releases'] = 'releases'; $routes['/projects/:id/releases'] = 'projectReleases'; $routes['/releases/:id'] = 'release'; -$routes['/stories'] = 'stories'; -$routes['/products/:id/stories'] = 'stories'; -$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['/stories/:id/active'] = 'storyActive'; -$routes['/stories/:id/assign'] = 'storyAssignto'; +$routes['/stories'] = 'stories'; +$routes['/products/:id/stories'] = 'stories'; +$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['/stories/:id/active'] = 'storyActive'; +$routes['/stories/:id/assign'] = 'storyAssignto'; +$routes['/stories/:id/recordEstimate'] = 'storyRecordEstimate'; $routes['/module/:id/stories'] = 'moduleStories'; @@ -66,15 +67,16 @@ $routes['/projects/:id/executions'] = 'executions'; $routes['/executions'] = 'executions'; $routes['/executions/:id'] = 'execution'; -$routes['/executions/:id/tasks'] = 'tasks'; -$routes['/tasks'] = 'tasks'; -$routes['/tasks/:id'] = 'task'; -$routes['/tasks/:id/component'] = 'taskComponent'; -$routes['/tasks/:id/assignto'] = 'taskAssignTo'; -$routes['/tasks/:id/start'] = 'taskStart'; -$routes['/tasks/:id/pause'] = 'taskPause'; -$routes['/tasks/:id/finish'] = 'taskFinish'; -$routes['/tasks/:id/close'] = 'taskClose'; +$routes['/executions/:id/tasks'] = 'tasks'; +$routes['/tasks'] = 'tasks'; +$routes['/tasks/:id'] = 'task'; +$routes['/tasks/:id/component'] = 'taskComponent'; +$routes['/tasks/:id/assignto'] = 'taskAssignTo'; +$routes['/tasks/:id/start'] = 'taskStart'; +$routes['/tasks/:id/pause'] = 'taskPause'; +$routes['/tasks/:id/finish'] = 'taskFinish'; +$routes['/tasks/:id/close'] = 'taskClose'; +$routes['/tasks/:id/recordEstimate'] = 'taskRecordEstimate'; $routes['/users'] = 'users'; $routes['/users/:id'] = 'user'; From e5e54bb0f1054ff88a41c47d4a825a631c085f4a Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Fri, 18 Mar 2022 09:43:19 +0800 Subject: [PATCH 29/31] *Change a story. --- api/v1/entries/storychange.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/api/v1/entries/storychange.php b/api/v1/entries/storychange.php index 67f5102eb4..174ec4620f 100644 --- a/api/v1/entries/storychange.php +++ b/api/v1/entries/storychange.php @@ -35,7 +35,7 @@ class storyChangeEntry extends Entry } $control = $this->loadController('story', 'change'); - $this->requireFields('title,spec,verify'); + $this->requireFields('title'); $control->change($storyID); From 96f9a0819669495745a9d48eb58aa8a3cf7566d1 Mon Sep 17 00:00:00 2001 From: zhengrunyu Date: Fri, 18 Mar 2022 13:15:31 +0800 Subject: [PATCH 30/31] *Add api for child story. --- api/v1/entries/storychild.php | 44 +++++++++++++++++++++++++++++++++++ config/routes.php | 1 + 2 files changed, 45 insertions(+) create mode 100644 api/v1/entries/storychild.php diff --git a/api/v1/entries/storychild.php b/api/v1/entries/storychild.php new file mode 100644 index 0000000000..0c9a292663 --- /dev/null +++ b/api/v1/entries/storychild.php @@ -0,0 +1,44 @@ + + * @package entries + * @version 1 + * @link http://www.zentao.net + **/ +class storyChildEntry extends Entry +{ + /** + * POST method. + * + * @param int $storyID + * @access public + * @return void + **/ + public function post($storyID) + { + $fields = 'title,spec,verify,reviewer,type,plan,module,moduleOptionMenu,source,sourceNote,category,pri,estimate,keywords,parent'; + $this->batchSetPost($fields); + + $fields = explode(',', $fields); + foreach($fields as $field) $this->setArrayPost($field); + $story = $this->loadModel('story')->getById($storyID); + + $control = $this->loadController('story', 'batchCreate'); + $control->batchCreate($story->product, 0, 0, $storyID); + + $data = $this->getData(); + + $story = $this->story->getById($data->idList[0]); + $this->send(200, $this->format($story, 'deadline:date,openedBy:user,openedDate:time,assignedTo:user,assignedDate:time,realStarted:time,finishedBy:user,finishedDate:time,closedBy:user,closedDate:time,canceledBy:user,canceledDate:time,lastEditedBy:user,lastEditedDate:time,deleted:bool,mailto:userList')); + } + + public function setArrayPost($field) + { + $_POST[$field] = array('0' => $_POST[$field]); + } +} + diff --git a/config/routes.php b/config/routes.php index 6f7c828f0b..7fa774b5af 100644 --- a/config/routes.php +++ b/config/routes.php @@ -49,6 +49,7 @@ $routes['/stories/:id/close'] = 'storyClose'; $routes['/stories/:id/active'] = 'storyActive'; $routes['/stories/:id/assign'] = 'storyAssignto'; $routes['/stories/:id/recordEstimate'] = 'storyRecordEstimate'; +$routes['/stories/:id/child'] = 'storyChild'; $routes['/module/:id/stories'] = 'moduleStories'; From 84a7e1ad4ce82c6ff7c1d2cf9e07256ae15412ed Mon Sep 17 00:00:00 2001 From: songchenxuan Date: Fri, 18 Mar 2022 14:14:10 +0800 Subject: [PATCH 31/31] *PUT->POST. --- api/v1/entries/storyactive.php | 8 +++--- api/v1/entries/storyassignto.php | 4 +-- api/v1/entries/storyclose.php | 4 +-- api/v1/entries/storyrecordestimate.php | 39 -------------------------- api/v1/entries/taskclose.php | 4 +-- api/v1/entries/taskfinish.php | 4 +-- api/v1/entries/taskpause.php | 4 +-- api/v1/entries/taskstart.php | 4 +-- 8 files changed, 16 insertions(+), 55 deletions(-) delete mode 100644 api/v1/entries/storyrecordestimate.php diff --git a/api/v1/entries/storyactive.php b/api/v1/entries/storyactive.php index cfaf4145bd..d5d6189f55 100644 --- a/api/v1/entries/storyactive.php +++ b/api/v1/entries/storyactive.php @@ -12,15 +12,15 @@ class storyActiveEntry extends Entry { - /** + /** * POST method. * * @param int $storyID * @access public * @return void */ - public function put($storyID) - { + public function post($storyID) + { $oldStory = $this->loadModel('story')->getByID($storyID); $fields = 'assignedTo,status,comment'; @@ -37,6 +37,6 @@ class storyActiveEntry extends Entry $story = $this->loadModel('story')->getByID($storyID); $this->send(200, $story); - } + } } diff --git a/api/v1/entries/storyassignto.php b/api/v1/entries/storyassignto.php index f6869b59f4..0b3477a1ee 100644 --- a/api/v1/entries/storyassignto.php +++ b/api/v1/entries/storyassignto.php @@ -12,13 +12,13 @@ class storyAssignToEntry extends Entry { /** - * PUT method. + * POST method. * * @param int $storyID * @access public * @return void */ - public function put($storyID) + public function post($storyID) { $task = $this->loadModel('story')->getByID($storyID); diff --git a/api/v1/entries/storyclose.php b/api/v1/entries/storyclose.php index 1f6057178d..a83948232e 100644 --- a/api/v1/entries/storyclose.php +++ b/api/v1/entries/storyclose.php @@ -12,13 +12,13 @@ class storyCloseEntry extends Entry { /** - * PUT method. + * POST method. * * @param int $storyID * @access public * @return void */ - public function put($storyID) + public function post($storyID) { $story = $this->loadModel('story')->getByID($storyID); diff --git a/api/v1/entries/storyrecordestimate.php b/api/v1/entries/storyrecordestimate.php deleted file mode 100644 index 389ede8726..0000000000 --- a/api/v1/entries/storyrecordestimate.php +++ /dev/null @@ -1,39 +0,0 @@ - - * @package entries - * @version 1 - * @link http://www.zentao.net - */ -class storyRecordEstimateEntry 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/taskclose.php b/api/v1/entries/taskclose.php index da57db1ec8..774c115c53 100644 --- a/api/v1/entries/taskclose.php +++ b/api/v1/entries/taskclose.php @@ -12,13 +12,13 @@ class taskCloseEntry extends Entry { /** - * PUT method. + * POST method. * * @param int $taskID * @access public * @return void */ - public function put($taskID) + public function post($taskID) { $task = $this->loadModel('task')->getByID($taskID); diff --git a/api/v1/entries/taskfinish.php b/api/v1/entries/taskfinish.php index 564b037bae..2c12a46cc6 100644 --- a/api/v1/entries/taskfinish.php +++ b/api/v1/entries/taskfinish.php @@ -12,13 +12,13 @@ class taskFinishEntry extends Entry { /** - * PUT method. + * POST method. * * @param int $taskID * @access public * @return void */ - public function put($taskID) + public function post($taskID) { $task = $this->loadModel('task')->getByID($taskID); diff --git a/api/v1/entries/taskpause.php b/api/v1/entries/taskpause.php index 438785b5f2..7548fa25e0 100644 --- a/api/v1/entries/taskpause.php +++ b/api/v1/entries/taskpause.php @@ -12,13 +12,13 @@ class taskPauseEntry extends Entry { /** - * PUT method. + * POST method. * * @param int $taskID * @access public * @return void */ - public function put($taskID) + public function post($taskID) { $task = $this->loadModel('task')->getByID($taskID); diff --git a/api/v1/entries/taskstart.php b/api/v1/entries/taskstart.php index 8a041bb377..d21d4bb37a 100644 --- a/api/v1/entries/taskstart.php +++ b/api/v1/entries/taskstart.php @@ -12,13 +12,13 @@ class taskStartEntry extends Entry { /** - * PUT method. + * POST method. * * @param int $taskID * @access public * @return void */ - public function put($taskID) + public function post($taskID) { $task = $this->loadModel('task')->getByID($taskID);