tao.php 4.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * The tao file of build module of ZenTaoPMS.
  4. *
  5. * @copyright Copyright 2009-2023 禅道软件(青岛)有限公司(ZenTao Software (Qingdao) Co., Ltd. www.zentao.net)
  6. * @license ZPL(https://zpl.pub/page/zplv12.html) or AGPL(https://www.gnu.org/licenses/agpl-3.0.en.html)
  7. * @author Shujie Tian <tianshujie@easycorp.ltd>
  8. * @package build
  9. * @link https://www.zentao.net
  10. */
  11. class buildTao extends buildModel
  12. {
  13. /**
  14. * 根据条件获取版本列表信息。
  15. * Get build list inormation by condition.
  16. *
  17. * @param array|int $productIdList
  18. * @param string $params hasdeleted|hasproject|singled
  19. * @param int $objectID
  20. * @param string $objectType
  21. * @param array $shadows
  22. * @access protected
  23. * @return array
  24. * @param int $system
  25. */
  26. protected function fetchBuilds($productIdList, $params = '', $objectID = 0, $objectType = '', $shadows = array(), $system = 0)
  27. {
  28. $fieldList = 't1.id, t1.name, t1.product, t1.branch, t1.project, t1.execution, t1.date, t1.deleted, t3.status as releaseStatus, t3.id as releaseID, t4.type as productType';
  29. if($objectType == 'execution' || $objectType == 'project') $fieldList .= ', t2.status as objectStatus';
  30. $userView = trim($this->app->user->view->projects, ',') . ',' . trim($this->app->user->view->sprints, ',');
  31. return $this->dao->select($fieldList)->from(TABLE_BUILD)->alias('t1')
  32. ->beginIF($objectType === 'execution')->leftJoin(TABLE_EXECUTION)->alias('t2')->on('t1.execution = t2.id')->fi()
  33. ->beginIF($objectType === 'project')->leftJoin(TABLE_PROJECT)->alias('t2')->on('t1.project = t2.id')->fi()
  34. ->leftJoin(TABLE_RELEASERELATED)->alias('t5')->on("t1.id=t5.objectID AND t5.objectType='build'")
  35. ->leftJoin(TABLE_RELEASE)->alias('t3')->on('t5.release=t3.id')
  36. ->leftJoin(TABLE_PRODUCT)->alias('t4')->on('t1.product = t4.id')
  37. ->where('1=1')
  38. ->beginIf(!empty($shadows))->andWhere('t1.id')->notIN($shadows)->fi()
  39. ->beginIF(strpos($params, 'hasdeleted') === false)->andWhere('t1.deleted')->eq(0)->fi()
  40. ->beginIF(strpos($params, 'hasproject') !== false)->andWhere('t1.project')->ne(0)->fi()
  41. ->beginIF(strpos($params, 'singled') !== false)->andWhere('t1.execution')->ne(0)->fi()
  42. ->beginIF(!empty($productIdList))->andWhere('t1.product')->in($productIdList)->fi()
  43. ->beginIF($objectType === 'execution' && $objectID)->andWhere('t1.execution')->eq($objectID)->fi()
  44. ->beginIF($objectType === 'project' && $objectID)->andWhere('t1.project')->eq($objectID)->fi()
  45. ->beginIF($objectType === 'project' && !$this->app->user->admin)->andWhere('t1.project')->in($userView)->fi()
  46. ->beginIF($system)->andWhere('t1.system')->eq($system)->fi()
  47. ->orderBy('t1.date desc, t1.id desc')
  48. ->fetchAll('id');
  49. }
  50. /**
  51. * 获取项目、执行关联的版本信息。
  52. * Get the builds that the project,execution has been linked.
  53. *
  54. * @param string|int $buildIdList
  55. * @param array|int $productIdList
  56. * @param string $params hasdeleted
  57. * @param int $objectID
  58. * @param string $objectType
  59. * @access protected
  60. * @return array
  61. */
  62. protected function selectedBuildPairs($buildIdList, $productIdList, $params, $objectID, $objectType)
  63. {
  64. $selectedBuilds = array();
  65. if($buildIdList)
  66. {
  67. $selectedBuilds = $this->dao->select('id, name')->from(TABLE_BUILD)
  68. ->where('id')->in($buildIdList)
  69. ->beginIF(!empty($productIdList))->andWhere('product')->in($productIdList)->fi()
  70. ->beginIF($objectType === 'execution' && $objectID)->andWhere('execution')->eq($objectID)->fi()
  71. ->beginIF($objectType === 'project' && $objectID)->andWhere('project')->eq($objectID)->fi()
  72. ->beginIF(strpos($params, 'hasdeleted') === false)->andWhere('deleted')->eq(0)->fi()
  73. ->fetchPairs();
  74. }
  75. return $selectedBuilds;
  76. }
  77. }