or.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * 获取批量创建需求后的跳转地址。
  4. * Get after batch create location.
  5. *
  6. * @param int $productID
  7. * @param string $branch
  8. * @param int $executionID
  9. * @param int $storyID
  10. * @param string $storyType
  11. * @access protected
  12. * @return string
  13. */
  14. protected function getAfterBatchCreateLocation($productID, $branch, $executionID, $storyID, $storyType)
  15. {
  16. if($this->config->vision == 'or') return $this->createLink('product', 'browse', "productID=$productID&branch=$branch&browseType=assignedtome&queryID=0&storyType=$storyType");
  17. return parent::getAfterBatchCreateLocation($productID, $branch, $executionID, $storyID, $storyType);
  18. }
  19. /**
  20. * 构建编辑需求数据。
  21. * Build story for edit
  22. *
  23. * @param int $storyID
  24. * @access protected
  25. * @return object|false
  26. */
  27. protected function buildStoryForEdit($storyID)
  28. {
  29. $story = parent::buildStoryForEdit($storyID);
  30. $oldStory = $this->story->getById($storyID);
  31. if(!$story) return false;
  32. if($story->roadmap != $oldStory->roadmap)
  33. {
  34. $roadmap = $this->loadModel('roadmap')->getById($story->roadmap);
  35. $story->stage = 'wait';
  36. if($roadmap) $story->stage = $roadmap->status == 'launched' ? 'incharter' : 'inroadmap';
  37. }
  38. return $story;
  39. }
  40. /**
  41. * 构建批量创建需求数据。
  42. * Build stories for batch create.
  43. *
  44. * @param int $productID
  45. * @param string $storyType
  46. * @access protected
  47. * @return array
  48. */
  49. protected function buildStoriesForBatchCreate($productID, $storyType)
  50. {
  51. $roadmaps = $this->loadModel('roadmap')->getList();
  52. $forceReview = $this->story->checkForceReview($storyType);
  53. $fields = $this->config->story->form->batchCreate;
  54. $account = $this->app->user->account;
  55. $now = helper::now();
  56. $saveDraft = $this->post->status == 'draft';
  57. if($forceReview) $fields['reviewer']['required'] = true;
  58. $stories = form::batchData($fields)->get();
  59. foreach($stories as $i => $story)
  60. {
  61. $story->type = $storyType;
  62. $story->status = (empty($story->reviewer) && !$forceReview) ? 'active' : 'reviewing';
  63. $story->status = $saveDraft ? 'draft' : $story->status;
  64. $story->product = $productID;
  65. $story->openedBy = $account;
  66. $story->vision = $this->config->vision;
  67. $story->openedDate = $now;
  68. $story->version = 1;
  69. $story->roadmap = 0;
  70. if(in_array($this->app->tab, array('project', 'execution')))
  71. {
  72. $story->stage = 'projected';
  73. }
  74. if($story->roadmap && isset($roadmaps[$story->roadmap]))
  75. {
  76. $story->stage = $roadmaps[$story->roadmap]->status == 'launched' ? 'incharter' : 'inroadmap';
  77. }
  78. !empty($story->assignedTo) && $story->assignedDate = $now;
  79. if($this->post->uploadImage && $this->post->uploadImage[$i]) $story->uploadImage = $this->post->uploadImage[$i];
  80. }
  81. return $stories;
  82. }