release.php 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. /**
  3. * The release 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 releaseEntry extends entry
  13. {
  14. /**
  15. * GET method.
  16. *
  17. * @param int $planID
  18. * @access public
  19. * @return string
  20. */
  21. public function get($releaseID)
  22. {
  23. $control = $this->loadController('release', 'view');
  24. $control->view($releaseID);
  25. $data = $this->getData();
  26. if(!$data or !isset($data->status)) return $this->send400('error');
  27. if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
  28. $release = $this->format($data->data->release, 'date:date,deleted:bool');
  29. return $this->send(200, $release);
  30. }
  31. /**
  32. * PUT method.
  33. *
  34. * @param int $releaseID
  35. * @access public
  36. * @return string
  37. */
  38. public function put($releaseID)
  39. {
  40. $control = $this->loadController('release', 'edit');
  41. $oldRelease = $this->loadModel('release')->getByID($releaseID);
  42. /* Set $_POST variables. */
  43. $fields = 'name,build,status,desc';
  44. $this->batchSetPost($fields, $oldRelease);
  45. $control->edit($releaseID);
  46. $data = $this->getData();
  47. if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
  48. $release = $this->release->getByID($releaseID);
  49. return $this->sendSuccess(200, $this->format($release, 'date:date,deleted:bool'));
  50. }
  51. /**
  52. * DELETE method.
  53. *
  54. * @param int $releaseID
  55. * @access public
  56. * @return string
  57. */
  58. public function delete($releaseID)
  59. {
  60. $control = $this->loadController('release', 'delete');
  61. $control->delete($releaseID, 'yes');
  62. $this->getData();
  63. return $this->sendSuccess(200, 'success');
  64. }
  65. }