executionbugs.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * The execution bugs 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 executionBugsEntry extends entry
  13. {
  14. /**
  15. * GET method.
  16. *
  17. * @param int $executionID
  18. * @access public
  19. * @return string
  20. */
  21. public function get($executionID = 0)
  22. {
  23. if(!$executionID) $executionID = $this->param('execution', 0);
  24. if(empty($executionID)) return $this->sendError(400, 'Need execution id.');
  25. $control = $this->loadController('execution', 'bug');
  26. $control->bug($executionID, $this->param('product', 0), $this->param('branch', 0), $this->param('order', 'status,id_desc'), $this->param('build', 0), $this->param('status', 'all'), 0, 0, $this->param('limit', 20), $this->param('page', 1));
  27. $data = $this->getData();
  28. if(isset($data->status) and $data->status == 'success')
  29. {
  30. $bugs = $data->data->bugs;
  31. $pager = $data->data->pager;
  32. $result = array();
  33. $this->loadModel('product');
  34. foreach($bugs as $bug)
  35. {
  36. $status = array('code' => $bug->status, 'name' => $this->lang->bug->statusList[$bug->status]);
  37. if($bug->status == 'active' and $bug->confirmed) $status = array('code' => 'confirmed', 'name' => $this->lang->bug->labelConfirmed);
  38. if($bug->resolution == 'postponed') $status = array('code' => 'postponed', 'name' => $this->lang->bug->labelPostponed);
  39. if(!empty($bug->delay)) $status = array('code' => 'delay', 'name' => $this->lang->bug->overdueBugs);
  40. $bug->status = $status['code'];
  41. $bug->statusName = $status['name'];
  42. $product = $this->product->getById($bug->product);
  43. $bug->productStatus = $product->status;
  44. $result[$bug->id] = $this->format($bug, 'activatedDate:time,openedDate:time,assignedDate:time,resolvedDate:time,closedDate:time,lastEditedDate:time,deadline:date,deleted:bool');
  45. }
  46. $storyChangeds = $this->dao->select('t1.id')->from(TABLE_BUG)->alias('t1')
  47. ->leftJoin(TABLE_STORY)->alias('t2')->on('t1.story=t2.id')
  48. ->where('t1.id')->in(array_keys($result))
  49. ->andWhere('t1.story')->ne('0')
  50. ->andWhere('t1.storyVersion != t2.version')
  51. ->fetchPairs('id', 'id');
  52. foreach($storyChangeds as $bugID)
  53. {
  54. $status = array('code' => 'storyChanged', 'name' => $this->lang->bug->changed);
  55. $result[$bugID]->status = $status['code'];
  56. $result[$bugID]->statusName = $status['name'];
  57. }
  58. return $this->send(200, array('page' => $pager->pageID, 'total' => $pager->recTotal, 'limit' => $pager->recPerPage, 'bugs' => array_values($result)));
  59. }
  60. if(isset($data->status) and $data->status == 'fail') return $this->sendError(zget($data, 'code', 400), $data->message);
  61. return $this->sendError(400, 'error');
  62. }
  63. }