* adjust code for task #536.

This commit is contained in:
shiyangyangwork@yahoo.cn
2011-10-29 03:35:05 +00:00
parent 7b7c7497f0
commit 7781f1cbca
13 changed files with 323 additions and 325 deletions

View File

@@ -567,6 +567,65 @@ class projectModel extends model
}
}
/**
* Import task from Bug.
*
* @param int $projectID
* @access public
* @return void
*/
public function importBug($projectID)
{
$this->loadModel('bug');
$bugLang = $this->app->loadLang('bug');
$this->loadModel('task');
$this->loadModel('story');
$now = helper::now();
$BugToTasks = fixer::input('post')->get();
foreach($BugToTasks->import as $key => $value)
{
$bug = $this->bug->getById($key);
$task->project = $projectID;
$task->story = $bug->story;
$task->storyVersion = $bug->story;
$task->fromBug = $key;
$task->name = $bug->title;
$task->type = 'devel';
$task->pri = $BugToTasks->pri[$key];
$task->consumed = 0;
$task->status = 'wait';
$task->statusCustom = 1;
$task->desc = $bugLang->bug->resolve . ':' . sprintf('%03d', $key);
$task->openedDate = $now;
$task->openedBy = $this->app->user->account;
if(!empty($BugToTasks->estimate[$key]))
{
$task->estimate = $BugToTasks->estimate[$key];
$task->left = $task->estimate;
}
if(!empty($BugToTasks->assignedTo[$key]))
{
$task->assignedTo = $BugToTasks->assignedTo[$key];
$task->assignedDate = $now;
}
$this->dao->insert(TABLE_TASK)->data($task)->checkIF($BugToTasks->estimate[$key] != '', 'estimate', 'float')->exec();
if(dao::isError())
{
echo js::error(dao::getError());
die(js::reload('parent'));
}
$taskID = $this->dao->lastInsertID();
if($task->story != false) $this->story->setStage($task->story);
$actionID = $this->loadModel('action')->create('task', $taskID, 'Opened', '');
$this->dao->update(TABLE_BUG)->set('toTask')->eq($taskID)->where('id')->eq($key)->exec();
$mails[$key]->taskID = $taskID;
$mails[$key]->actionID = $actionID;
}
return $mails;
}
/**
* Get child projects.
*