ticket.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. * The ticket 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 ticketEntry extends entry
  13. {
  14. /**
  15. * GET method.
  16. *
  17. * @param int $ticketID
  18. * @access public
  19. * @return string
  20. */
  21. public function get($ticketID)
  22. {
  23. $control = $this->loadController('ticket', 'view');
  24. $control->view($ticketID);
  25. $data = $this->getData();
  26. $ticket = $data->data->ticket;
  27. $ticket->productName = $data->data->product;
  28. $ticket->moduleName = isset($data->data->modulePath[0]->name) ? $data->data->modulePath[0]->name : '/';
  29. if(!$data or !isset($data->status)) return $this->send400('error');
  30. if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
  31. $ticket->actions = $this->loadModel('action')->processActionForAPI($data->data->actions, $data->data->users, $this->lang->ticket);
  32. return $this->send(200, $this->format($ticket, 'activatedDate:time,openedBy:user,openedDate:time,assignedTo:user,assignedDate:time,mailto:userList,resolvedBy:user,resolvedDate:time,closedBy:user,closedDate:time,lastEditedBy:user,lastEditedDate:time,deadline:date,deleted:bool'));
  33. }
  34. /**
  35. * PUT method.
  36. *
  37. * @param int $ticketID
  38. * @access public
  39. * @return string
  40. */
  41. public function put($ticketID)
  42. {
  43. $control = $this->loadController('ticket', 'edit');
  44. $oldTicket = $this->loadModel('ticket')->getById($ticketID);
  45. $fields = 'module,product,type,openedBuild,assignedTo,deadline,title,desc,status,notify,uid';
  46. $this->batchSetPost($fields, $oldTicket);
  47. $control->edit($ticketID);
  48. $data = $this->getData();
  49. if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
  50. if(!isset($data->result)) return $this->sendError(400, 'error');
  51. $ticket = $this->ticket->getByID($ticketID);
  52. return $this->send(200, $this->format($ticket, 'openedBy:user,openedDate:time,activatedBy:user,activatedDate:time,finishedBy:user,finishedDate:time,closedBy:user,closedDate:time,editedBy:user,editedDate:time,deadline:time,assignedTo:user,mailto:userList,deleted:bool'));
  53. }
  54. /**
  55. * DELETE method.
  56. *
  57. * @param int $ticketID
  58. * @access public
  59. * @return string
  60. */
  61. public function delete($ticketID)
  62. {
  63. $control = $this->loadController('ticket', 'delete');
  64. $control->delete($ticketID, 'yes');
  65. $this->getData();
  66. return $this->sendSuccess(200, 'success');
  67. }
  68. }