storychange.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * The bug change 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 storyChangeEntry extends entry
  13. {
  14. /**
  15. * POST method.
  16. *
  17. * @param int $storyID
  18. * @access public
  19. * @return string
  20. */
  21. public function post($storyID)
  22. {
  23. $control = $this->loadController('story', 'change');
  24. $oldStory = $this->loadModel('story')->getByID($storyID);
  25. $fields = 'reviewer,comment,executions,bugs,cases,tasks,reviewedBy,uid';
  26. $this->batchSetPost($fields);
  27. $fields = 'title,spec,verify';
  28. $this->batchSetPost($fields, $oldStory);
  29. $this->setPost('status', 'reviewing');
  30. /* If reviewer is not post, set needNotReview. */
  31. if(!$this->request('reviewer'))
  32. {
  33. $this->setPost('status', $oldStory->status);
  34. $this->setPost('reviewer', array());
  35. $this->setPost('needNotReview', 1);
  36. }
  37. $this->requireFields('title');
  38. $control->change($storyID, '', $oldStory->type);
  39. $data = $this->getData();
  40. if(!$data) return $this->send400('error');
  41. if(isset($data->result) && $data->result == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
  42. if(isset($data->status) && $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
  43. $story = $this->loadModel('story')->getByID($storyID);
  44. return $this->send(200, $this->format($story, 'openedDate:time,assignedDate:time,reviewedDate:time,lastEditedDate:time,closedDate:time'));
  45. }
  46. }