From 15bd66d47bd727f6124745e8168dfb13ccaf27cf Mon Sep 17 00:00:00 2001 From: hufangzhou Date: Wed, 4 Aug 2021 14:22:59 +0800 Subject: [PATCH 1/9] * Fix bug #14044. --- module/action/lang/en.php | 2 +- module/action/lang/zh-cn.php | 2 +- module/action/model.php | 12 +++++++++++- module/doc/control.php | 8 ++++++-- module/doc/model.php | 22 +++++++++++++++------- 5 files changed, 34 insertions(+), 12 deletions(-) diff --git a/module/action/lang/en.php b/module/action/lang/en.php index e3b3b3aee2..6c13ef31b2 100755 --- a/module/action/lang/en.php +++ b/module/action/lang/en.php @@ -477,7 +477,7 @@ $lang->action->label->testtask = 'Request|testtask|view|caseID=%s'; $lang->action->label->testsuite = 'Test Suite|testsuite|view|suiteID=%s'; $lang->action->label->caselib = 'Case Library|caselib|view|libID=%s'; $lang->action->label->todo = 'Todo|todo|view|todoID=%s'; -$lang->action->label->doclib = 'Doc Library|doc|browse|libID=%s'; +$lang->action->label->doclib = 'Doc Library|doc|objectLibs|type=%s&objectID=%s&libID=%s&docID=&version=&appendLib=%s'; $lang->action->label->doc = 'Doc|doc|view|docID=%s'; $lang->action->label->user = 'User|user|view|account=%s'; $lang->action->label->testreport = 'Report|testreport|view|report=%s'; diff --git a/module/action/lang/zh-cn.php b/module/action/lang/zh-cn.php index a328ca7951..668e3db99d 100755 --- a/module/action/lang/zh-cn.php +++ b/module/action/lang/zh-cn.php @@ -477,7 +477,7 @@ $lang->action->label->testtask = '测试单|testtask|view|caseID=%s'; $lang->action->label->testsuite = '测试套件|testsuite|view|suiteID=%s'; $lang->action->label->caselib = '用例库|caselib|view|libID=%s'; $lang->action->label->todo = '待办|todo|view|todoID=%s'; -$lang->action->label->doclib = '文档库|doc|objectLibs|type=&objectID=&libID=%s'; +$lang->action->label->doclib = '文档库|doc|objectLibs|type=%s&objectID=%s&libID=%s&docID=&version=&appendLib=%s'; $lang->action->label->doc = '文档|doc|view|docID=%s'; $lang->action->label->user = '用户|user|view|account=%s'; $lang->action->label->testreport = '报告|testreport|view|report=%s'; diff --git a/module/action/model.php b/module/action/model.php index d20d43f87d..2fa6a5bf5f 100755 --- a/module/action/model.php +++ b/module/action/model.php @@ -1093,7 +1093,17 @@ class actionModel extends model } else { - $action->objectLink = helper::createLink($moduleName, $methodName, sprintf($vars, $action->objectID), '', '', $projectID); + if($action->objectType == 'doclib') + { + $docLib = $this->dao->select('type,product,project,execution,deleted')->from(TABLE_DOCLIB)->where('id')->eq($action->objectID)->fetch(); + $docLib->objectID = strpos('product,project,execution', $docLib->type) !== false ? $docLib->{$docLib->type} : 0; + $appendLib = $docLib->deleted == '1' ? $action->objectID : 0; + $action->objectLink = helper::createLink('doc', 'objectLibs', sprintf($vars, $docLib->type, $docLib->objectID, $action->objectID, $appendLib)); + } + else + { + $action->objectLink = helper::createLink($moduleName, $methodName, sprintf($vars, $action->objectID), '', '', $projectID); + } } $action->objectLabel = $objectLabel; } diff --git a/module/doc/control.php b/module/doc/control.php index 08aa7fac51..0fd59e4825 100644 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -875,12 +875,16 @@ class doc extends control * @param int $libID * @param int $docID * @param int $version + * @param int $appendLib * @access public * @return void */ - public function objectLibs($type, $objectID = 0, $libID = 0, $docID = 0, $version = 0) + public function objectLibs($type, $objectID = 0, $libID = 0, $docID = 0, $version = 0, $appendLib = 0) { - list($libs, $libID, $object, $objectID) = $this->doc->setMenuByType($type, $objectID, $libID); + $lib = $this->doc->getLibById($libID); + if(!empty($lib) and $lib->deleted == '1') $appendLib = $libID; + + list($libs, $libID, $object, $objectID) = $this->doc->setMenuByType($type, $objectID, $libID, $appendLib); /* Set Custom. */ foreach(explode(',', $this->config->doc->customObjectLibs) as $libType) $customObjectLibs[$libType] = $this->lang->doc->customObjectLibs[$libType]; diff --git a/module/doc/model.php b/module/doc/model.php index fc95142170..9ec28509f3 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -1050,16 +1050,18 @@ class docModel extends model * @param string $type * @param int $objectID * @param string $mode + * @param int $appendLib * @access public * @return array */ - public function getLibsByObject($type, $objectID, $mode = '') + public function getLibsByObject($type, $objectID, $mode = '', $appendLib = 0) { if($type == 'custom' or $type == 'book') { $objectLibs = $this->dao->select('*')->from(TABLE_DOCLIB) ->where('deleted')->eq(0) ->andWhere('type')->eq($type) + ->beginIF(!empty($appendLib))->orWhere('id')->eq($appendLib)->fi() ->beginIF($type == 'custom')->orderBy('`order`, id')->fi() ->beginIF($type == 'book')->orderBy('id_desc')->fi() ->fetchAll('id'); @@ -1070,12 +1072,17 @@ class docModel extends model } else { - $objectLibs = $this->dao->select('*')->from(TABLE_DOCLIB)->where('deleted')->eq(0)->andWhere($type)->eq($objectID)->orderBy('`order`, id')->fetchAll('id'); + $objectLibs = $this->dao->select('*')->from(TABLE_DOCLIB) + ->where('deleted')->eq(0) + ->andWhere($type)->eq($objectID) + ->beginIF(!empty($appendLib))->orWhere('id')->eq($appendLib)->fi() + ->orderBy('`order`, id') + ->fetchAll('id'); } if($type == 'product') { - $hasProject = $this->dao->select('DISTINCT t1.product, count(t1.project) as projectCount')->from(TABLE_PROJECTPRODUCT)->alias('t1') + $hasProject = $this->dao->select('DISTINCT t1.product, count(t1.project) as projectCount')->from(TABLE_PROJECTPRODUCT)->alias('t1') ->leftJoin(TABLE_EXECUTION)->alias('t2')->on('t1.project=t2.id') ->where('t1.product')->eq($objectID) ->beginIF(strpos($this->config->doc->custom->showLibs, 'unclosed') !== false)->andWhere('t2.status')->notin('done,closed')->fi() @@ -2253,10 +2260,11 @@ EOT; * @param string $type * @param int $objectID * @param int $libID + * @param int $appendLib * @access public * @return array */ - public function setMenuByType($type, $objectID, $libID) + public function setMenuByType($type, $objectID, $libID, $appendLib = 0) { if(empty($type)) { @@ -2271,7 +2279,7 @@ EOT; if($type == 'custom') { - $libs = $this->getLibsByObject('custom', 0); + $libs = $this->getLibsByObject('custom', 0, '', $appendLib); $this->app->rawMethod = 'custom'; if($libID == 0) $libID = key($libs); $this->lang->modulePageNav = $this->select($type, $objects, $objectID, $libs, $libID); @@ -2281,7 +2289,7 @@ EOT; } elseif($type == 'book') { - $libs = $this->getLibsByObject('book', 0); + $libs = $this->getLibsByObject('book', 0, '', $appendLib); $this->app->rawMethod = 'book'; if($libID == 0 and !empty($libs)) $libID = reset($libs)->id; $this->lang->modulePageNav = $this->select($type, $objects, $objectID, $libs, $libID); @@ -2293,7 +2301,7 @@ EOT; { $objectID = $this->loadModel($type)->saveState($objectID, $objects); $table = $this->config->objectTables[$type]; - $libs = $this->getLibsByObject($type, $objectID); + $libs = $this->getLibsByObject($type, $objectID, '', $appendLib); if($libID == 0) $libID = key($libs); $this->lang->modulePageNav = $this->select($type, $objects, $objectID, $libs, $libID); From b8156cc66c36f885a58603cf195a946227915759 Mon Sep 17 00:00:00 2001 From: hufangzhou Date: Wed, 4 Aug 2021 14:26:58 +0800 Subject: [PATCH 2/9] * Fix bug #13983. --- module/doc/css/objectlibs.css | 1 + 1 file changed, 1 insertion(+) diff --git a/module/doc/css/objectlibs.css b/module/doc/css/objectlibs.css index 68f7199b07..1cadc6f3f0 100644 --- a/module/doc/css/objectlibs.css +++ b/module/doc/css/objectlibs.css @@ -39,3 +39,4 @@ #outline li.has-list.open:before {content: unset;} .title {font-size: 20px !important;} +.article-content.comment {width: 100% !important;} From 59d8d2f3dc5a0a0c64c555dc6bdb62fea776cc6c Mon Sep 17 00:00:00 2001 From: hufangzhou Date: Wed, 4 Aug 2021 14:53:43 +0800 Subject: [PATCH 3/9] * Fix bug #14044. --- module/action/model.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/module/action/model.php b/module/action/model.php index 2fa6a5bf5f..7d37907654 100755 --- a/module/action/model.php +++ b/module/action/model.php @@ -1096,7 +1096,8 @@ class actionModel extends model if($action->objectType == 'doclib') { $docLib = $this->dao->select('type,product,project,execution,deleted')->from(TABLE_DOCLIB)->where('id')->eq($action->objectID)->fetch(); - $docLib->objectID = strpos('product,project,execution', $docLib->type) !== false ? $docLib->{$docLib->type} : 0; + $docLib->type = $docLib->type == 'execution' ? 'project' : $docLib->type; + $docLib->objectID = strpos('product,project', $docLib->type) !== false ? $docLib->{$docLib->type} : 0; $appendLib = $docLib->deleted == '1' ? $action->objectID : 0; $action->objectLink = helper::createLink('doc', 'objectLibs', sprintf($vars, $docLib->type, $docLib->objectID, $action->objectID, $appendLib)); } From f4361e7d28f8d50ceb3384c11e0753956ce86835 Mon Sep 17 00:00:00 2001 From: zenggang Date: Wed, 4 Aug 2021 15:02:57 +0800 Subject: [PATCH 4/9] * delete not need --- test.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 test.txt diff --git a/test.txt b/test.txt deleted file mode 100644 index e69de29bb2..0000000000 From 67a3e241558dbccb975a4b3b476e7b68b4ff31bf Mon Sep 17 00:00:00 2001 From: dingguodong Date: Wed, 4 Aug 2021 15:22:05 +0800 Subject: [PATCH 5/9] * Set menu when changing tab(menu) from gitlab to repo. --- module/gitlab/control.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/module/gitlab/control.php b/module/gitlab/control.php index ba1521bdba..7b57720e1b 100644 --- a/module/gitlab/control.php +++ b/module/gitlab/control.php @@ -23,6 +23,9 @@ class gitlab extends control */ public function browse($orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) { + /* This is essential when changing tab(menu) from gitlab to repo. */ + common::setMenuVars('devops', $this->session->repoID); + $this->app->loadClass('pager', $static = true); $pager = new pager($recTotal, $recPerPage, $pageID); From 4fb7cb2fda9f27d58ab3060549f4fb743cfa65fb Mon Sep 17 00:00:00 2001 From: zenggang Date: Wed, 4 Aug 2021 15:43:56 +0800 Subject: [PATCH 6/9] * Finish task #40893 --- module/bug/js/common.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/module/bug/js/common.js b/module/bug/js/common.js index 21b9e0fdd8..af1bf9a0bf 100644 --- a/module/bug/js/common.js +++ b/module/bug/js/common.js @@ -525,7 +525,11 @@ function loadAssignedTo(executionID, selectedUser) $('#assignedTo').next('.picker').remove(); $('#assignedTo').replaceWith(data); var defaultAssignedTo = $('#assignedTo').val(); - if(defaultAssignedTo !== oldAssignedTo && selectedUser == '') $('#assignedTo').append(defaultOption); + if(defaultAssignedTo !== oldAssignedTo && selectedUser == '') + { + if($('#assignedTo option[value="' + oldAssignedTo + '"]').length > 0) $('#assignedTo option[value="' + oldAssignedTo + '"]').remove(); + $('#assignedTo').append(defaultOption); + } $('#assignedTo').chosen(); }); } From d19f75d212b5d57a990ce6f3f9378ce7f09c8aa0 Mon Sep 17 00:00:00 2001 From: Guan Xiying Date: Wed, 4 Aug 2021 15:57:53 +0800 Subject: [PATCH 7/9] * Adjust default per_page param for get commits from gitlab api. --- lib/scm/gitlab.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/scm/gitlab.class.php b/lib/scm/gitlab.class.php index 7b3c455158..36cd0ac41e 100644 --- a/lib/scm/gitlab.class.php +++ b/lib/scm/gitlab.class.php @@ -519,7 +519,7 @@ class gitlab $api = "commits"; /* TODO Put getCommits into cron job. And check best size of $count. */ - if(empty($count)) $count = 1; + if(empty($count)) $count = 10; $params = array(); $params['ref_name'] = $branch; From 1cf618686d73a24faf18c94222620d7b37bc0288 Mon Sep 17 00:00:00 2001 From: Guan Xiying Date: Wed, 4 Aug 2021 15:58:53 +0800 Subject: [PATCH 8/9] * Fix prefix of gitlab repo. --- module/repo/model.php | 6 ++++-- module/upgrade/model.php | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/module/repo/model.php b/module/repo/model.php index 8dd2505800..f96cad2fe1 100644 --- a/module/repo/model.php +++ b/module/repo/model.php @@ -202,6 +202,7 @@ class repoModel extends model ->setIf($this->post->SCM == 'Gitlab', 'path', $this->post->gitlabProject) ->setIf($this->post->SCM == 'Gitlab', 'client', $this->post->gitlabHost) ->setIf($this->post->SCM == 'Gitlab', 'extra', $this->post->gitlabProject) + ->setIf($this->post->SCM == 'Gitlab', 'prefix', '') ->skipSpecial('path,client,account,password') ->setDefault('product', '') ->join('product', ',') @@ -249,8 +250,9 @@ class repoModel extends model ->setIf($this->post->SCM == 'Gitlab', 'path', $this->post->gitlabProject) ->setIf($this->post->SCM == 'Gitlab', 'client', $this->post->gitlabHost) ->setIf($this->post->SCM == 'Gitlab', 'extra', $this->post->gitlabProject) - ->setDefault('client', 'svn') ->setDefault('prefix', $repo->prefix) + ->setIf($this->post->SCM == 'Gitlab', 'prefix', '') + ->setDefault('client', 'svn') ->setDefault('product', '') ->skipSpecial('path,client,account,password') ->join('product', ',') @@ -429,7 +431,7 @@ class repoModel extends model public function getCommits($repo, $entry, $revision = 'HEAD', $type = 'dir', $pager = null, $begin = 0, $end = 0) { $entry = ltrim($entry, '/'); - if($repo->SCM != 'Gitlab') $entry = $repo->prefix . (empty($entry) ? '' : '/' . $entry); + $entry = $repo->prefix . (empty($entry) ? '' : '/' . $entry); $repoID = $repo->id; $revisionTime = $this->dao->select('time')->from(TABLE_REPOHISTORY)->alias('t1') diff --git a/module/upgrade/model.php b/module/upgrade/model.php index cc8fa960fb..d14a6b53c3 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -5151,6 +5151,7 @@ class upgradeModel extends model $gitlabID = $this->dao->lastInsertID(); $this->dao->update(TABLE_REPO)->set('client')->eq($gitlabID)->set('path')->eq($repo->extra)->where('id')->eq($repo->id)->exec(); } + $this->dao->update(TABLE_REPO)->set('prefix')->eq('')->where('SCM')->eq('Gitlab')->exec(); return true; } From 183bd16df3e3ed22885d4ef536c1cabd18082173 Mon Sep 17 00:00:00 2001 From: tianshujie98 Date: Wed, 4 Aug 2021 16:29:10 +0800 Subject: [PATCH 9/9] * Fix bug #13973. --- module/execution/control.php | 2 +- module/project/control.php | 2 +- module/testcase/control.php | 2 +- module/upgrade/model.php | 13 +++++++++++-- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/module/execution/control.php b/module/execution/control.php index f62dbed7e6..eaf395ea53 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1758,7 +1758,7 @@ class execution extends control */ public function view($executionID) { - $executionID = (int)$executionID; + $executionID = $this->execution->saveState((int)$executionID, $this->executions); $execution = $this->execution->getById($executionID, true); if(empty($execution) || strpos('stage,sprint', $execution->type) === false) die(js::error($this->lang->notFound) . js::locate('back')); diff --git a/module/project/control.php b/module/project/control.php index 8795e52885..29c2257158 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -558,7 +558,7 @@ class project extends control */ public function view($projectID = 0) { - $projectID = (int)$projectID; + $projectID = $this->project->saveState((int)$projectID, $this->project->getPairsByProgram()); $project = $this->project->getById($projectID); if(empty($project) || strpos('scrum,waterfall', $project->model) === false) die(js::error($this->lang->notFound) . js::locate('back')); diff --git a/module/testcase/control.php b/module/testcase/control.php index 96f74d4eab..fe08fa75b8 100644 --- a/module/testcase/control.php +++ b/module/testcase/control.php @@ -117,7 +117,7 @@ class testcase extends control /* Set menu, save session. */ if($this->app->openApp == 'project') { - $this->products = array('0' => $this->lang->product->all) + $this->loadModel('project')->getProducts($this->session->project, false); + $this->products = array('0' => $this->lang->product->all) + $this->loadModel('project')->getProducts($projectID, false); $this->loadModel('project')->setMenu($projectID); } else diff --git a/module/upgrade/model.php b/module/upgrade/model.php index ddadd9c477..86e3a038b0 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -4508,7 +4508,6 @@ class upgradeModel extends model if(!$projectID) die(js::alert($this->lang->upgrade->projectEmpty)); $this->dao->update(TABLE_BUG)->set('project')->eq($projectID)->where('product')->in($productIdList)->exec(); - $this->dao->update(TABLE_CASE)->set('project')->eq($projectID)->where('product')->in($productIdList)->exec(); $this->dao->update(TABLE_TESTREPORT)->set('project')->eq($projectID)->where('product')->in($productIdList)->exec(); $this->dao->update(TABLE_TESTSUITE)->set('project')->eq($projectID)->where('product')->in($productIdList)->exec(); $this->dao->update(TABLE_BUILD)->set('project')->eq($projectID)->where('product')->in($productIdList)->exec(); @@ -4519,6 +4518,7 @@ class upgradeModel extends model $this->dao->update(TABLE_BUG)->set('project')->eq($projectID)->where('execution')->in($sprintIdList)->andWhere('project')->eq(0)->exec(); $this->dao->update(TABLE_DOC)->set('project')->eq($projectID)->set('type')->eq('execution')->where("lib IN(SELECT id from " . TABLE_DOCLIB . " WHERE type = 'project' and execution " . helper::dbIN($sprintIdList) . ')')->exec(); $this->dao->update(TABLE_DOCLIB)->set('project')->eq($projectID)->where('type')->eq('execution')->andWhere('execution')->in($sprintIdList)->exec(); + $this->dao->update(TABLE_TESTTASK)->set('project')->eq($projectID)->where('execution')->in($sprintIdList)->exec(); /* Put sprint stories into project story mdoule. */ $sprintStories = $this->dao->select('*')->from(TABLE_PROJECTSTORY) @@ -4539,9 +4539,18 @@ class upgradeModel extends model ->where('t1.execution')->in($sprintIdList) ->fetchAll(); + $sprintCases += $this->dao->select('`case`,product,project,count,version')->from(TABLE_PROJECTCASE)->where('project')->in($sprintIdList)->fetchAll(); + foreach($sprintCases as $projectCase) { - $projectCase->order = $projectCase * 5; + $caes = new stdClass(); + $case->case = $projectCase->case; + $case->order = $projectCase->case * 5; + $case->project = $projectCase->project; + $case->product = $projectCase->product; + $this->dao->replace(TABLE_PROJECTCASE)->data($case)->exec(); + + $projectCase->order = $projectCase->case * 5; $projectCase->project = $projectID; $this->dao->replace(TABLE_PROJECTCASE)->data($projectCase)->exec(); }