tao.php 3.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. /**
  3. * The tao file of branch 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 branch
  9. * @link https://www.zentao.net
  10. */
  11. class branchTao extends branchModel
  12. {
  13. /**
  14. * 合并分支后的其他数据处理。
  15. * other data process after merge branch.
  16. *
  17. * @param int $productID
  18. * @param int $targetBranch
  19. * @param string $mergedBranches
  20. * @param object $data
  21. * @access protected
  22. * @return bool
  23. */
  24. protected function afterMerge($productID, $targetBranch, $mergedBranches, $data)
  25. {
  26. $this->dao->update(TABLE_RELEASE)->set('branch')->eq($targetBranch)->where('branch')->in($mergedBranches)->exec(); // Update release branch.
  27. $this->dao->update(TABLE_BUILD)->set('branch')->eq($targetBranch)->where('branch')->in($mergedBranches)->exec(); // Update build branch.
  28. $this->dao->update(TABLE_PRODUCTPLAN)->set('branch')->eq($targetBranch)->where('branch')->in($mergedBranches)->exec(); // Update plan branch.
  29. $this->dao->update(TABLE_MODULE)->set('branch')->eq($targetBranch)->where('branch')->in($mergedBranches)->exec(); // Update module branch.
  30. $this->dao->update(TABLE_BUG)->set('branch')->eq($targetBranch)->where('branch')->in($mergedBranches)->exec(); // Update bug branch.
  31. $this->dao->update(TABLE_CASE)->set('branch')->eq($targetBranch)->where('branch')->in($mergedBranches)->exec(); // Update case branch.
  32. /* Update story branch. */
  33. $this->dao->update(TABLE_STORY)->set('branch')->eq($targetBranch)->where('branch')->in($mergedBranches)->exec();
  34. $this->dao->update(TABLE_PROJECTSTORY)->set('branch')->eq($targetBranch)->where('branch')->in($mergedBranches)->exec();
  35. /* Linked project or execution. */
  36. $linkedProject = $this->dao->select('*')->from(TABLE_PROJECTPRODUCT)
  37. ->where('branch')->in($mergedBranches . ",$targetBranch")
  38. ->andWhere('product')->eq($productID)
  39. ->fetchGroup('project');
  40. $this->dao->delete()->from(TABLE_PROJECTPRODUCT)->where('branch')->in($mergedBranches . ",$targetBranch")
  41. ->andWhere('product')->eq($productID)
  42. ->exec();
  43. foreach($linkedProject as $projectID => $projectProducts)
  44. {
  45. $plan = 0;
  46. if($data->createBranch) continue;
  47. /* Get the linked plan of the target branch. */
  48. foreach($projectProducts as $projectProduct)
  49. {
  50. if($projectProduct->branch == $targetBranch)
  51. {
  52. $plan = $projectProduct->plan;
  53. break;
  54. }
  55. }
  56. $projectProduct = new stdClass();
  57. $projectProduct->project = $projectID;
  58. $projectProduct->product = $productID;
  59. $projectProduct->branch = $targetBranch;
  60. $projectProduct->plan = $plan;
  61. $this->dao->insert(TABLE_PROJECTPRODUCT)->data($projectProduct)->autoCheck()->exec();
  62. }
  63. return !dao::isError();
  64. }
  65. /**
  66. * 根据产品和执行ID获取分支ID列表。
  67. * Get branch ID list by product and execution ID.
  68. *
  69. * @param int $productID
  70. * @param int $executionID
  71. * @access protected
  72. * @return array
  73. */
  74. protected function getIdListByRelation($productID, $executionID)
  75. {
  76. return $this->dao->select('*')->from(TABLE_PROJECTPRODUCT)
  77. ->where('project')->eq($executionID)
  78. ->andWhere('product')->eq($productID)
  79. ->fetchAll('branch');
  80. }
  81. }