Merge branch 'master' of github.com:easysoft/zentaopms

This commit is contained in:
tianshujie98
2020-07-17 09:00:05 +08:00
25 changed files with 120 additions and 88 deletions
+2 -2
View File
@@ -38,7 +38,7 @@ class control extends baseControl
if(!isset($this->config->bizVersion)) return false;
/* Code for task #9224. Set requiredFields for workflow. */
if($this->dbh or defined('IN_USE') or (defined('RUN_MODE') and RUN_MODE == 'api'))
if($this->dbh and (defined('IN_USE') or (defined('RUN_MODE') and RUN_MODE == 'api')))
{
$this->checkRequireFlowField();
@@ -319,7 +319,7 @@ class control extends baseControl
foreach($fieldRules as $ruleID)
{
if(!isset($rules[$ruleID])) continue;
if(!is_string($_POST[$field->field])) continue;
if(!empty($_POST[$field->field]) and !is_string($_POST[$field->field])) continue;
$rule = $rules[$ruleID];
if($rule->type == 'system' and $rule->rule == 'notempty')
+1
View File
@@ -354,6 +354,7 @@ class router extends baseRouter
/* Check if the requested module is defined in workflow. */
$flow = $this->dbh->query("SELECT * FROM " . TABLE_WORKFLOW . " WHERE `module` = '$this->moduleName'")->fetch();
if(!$flow) return parent::setControlFile($exitIfNone);
if($flow->status != 'normal') die("<html><head><meta charset='utf-8'></head><body>{$this->lang->flowNotRelease}</body></html>");
/**
* 工作流中配置的标签应该请求browse方法,而某些内置流程本身包含browse方法。在这里处理请求的时候会无法区分是内置的browse方法还是工作
+5 -1
View File
@@ -989,7 +989,11 @@ class baseFixer
$fields = $this->processFields($fieldName);
foreach($fields as $fieldName)
{
if(empty($this->stripedFields) or !isset($this->stripedFields[$fieldName])) $this->data->$fieldName = $this->specialArray($this->data->$fieldName);
if(empty($this->stripedFields) or !isset($this->stripedFields[$fieldName]))
{
$this->data->$fieldName = $this->specialArray($this->data->$fieldName);
$this->stripedFields[$fieldName] = $fieldName;
}
}
return $this;
}
+1 -1
View File
@@ -481,7 +481,7 @@ class SMTP {
$max_line_length = 998; // used below; set here for ease in change
while(list(,$line) = each($lines)) {
foreach($lines as $line) {
$lines_out = null;
if($line == "" && $in_headers) {
$in_headers = false;
+32 -26
View File
@@ -13,6 +13,8 @@
<?php
class bugModel extends model
{
public $steps = array();
/**
* Set menu.
*
@@ -1671,36 +1673,24 @@ class bugModel extends model
{
$i = 1;
$bugStep = '';
foreach($steps as $stepId)
{
if(!isset($caseSteps[$stepId])) continue;
$step = $caseSteps[$stepId];
$bugStep .= $i . '. ' . $step->desc . "<br />";
$i++;
}
$bugSteps .= $bugStep ? str_replace('<br/>', '', $this->lang->bug->tplStep) . $bugStep : $this->lang->bug->tplStep;
$i = 1;
$bugResult = '';
foreach($steps as $stepId)
{
if(!isset($stepResults[$stepId]) or empty($stepResults[$stepId]['real'])) continue;
$bugResult .= $i . '. ' . $stepResults[$stepId]['real'] . "<br />";
$i++;
}
$bugSteps .= $bugResult ? str_replace('<br/>', '', $this->lang->bug->tplResult) . $bugResult : $this->lang->bug->tplResult;
$i = 1;
$bugExpect = '';
foreach($steps as $stepId)
{
if(!isset($caseSteps[$stepId])) continue;
$step = $caseSteps[$stepId];
if($step->expect) $bugExpect .= $i . '. ' . $step->expect . "<br />";
list($i, $order) = $this->buildStepOrder($step, $steps, $i);
$stepResult = (!isset($stepResults[$stepId]) or empty($stepResults[$stepId]['real'])) ? '' : $stepResults[$stepId]['real'];
$bugStep .= $order . '. ' . $step->desc . "<br />";
$bugResult .= $order . '. ' . $stepResult . "<br />";
$bugExpect .= $order . '. ' . $step->expect . "<br />";
$i++;
}
$bugSteps .= $bugStep ? str_replace('<br/>', '', $this->lang->bug->tplStep) . $bugStep : $this->lang->bug->tplStep;
$bugSteps .= $bugResult ? str_replace('<br/>', '', $this->lang->bug->tplResult) . $bugResult : $this->lang->bug->tplResult;
$bugSteps .= $bugExpect ? str_replace('<br/>', '', $this->lang->bug->tplExpect) . $bugExpect : $this->lang->bug->tplExpect;
}
else
@@ -2664,10 +2654,6 @@ class bugModel extends model
{
echo html::a(helper::createLink('build', 'view', "buildID=$buildID"), $build, '', "title='$bug->openedBuild'");
}
else
{
echo $build;
}
}
break;
case 'assignedTo':
@@ -2862,4 +2848,24 @@ class bugModel extends model
return sprintf($this->lang->bug->summary, count($bugs), $unresolved);
}
/**
* Build step order.
*
* @param object $step
* @param array $caseSteps
* @param int $i
* @access public
* @return array
*/
public function buildStepOrder($step, $caseSteps, $i)
{
if($step->parent == 0 or !in_array($step->parent, $caseSteps)) return array($i, $i);
$i --;
$j = isset($this->steps[$step->parent]) ? (count($this->steps[$step->parent]) + 1) : 1;
$this->steps[$step->parent][] = $step->id;
return array($i, "$i.$j");
}
}
+13 -17
View File
@@ -57,16 +57,14 @@ class ciModel extends model
$jenkinsServer = $compile->url;
$jenkinsUser = $compile->account;
$jenkinsPassword = $compile->token ? $compile->token : base64_decode($compile->password);
$userPwd = "$jenkinsUser:$jenkinsPassword";
$queueUrl = sprintf('%s/queue/item/%s/api/json', $jenkinsServer, $compile->queue);
$jenkinsAuth = '://' . $jenkinsUser . ':' . $jenkinsPassword . '@';
$jenkinsServer = str_replace('://', $jenkinsAuth, $jenkinsServer);
$queueUrl = sprintf('%s/queue/item/%s/api/json', $jenkinsServer, $compile->queue);
$response = common::http($queueUrl);
$response = common::http($queueUrl, '', false, $userPwd);
if(strripos($response, "404") > -1)
{
$infoUrl = sprintf("%s/job/%s/api/xml?tree=builds[id,number,result,queueId]&xpath=//build[queueId=%s]", $jenkinsServer, $compile->jkJob, $compile->queue);
$response = common::http($infoUrl);
$response = common::http($infoUrl, '', false, $userPwd);
if($response)
{
$buildInfo = simplexml_load_string($response);
@@ -77,7 +75,7 @@ class ciModel extends model
$this->updateBuildStatus($compile, $result);
$logUrl = sprintf('%s/job/%s/%s/consoleText', $jenkinsServer, $compile->jkJob, $buildNumber);
$response = common::http($logUrl);
$response = common::http($logUrl, '', false, $userPwd);
$this->dao->update(TABLE_COMPILE)->set('logs')->eq($response)->where('id')->eq($compile->id)->exec();
}
}
@@ -86,10 +84,8 @@ class ciModel extends model
$queueInfo = json_decode($response);
if(!empty($queueInfo->executable))
{
$buildUrl = $queueInfo->executable->url . 'api/json?pretty=true';
$buildUrl = str_replace('://', $jenkinsAuth, $buildUrl);
$response = common::http($buildUrl);
$buildUrl = $queueInfo->executable->url . 'api/json?pretty=true';
$response = common::http($buildUrl, '', false, $userPwd);
$buildInfo = json_decode($response);
if($buildInfo->building)
@@ -102,8 +98,7 @@ class ciModel extends model
$this->updateBuildStatus($compile, $result);
$logUrl = $buildInfo->url . 'logText/progressiveText/api/json';
$logUrl = str_replace('://', $jenkinsAuth, $logUrl);
$response = common::http($logUrl);
$response = common::http($logUrl, '', false, $userPwd);
$this->dao->update(TABLE_COMPILE)->set('logs')->eq($response)->where('id')->eq($compile->id)->exec();
}
}
@@ -127,16 +122,17 @@ class ciModel extends model
/**
* Send request.
*
* @param string $url
* @param object $data
* @param string $url
* @param object $data
* @param string $userPwd
* @access public
* @return int
*/
public function sendRequest($url, $data)
public function sendRequest($url, $data, $userPwd = '')
{
if(!empty($data->PARAM_TAG)) $data->PARAM_REVISION = '';
$response = common::http($url, $data, true);
$response = common::http($url, $data, true, $userPwd);
if(preg_match("!Location: .*item/(.*)/!", $response, $matches)) return $matches[1];
return 0;
}
+5 -1
View File
@@ -1836,11 +1836,13 @@ EOD;
*
* @param string $url
* @param string|array $data
* @param bool $optHeader
* @param string $userPwd
* @static
* @access public
* @return string
*/
public static function http($url, $data = null, $optHeader = false)
public static function http($url, $data = null, $optHeader = false, $userPwd = '')
{
global $lang, $app;
if(!extension_loaded('curl')) return json_encode(array('result' => 'fail', 'message' => $lang->error->noCurlExt));
@@ -1868,6 +1870,8 @@ EOD;
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
}
if(!empty($userPwd)) curl_setopt($curl, CURLOPT_USERPWD, $userPwd);
$response = curl_exec($curl);
$errors = curl_error($curl);
curl_close($curl);
+7 -7
View File
@@ -72,9 +72,9 @@ class compileModel extends model
/**
* Get build url.
*
* @param object $jenkins
* @param object $jenkins
* @access public
* @return string
* @return object
*/
public function getBuildUrl($jenkins)
{
@@ -82,10 +82,10 @@ class compileModel extends model
$jenkinsUser = $jenkins->account;
$jenkinsPassword = $jenkins->token ? $jenkins->token : base64_decode($jenkins->password);
$jenkinsAuth = '://' . $jenkinsUser . ':' . $jenkinsPassword . '@';
$jenkinsServer = str_replace('://', $jenkinsAuth, $jenkinsServer);
$buildUrl = sprintf('%s/job/%s/buildWithParameters/api/json', $jenkinsServer, $jenkins->jkJob);
return $buildUrl;
$build = new stdclass();
$build->userPwd = "$jenkinsUser:$jenkinsPassword";
$build->url = sprintf('%s/job/%s/buildWithParameters/api/json', $jenkinsServer, $jenkins->jkJob);
return $build;
}
/**
@@ -134,7 +134,7 @@ class compileModel extends model
$buildUrl = $this->getBuildUrl($job);
$build = new stdclass();
$build->queue = $this->loadModel('ci')->sendRequest($buildUrl, $data);
$build->queue = $this->loadModel('ci')->sendRequest($buildUrl->url, $data, $buildUrl->userPwd);
$build->status = $build->queue ? 'created' : 'create_fail';
$build->updateDate = helper::now();
$this->dao->update(TABLE_COMPILE)->data($build)->where('id')->eq($compile->id)->exec();
+1 -2
View File
@@ -1,7 +1,6 @@
.versions .dropdown-menu{max-height:260px; overflow-y:auto;}
.table-data > tbody > tr > th.w-80px {width:80px;}
.article-content{overflow: visible}
.detail-content .file-image{position: relative; padding: 0 10px;}
.detail-content .file-image{position: relative; padding: 0 10px; margin-right: 10px;}
.detail-content .file-image > span.right-icon{position: absolute; right: -10px; top: 0;}
#urlIframe{border:0px;}
+1 -1
View File
@@ -23,7 +23,7 @@
<table class='table table-form'>
<tr>
<th class='w-110px'><?php echo $lang->doc->libType?></th>
<td><?php echo html::radio('type', $libTypeList, $type ? $type : 'product')?></td>
<td><?php echo html::radio('type', $libTypeList, $type ? $type : key($libTypeList))?></td>
</tr>
<tr class='product'>
<th><?php echo $lang->doc->product?></th>
+2 -4
View File
@@ -71,10 +71,8 @@ class jenkinsModel extends model
$jenkinsUser = $jenkins->account;
$jenkinsPassword = $jenkins->token ? $jenkins->token : $jenkins->password;
$jenkinsAuth = '://' . $jenkinsUser . ':' . $jenkinsPassword . '@';
$jenkinsServer = str_replace('://', $jenkinsAuth, $jenkinsServer);
$response = common::http($jenkinsServer . '/api/json/items/list');
$userPwd = "$jenkinsUser:$jenkinsPassword";
$response = common::http($jenkinsServer . '/api/json/items/list', '', false, $userPwd);
$response = json_decode($response);
$tasks = array();
+2 -2
View File
@@ -221,7 +221,7 @@ class jobModel extends model
->fetch();
if(!$job) return false;
$buildUrl = $this->loadModel('compile')->getBuildUrl($job);
$buildUrl = $this->loadModel('compile')->getBuildUrl($job);
$build = new stdclass();
$build->job = $job->id;
$build->name = $job->name;
@@ -273,7 +273,7 @@ class jobModel extends model
$data->ZENTAO_DATA = "compile={$compileID}";
$compile = new stdclass();
$compile->queue = $this->loadModel('ci')->sendRequest($buildUrl, $data);
$compile->queue = $this->loadModel('ci')->sendRequest($buildUrl->url, $data, $buildUrl->userPwd);
$compile->status = $compile->queue ? 'created' : 'create_fail';
$this->dao->update(TABLE_COMPILE)->data($compile)->where('id')->eq($compileID)->exec();
+1 -1
View File
@@ -212,7 +212,7 @@ class project extends control
$this->view->modules = $this->tree->getTaskOptionMenu($projectID, 0, 0, $showAllModule ? 'allModule' : '');
$this->view->moduleID = $moduleID;
$this->view->moduleTree = $this->tree->getTaskTreeMenu($projectID, $productID, $startModuleID = 0, array('treeModel', 'createTaskLink'), $extra);
$this->view->memberPairs = $memberPairs;
$this->view->memberPairs = $memberPairs + array('closed' => 'Closed');
$this->view->branchGroups = $this->loadModel('branch')->getByProducts(array_keys($products), 'noempty');
$this->view->setModule = true;
+3 -2
View File
@@ -17,13 +17,14 @@ class qaModel extends model
* @param array $products
* @param int $productID
* @param int $branch
* @param string $extra
* @access public
* @return void
*/
public function setMenu($products, $productID, $branch = 0)
public function setMenu($products, $productID, $branch = 0, $extra = '')
{
$this->loadModel('product')->setMenu($products, $productID, $branch);
$selectHtml = $this->product->select($products, $productID, 'qa', 'index', '', $branch);
$selectHtml = $this->product->select($products, $productID, 'qa', 'index', $extra, $branch);
$productIndex = '';
$isMobile = $this->app->viewType == 'mhtml';
+3 -3
View File
@@ -111,13 +111,13 @@ class releaseModel extends model
{
$productID = (int)$productID;
$branch = (int)$branch;
$buildID = 0;
$buildID = strpos($this->config->release->create->requiredFields, 'build') === false ? 0 : '';
/* Check date must be not more than today. */
if($this->post->date > date('Y-m-d')) return dao::$errors[] = $this->lang->release->errorDate;
/* Auto create build when release is not link build. */
if($this->post->build == false && $this->post->name)
if($this->post->build == false and $this->post->name and strpos($this->config->release->create->requiredFields, 'build') === false)
{
$build = $this->dao->select('*')->from(TABLE_BUILD)
->where('deleted')->eq('0')
@@ -161,7 +161,7 @@ class releaseModel extends model
->stripTags($this->config->release->editor->create['id'], $this->config->allowedTags)
->remove('allchecker,files,labels,uid')
->get();
$release = $this->loadModel('file')->processImgURL($release, $this->config->release->editor->create['id'], $this->post->uid);
$this->dao->insert(TABLE_RELEASE)->data($release)
->autoCheck()
+1 -1
View File
@@ -524,7 +524,7 @@ class task extends control
$this->view->title = $this->view->project->name . $this->lang->colon . $this->lang->task->assign;
$this->view->position[] = $this->lang->task->assign;
$this->view->task = $task;
$this->view->members = $members;
$this->view->members = $members + array('closed' => 'Closed');
$this->view->users = $this->loadModel('user')->getPairs();
$this->display();
}
+3 -1
View File
@@ -1603,6 +1603,7 @@ class taskModel extends model
->get();
$this->dao->update(TABLE_TASK)->data($task)->autoCheck()->where('id')->eq((int)$taskID)->exec();
if($oldTask->fromBug) $this->dao->update(TABLE_BUG)->set('toTask')->eq(0)->where('id')->eq($oldTask->fromBug)->exec();
if($oldTask->parent > 0) $this->updateParentStatus($taskID);
if($oldTask->parent == '-1')
{
@@ -2491,6 +2492,7 @@ class taskModel extends model
{
$tasks = $this->dao->select('id,deadline')->from(TABLE_TASK)->alias('t1')
->where($this->reportCondition())
->orderBy('deadline asc')
->fetchAll('id');
if(!$tasks) return array();
@@ -2662,7 +2664,7 @@ class taskModel extends model
if(!isset($fields[$task->$field])) $fields[$task->$field] = 0;
$fields[$task->$field] ++;
}
asort($fields);
if($field != 'date' and $field != 'deadline') asort($fields);
foreach($fields as $field => $count)
{
$data = new stdclass();
@@ -64,7 +64,7 @@
<h5><?php echo $lang->testreport->$infoKey?></h5>
<div class='chart-canvas'>
<?php if(isset($_POST["chart-{$infoKey}"])):?>
<img src='<?php echo $_POST["chart-{$infoKey}"]?>' />
<img src='<?php echo strip_tags($_POST["chart-{$infoKey}"])?>' />
<?php else:?>
<canvas id='chart-<?php echo $infoKey?>' width='90' height='20' data-responsive='true'></canvas>
<?php endif;?>
+2 -2
View File
@@ -41,7 +41,7 @@
<span class='input-group-addon'> ~ </span>
<?php echo html::input('end', $end, "class='form-control form-date'")?>
<?php
echo html::hidden('product', $productIdList) . ($config->global->flow != 'onlyTest' ? html::hidden('project', $project->id) : '') . html::hidden('tasks', $tasks);
echo html::hidden('product', $productIdList) . ($config->global->flow != 'onlyTest' ? html::hidden('project', isset($project->id) ? $project->id : 0) : '') . html::hidden('tasks', $tasks);
echo html::hidden('objectID', $objectID) . html::hidden('objectType', $objectType);
?>
</div>
@@ -67,7 +67,7 @@
<?php if($config->global->flow != 'onlyTest'):?>
<tr>
<th><?php echo $lang->testreport->goal?></th>
<td colspan='2'><?php echo $project->desc?></td>
<td colspan='2'><?php echo isset($project->desc) ? $project->desc : '';?></td>
<td></td>
</tr>
<?php endif;?>
+15 -1
View File
@@ -861,7 +861,21 @@ class testtask extends control
$this->loadModel('testcase');
$this->config->testcase->search['params']['product']['values']= array($productID => $this->products[$productID]);
$this->config->testcase->search['params']['module']['values'] = $this->loadModel('tree')->getOptionMenu($productID, $viewType = 'case');
$this->config->testcase->search['actionURL'] = inlink('linkcase', "taskID=$taskID");
$this->config->testcase->search['actionURL'] = inlink('linkcase', "taskID=$taskID&type=$type&param=myQueryID");
$this->config->testcase->search['queryID'] = $param;
if($param)
{
$query = $this->loadModel('search')->getQuery($param);
if($query)
{
$this->session->set('testcaseQuery', $query->sql);
$this->session->set('testcaseForm', $query->form);
}
else
{
$this->session->set('testcaseQuery', ' 1 = 1');
}
}
if($this->session->currentProductType == 'normal')
{
unset($this->config->testcase->search['fields']['branch']);
+1 -1
View File
@@ -103,7 +103,7 @@ $status = $this->session->testTaskVersionStatus;
<?php
echo '<div id="action-divider">';
common::printIcon('testtask', 'cases', "taskID=$task->id", $task, 'list', 'sitemap');
common::printIcon('testtask', 'linkCase', "taskID=$task->id", $task, 'list', 'link');
common::printIcon('testtask', 'linkCase', "taskID=$task->id&type=all&param=myQueryID", $task, 'list', 'link');
common::printIcon('testreport', 'browse', "objectID=$task->product&objectType=product&extra=$task->id", $task, 'list','flag');
echo '</div>';
common::printIcon('testtask', 'view', "taskID=$task->id", '', 'list', 'list-alt','','iframe',true);
+1
View File
@@ -147,6 +147,7 @@ class webhook extends control
$this->session->set('bugList', $uri);
$this->session->set('caseList', $uri);
$this->session->set('testtaskList', $uri);
$this->session->set('todoList', $uri);
$this->app->loadClass('pager', $static = true);
$pager = new pager($recTotal, $recPerPage, $pageID);
+5 -1
View File
@@ -66,6 +66,7 @@ class webhookModel extends model
$this->loadModel('action');
$actions = $this->dao->select('*')->from(TABLE_ACTION)->where('id')->in($actions)->fetchAll('id');
$users = $this->loadModel('user')->getPairs('noletter');
foreach($logs as $log)
{
@@ -80,7 +81,7 @@ class webhookModel extends model
$object = $this->dao->select('*')->from($this->config->objectTables[$action->objectType])->where('id')->eq($action->objectID)->fetch();
$field = zget($this->config->action->objectNameFields, $action->objectType, $action->objectType);
if(!is_object($object))
if(!is_object($object))
{
$object = new stdclass;
$object->$field = '';
@@ -102,6 +103,9 @@ class webhookModel extends model
$log->action = $text;
$log->actionURL = $this->getViewLink($action->objectType, $action->objectID);
$log->module = $action->objectType;
$log->moduleID = $action->objectID;
$log->dialog = $action->objectType == 'todo' ? 1 : 0;
}
return $logs;
}
+5 -3
View File
@@ -43,9 +43,11 @@
<tr>
<td class='text-center'><?php echo $id;?></td>
<td><?php echo $log->date;?></td>
<td class='text' title='<?php echo $log->url;?>'><?php echo $log->url;?></td>
<td class='text' title='<?php echo $log->action;?>'><?php echo html::a($log->actionURL, $log->action);?></td>
<td class='text-center'><?php echo $log->contentType;?></td>
<td title='<?php echo $log->url;?>'><?php echo $log->url;?></td>
<?php $iframe = $log->dialog == 1 ? 'data-toggle="modal" data-type="iframe"' : '';?>
<?php if($log->dialog == 1) $log->actionURL = $this->createLink($log->module, 'view', "id=$log->moduleID", '' , true)?>
<td title='<?php echo $log->action;?>'><?php echo html::a($log->actionURL, $log->action, '', $iframe);?></td>
<td title='<?php echo $log->contentType;?>'><?php echo $log->contentType;?></td>
<td title='<?php echo $log->result;?>'><?php echo $log->result;?></td>
</tr>
<?php endforeach;?>
+7 -7
View File
File diff suppressed because one or more lines are too long