This commit is contained in:
chenfei
2020-07-16 16:28:47 +08:00
21 changed files with 57 additions and 55 deletions
+2 -2
View File
@@ -38,7 +38,7 @@ class control extends baseControl
if(!isset($this->config->bizVersion)) return false; if(!isset($this->config->bizVersion)) return false;
/* Code for task #9224. Set requiredFields for workflow. */ /* 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(); $this->checkRequireFlowField();
@@ -319,7 +319,7 @@ class control extends baseControl
foreach($fieldRules as $ruleID) foreach($fieldRules as $ruleID)
{ {
if(!isset($rules[$ruleID])) continue; 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]; $rule = $rules[$ruleID];
if($rule->type == 'system' and $rule->rule == 'notempty') 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. */ /* Check if the requested module is defined in workflow. */
$flow = $this->dbh->query("SELECT * FROM " . TABLE_WORKFLOW . " WHERE `module` = '$this->moduleName'")->fetch(); $flow = $this->dbh->query("SELECT * FROM " . TABLE_WORKFLOW . " WHERE `module` = '$this->moduleName'")->fetch();
if(!$flow) return parent::setControlFile($exitIfNone); 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方法还是工作 * 工作流中配置的标签应该请求browse方法,而某些内置流程本身包含browse方法。在这里处理请求的时候会无法区分是内置的browse方法还是工作
+1 -1
View File
@@ -481,7 +481,7 @@ class SMTP {
$max_line_length = 998; // used below; set here for ease in change $max_line_length = 998; // used below; set here for ease in change
while(list(,$line) = each($lines)) { foreach($lines as $line) {
$lines_out = null; $lines_out = null;
if($line == "" && $in_headers) { if($line == "" && $in_headers) {
$in_headers = false; $in_headers = false;
-4
View File
@@ -2654,10 +2654,6 @@ class bugModel extends model
{ {
echo html::a(helper::createLink('build', 'view', "buildID=$buildID"), $build, '', "title='$bug->openedBuild'"); echo html::a(helper::createLink('build', 'view', "buildID=$buildID"), $build, '', "title='$bug->openedBuild'");
} }
else
{
echo $build;
}
} }
break; break;
case 'assignedTo': case 'assignedTo':
+12 -13
View File
@@ -57,16 +57,14 @@ class ciModel extends model
$jenkinsServer = $compile->url; $jenkinsServer = $compile->url;
$jenkinsUser = $compile->account; $jenkinsUser = $compile->account;
$jenkinsPassword = $compile->token ? $compile->token : base64_decode($compile->password); $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 . '@'; $response = common::http($queueUrl, '', false, $userPwd);
$jenkinsServer = str_replace('://', $jenkinsAuth, $jenkinsServer);
$queueUrl = sprintf('%s/queue/item/%s/api/json', $jenkinsServer, $compile->queue);
$response = common::http($queueUrl);
if(strripos($response, "404") > -1) 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); $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) if($response)
{ {
$buildInfo = simplexml_load_string($response); $buildInfo = simplexml_load_string($response);
@@ -77,7 +75,7 @@ class ciModel extends model
$this->updateBuildStatus($compile, $result); $this->updateBuildStatus($compile, $result);
$logUrl = sprintf('%s/job/%s/%s/consoleText', $jenkinsServer, $compile->jkJob, $buildNumber); $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(); $this->dao->update(TABLE_COMPILE)->set('logs')->eq($response)->where('id')->eq($compile->id)->exec();
} }
} }
@@ -89,7 +87,7 @@ class ciModel extends model
$buildUrl = $queueInfo->executable->url . 'api/json?pretty=true'; $buildUrl = $queueInfo->executable->url . 'api/json?pretty=true';
$buildUrl = str_replace('://', $jenkinsAuth, $buildUrl); $buildUrl = str_replace('://', $jenkinsAuth, $buildUrl);
$response = common::http($buildUrl); $response = common::http($buildUrl, '', false, $userPwd);
$buildInfo = json_decode($response); $buildInfo = json_decode($response);
if($buildInfo->building) if($buildInfo->building)
@@ -103,7 +101,7 @@ class ciModel extends model
$logUrl = $buildInfo->url . 'logText/progressiveText/api/json'; $logUrl = $buildInfo->url . 'logText/progressiveText/api/json';
$logUrl = str_replace('://', $jenkinsAuth, $logUrl); $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(); $this->dao->update(TABLE_COMPILE)->set('logs')->eq($response)->where('id')->eq($compile->id)->exec();
} }
} }
@@ -127,16 +125,17 @@ class ciModel extends model
/** /**
* Send request. * Send request.
* *
* @param string $url * @param string $url
* @param object $data * @param object $data
* @param string $userPwd
* @access public * @access public
* @return int * @return int
*/ */
public function sendRequest($url, $data) public function sendRequest($url, $data, $userPwd = '')
{ {
if(!empty($data->PARAM_TAG)) $data->PARAM_REVISION = ''; 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]; if(preg_match("!Location: .*item/(.*)/!", $response, $matches)) return $matches[1];
return 0; return 0;
} }
+5 -1
View File
@@ -1836,11 +1836,13 @@ EOD;
* *
* @param string $url * @param string $url
* @param string|array $data * @param string|array $data
* @param bool $optHeader
* @param string $userPwd
* @static * @static
* @access public * @access public
* @return string * @return string
*/ */
public static function http($url, $data = null, $optHeader = false) public static function http($url, $data = null, $optHeader = false, $userPwd = '')
{ {
global $lang, $app; global $lang, $app;
if(!extension_loaded('curl')) return json_encode(array('result' => 'fail', 'message' => $lang->error->noCurlExt)); 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); curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
} }
if(!empty($userPwd)) curl_setopt($curl, CURLOPT_USERPWD, $userPwd);
$response = curl_exec($curl); $response = curl_exec($curl);
$errors = curl_error($curl); $errors = curl_error($curl);
curl_close($curl); curl_close($curl);
+7 -7
View File
@@ -72,9 +72,9 @@ class compileModel extends model
/** /**
* Get build url. * Get build url.
* *
* @param object $jenkins * @param object $jenkins
* @access public * @access public
* @return string * @return object
*/ */
public function getBuildUrl($jenkins) public function getBuildUrl($jenkins)
{ {
@@ -82,10 +82,10 @@ class compileModel extends model
$jenkinsUser = $jenkins->account; $jenkinsUser = $jenkins->account;
$jenkinsPassword = $jenkins->token ? $jenkins->token : base64_decode($jenkins->password); $jenkinsPassword = $jenkins->token ? $jenkins->token : base64_decode($jenkins->password);
$jenkinsAuth = '://' . $jenkinsUser . ':' . $jenkinsPassword . '@'; $build = new stdclass();
$jenkinsServer = str_replace('://', $jenkinsAuth, $jenkinsServer); $build->userPwd = "$jenkinsUser:$jenkinsPassword";
$buildUrl = sprintf('%s/job/%s/buildWithParameters/api/json', $jenkinsServer, $jenkins->jkJob); $build->url = sprintf('%s/job/%s/buildWithParameters/api/json', $jenkinsServer, $jenkins->jkJob);
return $buildUrl; return $build;
} }
/** /**
@@ -134,7 +134,7 @@ class compileModel extends model
$buildUrl = $this->getBuildUrl($job); $buildUrl = $this->getBuildUrl($job);
$build = new stdclass(); $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->status = $build->queue ? 'created' : 'create_fail';
$build->updateDate = helper::now(); $build->updateDate = helper::now();
$this->dao->update(TABLE_COMPILE)->data($build)->where('id')->eq($compile->id)->exec(); $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;} .versions .dropdown-menu{max-height:260px; overflow-y:auto;}
.table-data > tbody > tr > th.w-80px {width:80px;} .table-data > tbody > tr > th.w-80px {width:80px;}
.article-content{overflow: visible} .detail-content .file-image{position: relative; padding: 0 10px; margin-right: 10px;}
.detail-content .file-image{position: relative; padding: 0 10px;}
.detail-content .file-image > span.right-icon{position: absolute; right: -10px; top: 0;} .detail-content .file-image > span.right-icon{position: absolute; right: -10px; top: 0;}
#urlIframe{border:0px;} #urlIframe{border:0px;}
+1 -1
View File
@@ -23,7 +23,7 @@
<table class='table table-form'> <table class='table table-form'>
<tr> <tr>
<th class='w-110px'><?php echo $lang->doc->libType?></th> <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>
<tr class='product'> <tr class='product'>
<th><?php echo $lang->doc->product?></th> <th><?php echo $lang->doc->product?></th>
+2 -4
View File
@@ -71,10 +71,8 @@ class jenkinsModel extends model
$jenkinsUser = $jenkins->account; $jenkinsUser = $jenkins->account;
$jenkinsPassword = $jenkins->token ? $jenkins->token : $jenkins->password; $jenkinsPassword = $jenkins->token ? $jenkins->token : $jenkins->password;
$jenkinsAuth = '://' . $jenkinsUser . ':' . $jenkinsPassword . '@'; $userPwd = "$jenkinsUser:$jenkinsPassword";
$jenkinsServer = str_replace('://', $jenkinsAuth, $jenkinsServer); $response = common::http($jenkinsServer . '/api/json/items/list', '', false, $userPwd);
$response = common::http($jenkinsServer . '/api/json/items/list');
$response = json_decode($response); $response = json_decode($response);
$tasks = array(); $tasks = array();
+2 -2
View File
@@ -221,7 +221,7 @@ class jobModel extends model
->fetch(); ->fetch();
if(!$job) return false; if(!$job) return false;
$buildUrl = $this->loadModel('compile')->getBuildUrl($job); $buildUrl = $this->loadModel('compile')->getBuildUrl($job);
$build = new stdclass(); $build = new stdclass();
$build->job = $job->id; $build->job = $job->id;
$build->name = $job->name; $build->name = $job->name;
@@ -273,7 +273,7 @@ class jobModel extends model
$data->ZENTAO_DATA = "compile={$compileID}"; $data->ZENTAO_DATA = "compile={$compileID}";
$compile = new stdclass(); $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'; $compile->status = $compile->queue ? 'created' : 'create_fail';
$this->dao->update(TABLE_COMPILE)->data($compile)->where('id')->eq($compileID)->exec(); $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->modules = $this->tree->getTaskOptionMenu($projectID, 0, 0, $showAllModule ? 'allModule' : '');
$this->view->moduleID = $moduleID; $this->view->moduleID = $moduleID;
$this->view->moduleTree = $this->tree->getTaskTreeMenu($projectID, $productID, $startModuleID = 0, array('treeModel', 'createTaskLink'), $extra); $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->branchGroups = $this->loadModel('branch')->getByProducts(array_keys($products), 'noempty');
$this->view->setModule = true; $this->view->setModule = true;
+3 -2
View File
@@ -17,13 +17,14 @@ class qaModel extends model
* @param array $products * @param array $products
* @param int $productID * @param int $productID
* @param int $branch * @param int $branch
* @param string $extra
* @access public * @access public
* @return void * @return void
*/ */
public function setMenu($products, $productID, $branch = 0) public function setMenu($products, $productID, $branch = 0, $extra = '')
{ {
$this->loadModel('product')->setMenu($products, $productID, $branch); $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 = ''; $productIndex = '';
$isMobile = $this->app->viewType == 'mhtml'; $isMobile = $this->app->viewType == 'mhtml';
+3 -3
View File
@@ -111,13 +111,13 @@ class releaseModel extends model
{ {
$productID = (int)$productID; $productID = (int)$productID;
$branch = (int)$branch; $branch = (int)$branch;
$buildID = 0; $buildID = strpos($this->config->release->create->requiredFields, 'build') === false ? 0 : '';
/* Check date must be not more than today. */ /* Check date must be not more than today. */
if($this->post->date > date('Y-m-d')) return dao::$errors[] = $this->lang->release->errorDate; if($this->post->date > date('Y-m-d')) return dao::$errors[] = $this->lang->release->errorDate;
/* Auto create build when release is not link build. */ /* 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) $build = $this->dao->select('*')->from(TABLE_BUILD)
->where('deleted')->eq('0') ->where('deleted')->eq('0')
@@ -161,7 +161,7 @@ class releaseModel extends model
->stripTags($this->config->release->editor->create['id'], $this->config->allowedTags) ->stripTags($this->config->release->editor->create['id'], $this->config->allowedTags)
->remove('allchecker,files,labels,uid') ->remove('allchecker,files,labels,uid')
->get(); ->get();
$release = $this->loadModel('file')->processImgURL($release, $this->config->release->editor->create['id'], $this->post->uid); $release = $this->loadModel('file')->processImgURL($release, $this->config->release->editor->create['id'], $this->post->uid);
$this->dao->insert(TABLE_RELEASE)->data($release) $this->dao->insert(TABLE_RELEASE)->data($release)
->autoCheck() ->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->title = $this->view->project->name . $this->lang->colon . $this->lang->task->assign;
$this->view->position[] = $this->lang->task->assign; $this->view->position[] = $this->lang->task->assign;
$this->view->task = $task; $this->view->task = $task;
$this->view->members = $members; $this->view->members = $members + array('closed' => 'Closed');
$this->view->users = $this->loadModel('user')->getPairs(); $this->view->users = $this->loadModel('user')->getPairs();
$this->display(); $this->display();
} }
+3 -1
View File
@@ -1603,6 +1603,7 @@ class taskModel extends model
->get(); ->get();
$this->dao->update(TABLE_TASK)->data($task)->autoCheck()->where('id')->eq((int)$taskID)->exec(); $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 > 0) $this->updateParentStatus($taskID);
if($oldTask->parent == '-1') if($oldTask->parent == '-1')
{ {
@@ -2491,6 +2492,7 @@ class taskModel extends model
{ {
$tasks = $this->dao->select('id,deadline')->from(TABLE_TASK)->alias('t1') $tasks = $this->dao->select('id,deadline')->from(TABLE_TASK)->alias('t1')
->where($this->reportCondition()) ->where($this->reportCondition())
->orderBy('deadline asc')
->fetchAll('id'); ->fetchAll('id');
if(!$tasks) return array(); if(!$tasks) return array();
@@ -2662,7 +2664,7 @@ class taskModel extends model
if(!isset($fields[$task->$field])) $fields[$task->$field] = 0; if(!isset($fields[$task->$field])) $fields[$task->$field] = 0;
$fields[$task->$field] ++; $fields[$task->$field] ++;
} }
asort($fields); if($field != 'date' and $field != 'deadline') asort($fields);
foreach($fields as $field => $count) foreach($fields as $field => $count)
{ {
$data = new stdclass(); $data = new stdclass();
+2 -2
View File
@@ -41,7 +41,7 @@
<span class='input-group-addon'> ~ </span> <span class='input-group-addon'> ~ </span>
<?php echo html::input('end', $end, "class='form-control form-date'")?> <?php echo html::input('end', $end, "class='form-control form-date'")?>
<?php <?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); echo html::hidden('objectID', $objectID) . html::hidden('objectType', $objectType);
?> ?>
</div> </div>
@@ -67,7 +67,7 @@
<?php if($config->global->flow != 'onlyTest'):?> <?php if($config->global->flow != 'onlyTest'):?>
<tr> <tr>
<th><?php echo $lang->testreport->goal?></th> <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> <td></td>
</tr> </tr>
<?php endif;?> <?php endif;?>
+1
View File
@@ -147,6 +147,7 @@ class webhook extends control
$this->session->set('bugList', $uri); $this->session->set('bugList', $uri);
$this->session->set('caseList', $uri); $this->session->set('caseList', $uri);
$this->session->set('testtaskList', $uri); $this->session->set('testtaskList', $uri);
$this->session->set('todoList', $uri);
$this->app->loadClass('pager', $static = true); $this->app->loadClass('pager', $static = true);
$pager = new pager($recTotal, $recPerPage, $pageID); $pager = new pager($recTotal, $recPerPage, $pageID);
+1
View File
@@ -104,6 +104,7 @@ class webhookModel extends model
$log->action = $text; $log->action = $text;
$log->actionURL = $this->getViewLink($action->objectType, $action->objectID); $log->actionURL = $this->getViewLink($action->objectType, $action->objectID);
$log->module = $action->objectType; $log->module = $action->objectType;
$log->moduleID = $action->objectID;
$log->dialog = $action->objectType == 'todo' ? 1 : 0; $log->dialog = $action->objectType == 'todo' ? 1 : 0;
} }
return $logs; return $logs;
+1 -1
View File
@@ -45,7 +45,7 @@
<td><?php echo $log->date;?></td> <td><?php echo $log->date;?></td>
<td title='<?php echo $log->url;?>'><?php echo $log->url;?></td> <td title='<?php echo $log->url;?>'><?php echo $log->url;?></td>
<?php $iframe = $log->dialog == 1 ? 'data-toggle="modal" data-type="iframe"' : '';?> <?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->objectID", '' , true)?> <?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->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->contentType;?>'><?php echo $log->contentType;?></td>
<td title='<?php echo $log->result;?>'><?php echo $log->result;?></td> <td title='<?php echo $log->result;?>'><?php echo $log->result;?></td>
+7 -7
View File
File diff suppressed because one or more lines are too long