* Fix getRows and set config for bug.

This commit is contained in:
tanghucheng
2022-07-08 11:00:47 +08:00
parent 3b66f5dfd8
commit ad32cd3092
5 changed files with 138 additions and 192 deletions
+77 -2
View File
@@ -26,7 +26,7 @@ $config->bug->list->allFields = 'id, module, execution, story, task,
$config->bug->list->defaultFields = 'id,severity,pri,title,openedBy,assignedTo,resolvedBy,resolution';
$config->bug->list->exportFields = 'id, product, branch, module, project, execution, story, task,
$config->bug->exportFields = 'id, product, branch, module, project, execution, story, task,
title, keywords, severity, pri, type, os, browser,
steps, status, deadline, activatedCount, confirmed, mailto,
openedBy, openedDate, openedBuild,
@@ -37,7 +37,82 @@ $config->bug->list->exportFields = 'id, product, branch, module, project, execut
case,
lastEditedBy,
lastEditedDate, files ,feedbackBy, notifyEmail';
if($config->systemMode == 'classic') $config->bug->list->exportFields = str_replace(' project,', '', $config->bug->list->exportFields);
$config->bug->fieldList['id']['title'] = 'id';
$config->bug->fieldList['product']['title'] = 'product';
//$config->bug->fieldList['product']['foreignKey'] = true;
//$config->bug->fieldList['product']['foreignKeySource'] = ;
$config->bug->fieldList['branch']['title'] = 'branch';
$config->bug->fieldList['branch']['foreignKey'] = true;
$config->bug->fieldList['branch']['foreignKeySource'] = array('module' => 'branch', 'method' => 'getPairs', 'params' => '$executionID');
$config->bug->fieldList['module']['title'] = 'module';
$config->bug->fieldList['module']['foreignKey'] = true;
$config->bug->fieldList['module']['foreignKeySource'] = array('module' => 'tree', 'method' => 'getAllModulePairs', 'params' => 'bug');;
$config->bug->fieldList['project']['title'] = 'project';
$config->bug->fieldList['project']['foreignKey'] = true;
$config->bug->fieldList['project']['foreignKeySource'] = array('module' => 'product', 'method' => 'getProjectPairsByProduct', 'params' => '$productID');
$config->bug->fieldList['execution']['title'] = 'execution';
$config->bug->fieldList['execution']['foreignKey'] = true;
$config->bug->fieldList['execution']['foreignKeySource'] = array('module' => 'execution', 'method' =>'getPairs');
$config->bug->fieldList['story']['title'] = 'story';
$config->bug->fieldList['story']['foreignKey'] = true;
$config->bug->fieldList['story']['foreignKeySource'] = array('module' => 'bug', 'method' =>'getRelatedObjects', 'params' => 'story&id,title');
$config->bug->fieldList['task']['title'] = 'task';
$config->bug->fieldList['steps']['title'] = 'steps';
$config->bug->fieldList['status']['title'] = 'status';
$config->bug->fieldList['deadline']['title'] = 'deadline';
$config->bug->fieldList['activatedCount']['title'] = 'activatedCount';
$config->bug->fieldList['confirmed']['title'] = 'confirmed';
$config->bug->fieldList['mailto']['title'] = 'mailto';
$config->bug->fieldList['openedBy']['title'] = 'openedBy';
$config->bug->fieldList['openedDate']['title'] = 'openedDate';
$config->bug->fieldList['openedBuild']['title'] = 'openedBuild';
$config->bug->fieldList['assignedTo']['title'] = 'assignedTo';
$config->bug->fieldList['assignedDate']['title'] = 'assignedDate';
$config->bug->fieldList['resolvedBy']['title'] = 'resolvedBy';
$config->bug->fieldList['resolution']['title'] = 'resolution';
$config->bug->fieldList['resolvedBuild']['title'] = 'resolvedBuild';
$config->bug->fieldList['resolvedDate']['title'] = 'resolvedDate';
$config->bug->fieldList['closedBy']['title'] = 'closedBy';
$config->bug->fieldList['closedDate']['title'] = 'closedDate';
$config->bug->fieldList['duplicateBug']['title'] = 'duplicateBug';
$config->bug->fieldList['linkBug']['title'] = 'linkBug';
$config->bug->fieldList['case']['title'] = 'case';
$config->bug->fieldList['lastEditedBy']['title'] = 'lastEditedBy';
$config->bug->fieldList['lastEditedDate']['title'] = 'lastEditedDate';
$config->bug->fieldList['files']['title'] = 'files';
$config->bug->fieldList['feedbackBy']['title'] = 'feedbackBy';
$config->bug->fieldList['notifyEmail']['title'] = 'notifyEmail';
if($config->systemMode == 'classic') $config->bug->exportFields = str_replace(' project,', '', $config->bug->exportFields);
$config->bug->list->customCreateFields = 'execution,noticefeedbackBy,story,task,pri,severity,os,browser,deadline,mailto,keywords';
$config->bug->list->customBatchEditFields = 'type,severity,pri,productplan,assignedTo,deadline,resolvedBy,resolution,os,browser,keywords';
+2 -175
View File
@@ -2268,181 +2268,8 @@ class bug extends control
{
$this->loadModel('file');
$this->loadModel('branch');
$bugLang = $this->lang->bug;
$bugConfig = $this->config->bug;
/* Create field lists. */
$fields = $this->post->exportFields ? $this->post->exportFields : explode(',', $bugConfig->list->exportFields);
foreach($fields as $key => $fieldName)
{
$fieldName = trim($fieldName);
$fields[$fieldName] = isset($bugLang->$fieldName) ? $bugLang->$fieldName : $fieldName;
unset($fields[$key]);
}
/* Get bugs. */
$bugs = $this->dao->select('*')->from(TABLE_BUG)->where($this->session->bugQueryCondition)
->beginIF($this->post->exportType == 'selected')->andWhere('id')->in($this->cookie->checkedItem)->fi()
->orderBy($orderBy)->fetchAll('id');
/* Get users, products and executions. */
$users = $this->loadModel('user')->getPairs('noletter');
$products = $this->loadModel('product')->getPairs();
$projects = $this->loadModel('project')->getPairsByProgram();
$executions = $this->loadModel('execution')->getPairs($this->projectID, 'all', 'all');
/* Get related objects id lists. */
$relatedProductIdList = array();
$relatedStoryIdList = array();
$relatedTaskIdList = array();
$relatedBugIdList = array();
$relatedCaseIdList = array();
$relatedBuildIdList = array();
$relatedBranchIdList = array();
foreach($bugs as $bug)
{
$relatedProductIdList[$bug->product] = $bug->product;
$relatedStoryIdList[$bug->story] = $bug->story;
$relatedTaskIdList[$bug->task] = $bug->task;
$relatedCaseIdList[$bug->case] = $bug->case;
$relatedBugIdList[$bug->duplicateBug] = $bug->duplicateBug;
$relatedBranchIdList[$bug->branch] = $bug->branch;
/* Process link bugs. */
$linkBugs = explode(',', $bug->linkBug);
foreach($linkBugs as $linkBugID)
{
if($linkBugID) $relatedBugIdList[$linkBugID] = trim($linkBugID);
}
/* Process builds. */
$builds = $bug->openedBuild . ',' . $bug->resolvedBuild;
$builds = explode(',', $builds);
foreach($builds as $buildID)
{
if($buildID) $relatedBuildIdList[$buildID] = trim($buildID);
}
}
/* Get related objects title or names. */
$productsType = $this->dao->select('id, type')->from(TABLE_PRODUCT)->where('id')->in($relatedProductIdList)->fetchPairs();
$relatedStories = $this->dao->select('id,title')->from(TABLE_STORY) ->where('id')->in($relatedStoryIdList)->fetchPairs();
$relatedTasks = $this->dao->select('id, name')->from(TABLE_TASK)->where('id')->in($relatedTaskIdList)->fetchPairs();
$relatedBugs = $this->dao->select('id, title')->from(TABLE_BUG)->where('id')->in($relatedBugIdList)->fetchPairs();
$relatedCases = $this->dao->select('id, title')->from(TABLE_CASE)->where('id')->in($relatedCaseIdList)->fetchPairs();
$relatedBranch = array('0' => $this->lang->branch->main) + $this->dao->select('id, name')->from(TABLE_BRANCH)->where('id')->in($relatedBranchIdList)->fetchPairs();
$relatedBuilds = array('trunk' => $this->lang->trunk) + $this->dao->select('id, name')->from(TABLE_BUILD)->where('id')->in($relatedBuildIdList)->fetchPairs();
$relatedFiles = $this->dao->select('id, objectID, pathname, title')->from(TABLE_FILE)->where('objectType')->eq('bug')->andWhere('objectID')->in(@array_keys($bugs))->andWhere('extra')->ne('editor')->fetchGroup('objectID');
$relatedModules = $this->loadModel('tree')->getAllModulePairs('bug');
if($this->config->edition == 'max') $reviews = $this->loadModel('review')->getPairs(0, $productID);
foreach($bugs as $bug)
{
if($this->post->fileType == 'csv')
{
$bug->steps = str_replace("<br />", "\n", $bug->steps);
$bug->steps = str_replace('"', '""', $bug->steps);
$bug->steps = str_replace('&nbsp;', ' ', $bug->steps);
}
$bug->openedDate = !helper::isZeroDate($bug->openedDate) ? $bug->openedDate : '';
$bug->assignedDate = !helper::isZeroDate($bug->assignedDate) ? $bug->assignedDate : '';
$bug->resolvedDate = !helper::isZeroDate($bug->resolvedDate) ? $bug->resolvedDate : '';
$bug->closedDate = !helper::isZeroDate($bug->closedDate) ? $bug->closedDate : '';
$bug->lastEditedDate = !helper::isZeroDate($bug->lastEditedDate) ? $bug->lastEditedDate : '';
$bug->deadline = !helper::isZeroDate($bug->deadline) ? $bug->deadline : '';
/* fill some field with useful value. */
$bug->product = !isset($products[$bug->product]) ? '' : $products[$bug->product] . "(#$bug->product)";
$bug->project = !isset($projects[$bug->project]) ? '' : $projects[$bug->project] . "(#$bug->project)";
$bug->execution = !isset($executions[$bug->execution]) ? '' : $executions[$bug->execution] . "(#$bug->execution)";
$bug->story = !isset($relatedStories[$bug->story]) ? '' : $relatedStories[$bug->story] . "(#$bug->story)";
$bug->task = !isset($relatedTasks[$bug->task]) ? '' : $relatedTasks[$bug->task] . "($bug->task)";
$bug->case = !isset($relatedCases[$bug->case]) ? '' : $relatedCases[$bug->case] . "($bug->case)";
if($this->config->edition == 'max' and isset($reviews)) $bug->identify = !isset($reviews[$bug->identify]) ? '' : $reviews[$bug->identify] . "(#$bug->identify)";
if(isset($relatedModules[$bug->module])) $bug->module = $relatedModules[$bug->module] . "(#$bug->module)";
if(isset($relatedBugs[$bug->duplicateBug])) $bug->duplicateBug = $relatedBugs[$bug->duplicateBug] . "($bug->duplicateBug)";
if(isset($relatedBuilds[$bug->resolvedBuild])) $bug->resolvedBuild = $relatedBuilds[$bug->resolvedBuild] . "(#$bug->resolvedBuild)";
if(isset($relatedBranch[$bug->branch])) $bug->branch = $relatedBranch[$bug->branch] . "(#$bug->branch)";
if(isset($bugLang->priList[$bug->pri])) $bug->pri = $bugLang->priList[$bug->pri];
if(isset($bugLang->typeList[$bug->type])) $bug->type = $bugLang->typeList[$bug->type];
if(isset($bugLang->severityList[$bug->severity])) $bug->severity = $bugLang->severityList[$bug->severity];
if(isset($bugLang->osList[$bug->os])) $bug->os = $bugLang->osList[$bug->os];
if(isset($bugLang->browserList[$bug->browser])) $bug->browser = $bugLang->browserList[$bug->browser];
if(isset($bugLang->statusList[$bug->status])) $bug->status = $this->processStatus('bug', $bug);
if(isset($bugLang->confirmedList[$bug->confirmed])) $bug->confirmed = $bugLang->confirmedList[$bug->confirmed];
if(isset($bugLang->resolutionList[$bug->resolution])) $bug->resolution = $bugLang->resolutionList[$bug->resolution];
if(isset($users[$bug->openedBy])) $bug->openedBy = $users[$bug->openedBy];
if(isset($users[$bug->assignedTo])) $bug->assignedTo = $users[$bug->assignedTo] . "(#$bug->assignedTo)";
if(isset($users[$bug->resolvedBy])) $bug->resolvedBy = $users[$bug->resolvedBy];
if(isset($users[$bug->lastEditedBy])) $bug->lastEditedBy = $users[$bug->lastEditedBy];
if(isset($users[$bug->closedBy])) $bug->closedBy = $users[$bug->closedBy];
$bug->title = htmlspecialchars_decode($bug->title,ENT_QUOTES);
if($bug->linkBug)
{
$tmpLinkBugs = array();
$linkBugIdList = explode(',', $bug->linkBug);
foreach($linkBugIdList as $linkBugID)
{
$linkBugID = trim($linkBugID);
$tmpLinkBugs[] = isset($relatedBugs[$linkBugID]) ? $relatedBugs[$linkBugID] : $linkBugID;
}
$bug->linkBug = join("; \n", $tmpLinkBugs);
}
if($bug->openedBuild)
{
$tmpOpenedBuilds = array();
$tmpResolvedBuilds = array();
$buildIdList = explode(',', $bug->openedBuild);
foreach($buildIdList as $buildID)
{
$buildID = trim($buildID);
$tmpOpenedBuilds[] = isset($relatedBuilds[$buildID]) ? $relatedBuilds[$buildID] . "(#$buildID)" : $buildID;
}
$bug->openedBuild = join("\n", $tmpOpenedBuilds);
if($this->post->fileType == 'html') $bug->openedBuild = nl2br($bug->openedBuild);
}
/* Set related files. */
$bug->files = '';
if(isset($relatedFiles[$bug->id]))
{
foreach($relatedFiles[$bug->id] as $file)
{
$fileURL = common::getSysURL() . $this->file->webPath . $this->file->getRealPathName($file->pathname);
$bug->files .= html::a($fileURL, $file->title, '_blank') . '<br />';
}
}
$bug->mailto = trim(trim($bug->mailto), ',');
$mailtos = explode(',', $bug->mailto);
$bug->mailto = '';
foreach($mailtos as $mailto)
{
$mailto = trim($mailto);
if(isset($users[$mailto])) $bug->mailto .= $users[$mailto] . ',';
}
$bug->mailto = rtrim($bug->mailto, ',');
unset($bug->caseVersion);
unset($bug->result);
unset($bug->deleted);
}
if(!(in_array('platform', $productsType) or in_array('branch', $productsType))) unset($fields['branch']);// If products's type are normal, unset branch field.
if($this->config->edition != 'open') list($fields, $bugs) = $this->loadModel('workflowfield')->appendDataFromFlow($fields, $bugs);
$this->post->set('fields', $fields);
$this->post->set('rows', $bugs);
$this->post->set('kind', 'bug');
$this->fetch('file', 'export2' . $this->post->fileType, $_POST);
$this->fetch('port', 'export', 'model=bug&params=productID=' . $productID . ',executionID=' . $executionID);
}
$fileName = $this->lang->bug->common;
@@ -2460,7 +2287,7 @@ class bug extends control
}
$this->view->fileName = $fileName;
$this->view->allExportFields = $this->config->bug->list->exportFields;
$this->view->allExportFields = $this->config->bug->exportFields;
$this->view->customExport = true;
$this->display();
}
+29
View File
@@ -3433,4 +3433,33 @@ class bugModel extends model
return $menu;
}
/**
* Get related objects id lists.
*
* @param int $object
* @param string $name
* @access public
* @return void
*/
public function getRelatedObjects($object, $pairs = '')
{
/* Get bugs. */
$bugs = $this->dao->select('*')->from(TABLE_BUG)->where($this->session->bugQueryCondition)
->fetchAll('id');
/* Get related objects id lists. */
$relatedObjectIdList = array();
$relatedObjects = array();
foreach($bugs as $bug)
{
$relatedObjectIdList[$bug->$object] = $bug->$object;
}
/* Get related objects title or names. */
$table = $this->config->objectTables[$object];
if($table) $relatedObjects = $this->dao->select($pairs)->from($table) ->where('id')->in($relatedObjectIdList)->fetchPairs();
return $relatedObjects;
}
}