program.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * The program 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 programEntry extends entry
  13. {
  14. /**
  15. * GET method.
  16. *
  17. * @param int $programID
  18. * @access public
  19. * @return string
  20. */
  21. public function get($programID)
  22. {
  23. $program = $this->loadModel('program')->getByID($programID);
  24. if(!$program) return $this->send404();
  25. return $this->send(200, $this->format($program, 'begin:date,end:date,PO:user,PM:user,QD:user,RD:user,realBegan:date,realEnd:date,openedBy:user,openedDate:time,lastEditedDate:time,closedBy:user,closedDate:time,canceledBy:user,canceledDate:time,deleted:bool,whitelist:userList'));
  26. }
  27. /**
  28. * PUT method.
  29. *
  30. * @param int $programID
  31. * @access public
  32. * @return string
  33. */
  34. public function put($programID)
  35. {
  36. $control = $this->loadController('program', 'edit');
  37. $oldProgram = $this->loadModel('program')->getByID($programID);
  38. /* Set $_POST variables. */
  39. $fields = 'name,PM,budget,budgetUnit,desc,parent,begin,end,realBegan,realEnd,acl,whitelist';
  40. $this->batchSetPost($fields, $oldProgram);
  41. $this->setPost('parent', $this->request('parent', 0));
  42. $control->edit($programID);
  43. $data = $this->getData();
  44. if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
  45. $program = $this->program->getByID($programID);
  46. return $this->send(200, $this->format($program, 'begin:date,end:date,PO:user,PM:user,QD:user,RD:user,realBegan:date,realEnd:date,openedBy:user,openedDate:time,lastEditedDate:time,closedBy:user,closedDate:time,canceledBy:user,canceledDate:time,deleted:bool,whitelist:userList'));
  47. }
  48. /**
  49. * DELETE method.
  50. *
  51. * @param int $programID
  52. * @access public
  53. * @return string
  54. */
  55. public function delete($programID)
  56. {
  57. $control = $this->loadController('program', 'delete');
  58. $control->delete($programID, 'true');
  59. $data = $this->getData();
  60. if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
  61. return $this->sendSuccess(200, 'success');
  62. }
  63. }