feedbacks.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /**
  3. * The executions 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 feedbacksEntry extends entry
  13. {
  14. /**
  15. * GET method.
  16. *
  17. * @access public
  18. * @return string
  19. */
  20. public function get()
  21. {
  22. if(strpos(strtolower($this->param('fields')), 'moduleandproduct') !== false) return $this->getModuleAndProduct();
  23. $control = $this->loadController('feedback', 'admin');
  24. $control->session->set('feedbackProduct', 0);
  25. $control->admin($this->param('status', 'unclosed'), 0, $this->param('orderBy', 'id_desc'), 0, $this->param('limit', 20), $this->param('page', 1));
  26. $data = $this->getData();
  27. if(!$data or !isset($data->status)) return $this->sendError(400, 'error');
  28. if(isset($data->status) and $data->status == 'fail') return $this->sendError(400, $data->message);
  29. $feedbacks = $data->data->feedbacks;
  30. $pager = $data->data->pager;
  31. $result = array();
  32. foreach($feedbacks as $feedback)
  33. {
  34. $result[] = $this->format($feedback, 'openedBy:user,openedDate:time,reviewedBy:user,reviewedDate:time,processedBy:user,processedDate:time,closedBy:user,closedDate:time,editedBy:user,editedDate:time,assignedTo:user,mailto:userList,deleted:bool');
  35. }
  36. $data = array();
  37. $data['page'] = $pager->pageID;
  38. $data['total'] = $pager->recTotal;
  39. $data['limit'] = $pager->recPerPage;
  40. $data['feedbacks'] = $result;
  41. return $this->send(200, $data);
  42. }
  43. /**
  44. * POST method.
  45. *
  46. * @access public
  47. * @return string
  48. */
  49. public function post()
  50. {
  51. $control = $this->loadController('feedback', 'create');
  52. $fields = 'module,product,type,title,public,desc,status,feedbackBy,notify,uid,pri';
  53. $this->batchSetPost($fields);
  54. $this->setPost('notifyEmail', $this->request('notifyEmail', ''));
  55. $this->requireFields('title,product');
  56. $control->create();
  57. $data = $this->getData();
  58. if(isset($data->result) and $data->result == 'fail') return $this->sendError(400, $data->message);
  59. $feedback = $this->loadModel('feedback')->getById($data->id);
  60. return $this->send(201, $this->format($feedback, 'openedBy:user,openedDate:time,reviewedBy:user,reviewedDate:time,processedBy:user,processedDate:time,closedBy:user,closedDate:time,editedBy:user,editedDate:time,assignedTo:user,assignedDate:time,feedbackBy:user,mailto:userList,deleted:bool'));
  61. }
  62. /**
  63. * GET method.
  64. *
  65. * @access public
  66. * @return string
  67. */
  68. public function getModuleAndProduct()
  69. {
  70. $control = $this->loadController('feedback', 'create');
  71. $control->create();
  72. $data = $this->getData();
  73. $modules = $data->data->modules;
  74. $products = $data->data->products;
  75. $data = array();
  76. $data['modules'] = $modules;
  77. $data['products'] = $products;
  78. return $this->send(200, $data);
  79. }
  80. }