projectstories.php 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * The project 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 project
  9. * @version 1
  10. * @link https://www.zentao.net
  11. */
  12. class projectStoriesEntry extends entry
  13. {
  14. /**
  15. * GET method.
  16. *
  17. * @param int $projectID
  18. * @access public
  19. * @return string
  20. */
  21. public function get($projectID)
  22. {
  23. if(!$projectID) $projectID = $this->param('project');
  24. if(!$projectID) return $this->sendError(400, 'Need product id.');
  25. $control = $this->loadController('projectstory', 'story');
  26. $control->story($projectID, $this->param('product', 0), $this->param('branch', ''), $this->param('status', 'unclosed'), 0, 'story', $this->param('order', 'id_desc'), 0, $this->param('limit', 20), $this->param('page', 1));
  27. $data = $this->getData();
  28. if(isset($data->status) and $data->status == 'success')
  29. {
  30. $stories = $data->data->stories;
  31. $pager = $data->data->pager;
  32. $result = array();
  33. $this->loadModel('product');
  34. foreach($stories as $story)
  35. {
  36. $product = $this->product->getById($story->product);
  37. $story->productStatus = $product->status;
  38. $result[] = $this->format($story, 'openedBy:user,openedDate:time,assignedTo:user,assignedDate:time,reviewedBy:user,reviewedDate:time,lastEditedBy:user,lastEditedDate:time,closedBy:user,closedDate:time,deleted:bool,mailto:userList');
  39. }
  40. return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'stories' => $result));
  41. }
  42. if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
  43. return $this->sendError(400, 'error');
  44. }
  45. }