feedback.php 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. /**
  3. * The product 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 feedbackEntry extends entry
  13. {
  14. /**
  15. * GET method.
  16. *
  17. * @param int $feedbackID
  18. * @access public
  19. * @return string
  20. */
  21. public function get($feedbackID)
  22. {
  23. $control = $this->loadController('feedback', 'adminView');
  24. $control->adminView($feedbackID);
  25. $data = $this->getData();
  26. if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
  27. $feedback = $data->data->feedback;
  28. $feedback->publicStatus = $feedback->public;
  29. $feedback->productName = $data->data->product;
  30. $feedback->moduleName = isset($data->data->modulePath[0]->name) ? $data->data->modulePath[0]->name : '/';
  31. if(isset($data->data->type)) $feedback->resultType = $data->data->type;
  32. if(isset($feedback->resultInfo) and $feedback->resultInfo->deleted == 0) $feedback->resultStatus = $this->loadModel('feedback')->processStatus($feedback->resultType, $feedback->resultInfo);
  33. if(!$data or !isset($data->status)) return $this->send400('error');
  34. if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
  35. $feedback->actions = $this->loadModel('action')->processActionForAPI($data->data->actions, $data->data->users, $this->lang->feedback);
  36. return $this->send(200, $this->format($feedback, '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'));
  37. }
  38. /**
  39. * PUT method.
  40. *
  41. * @param int $feedbackID
  42. * @access public
  43. * @return string
  44. */
  45. public function put($feedbackID)
  46. {
  47. $control = $this->loadController('feedback', 'edit');
  48. $oldFeedback = $this->loadModel('feedback')->getById($feedbackID);
  49. $fields = 'module,product,type,title,public,desc,status,feedbackBy,notifyEmail,notify,uid,pri';
  50. $this->batchSetPost($fields, $oldFeedback);
  51. $control->edit($feedbackID, '');
  52. $data = $this->getData();
  53. if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
  54. if(!isset($data->result)) return $this->sendError(400, 'error');
  55. $feedback = $this->feedback->getByID($feedbackID);
  56. return $this->send(200, $this->format($feedback, 'openedBy:user,openedDate:time,reviewedBy:user,reviewedDate:time,processedBy:user,processedDate:time,closedBy:user,closedDate:time,editedBy:user,editedDate:time,mailto:userList,deleted:bool'));
  57. }
  58. /**
  59. * DELETE method.
  60. *
  61. * @param int $feedbackID
  62. * @access public
  63. * @return string
  64. */
  65. public function delete($feedbackID)
  66. {
  67. $control = $this->loadController('feedback', 'delete');
  68. $control->delete($feedbackID, 'yes');
  69. $this->getData();
  70. return $this->sendSuccess(200, 'success');
  71. }
  72. }