create.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. <?php
  2. helper::importControl('task');
  3. class myTask extends task
  4. {
  5. /**
  6. * 创建一个任务。
  7. * Create a task.
  8. *
  9. * @param int $executionID
  10. * @param int $storyID
  11. * @param int $moduleID
  12. * @param int $taskID
  13. * @param int $todoID
  14. * @param string $extra
  15. * @param int $bugID
  16. * @access public
  17. * @return void
  18. */
  19. public function create($executionID = 0, $storyID = 0, $moduleID = 0, $taskID = 0, $todoID = 0, $extra = '', $bugID = 0)
  20. {
  21. $executions = $this->execution->getPairs();
  22. if(empty($executions)) $this->sendError($this->lang->task->kanbanDenied, helper::createLink('execution', 'create'));
  23. $executionID = $this->execution->checkAccess($executionID, $executions);
  24. $regionList = $this->loadModel('kanban')->getRegionPairs($executionID, 0, 'execution');
  25. /* Filter Kanban without Lane. */
  26. $lanes = $this->kanban->getLaneGroupByRegion(array_keys($regionList), 'task');
  27. foreach($regionList as $key => $region)
  28. {
  29. if(!isset($lanes[$key])) unset($regionList[$key]);
  30. }
  31. $laneList = array();
  32. $regionID = key($lanes);
  33. if($regionID) $laneList = $this->kanban->getLanePairsByRegion($regionID, 'task');
  34. $this->view->regionList = $regionList;
  35. $this->view->laneList = $laneList;
  36. $this->view->extra = $extra;
  37. $extra = str_replace(array(',', ' '), array('&', ''), $extra);
  38. parse_str($extra, $output);
  39. if(isset($output['laneID']))
  40. {
  41. $regionID = $this->dao->select("*")->from(TABLE_KANBANLANE)->where('id')->eq($output['laneID'])->fetch('region');
  42. $this->view->regionID = $regionID;
  43. }
  44. if(isset($_POST['region']))
  45. {
  46. $regionID = $_POST['region'];
  47. $laneID = $_POST['lane'];
  48. $columnID = $this->dao->select("t1.id")->from(TABLE_KANBANCOLUMN)->alias('t1')
  49. ->leftJoin(TABLE_KANBANLANE)->alias('t2')
  50. ->on("t2.group = t1.group")
  51. ->where('t1.deleted')->eq('0')
  52. ->andWhere('t2.id')->eq($laneID)
  53. ->andWhere('t1.type')->eq('wait')
  54. ->fetch('id');
  55. $extra = "laneID=$laneID,columnID=$columnID";
  56. }
  57. return parent::create($executionID, $storyID, $moduleID, $taskID, $todoID, $extra, $bugID);
  58. }
  59. }