build.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. /**
  3. * The build entry point of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.cnezsoft.com)
  6. * @license ZPL(http://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author Chunsheng Wang <chunsheng@cnezsoft.com>
  8. * @package entries
  9. * @version 1
  10. * @link https://www.zentao.net
  11. */
  12. class buildEntry extends entry
  13. {
  14. /**
  15. * GET method.
  16. *
  17. * @param int $buildID
  18. * @access public
  19. * @return string
  20. */
  21. public function get($buildID)
  22. {
  23. $control = $this->loadController('build', 'view');
  24. $control->view($buildID);
  25. $data = $this->getData();
  26. if(isset($data->status) and $data->status == 'success') return $this->send(200, $this->format($data->data->build, 'builder:user,stories:idList,bugs:idList,deleted:bool'));
  27. /* Exception handling. */
  28. if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
  29. return $this->sendError(400, 'error');
  30. }
  31. /**
  32. * PUT method.
  33. *
  34. * @param int $buildID
  35. * @access public
  36. * @return string
  37. */
  38. public function put($buildID)
  39. {
  40. $control = $this->loadController('build', 'edit');
  41. $oldBuild = $this->loadModel('build')->getByID($buildID);
  42. /* Set $_POST variables. */
  43. $fields = 'execution,product,branch,name,builder,date,scmPath,filePath,desc';
  44. $this->batchSetPost($fields, $oldBuild);
  45. $control->edit($buildID);
  46. $data = $this->getData();
  47. if(!$data or (isset($data->message) and $data->message == '404 Not found')) return $this->send404();
  48. if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
  49. $build = $this->build->getByID($buildID);
  50. return $this->send(200, $this->format($build, 'builder:user,stories:idList,bugs:idList,deleted:bool'));
  51. }
  52. /**
  53. * DELETE method.
  54. *
  55. * @param int $buildID
  56. * @access public
  57. * @return string
  58. */
  59. public function delete($buildID)
  60. {
  61. $control = $this->loadController('build', 'delete');
  62. $control->delete($buildID, 'true');
  63. $this->getData();
  64. return $this->sendSuccess(200, 'success');
  65. }
  66. }