* Refactor testtask::edit.
This commit is contained in:
@@ -1,6 +1,117 @@
|
||||
<?php
|
||||
class testtaskZen extends testtask
|
||||
{
|
||||
/**
|
||||
* 设置菜单。
|
||||
* Set menu.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param int $branch
|
||||
* @param int $projectID
|
||||
* @param int $executionID
|
||||
* @param int $taskID
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected function setMenu(int $productID, int $branch, int $projectID, int $executionID, int $taskID): void
|
||||
{
|
||||
/* 设置菜单。 */
|
||||
/* Set menu. */
|
||||
if($this->app->tab == 'project')
|
||||
{
|
||||
$this->loadModel('project')->setMenu($projectID);
|
||||
}
|
||||
elseif($this->app->tab == 'execution')
|
||||
{
|
||||
$this->loadModel('execution')->setMenu($executionID);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->testtask->setMenu($this->products, $productID, $branch, $taskID);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建编辑的测试单数据。
|
||||
* Build task for editing.
|
||||
*
|
||||
* @param int $taskID
|
||||
* @param int $productID
|
||||
* @access protected
|
||||
* @return object
|
||||
*/
|
||||
protected function buildTaskForEdit(int $taskID, int $productID): object
|
||||
{
|
||||
$task = form::data($this->config->testtask->form->edit)
|
||||
->add('id', $taskID)
|
||||
->add('product', $productID)
|
||||
->stripTags($this->config->testtask->editor->edit['id'], $this->config->allowedTags)
|
||||
->get();
|
||||
|
||||
$task = $this->loadModel('file')->processImgURL($task, $this->config->testtask->editor->edit['id'], $this->post->uid);
|
||||
return $task;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查编辑的测试单数据是否符合要求。
|
||||
* Check task for editing.
|
||||
*
|
||||
* @param object $task
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected function checkTaskForEdit(object $task): bool
|
||||
{
|
||||
$requiredErrors = array();
|
||||
/* Check required fields of editing task . */
|
||||
foreach(explode(',', $this->config->testtask->edit->requiredFields) as $requiredField)
|
||||
{
|
||||
if(!isset($task->{$requiredField}) || strlen(trim($task->{$requiredField})) == 0) $requiredErrors[$requiredField][] = sprintf($this->lang->error->notempty, isset($this->lang->testtask->{$requiredField}) ? $this->lang->testtask->$requiredField : $requiredField);
|
||||
}
|
||||
if(!empty($requiredErrors)) dao::$errors = $requiredErrors;
|
||||
|
||||
if($task->end && $task->begin > $task->end) dao::$errors['end'][] = sprintf($this->lang->error->ge, $this->lang->testtask->end, $this->lang->testtask->begin);
|
||||
|
||||
return !dao::isError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Assign variables for editing test task.
|
||||
*
|
||||
* @param object $task
|
||||
* @param int $productID
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected function assignForEdit(object $task, int $productID): void
|
||||
{
|
||||
/* Create testtask from testtask of test.*/
|
||||
$this->loadModel('project');
|
||||
$productID = $productID ? $productID : key($this->products);
|
||||
$projectID = $this->lang->navGroup->testtask == 'qa' ? 0 : $this->session->project;
|
||||
$executionID = $task->execution;
|
||||
$executions = empty($productID) ? array() : $this->product->getExecutionPairsByProduct($productID, 0, 'id_desc', $projectID);
|
||||
if($executionID && !isset($executions[$executionID]))
|
||||
{
|
||||
$execution = $this->loadModel('execution')->getById($executionID);
|
||||
$executions[$executionID] = $execution->name;
|
||||
if(empty($execution->multiple))
|
||||
{
|
||||
$project = $this->project->getById($execution->project);
|
||||
$executions[$executionID] = "{$project->name}({$this->lang->project->disableExecution})";
|
||||
}
|
||||
}
|
||||
|
||||
$this->view->title = $this->products[$productID] . $this->lang->colon . $this->lang->testtask->edit;
|
||||
$this->view->task = $task;
|
||||
$this->view->project = $this->project->getByID($projectID);
|
||||
$this->view->executions = $executions;
|
||||
$this->view->builds = empty($productID) ? array() : $this->loadModel('build')->getBuildPairs($productID, 'all', 'noempty,notrunk,withexecution', $executionID ? $executionID : $task->project, $executionID ? 'execution' : 'project', $task->build, false);
|
||||
$this->view->testreports = $this->loadModel('testreport')->getPairs($task->product, $task->testreport);
|
||||
$this->view->users = $this->loadModel('user')->getPairs('nodeleted|noclosed', $task->owner);
|
||||
$this->view->contactLists = $this->user->getContactLists($this->app->user->account, 'withnote');
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据不同情况获取不同的产品列表,大多用于1.5级导航。
|
||||
* Get products.
|
||||
|
||||
Reference in New Issue
Block a user