story.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * 初始化创建需求的一些字段的数据。
  4. * Init story for create.
  5. *
  6. * @param int $planID
  7. * @param int $storyID
  8. * @param int $bugID
  9. * @param int $todoID
  10. * @param string $extra feedback扩展使用
  11. * @access public
  12. * @return object
  13. */
  14. public function initStoryForCreate($planID, $storyID, $bugID, $todoID, $extra = '')
  15. {
  16. $fields = parent::initStoryForCreate($planID, $storyID, $bugID, $todoID, $extra);
  17. $extra = str_replace(array(',', ' '), array('&', ''), $extra);
  18. parse_str($extra, $output);
  19. extract($output);
  20. if(!empty($fromType))
  21. {
  22. /* Get information and history of from object. */
  23. $fromObject = $this->loadModel($fromType)->getById($fromID);
  24. $fromOpenedBy = $this->loadModel('user')->getById($fromObject->openedBy);
  25. $actions = $this->loadModel('action')->getList($fromType, $fromID);
  26. /* Change desc if feedback has been reviewed. */
  27. if($fromType == 'feedback')
  28. {
  29. foreach($actions as $action)
  30. {
  31. if($action->action == 'reviewed' and $action->comment) $fromObject->desc .= $fromObject->desc ? '<br/>' . $this->lang->feedback->reviewOpinion . ':' . $action->comment : $this->lang->feedback->reviewOpinion . ':' . $action->comment;
  32. }
  33. }
  34. $fields->source = $fromOpenedBy->role;
  35. $fields->sourceNote = $fromOpenedBy->realname;
  36. $fields->productID = $fromObject->product;
  37. $fields->title = $fromObject->title;
  38. $fields->module = $fromObject->module;
  39. $fields->spec = $fromObject->desc;
  40. }
  41. return $fields;
  42. }
  43. /**
  44. * 获取创建需求后的跳转地址。
  45. * Get location when after create story.
  46. *
  47. * @param int $productID
  48. * @param string $branch
  49. * @param int $objectID
  50. * @param int $storyID
  51. * @param string $storyType
  52. * @param string $extra
  53. * @access public
  54. * @return string
  55. */
  56. public function getAfterCreateLocation($productID, $branch, $objectID, $storyID, $storyType, $extra = '')
  57. {
  58. $extra = str_replace(array(',', ' '), array('&', ''), $extra);
  59. parse_str($extra, $output);
  60. extract($output);
  61. if(empty($fromType)) return parent::getAfterCreateLocation($productID, $branch, $objectID, $storyID, $storyType, $extra);
  62. $location = $fromType == 'feedback' ? $this->createLink('feedback', 'adminView', "feedbackID=$fromID") : $this->createLink($fromType, 'view', "fromObjectID=$fromID");
  63. return $location;
  64. }