* [misc] Remove functions of relate object to biz.
This commit is contained in:
@@ -129,29 +129,3 @@ $config->custom->browseStoryConcept->actionList['delete']['data-confirm'] = arra
|
||||
|
||||
$config->custom->nonInterface = new stdclass();
|
||||
$config->custom->nonInterface->lang = array('epic-stageList', 'requirement-stageList');
|
||||
|
||||
$config->custom->relateObjectList = array();
|
||||
$config->custom->relateObjectList['epic'] = $lang->ERCommon;
|
||||
$config->custom->relateObjectList['requirement'] = $lang->URCommon;
|
||||
$config->custom->relateObjectList['story'] = $lang->SRCommon;
|
||||
$config->custom->relateObjectList['task'] = $lang->task->common;
|
||||
$config->custom->relateObjectList['bug'] = $lang->bug->common;
|
||||
$config->custom->relateObjectList['testcase'] = $lang->testcase->common;
|
||||
$config->custom->relateObjectList['doc'] = $lang->doc->common;
|
||||
$config->custom->relateObjectList['repocommit'] = $lang->repo->commit;
|
||||
$config->custom->relateObjectList['design'] = $lang->design->common;
|
||||
|
||||
$config->custom->objectOwner = array();
|
||||
$config->custom->objectOwner['product'] = array('epic', 'requirement', 'story', 'bug', 'testcase', 'doc');
|
||||
$config->custom->objectOwner['project'] = array('design', 'doc');
|
||||
$config->custom->objectOwner['execution'] = array('task', 'doc');
|
||||
|
||||
$config->custom->relateObjectFields['epic'] = array('id', 'pri', 'title', 'relation', 'product', 'module', 'openedBy', 'assignedTo', 'status');
|
||||
$config->custom->relateObjectFields['requirement'] = array('id', 'pri', 'title', 'relation', 'product', 'module', 'openedBy', 'assignedTo', 'status');
|
||||
$config->custom->relateObjectFields['story'] = array('id', 'pri', 'title', 'relation', 'product', 'module', 'openedBy', 'assignedTo', 'status');
|
||||
$config->custom->relateObjectFields['task'] = array('id', 'pri', 'name', 'relation', 'project', 'execution', 'openedBy', 'assignedTo', 'status');
|
||||
$config->custom->relateObjectFields['bug'] = array('id', 'pri', 'severity', 'title', 'relation', 'product', 'project', 'openedBy', 'assignedTo', 'status');
|
||||
$config->custom->relateObjectFields['testcase'] = array('id', 'pri', 'title', 'relation', 'product', 'openedBy', 'assignedTo', 'status');
|
||||
$config->custom->relateObjectFields['doc'] = array('id', 'title', 'relation', 'addedBy', 'addedDate', 'editedBy', 'editedDate');
|
||||
$config->custom->relateObjectFields['repocommit'] = array('id', 'relation', 'repo', 'committer', 'time');
|
||||
$config->custom->relateObjectFields['design'] = array('id', 'name', 'relation', 'product', 'project', 'createdBy', 'assignedTo');
|
||||
|
||||
@@ -590,77 +590,4 @@ class custom extends control
|
||||
|
||||
$this->send(array('result' => 'success'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联对象。
|
||||
* Relate Object.
|
||||
*
|
||||
* @param int $objectID
|
||||
* @param string $objectType
|
||||
* @param string $relatedObjectType
|
||||
* @param string $actionType link|unlink
|
||||
* @param int $relatedObjectID
|
||||
* @param string $browseType bySearch
|
||||
* @param string $orderBy
|
||||
* @param int $recTotal
|
||||
* @param int $recPerPage
|
||||
* @param int $pageID
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function relateObject(int $objectID, string $objectType = '', $relatedObjectType = '', string $browseType = '', string $orderBy = 'id_desc', int $recTotal = 0, int $recPerPage = 20, int $pageID = 1)
|
||||
{
|
||||
if($_POST)
|
||||
{
|
||||
$this->custom->relateObject($objectID, $objectType, $this->post->relation, $relatedObjectType);
|
||||
if(dao::isError()) return $this->sendError(array('message' => dao::getError()));
|
||||
|
||||
return $this->sendSuccess(array('load' => true));
|
||||
}
|
||||
|
||||
if($this->config->edition != 'open') $this->custom->setConfig4Workflow();
|
||||
|
||||
$this->customZen->buildSearchForm($objectID, $objectType, $relatedObjectType);
|
||||
|
||||
/* Load page. */
|
||||
$this->app->loadClass('pager', true);
|
||||
$pager = new pager($recTotal, $recPerPage, $pageID);
|
||||
|
||||
$objects = $this->custom->getObjects($relatedObjectType, $browseType, $orderBy, $pager);
|
||||
if($relatedObjectType == $objectType && isset($objects[$objectID])) unset($objects[$objectID]);
|
||||
|
||||
$this->view->recTotal = $recTotal;
|
||||
$this->view->recPerPage = $recPerPage;
|
||||
$this->view->pageID = $pageID;
|
||||
$this->view->pager = $pager;
|
||||
$this->view->orderBy = $orderBy;
|
||||
$this->view->objectID = $objectID;
|
||||
$this->view->objectType = $objectType;
|
||||
$this->view->relatedObjectType = $relatedObjectType;
|
||||
$this->view->browseType = $browseType;
|
||||
$this->view->users = $this->loadModel('user')->getPairs('noletter');
|
||||
$this->view->objects = $objects;
|
||||
$this->view->cols = $this->custom->getObjectCols($relatedObjectType);
|
||||
$this->view->relationPairs = $this->custom->getRelationList(true);
|
||||
$this->display();
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除关联对象。
|
||||
* Remove objects.
|
||||
*
|
||||
* @param int $objectID
|
||||
* @param string $objectType
|
||||
* @param string $relationName
|
||||
* @param int $relatedObjectID
|
||||
* @param string $relatedObjectType
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function removeObjects(int $objectID, string $objectType, string $relationName, int $relatedObjectID, string $relatedObjectType)
|
||||
{
|
||||
$this->custom->removeObjects($objectID, $objectType, $relationName, $relatedObjectID, $relatedObjectType);
|
||||
if(dao::isError()) return $this->sendError(array('message' => dao::getError()));
|
||||
return $this->sendSuccess(array('load' => true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1250,326 +1250,4 @@ class customModel extends model
|
||||
$cron = $this->dao->select('id,status')->from(TABLE_CRON)->where('command')->like('%methodName=execCrontabQueue')->fetch();
|
||||
if($cron && $cron->status != $cronStatus) $this->cron->changeStatus($cron->id, $cronStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取关联对象列表。
|
||||
* Get objects.
|
||||
*
|
||||
* @param string $objectType
|
||||
* @param string $browseType
|
||||
* @param string $orderBy
|
||||
* @param object $pager
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getObjects(string $objectType, string $browseType = '', string $orderBy = 'id_desc', object $pager = null): array
|
||||
{
|
||||
$objectTable = zget($this->config->objectTables, $objectType);
|
||||
|
||||
$hasVisionField = $this->dao->select('COUNT(1) AS count')->from('information_schema.COLUMNS')
|
||||
->where('TABLE_SCHEMA')->eq($this->config->db->name)
|
||||
->andWhere('TABLE_NAME')->eq($objectTable)
|
||||
->andWhere('COLUMN_NAME')->eq('vision')
|
||||
->fetch('count');
|
||||
|
||||
$hasDeletedField = $this->dao->select('COUNT(1) AS count')->from('information_schema.COLUMNS')
|
||||
->where('TABLE_SCHEMA')->eq($this->config->db->name)
|
||||
->andWhere('TABLE_NAME')->eq($objectTable)
|
||||
->andWhere('COLUMN_NAME')->eq('deleted')
|
||||
->fetch('count');
|
||||
|
||||
$module = in_array($objectType, array('epic', 'requirement')) ? 'story' : $objectType;
|
||||
$objectQuery = $module . 'Query';
|
||||
if($browseType == 'bySearch' && $this->session->$objectQuery === false) $this->session->set($objectQuery, ' 1 = 1');
|
||||
|
||||
$caseID = $objectType == 'testcase' ? ',id as caseID' : '';
|
||||
$flowName = strpos($objectType, 'workflow_') !== false ? ",CONCAT('{$this->lang->workflow->common}', id) as flowName" : '';
|
||||
$query = $this->dao->select('*, 1 as relation' . $caseID . $flowName)->from($objectTable)
|
||||
->where('1=1')
|
||||
->beginIF($hasDeletedField)->andWhere('deleted')->eq(0)->fi()
|
||||
->beginIF(in_array($objectType, array('epic', 'requirement', 'story')))->andWhere('type')->eq($objectType)->fi()
|
||||
->beginIF($objectType == 'doc')->andWhere('acl')->eq('open')->andWhere('status')->eq('normal')->fi()
|
||||
->beginIF($browseType == 'bySearch')->andWhere($this->session->$objectQuery)->fi();
|
||||
|
||||
$userView = '';
|
||||
if(in_array($objectType, $this->config->custom->objectOwner['product'])) $userView .= '`product` IN (' . trim($this->app->user->view->products, ',') . ')';
|
||||
if(in_array($objectType, $this->config->custom->objectOwner['project'])) $userView .= (empty($userView) ? '' : ' OR ') . '`project` IN (' . trim($this->app->user->view->projects, ',') . ')';
|
||||
if(in_array($objectType, $this->config->custom->objectOwner['execution'])) $userView .= (empty($userView) ? '' : ' OR ') . '`execution` IN (' . trim($this->app->user->view->sprints, ',') . ')';
|
||||
$query = $query->beginIF(!empty($userView))->andWhere("($userView)")->fi();
|
||||
|
||||
if($hasVisionField)
|
||||
{
|
||||
$query = $query->andWhere("FIND_IN_SET('{$this->config->vision}', vision)", 1);
|
||||
foreach(explode(',', trim($this->app->user->visions, ',')) as $userVision)
|
||||
{
|
||||
if($userVision == $this->config->vision) continue;
|
||||
$query = $query->orWhere("FIND_IN_SET('{$userVision}', vision)");
|
||||
}
|
||||
$query = $query->markRight(1);
|
||||
}
|
||||
|
||||
$objects = $query->orderBy($orderBy)->page($pager)->fetchAll('id');
|
||||
return $objects;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取关联对象列。
|
||||
* Get object cols.
|
||||
*
|
||||
* @param string $objectType
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getObjectCols(string $objectType): array
|
||||
{
|
||||
$this->loadModel('product');
|
||||
$this->loadModel('project');
|
||||
$this->loadModel('execution');
|
||||
$this->loadModel('tree');
|
||||
$this->loadModel('repo');
|
||||
|
||||
$cols = array();
|
||||
if(isset($this->config->custom->relateObjectFields[$objectType]))
|
||||
{
|
||||
$module = in_array($objectType, array('epic', 'requirement', 'story')) ? 'story' : ($objectType == 'repocommit' ? 'repo' : $objectType);
|
||||
$this->loadModel($module);
|
||||
$fieldList = $this->config->$module->dtable->fieldList;
|
||||
if($module == 'repo') $fieldList = $this->config->repo->commentDtable->fieldList;
|
||||
foreach($this->config->custom->relateObjectFields[$objectType] as $fieldKey)
|
||||
{
|
||||
$fieldSetting = isset($fieldList[$fieldKey]) ? $fieldList[$fieldKey] : array();
|
||||
|
||||
$fieldSetting['sortType'] = true;
|
||||
if(!isset($fieldSetting['title'])) $fieldSetting['title'] = zget($this->lang->$module, $fieldKey, $fieldKey);
|
||||
if(isset($fieldSetting['fixed']) && $fieldSetting['fixed']) $fieldSetting['fixed'] = false;
|
||||
if((isset($fieldSetting['type']) && in_array($fieldSetting['type'], array('assign'))) || $fieldKey == 'createdBy') $fieldSetting['type'] = 'user';
|
||||
if(isset($fieldSetting['hidden'])) unset($fieldSetting['hidden']);
|
||||
|
||||
if($fieldKey == 'id')
|
||||
{
|
||||
$fieldSetting['title'] = 'ID';
|
||||
$fieldSetting['name'] = 'id';
|
||||
$fieldSetting['type'] = 'checkID';
|
||||
}
|
||||
if(in_array($fieldKey, array('product', 'module', 'project', 'execution'))) $fieldSetting['type'] = 'category';
|
||||
if($fieldKey == 'product') $fieldSetting['map'] = array(0 => '') + $this->product->getPairs('all', 0, '', 'all');
|
||||
if($fieldKey == 'project') $fieldSetting['map'] = array(0 => '') + $this->project->getPairs();
|
||||
if($fieldKey == 'execution') $fieldSetting['map'] = array(0 => '') + $this->execution->getPairs(0, 'all', 'all');
|
||||
if($fieldKey == 'pool') $fieldSetting['map'] = array(0 => '') + $this->dao->select('id,name')->from(TABLE_DEMANDPOOL)->fetchPairs();
|
||||
if($fieldKey == 'module') $fieldSetting['map'] = $this->tree->getAllModulePairs($objectType);
|
||||
if($fieldKey == 'repo') $fieldSetting['map'] = $this->repo->getRepoPairs('');
|
||||
if($fieldKey == 'relation') $fieldSetting = array('name' => 'relation', 'title' => $this->lang->custom->relation, 'type' => 'control', 'control' => 'picker', 'sortType' => false);
|
||||
if($fieldKey == 'title' || $fieldKey == 'name')
|
||||
{
|
||||
$fieldSetting['data-toggle'] = 'modal';
|
||||
$fieldSetting['data-size'] = 'lg';
|
||||
}
|
||||
|
||||
$cols[$fieldKey] = $fieldSetting;
|
||||
}
|
||||
}
|
||||
|
||||
if(strpos($objectType, 'workflow_') !== false)
|
||||
{
|
||||
$this->app->loadLang('workflowfield');
|
||||
$flowModule = substr($objectType, 9);
|
||||
$cols['id'] = array('name' => 'id', 'title' => 'ID', 'type' => 'checkID');
|
||||
$cols['flowName'] = array('name' => 'flowName', 'title' => $this->lang->workflowfield->name, 'type' => 'title', 'link' => array('module' => $flowModule, 'method' => 'view', 'params' => "id={id}"));
|
||||
$cols['relation'] = array('name' => 'relation', 'title' => $this->lang->custom->relation, 'type' => 'control', 'control' => 'picker', 'sortType' => false);
|
||||
$cols['createdBy'] = array('name' => 'createdBy', 'title' => $this->lang->workflowfield->default->fields['createdBy'], 'type' => 'user');
|
||||
$cols['assignedTo'] = array('name' => 'assignedTo', 'title' => $this->lang->workflowfield->default->fields['assignedTo'], 'type' => 'user');
|
||||
$cols['status'] = array('name' => 'status', 'title' => $this->lang->workflowfield->default->fields['status'], 'sortType' => true);
|
||||
|
||||
$statusList = $this->dao->select('options')->from(TABLE_WORKFLOWFIELD)->where('module')->eq(substr($flowModule, 9))->andWhere('field')->eq('status')->fetch('options');
|
||||
$cols['status']['map'] = json_decode($statusList);
|
||||
}
|
||||
|
||||
return $cols;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取关联关系列表。
|
||||
* Get relation list.
|
||||
*
|
||||
* @param bool $getParis
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getRelationList(bool $getParis = false): array
|
||||
{
|
||||
$this->app->loadLang('custom');
|
||||
$lang = $this->app->getClientLang();
|
||||
|
||||
$relations = $this->dao->select('`key`, `value`, `system`')->from(TABLE_LANG)
|
||||
->where('lang')->in($lang . ',all')
|
||||
->andWhere('module')->eq('custom')
|
||||
->andWhere('section')->eq('relationList')
|
||||
->fetchAll();
|
||||
|
||||
$relationList = array();
|
||||
foreach($relations as $relation)
|
||||
{
|
||||
$value = json_decode($relation->value);
|
||||
$relationList[$relation->key] = new stdclass();
|
||||
$relationList[$relation->key]->key = $relation->key;
|
||||
$relationList[$relation->key]->relation = $value->relation;
|
||||
$relationList[$relation->key]->relativeRelation = $value->relativeRelation;
|
||||
$relationList[$relation->key]->system = $relation->system;
|
||||
}
|
||||
ksort($relationList);
|
||||
|
||||
if($getParis)
|
||||
{
|
||||
$relationPairs = array();
|
||||
foreach($relationList as $relation) $relationPairs[$relation->key] = $relation->relation;
|
||||
return $relationPairs;
|
||||
}
|
||||
|
||||
return $relationList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联对象。
|
||||
* Relate object.
|
||||
*
|
||||
* @param int $objectID
|
||||
* @param string $objectType
|
||||
* @param array $objectRelation
|
||||
* @param string $relatedObjectType
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function relateObject(int $objectID, string $objectType, array $objectRelation, string $relatedObjectType)
|
||||
{
|
||||
$relatedObjectList = $this->dao->select('BID,relation')->from(TABLE_RELATION)
|
||||
->where('AID')->eq($objectID)
|
||||
->andWhere('AType')->eq($objectType)
|
||||
->andWhere('BType')->eq($relatedObjectType)
|
||||
->fetchGroup('BID', 'relation');
|
||||
|
||||
foreach($objectRelation as $relatedID => $relationID)
|
||||
{
|
||||
if(isset($relatedObjectList[$relatedID][$relationID])) continue;
|
||||
|
||||
$relation = new stdclass();
|
||||
$relation->AID = $objectID;
|
||||
$relation->AType = $objectType;
|
||||
$relation->relation = $relationID;
|
||||
$relation->BID = $relatedID;
|
||||
$relation->BType = $relatedObjectType;
|
||||
$this->dao->insert(TABLE_RELATION)->data($relation)->exec();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除关联对象。
|
||||
* Remove objects.
|
||||
*
|
||||
* @param int $objectID
|
||||
* @param string $objectType
|
||||
* @param string $relationName
|
||||
* @param int $relatedObjectID
|
||||
* @param string $relatedObjectType
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function removeObjects(int $objectID, string $objectType, string $relationName, int $relatedObjectID, string $relatedObjectType): bool
|
||||
{
|
||||
$relationIdList = array();
|
||||
$relationList = $this->getRelationList();
|
||||
foreach($relationList as $relationID => $relation)
|
||||
{
|
||||
if($relation->relation == $relationName || $relation->relativeRelation == $relationName) $relationIdList[$relationID] = $relationID;
|
||||
}
|
||||
|
||||
$this->dao->delete()->from(TABLE_RELATION)
|
||||
->where('relation')->in($relationIdList)
|
||||
->andWhere('AID')->in("$objectID,$relatedObjectID")
|
||||
->andWhere('BID')->in("$objectID,$relatedObjectID")
|
||||
->andWhere('AType')->in("$objectType,$relatedObjectType")
|
||||
->andWhere('BType')->in("$objectType,$relatedObjectType")
|
||||
->exec();
|
||||
return !dao::isError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取已关联的对象列表。
|
||||
* Get related object list.
|
||||
*
|
||||
* @param int $objectID
|
||||
* @param string $objectType
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getRelatedObjectList(int $objectID, string $objectType): array
|
||||
{
|
||||
$relationList = $this->getRelationList();
|
||||
$relationObjects = $this->dao->select('*')->from(TABLE_RELATION)
|
||||
->where('relation')->in(array_keys($relationList))
|
||||
->andWhere("( `AID` = $objectID AND `AType` = '$objectType' )", true)
|
||||
->orWhere("( `BID` = $objectID AND `BType` = '$objectType' ))")
|
||||
->fetchAll('id');
|
||||
ksort($relationObjects);
|
||||
|
||||
$relationObjectList = array();
|
||||
foreach($relationObjects as $object)
|
||||
{
|
||||
$relationName = $object->AID == $objectID ? $relationList[$object->relation]->relation : $relationList[$object->relation]->relativeRelation;
|
||||
$id = $object->AID == $objectID ? 'BID' : 'AID';
|
||||
$type = $object->AID == $objectID ? 'BType' : 'AType';
|
||||
if(!isset($relationObjectList[$relationName])) $relationObjectList[$relationName] = array();
|
||||
if(!isset($relationObjectList[$relationName][$object->$type])) $relationObjectList[$relationName][$object->$type] = array();
|
||||
|
||||
if($object->$type == 'repocommit')
|
||||
{
|
||||
$objectInfo = $this->dao->select('*')->from(TABLE_REPOHISTORY)->where('id')->eq($object->$id)->fetch();
|
||||
$title = $objectInfo->revision;
|
||||
$url = helper::createLink('repo', 'revision', "repo={$objectInfo->repo}&objectID=0&revision={$objectInfo->revision}");
|
||||
}
|
||||
elseif(strpos($object->$type, 'workflow_') !== false)
|
||||
{
|
||||
$table = zget($this->config->objectTables, substr($object->$type, 9));
|
||||
$objectInfo = $this->dao->select('*')->from($table)->where('id')->eq($object->$id)->fetch();
|
||||
$title = $this->lang->workflow->common . $object->$id;
|
||||
$url = helper::createLink(substr($object->$type, 9), 'view', "objectID={$object->$id}");
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$objectInfo = $this->loadModel($object->$type)->fetchByID($object->$id);
|
||||
$title = empty($objectInfo->title) ? (empty($objectInfo->name) ? '' : $objectInfo->name) : $objectInfo->title;
|
||||
$url = helper::createLink($object->$type, 'view', "objectID={$object->$id}");
|
||||
}
|
||||
|
||||
$hasPriv = false;
|
||||
if(common::hasPriv($object->$type, 'view'))
|
||||
{
|
||||
if($this->app->user->admin) $hasPriv = true;
|
||||
if(in_array($object->$type, $this->config->custom->objectOwner['product']) && !empty($objectInfo->product) && strpos(",{$this->app->user->view->products},", ",{$objectInfo->product},") !== false) $hasPriv = true;
|
||||
if(in_array($object->$type, $this->config->custom->objectOwner['project']) && !empty($objectInfo->project) && strpos(",{$this->app->user->view->projects},", ",{$objectInfo->project},") !== false) $hasPriv = true;
|
||||
if(in_array($object->$type, $this->config->custom->objectOwner['execution']) && !empty($objectInfo->execution) && strpos(",{$this->app->user->view->sprints},", ",{$objectInfo->execution},") !== false) $hasPriv = true;
|
||||
}
|
||||
|
||||
$relationObjectList[$relationName][$object->$type][$object->$id] = array('title' => $title, 'url' => $hasPriv ? $url : null);
|
||||
}
|
||||
|
||||
return $relationObjectList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将工作流添加到配置中。
|
||||
* Add work flow to config.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function setConfig4Workflow()
|
||||
{
|
||||
$workflowList = $this->dao->select('module,name,`table`')->from(TABLE_WORKFLOW)->where('buildin')->eq(0)->andWhere('status')->eq('normal')->fetchAll();
|
||||
foreach($workflowList as $workflow)
|
||||
{
|
||||
$this->config->custom->relateObjectList['workflow_' . $workflow->module] = $workflow->name;
|
||||
$this->config->objectTables['workflow_' . $workflow->module] = "`{$workflow->table}`";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -399,94 +399,4 @@ class customZen extends custom
|
||||
|
||||
return !dao::isError();
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建搜索表单。
|
||||
* Build search form.
|
||||
*
|
||||
* @param int $objectID
|
||||
* @param string $objectType
|
||||
* @param string $relatedObjectType
|
||||
* @access protected
|
||||
* @return void
|
||||
*/
|
||||
protected function buildSearchForm(int $objectID, string $objectType, string $relatedObjectType)
|
||||
{
|
||||
$actionURL = $this->createLink('custom', 'relateObject', "objectID=$objectID&objectType=$objectType&relatedObjectType=$relatedObjectType&browseType=bySearch");
|
||||
if(in_array($relatedObjectType, array('epic', 'requirement', 'story'))) $this->loadModel('product')->buildSearchForm(0, array(), 0, $actionURL, $relatedObjectType);
|
||||
if($relatedObjectType == 'task') $this->loadModel('execution')->buildTaskSearchForm(0, array(), 0, $actionURL);
|
||||
if($relatedObjectType == 'bug') $this->loadModel('bug')->buildSearchForm(0, array(), 0, $actionURL);
|
||||
if($relatedObjectType == 'testcase') $this->loadModel('testcase')->buildSearchForm(0, array(), 0, $actionURL);
|
||||
if($relatedObjectType == 'issue') $this->loadModel('issue')->buildSearchForm($actionURL, 0);
|
||||
if($relatedObjectType == 'risk') $this->loadModel('risk')->buildSearchForm(0, $actionURL);
|
||||
if($relatedObjectType == 'feedback') $this->loadModel('feedback')->buildSearchForm($actionURL);
|
||||
if($relatedObjectType == 'ticket') $this->loadModel('ticket')->buildSearchForm(0, $actionURL, 'all');
|
||||
if($relatedObjectType == 'design')
|
||||
{
|
||||
$this->loadModel('design');
|
||||
$this->config->design->search['actionURL'] = $actionURL;
|
||||
$this->config->design->search['queryID'] = 0;
|
||||
$this->loadModel('search')->setSearchParams($this->config->design->search);
|
||||
}
|
||||
if($relatedObjectType == 'doc')
|
||||
{
|
||||
$this->loadModel('doc');
|
||||
$products = $this->loadModel('product')->getPairs();
|
||||
$projects = $this->loadModel('project')->getPairs();
|
||||
$executions = $this->loadModel('execution')->getPairs();
|
||||
$this->config->doc->search['module'] = 'doc';
|
||||
$this->config->doc->search['actionURL'] = $actionURL;
|
||||
$this->config->doc->search['queryID'] = 0;
|
||||
$this->config->doc->search['params']['product']['values'] = $products;
|
||||
$this->config->doc->search['params']['execution']['values'] = $executions;
|
||||
$this->config->doc->search['params']['lib']['values'] = $this->doc->getLibPairs('all', '', 0, '', $products, $projects, $executions);
|
||||
$this->loadModel('search')->setSearchParams($this->config->doc->search);
|
||||
}
|
||||
if($relatedObjectType == 'repocommit')
|
||||
{
|
||||
$this->loadModel('repo');
|
||||
$this->config->repo->repocommitSearch = array();
|
||||
$this->config->repo->repocommitSearch['module'] = 'repocommit';
|
||||
$this->config->repo->repocommitSearch['actionURL'] = $actionURL;
|
||||
$this->config->repo->repocommitSearch['queryID'] = 0;
|
||||
$this->config->repo->repocommitSearch['fields'] = array();
|
||||
$this->config->repo->repocommitSearch['params'] = array();
|
||||
$this->config->repo->repocommitSearch['fields']['commit'] = $this->lang->repo->revisionA;
|
||||
$this->config->repo->repocommitSearch['fields']['time'] = $this->lang->repo->time;
|
||||
$this->config->repo->repocommitSearch['fields']['committer'] = $this->lang->repo->committer;
|
||||
$this->config->repo->repocommitSearch['params']['commit'] = array('operator' => 'include', 'control' => 'input', 'values' => '');
|
||||
$this->config->repo->repocommitSearch['params']['time'] = array('operator' => '=', 'control' => 'date', 'values' => '');
|
||||
$this->config->repo->repocommitSearch['params']['committer'] = array('operator' => 'include', 'control' => 'input', 'values' => '');
|
||||
$this->loadModel('search')->setSearchParams($this->config->repo->repocommitSearch);
|
||||
}
|
||||
if($relatedObjectType == 'demand')
|
||||
{
|
||||
$this->loadModel('demand');
|
||||
$this->config->demand->search['module'] = 'demand';
|
||||
$this->config->demand->search['actionURL'] = $actionURL;
|
||||
$this->config->demand->search['queryID'] = 0;
|
||||
$this->config->demand->search['params']['product']['values'] = array('' => '') + $this->loadModel('product')->getPairs();
|
||||
$this->config->demand->search['params']['pool']['values'] = array('' => '') + $this->dao->select('id,name')->from(TABLE_DEMANDPOOL)->where('deleted')->eq(0)->fetchPairs();
|
||||
$this->loadModel('search')->setSearchParams($this->config->demand->search);
|
||||
}
|
||||
if(strpos($relatedObjectType, 'workflow_') !== false)
|
||||
{
|
||||
$this->app->loadLang('workflowfield');
|
||||
$statusList = $this->dao->select('options')->from(TABLE_WORKFLOWFIELD)->where('module')->eq(substr($objectType, 9))->andWhere('field')->eq('status')->fetch('options');
|
||||
|
||||
$workflowSearch = array();
|
||||
$workflowSearch['module'] = $relatedObjectType;
|
||||
$workflowSearch['actionURL'] = $actionURL;
|
||||
$workflowSearch['queryID'] = 0;
|
||||
$workflowSearch['fields']['id'] = 'ID';
|
||||
$workflowSearch['fields']['createdBy'] = $this->lang->workflowfield->default->fields['createdBy'];
|
||||
$workflowSearch['fields']['assignedTo'] = $this->lang->workflowfield->default->fields['assignedTo'];
|
||||
$workflowSearch['fields']['status'] = $this->lang->workflowfield->default->fields['status'];
|
||||
$workflowSearch['params']['id'] = array('operator' => '=', 'control' => 'input', 'values' => '');
|
||||
$workflowSearch['params']['createdBy'] = array('operator' => '=', 'control' => 'select', 'values' => 'users');
|
||||
$workflowSearch['params']['assignedTo'] = array('operator' => '=', 'control' => 'select', 'values' => 'users');
|
||||
$workflowSearch['params']['status'] = array('operator' => '=', 'control' => 'select', 'values' => json_decode($statusList));
|
||||
$this->loadModel('search')->setSearchParams($workflowSearch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user