From 8f861c26afe09eec94de83711dcaa5a3e0c9c3d8 Mon Sep 17 00:00:00 2001 From: holan20180123 <56391770@qq.com> Date: Wed, 14 Apr 2021 09:37:09 +0800 Subject: [PATCH 01/30] * Fix bug #11940. --- module/task/control.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/module/task/control.php b/module/task/control.php index 2397be26ae..3e01190019 100644 --- a/module/task/control.php +++ b/module/task/control.php @@ -1228,6 +1228,13 @@ class task extends control die(js::locate($this->createLink('task', 'view', "taskID=$taskID"), 'parent')); } + if(!empty($this->view->task->team)) + { + $members = array(); + foreach($this->view->task->team as $account => $member) $members[$account] = zget($this->view->members, $account); + $this->view->members = $members; + } + if(!isset($this->view->members[$this->view->task->finishedBy])) $this->view->members[$this->view->task->finishedBy] = $this->view->task->finishedBy; $this->view->title = $this->view->execution->name . $this->lang->colon . $this->lang->task->activate; $this->view->position[] = $this->lang->task->activate; From c9ae3314038be0d82b6b65c07b297f9abff3ef8b Mon Sep 17 00:00:00 2001 From: tianshujie98 Date: Wed, 14 Apr 2021 09:37:43 +0800 Subject: [PATCH 02/30] * Fix bug #11495. --- module/extension/control.php | 2 +- module/extension/css/obtain.css | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/module/extension/control.php b/module/extension/control.php index 3d7e51b94e..f88933e476 100644 --- a/module/extension/control.php +++ b/module/extension/control.php @@ -89,7 +89,7 @@ class extension extends control { /* Init vars. */ $type = strtolower($type); - $moduleID = $type == 'bymodule' ? (int)$param : 0; + $moduleID = $type == 'bymodule' ? (int)base64_decode($param) : 0; $extensions = array(); $pager = null; diff --git a/module/extension/css/obtain.css b/module/extension/css/obtain.css index 43cfa0743a..00a2b3495f 100644 --- a/module/extension/css/obtain.css +++ b/module/extension/css/obtain.css @@ -1 +1,3 @@ .pager {margin-top: 0;} +.tree li>a:hover {color: #fff; background-color: #0c64eb;} +.tree li>a.active {color: #fff; background-color: #0c64eb;} From 909b3d9e13f25dc70adfe2d0d6a22076ad1d78d1 Mon Sep 17 00:00:00 2001 From: Yagami <976204163@qq.com> Date: Wed, 14 Apr 2021 09:43:53 +0800 Subject: [PATCH 03/30] * Fix doc details. --- module/doc/control.php | 2 +- module/doc/model.php | 9 +-------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/module/doc/control.php b/module/doc/control.php index c1fc4f5226..e90b33ef34 100644 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -310,7 +310,7 @@ class doc extends control $unclosed = strpos($this->config->doc->custom->showLibs, 'unclosed') !== false ? 'unclosedProject' : ''; $this->view->libID = $libID; - $this->view->libs = $this->doc->getLibs($type = 'all', $extra = "withObject,$unclosed", $libID, $objectID); + $this->view->libs = $this->doc->getLibs($objectType, $extra = "withObject,$unclosed", $libID, $objectID); $this->view->libName = $this->dao->findByID($libID)->from(TABLE_DOCLIB)->fetch('name'); $this->view->moduleOptionMenu = $this->tree->getOptionMenu($libID, 'doc', $startModuleID = 0); $this->view->moduleID = $moduleID ? (int)$moduleID : (int)$this->cookie->lastDocModule; diff --git a/module/doc/model.php b/module/doc/model.php index e0f2aa7f2a..0178b75275 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -37,14 +37,7 @@ class docModel extends model */ public function getLibs($type = '', $extra = '', $appendLibs = '', $objectID = 0) { - if($type == 'product' or $type == 'project' or $type == 'execution') - { - $stmt = $this->dao->select('*')->from(TABLE_DOCLIB) - ->where($type)->eq($objectID) - ->andWhere('deleted')->eq('0') - ->query(); - } - elseif($type == 'all') + if($type == 'all') { $stmt = $this->dao->select('*')->from(TABLE_DOCLIB) ->where('deleted')->eq(0) From 16d12813c4394d5db6da333b92af7c9b89b14257 Mon Sep 17 00:00:00 2001 From: Yagami <976204163@qq.com> Date: Wed, 14 Apr 2021 09:48:03 +0800 Subject: [PATCH 04/30] * Remove comment for execution setMenu. --- module/execution/model.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/module/execution/model.php b/module/execution/model.php index 80200ad880..ff16b54b77 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -69,16 +69,12 @@ class executionModel extends model /* Unset story, bug, build and testtask if type is ops. */ $execution = $this->getByID($executionID); - /* if($execution and $execution->lifetime == 'ops') { unset($this->lang->execution->menu->story); unset($this->lang->execution->menu->qa); - unset($this->lang->execution->subMenu->qa->bug); - unset($this->lang->execution->subMenu->qa->build); - unset($this->lang->execution->subMenu->qa->testtask); + unset($this->lang->execution->menu->build); } - */ /* Hide story and qa menu when execution is story or design type. */ /* From ba56961f03d8180cd1b79044192df5ad1e4d9516 Mon Sep 17 00:00:00 2001 From: tianshujie98 Date: Wed, 14 Apr 2021 09:52:47 +0800 Subject: [PATCH 05/30] * Fix bug #11544. --- module/execution/model.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/module/execution/model.php b/module/execution/model.php index 80200ad880..f950579149 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -1482,7 +1482,8 @@ class executionModel extends model ->leftJoin(TABLE_PRODUCT)->alias('t2') ->on('t1.product = t2.id') ->where('t1.project')->eq((int)$executionID) - ->andWhere('t2.deleted')->eq(0); + ->andWhere('t2.deleted')->eq(0) + ->beginIF(!$this->app->user->admin)->andWhere('t2.id')->in($this->app->user->view->products)->fi(); if(!$withBranch) return $query->fetchPairs('id', 'name'); return $query->fetchAll('id'); } From fd56c9d71ccb1d2330b9aaca1091f048d8f5710a Mon Sep 17 00:00:00 2001 From: holan20180123 <56391770@qq.com> Date: Wed, 14 Apr 2021 10:01:22 +0800 Subject: [PATCH 06/30] * Fix bug #11915. --- module/build/js/edit.js | 3 +-- module/build/model.php | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/module/build/js/edit.js b/module/build/js/edit.js index 3e58d95168..75f685f686 100644 --- a/module/build/js/edit.js +++ b/module/build/js/edit.js @@ -1,9 +1,8 @@ -var executionID = $('#execution').val(); function loadExecutions() { var productID = $('#product').val(); var branchID = $('#branch').length > 0 ? $('#branch').val() : 0; - $('#executionsBox').load(createLink('product', 'ajaxGetExecutions', 'productID=' + productID + '&executionID=' + executionID + '&branch=' + branchID), function() + $('#executionsBox').load(createLink('product', 'ajaxGetExecutions', 'productID=' + productID + '&executionID=0&branch=' + branchID), function() { $('#executionsBox #execution').chosen().removeAttr('onchange'); }); diff --git a/module/build/model.php b/module/build/model.php index 294f92c285..32f83db38a 100644 --- a/module/build/model.php +++ b/module/build/model.php @@ -394,7 +394,6 @@ class buildModel extends model $oldBuild = $this->dao->select('*')->from(TABLE_BUILD)->where('id')->eq($buildID)->fetch(); $build = fixer::input('post')->stripTags($this->config->build->editor->edit['id'], $this->config->allowedTags) ->setDefault('product', $oldBuild->product) - ->setDefault('branch', $oldBuild->branch) ->cleanInt('product,branch,execution') ->remove('allchecker,resolvedBy,files,labels,uid') ->get(); From 18840c71a45c0f015252c9fe3e55f6c073838ba8 Mon Sep 17 00:00:00 2001 From: leiyong <1549684884@qq.com> Date: Wed, 14 Apr 2021 02:01:46 +0000 Subject: [PATCH 07/30] * Adjust code. --- module/execution/model.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/module/execution/model.php b/module/execution/model.php index 2e96702dca..e4ec11c128 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -2055,12 +2055,13 @@ class executionModel extends model $planStories = array(); $planProducts = array(); $count = 0; + $this->loadModel('story'); if(!empty($plans)) { foreach($plans as $planID => $productID) { if(empty($planID)) continue; - $planStory = $this->loadModel('story')->getPlanStories($planID); + $planStory = $this->story->getPlanStories($planID); if(!empty($planStory)) { foreach($planStory as $id => $story) From 352fcc29b9864e1e1e676ea2d703a41ea9a4afc7 Mon Sep 17 00:00:00 2001 From: Yagami <976204163@qq.com> Date: Wed, 14 Apr 2021 10:01:20 +0800 Subject: [PATCH 08/30] * Add upgrade logic. --- VERSION | 2 +- config/config.php | 2 +- module/misc/lang/de.php | 2 ++ module/misc/lang/en.php | 2 ++ module/misc/lang/fr.php | 2 ++ module/misc/lang/vi.php | 2 ++ module/misc/lang/zh-cn.php | 2 ++ module/upgrade/lang/version.php | 1 + module/upgrade/model.php | 3 +++ 9 files changed, 16 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 893d61407f..a0bf4fe0a2 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -15.0.rc2 +15.0.rc3 diff --git a/config/config.php b/config/config.php index 149c92900b..a59d0e88eb 100644 --- a/config/config.php +++ b/config/config.php @@ -16,7 +16,7 @@ if(!class_exists('config')){class config{}} if(!function_exists('getWebRoot')){function getWebRoot(){}} /* 基本设置。Basic settings. */ -$config->version = '15.0.rc2'; // ZenTaoPHP的版本。 The version of ZenTaoPHP. Don't change it. +$config->version = '15.0.rc3'; // ZenTaoPHP的版本。 The version of ZenTaoPHP. Don't change it. $config->charset = 'UTF-8'; // ZenTaoPHP的编码。 The encoding of ZenTaoPHP. $config->cookieLife = time() + 2592000; // Cookie的生存时间。The cookie life time. $config->timezone = 'Asia/Shanghai'; // 时区设置。 The time zone setting, for more see http://www.php.net/manual/en/timezones.php. diff --git a/module/misc/lang/de.php b/module/misc/lang/de.php index 0127d934ac..470d71b388 100644 --- a/module/misc/lang/de.php +++ b/module/misc/lang/de.php @@ -84,6 +84,7 @@ $lang->misc->feature = new stdclass(); $lang->misc->feature->lastest = 'Letzte Version'; $lang->misc->feature->detailed = 'Details'; +$lang->misc->releaseDate['15.0.rc3'] = '2021-04-16'; $lang->misc->releaseDate['15.0.rc2'] = '2021-04-09'; $lang->misc->releaseDate['15.0.rc1'] = '2021-04-05'; $lang->misc->releaseDate['12.5.3'] = '2021-01-06'; @@ -140,6 +141,7 @@ $lang->misc->releaseDate['7.2.stable'] = '2015-05-22'; $lang->misc->releaseDate['7.1.stable'] = '2015-03-07'; $lang->misc->releaseDate['6.3.stable'] = '2014-11-07'; +$lang->misc->feature->all['15.0.rc3'][] = array('title' => 'Adjust details,Fix bug', 'desc' => ''); $lang->misc->feature->all['15.0.rc2'][] = array('title' => 'Fix Bug.', 'desc' => ''); $lang->misc->feature->all['15.0.rc1'][] = array('title' => 'Upgrade to 15,reframe menu, add program.', 'desc' => ''); $lang->misc->feature->all['12.5.3'][] = array('title' => 'Adjust annual data.', 'desc' => ''); diff --git a/module/misc/lang/en.php b/module/misc/lang/en.php index bb1e093367..bbb343a7b9 100644 --- a/module/misc/lang/en.php +++ b/module/misc/lang/en.php @@ -84,6 +84,7 @@ $lang->misc->feature = new stdclass(); $lang->misc->feature->lastest = 'Latest Version'; $lang->misc->feature->detailed = 'Detail'; +$lang->misc->releaseDate['15.0.rc3'] = '2021-04-16'; $lang->misc->releaseDate['15.0.rc2'] = '2021-04-09'; $lang->misc->releaseDate['15.0.rc1'] = '2021-04-05'; $lang->misc->releaseDate['12.5.3'] = '2021-01-06'; @@ -140,6 +141,7 @@ $lang->misc->releaseDate['7.2.stable'] = '2015-05-22'; $lang->misc->releaseDate['7.1.stable'] = '2015-03-07'; $lang->misc->releaseDate['6.3.stable'] = '2014-11-07'; +$lang->misc->feature->all['15.0.rc3'][] = array('title' => 'Adjust details,Fix bug', 'desc' => ''); $lang->misc->feature->all['15.0.rc2'][] = array('title' => 'Fix Bug.', 'desc' => ''); $lang->misc->feature->all['15.0.rc1'][] = array('title' => 'Upgrade to 15,reframe menu, add program.', 'desc' => ''); $lang->misc->feature->all['12.5.3'][] = array('title' => 'Adjust annual data.', 'desc' => ''); diff --git a/module/misc/lang/fr.php b/module/misc/lang/fr.php index 2d0458f56a..98688ab3d7 100644 --- a/module/misc/lang/fr.php +++ b/module/misc/lang/fr.php @@ -84,6 +84,7 @@ $lang->misc->feature = new stdclass(); $lang->misc->feature->lastest = 'Dernière Version'; $lang->misc->feature->detailed = 'Détail'; +$lang->misc->releaseDate['15.0.rc3'] = '2021-04-16'; $lang->misc->releaseDate['15.0.rc2'] = '2021-04-09'; $lang->misc->releaseDate['15.0.rc1'] = '2021-04-05'; $lang->misc->releaseDate['12.5.3'] = '2021-01-06'; @@ -140,6 +141,7 @@ $lang->misc->releaseDate['7.2.stable'] = '2015-05-22'; $lang->misc->releaseDate['7.1.stable'] = '2015-03-07'; $lang->misc->releaseDate['6.3.stable'] = '2014-11-07'; +$lang->misc->feature->all['15.0.rc3'][] = array('title' => 'Adjust details, fix bug.', 'desc' => ''); $lang->misc->feature->all['15.0.rc2'][] = array('title' => 'Fix Bug.', 'desc' => ''); $lang->misc->feature->all['15.0.rc1'][] = array('title' => 'Upgrade to 15,reframe menu, add program.', 'desc' => ''); $lang->misc->feature->all['12.5.3'][] = array('title' => 'Adjust annual data.', 'desc' => ''); diff --git a/module/misc/lang/vi.php b/module/misc/lang/vi.php index 557f27373b..6dc8ed4018 100644 --- a/module/misc/lang/vi.php +++ b/module/misc/lang/vi.php @@ -84,6 +84,7 @@ $lang->misc->feature = new stdclass(); $lang->misc->feature->lastest = 'Latest Version'; $lang->misc->feature->detailed = 'Chi tiết'; +$lang->misc->releaseDate['15.0.rc3'] = '2021-04-16'; $lang->misc->releaseDate['15.0.rc2'] = '2021-04-09'; $lang->misc->releaseDate['15.0.rc1'] = '2021-04-05'; $lang->misc->releaseDate['12.5.3'] = '2021-01-06'; @@ -140,6 +141,7 @@ $lang->misc->releaseDate['7.2.stable'] = '2015-05-22'; $lang->misc->releaseDate['7.1.stable'] = '2015-03-07'; $lang->misc->releaseDate['6.3.stable'] = '2014-11-07'; +$lang->misc->feature->all['15.0.rc3'][] = array('title' => 'Adjust detail, fix bug.', 'desc' => ''); $lang->misc->feature->all['15.0.rc2'][] = array('title' => 'Fix Bug.', 'desc' => ''); $lang->misc->feature->all['15.0.rc1'][] = array('title' => 'Upgrade to 15,reframe menu, add program.', 'desc' => ''); $lang->misc->feature->all['12.5.3'][] = array('title' => 'Adjust annual data.', 'desc' => ''); diff --git a/module/misc/lang/zh-cn.php b/module/misc/lang/zh-cn.php index eeace1960c..ebad9c5999 100644 --- a/module/misc/lang/zh-cn.php +++ b/module/misc/lang/zh-cn.php @@ -84,6 +84,7 @@ $lang->misc->feature = new stdclass(); $lang->misc->feature->lastest = '最新版本'; $lang->misc->feature->detailed = '详情'; +$lang->misc->releaseDate['15.0.rc3'] = '2021-04-16'; $lang->misc->releaseDate['15.0.rc2'] = '2021-04-09'; $lang->misc->releaseDate['15.0.rc1'] = '2021-04-05'; $lang->misc->releaseDate['12.5.3'] = '2021-01-06'; @@ -140,6 +141,7 @@ $lang->misc->releaseDate['7.2.stable'] = '2015-05-22'; $lang->misc->releaseDate['7.1.stable'] = '2015-03-07'; $lang->misc->releaseDate['6.3.stable'] = '2014-11-07'; +$lang->misc->feature->all['15.0.rc3'][] = array('title' => '完善细节,修复Bug', 'desc' => ''); $lang->misc->feature->all['15.0.rc2'][] = array('title' => '修复Bug,优化界面交互', 'desc' => ''); $lang->misc->feature->all['15.0.rc1'][] = array('title' => '升级到15版本,重构导航、文档库,增加项目集管理', 'desc' => ''); $lang->misc->feature->all['12.5.3'][] = array('title' => '优化年度总结', 'desc' => ''); diff --git a/module/upgrade/lang/version.php b/module/upgrade/lang/version.php index 2eede042cb..671e85e43d 100644 --- a/module/upgrade/lang/version.php +++ b/module/upgrade/lang/version.php @@ -134,3 +134,4 @@ $lang->upgrade->fromVersions['12_5_1'] = '12.5.1'; $lang->upgrade->fromVersions['12_5_2'] = '12.5.2'; $lang->upgrade->fromVersions['12_5_3'] = '12.5.3'; $lang->upgrade->fromVersions['15_0_rc1'] = '15.0.rc1'; +$lang->upgrade->fromVersions['15_0_rc2'] = '15.0.rc2'; diff --git a/module/upgrade/model.php b/module/upgrade/model.php index 94a6ba4d9c..4ee03e2537 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -643,6 +643,9 @@ class upgradeModel extends model $this->saveLogs('Execute 15_0_rc1'); $this->adjustUserView(); $this->appendExec('15_0_rc1'); + case '15_0_rc2': + $this->saveLogs('Execute 15_0_rc2'); + $this->appendExec('15_0_rc2'); } $this->deletePatch(); From 84f243d051dd5774405f404502e1d5e1be60ff68 Mon Sep 17 00:00:00 2001 From: leiyong <1549684884@qq.com> Date: Wed, 14 Apr 2021 02:06:35 +0000 Subject: [PATCH 09/30] * Fix bug. --- module/project/control.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/project/control.php b/module/project/control.php index f425d0f461..9936d7e077 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -612,7 +612,7 @@ class project extends control $this->session->set('caseList', $uri, 'qa'); $this->session->set('testtaskList', $uri, 'qa'); - if($this->config->maxVersion) + if(isset($this->config->maxVersion)) { $this->session->set('riskList', $uri, 'project'); $this->session->set('issueList', $uri, 'project'); From eee47cabc8f4b03d6e50e38fd740625b75bbb16a Mon Sep 17 00:00:00 2001 From: qiyu-xie Date: Wed, 14 Apr 2021 10:08:33 +0800 Subject: [PATCH 10/30] * Fix bug#11396. --- module/common/view/datatable.fix.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/common/view/datatable.fix.html.php b/module/common/view/datatable.fix.html.php index 95a77574d5..6ed9254b0d 100644 --- a/module/common/view/datatable.fix.html.php +++ b/module/common/view/datatable.fix.html.php @@ -84,7 +84,7 @@ $(function() moduleName == 'execution' && $app->methodName == 'task'):?> datatable->showAllModule;?> - datatable->showAllModuleList, isset($config->project->task->allModule) ? $config->project->task->allModule : 0);?> + datatable->showAllModuleList, isset($config->execution->task->allModule) ? $config->execution->task->allModule : 0);?> From 4b6f98f3cc8f880e57dd43ecaef5fd330147bcf3 Mon Sep 17 00:00:00 2001 From: tianshujie98 Date: Wed, 14 Apr 2021 10:10:54 +0800 Subject: [PATCH 11/30] * Fix bug #6952. --- module/task/control.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/module/task/control.php b/module/task/control.php index 3e01190019..8cb3656512 100644 --- a/module/task/control.php +++ b/module/task/control.php @@ -1567,6 +1567,18 @@ class task extends control if(isset($users[$task->closedBy])) $task->closedBy = $users[$task->closedBy]; if(isset($users[$task->lastEditedBy])) $task->lastEditedBy = $users[$task->lastEditedBy]; + /* Convert username to real name. */ + if(!empty($task->mailto)) + { + $mailtoList = explode(',', $task->mailto); + + $task->mailto = ''; + foreach($mailtoList as $mailto) + { + if(!empty($mailto)) $task->mailto .= ',' . zget($users, $mailto); + } + } + if($task->parent > 0 && strpos($task->name, htmlentities('>')) !== 0) $task->name = '>' . $task->name; if(!empty($task->team)) $task->name = '[' . $taskLang->multipleAB . '] ' . $task->name; From 6dc7aa8f58b5bb145b10cadd19e17800914dc086 Mon Sep 17 00:00:00 2001 From: Yagami <976204163@qq.com> Date: Wed, 14 Apr 2021 10:12:51 +0800 Subject: [PATCH 12/30] * Fix doc link. --- module/doc/view/index.html.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/module/doc/view/index.html.php b/module/doc/view/index.html.php index 47555a9600..cb6a9588dd 100644 --- a/module/doc/view/index.html.php +++ b/module/doc/view/index.html.php @@ -21,7 +21,7 @@
doc->orderByEdit;?>
@@ -127,7 +127,7 @@
doc->myDoc;?>
@@ -159,7 +159,7 @@
doc->myCollection;?>
From 068411733ce5d2ed016dbd73c597cc748b23c388 Mon Sep 17 00:00:00 2001 From: tianshujie98 Date: Wed, 14 Apr 2021 10:36:11 +0800 Subject: [PATCH 13/30] * Fix bug #11060. --- module/story/model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/story/model.php b/module/story/model.php index 1dec807d88..82bab545ac 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -526,7 +526,7 @@ class storyModel extends model $story = fixer::input('post') ->callFunc('title', 'trim') ->setDefault('lastEditedBy', $this->app->user->account) - ->setDefault('lastEditedDate', $now) + ->add('lastEditedDate', $now) ->setIF($this->post->assignedTo == '', 'assignedTo', $oldStory->assignedTo) ->setIF($this->post->assignedTo != '' and $this->post->assignedTo != $oldStory->assignedTo, 'assignedDate', $now) ->setIF($specChanged, 'version', $oldStory->version + 1) From 5d74fc96d26da990a390727dc9ef2b3d77872cfd Mon Sep 17 00:00:00 2001 From: tianshujie98 Date: Wed, 14 Apr 2021 10:46:54 +0800 Subject: [PATCH 14/30] * Fix bug #12030. --- module/product/control.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/module/product/control.php b/module/product/control.php index 771f5fd543..08a467b743 100644 --- a/module/product/control.php +++ b/module/product/control.php @@ -340,6 +340,10 @@ class product extends control $rdUsers = $this->user->getPairs('nodeleted|devfirst|noclosed', '', $this->config->maxCount); if(!empty($this->config->user->moreLink)) $this->config->moreLinks["RD"] = $this->config->user->moreLink; + $lines = array(); + if($programID) $lines = array('') + $this->product->getLinePairs($programID); + if($this->config->systemMode == 'classic') $lines = array('') + $this->product->getLinePairs(); + $this->view->title = $this->lang->product->create; $this->view->position[] = $this->view->title; $this->view->groups = $this->loadModel('group')->getPairs(); @@ -349,7 +353,7 @@ class product extends control $this->view->rdUsers = $rdUsers; $this->view->users = $this->user->getPairs('nodeleted|noclosed'); $this->view->programs = array('') + $this->loadModel('program')->getTopPairs('', 'noclosed'); - $this->view->lines = $this->config->systemMode == 'new' ? array() : array('' => '') + $this->product->getLinePairs(); + $this->view->lines = $lines; $this->view->URSRPairs = $this->loadModel('custom')->getURSRPairs(); unset($this->lang->product->typeList['']); From 941304aae6130019c5ce475e038fa25ffd74b827 Mon Sep 17 00:00:00 2001 From: qiyu-xie Date: Wed, 14 Apr 2021 10:51:26 +0800 Subject: [PATCH 15/30] * Fix bug#11371. --- module/story/model.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/story/model.php b/module/story/model.php index 82bab545ac..413fc6c928 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -2743,7 +2743,7 @@ class storyModel extends model } elseif($type == 'full') { - $property = '(' . $this->lang->story->pri . ':' . (!empty($this->lang->story->priList[$story->pri]) ? $this->lang->story->priList[$story->pri] : 0) . ',' . $this->lang->story->estimate . ':' . $this->lang->hourCommon . ')'; + $property = '(' . $this->lang->story->pri . ':' . (!empty($this->lang->story->priList[$story->pri]) ? $this->lang->story->priList[$story->pri] : 0) . ',' . $this->lang->story->estimate . ':' . $story->estimate . ')'; } else { From 5c810f2420702b8dd244124c1a37b40af77afa97 Mon Sep 17 00:00:00 2001 From: tianshujie98 Date: Wed, 14 Apr 2021 11:18:29 +0800 Subject: [PATCH 16/30] * Fix bug #11005. --- module/bug/view/batchedit.html.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/bug/view/batchedit.html.php b/module/bug/view/batchedit.html.php index 6950477e3e..0cd8db28cf 100644 --- a/module/bug/view/batchedit.html.php +++ b/module/bug/view/batchedit.html.php @@ -49,7 +49,7 @@ idAB;?> '>bug->type;?> - '>bug->severityAB;?> + '>bug->severity;?> '>bug->pri;?> bug->title;?> From 20be4489cbca54d49ddfda42f8f523d28c7c29c8 Mon Sep 17 00:00:00 2001 From: holan20180123 <56391770@qq.com> Date: Wed, 14 Apr 2021 11:19:13 +0800 Subject: [PATCH 17/30] * Fix bug #11797. --- module/task/model.php | 1 + 1 file changed, 1 insertion(+) diff --git a/module/task/model.php b/module/task/model.php index 8708321c9f..24199b3356 100644 --- a/module/task/model.php +++ b/module/task/model.php @@ -1490,6 +1490,7 @@ class taskModel extends model $data->status = $task->status; $data->lastEditedBy = $this->app->user->account; $data->lastEditedDate = $now; + if(helper::isZeroDate($task->realStarted)) $data->realStarted = $now; if($left == 0) { From b9d0de87db4a5a9d6a085b739e2367925175d169 Mon Sep 17 00:00:00 2001 From: tianshujie98 Date: Wed, 14 Apr 2021 11:45:12 +0800 Subject: [PATCH 18/30] * Fix bug #11858. --- module/bug/control.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/module/bug/control.php b/module/bug/control.php index 2042419b62..f973801bea 100644 --- a/module/bug/control.php +++ b/module/bug/control.php @@ -509,7 +509,7 @@ class bug extends control if(empty($moduleOptionMenu)) die(js::locate(helper::createLink('tree', 'browse', "productID=$productID&view=story"))); /* Get products and projects. */ - $products = $this->products; + $products = $this->config->CRProduct ? $this->products : $this->product->getPairs('noclosed'); $projects = array(0 => ''); if($projectID) { @@ -817,6 +817,11 @@ class bug extends control if($bug->type != $type) unset($this->lang->bug->typeList[$type]); } + if($this->app->openApp == 'qa') + { + $this->view->products = $this->config->CRProduct ? $this->products : $this->product->getPairs('noclosed'); + } + /* Set header and position. */ $this->view->title = $this->lang->bug->edit . "BUG #$bug->id $bug->title - " . $this->products[$productID]; $this->view->position[] = html::a($this->createLink('bug', 'browse', "productID=$productID"), $this->products[$productID]); From bffb33fcbcccac6f37c68ccb7a42247b768b79fb Mon Sep 17 00:00:00 2001 From: Guanxiying Date: Wed, 14 Apr 2021 12:00:32 +0800 Subject: [PATCH 19/30] * Add gitlab config. --- module/repo/config.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/module/repo/config.php b/module/repo/config.php index a86e7d8727..ebb573a0fe 100644 --- a/module/repo/config.php +++ b/module/repo/config.php @@ -42,6 +42,10 @@ $config->repo->edit->requiredFields = 'product,SCM,name,path,encoding,client'; $config->repo->svn = new stdclass(); $config->repo->svn->requiredFields = 'account,password'; +$config->repo->gitlab = new stdclass; +$config->repo->gitlab->perPage = 300; +$config->repo->gitlab->apiPath = "%s/api/v4/projects/%s/repository/"; + $config->repo->rules['module']['task'] = 'Task'; $config->repo->rules['module']['bug'] = 'Bug'; $config->repo->rules['module']['story'] = 'Story'; From 291702e3f50ca5216dcaa30671528dd6d1549e40 Mon Sep 17 00:00:00 2001 From: Guanxiying Date: Wed, 14 Apr 2021 12:01:10 +0800 Subject: [PATCH 20/30] * Add gitlab type to repo type list. --- module/repo/js/create.js | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/module/repo/js/create.js b/module/repo/js/create.js index 96fbc55790..0af0d52404 100644 --- a/module/repo/js/create.js +++ b/module/repo/js/create.js @@ -6,16 +6,38 @@ $(function() $form = $(this).closest('form'); $form.css('min-height', $form.height()); }) + + $('#gitlabHost, #gitlabToken').change(function() + { + host = Base64.encode($('#gitlabHost').val()); + token = $('#gitlabToken').val(); + url = createLink('repo', 'ajaxgetgitlabprojects', "host=" + host + '&token=' + token); + if(host == '' || token == '') return false; + + $.get(url, function(response) + { + $('#gitlabProject').html('').append(response); + $('#gitlabProject').chosen().trigger("chosen:updated");; + }); + }); + + $('#gitlabProject').change(function() + { + $option = $(this).find('option:selected'); + $('#name').val($option.data('name')); + }); + }); -function scmChanged(scm) { +function scmChanged(scm) +{ if(scm == 'Git') { $('.account-fields').addClass('hidden'); $('.tips-git').removeClass('hidden'); $('.tips-svn').addClass('hidden'); - } + } else { $('.account-fields').removeClass('hidden'); @@ -23,4 +45,7 @@ function scmChanged(scm) { $('.tips-git').addClass('hidden'); $('.tips-svn').removeClass('hidden'); } + + $('tr.gitlab').toggle(scm == 'Gitlab'); + $('tr.hide-gitlab').toggle(scm != 'Gitlab'); } From 87f49eb3e18c225ebeeba30ff930036662800297 Mon Sep 17 00:00:00 2001 From: Guanxiying Date: Wed, 14 Apr 2021 13:19:33 +0800 Subject: [PATCH 21/30] * Merge gitlab codes. --- lib/scm/gitlab.class.php | 655 +++++++++++++++++++++++++++++++ module/repo/js/edit.js | 29 +- module/repo/lang/en.php | 8 + module/repo/lang/zh-cn.php | 8 + module/repo/model.php | 26 ++ module/repo/view/create.html.php | 21 +- module/repo/view/edit.html.php | 21 +- 7 files changed, 759 insertions(+), 9 deletions(-) create mode 100644 lib/scm/gitlab.class.php diff --git a/lib/scm/gitlab.class.php b/lib/scm/gitlab.class.php new file mode 100644 index 0000000000..cbe2a0cbad --- /dev/null +++ b/lib/scm/gitlab.class.php @@ -0,0 +1,655 @@ +client = $client; + $this->root = rtrim($root, '/') . '/'; + $this->token = $password; + $this->branch = isset($_COOKIE['repoBranch']) ? $_COOKIE['repoBranch'] : ''; + } + + /** + * List files. + * + * @param string $path + * @param string $revision + * @access public + * @return array + */ + public function ls($path, $revision = 'HEAD') + { + if(!scm::checkRevision($revision)) return array(); + $api = "tree"; + + $param = new stdclass(); + $param->path = urlencode(ltrim($path, '/')); + $param->ref = $revision; + $param->recursive = 0; + + $list = $this->fetch($api, $param); + if(empty($list)) return array(); + + $infos = array(); + foreach($list as $file) + { + $info = new stdClass(); + if($file->type == 'blob') + { + $path = $file->path; + $file = $this->files($file->path); + + $info->name = $file->file_name; + $info->kind = 'file'; + $info->account = $file->committer; + $info->date = $file->date; + $info->size = $file->size; + $info->comment = $file->comment; + $info->revision = $file->revision; + } + else + { + $commits = $this->getCommitsByPath($file->path); + if(empty($commits)) continue; + $commit = $commits[0]; + + $info->name = $file->path; + $info->kind = 'dir'; + $info->revision = $commit->id; + $info->account = $commit->committer_name; + $info->date = date('Y-m-d H:i:s', strtotime($commit->committed_date)); + $info->size = 0; + $info->comment = $commit->message; + } + + $infos[] = $info; + unset($info); + } + + /* Sort by kind */ + foreach($infos as $key => $info) $kinds[$key] = $info->kind; + if($infos) array_multisort($kinds, SORT_ASC, $infos); + return $infos; + } + + /** + * Get files info. + * + * @param string $path + * @param string $ref + * @access public + * @return array + */ + public function files($path, $ref = 'master') + { + $path = urlencode($path); + $api = "files/$path"; + $param = new stdclass(); + $param->ref = $ref; + $file = $this->fetch($api, $param); + + $commits = $this->getCommitsByPath($path); + $file->revision = $file->commit_id; + $file->size = $this->formatBytes($file->size); + + if(!empty($commits)) + { + $commit = $commits[0]; + $file->committer = $commit->committer_name; + $file->comment = $commit->message; + $file->date = date('Y-m-d H:i:s', strtotime($commit->committed_date)); + } + + return $file; + } + + /** + * Get tags + * + * @param string $path + * @param string $revision + * @access public + * @return array + */ + public function tags($path, $revision = 'HEAD') + { + $api = "tags"; + $list = $this->fetch($api); + + $tags = array(); + foreach($list as $tag) $tags[] = $tag->name; + + return $tags; + } + + /** + * Get branch + * + * @access public + * @return array + */ + public function branch() + { + $api = "branches"; + $list = $this->fetch($api); + + $branches = array(); + foreach($list as $branch) $branches[$branch->name] = $branch->name; + asort($branches); + + return $branches; + } + + /** + * Get last log. + * + * @param string $path + * @param int $count + * @access public + * @return array + */ + public function getLastLog($path, $count = 10) + { + return $this->log($path); + } + + /** + * Get logs. + * + * @param string $path + * @param string $fromRevision + * @param string $toRevision + * @param int $count + * @access public + * @return array + */ + public function log($path, $fromRevision = 0, $toRevision = 'HEAD', $count = 0) + { + if(!scm::checkRevision($fromRevision)) return array(); + if(!scm::checkRevision($toRevision)) return array(); + + $path = ltrim($path, DIRECTORY_SEPARATOR); + $count = $count == 0 ? '' : "-n $count"; + + $list = $this->getCommitsByPath($path, $fromRevision, $toRevision); + foreach($list as $commit) $commit->diffs = $this->getFilesByCommit($commit->id); + + return $this->parseLog($list); + } + + /** + * Blame file + * + * @param string $path + * @param string $revision + * @access public + * @return array + */ + public function blame($path, $revision) + { + if(!scm::checkRevision($revision)) return array(); + + $path = ltrim($path, DIRECTORY_SEPARATOR); + $path = urlencode($path); + $api = "files/$path/blame"; + $param = new stdclass; + $param->ref = $this->branch; + $results = $this->fetch($api, $param); + + $blames = array(); + $revLine = 0; + $revision = ''; + + $lineNumber = 1; + foreach($results as $blame) + { + $line = array(); + $line['revision'] = $blame->commit->id; + $line['committer'] = $blame->commit->committer_name; + $line['time'] = $blame->commit->committer_name; + $line['line'] = $lineNumber; + $line['lines'] = count($blame->lines); + $line['content'] = array_shift($blame->lines); + + $blames[] = $line; + + $lineNumber ++; + + foreach($blame->lines as $line) + { + $blames[] = array('line' => $lineNumber, 'content' => $line); + $lineNumber ++; + } + } + + return $blames; + } + + /** + * Diff file. + * + * @param string $path + * @param string $fromRevision + * @param string $toRevision + * @access public + * @return array + */ + public function diff($path, $fromRevision, $toRevision) + { + if(!scm::checkRevision($fromRevision)) return array(); + if(!scm::checkRevision($toRevision)) return array(); + + $api = "compare"; + $params = array('from' => $fromRevision, 'to' => $toRevision, 'straight' => 1); + $results = $this->fetch($api, $params); + foreach($results->diffs as $key => $diff) + { + if($path != '' and strpos($diff->new_path, $path) === false) unset($results->diffs[$key]); + } + return $results->diffs; + } + + /** + * Cat file. + * + * @param string $entry + * @param string $revision + * @access public + * @return string + */ + public function cat($entry, $revision = 'HEAD') + { + if(!scm::checkRevision($revision)) return false; + $file = $this->files($entry, $revision); + return base64_decode($file->content); + } + + /** + * Get info. + * + * @param string $entry + * @param string $revision + * @access public + * @return object + */ + public function info($entry, $revision = 'HEAD') + { + if(!scm::checkRevision($revision)) return false; + + $info = new stdclass(); + $info->kind = 'dir'; + $info->path = $entry; + $info->root = ''; + + if($entry) + { + $parent = dirname($entry); + if($parent == '.') $parent = '/'; + if($parent == '') $parent = '/'; + $list = $this->tree($parent, 0); + + foreach($list as $node) if($node->path == $entry) $file = $node; + + $commits = $this->getCommitsByPath($entry); + + if(!empty($commits)) $file->revision = zget($commits[0], 'id', ''); + $info->kind = $file->type == 'tree' ? 'dir' : 'file'; + } + + return $info; + } + + /** + * Exec git cmd. + * + * @param string $cmd + * @access public + * @todo Exec commads by gitlab api. + * @return array + */ + public function exec($cmd) + { + chdir($this->root); + return execCmd(escapeCmd("$this->client $cmd"), 'array'); + } + + /** + * Parse diff. + * + * @param array $lines + * @access public + * @return array + */ + public function parseDiff($results) + { + if(empty($results)) return array(); + foreach($results as $file) + { + $diffFile = new stdclass(); + $diffFile->fileName = $file->new_path; + + $diff = new stdclass; + $diff->fileName = $file->new_path; + + preg_match('/^@@ -(\\d+)(,(\\d+))?\\s+\\+(\\d+)(,(\\d+))?\\s+@@/A', $file->diff, $matches); + if(empty($matches)) continue; + + $diff->oldStartLine = $matches[1]; + $diff->newStartLine = $matches[4]; + + $oldCurrentLine = $diff->oldStartLine; + $newCurrentLine = $diff->newStartLine; + if($file->new_file) + { + $oldCurrentLine = $diff->newStartLine; + $newCurrentLine = $diff->oldStartLine; + } + + $lines = explode("\n", $file->diff); + $newLines = array(); + foreach($lines as $line) + { + if(strpos($line, '@@') === 0) continue; + if(strpos($line, '\ No newline at end of file') === 0) continue; + $sign = empty($line) ? '' : $line[0]; + if($sign == '-' and $file->new_file) $sign = '+'; + $type = $sign != '-' ? $sign == '+' ? 'new' : 'all' : 'old'; + + if($sign == '+' or $sign == '-') + { + $line = substr_replace($line, ' ', 1, 0); + if($file->new_file) $line = preg_replace('/^\-/', '+', $line); + } + + $newLine = new stdclass(); + $newLine->type = $type; + $newLine->oldlc = $type != 'new' ? $oldCurrentLine : ''; + $newLine->newlc = $type != 'old' ? $newCurrentLine : ''; + $newLine->line = htmlspecialchars($line); + + if($type != 'new') $oldCurrentLine++; + if($type != 'old') $newCurrentLine++; + + $newLines[] = $newLine; + } + $diffFile->contents[] = $diff; + $diff->lines = $newLines; + $diffs[] = $diffFile; + } + return $diffs; + } + + /** + * Get commit count. + * + * @param int $commits + * @param string $lastVersion + * @access public + * @return int + */ + public function getCommitCount($commits = 0, $lastVersion = '') + { + if(!scm::checkRevision($lastVersion)) return false; + + chdir($this->root); + $revision = $this->branch ? $this->branch : 'HEAD'; + return execCmd(escapeCmd("$this->client rev-list --count $revision -- ./"), 'string'); + } + + /** + * Get first revision. + * + * @access public + * @return string + */ + public function getFirstRevision() + { + chdir($this->root); + $list = execCmd(escapeCmd("$this->client rev-list --reverse HEAD -- ./"), 'array'); + return $list[0]; + } + + /** + * Get latest revision + * + * @access public + * @return string + */ + public function getLatestRevision() + { + chdir($this->root); + $revision = $this->branch ? $this->branch : 'HEAD'; + $list = execCmd(escapeCmd("$this->client rev-list -1 $revision -- ./"), 'array'); + return $list[0]; + } + + /** + * Get commits. + * + * @param string $version + * @param int $count + * @param string $branch + * @access public + * @return array + */ + public function getCommits($version = '', $count = 0, $branch = '') + { + if(!scm::checkRevision($version)) return array(); + $api = "commits"; + + $count = 500; + $params = array(); + $params['ref_name'] = $branch; + $params['per_page'] = $count; + $params['all'] = 1; + + if($version) + { + $lastCommit = $this->getSingleCommit($version); + $params['until'] = $lastCommit->committed_date; + } + + $list = $this->fetch($api, $params); + + $commits = array(); + foreach($list as $commit) + { + $log = new stdclass; + $log->committer = $commit->committer_name; + $log->revision = $commit->id; + $log->comment = $commit->message; + $log->time = date('Y-m-d H:i:s', strtotime($commit->created_at)); + + $commits[$commit->id] = $log; + $files[$commit->id] = $this->getFilesByCommit($log->revision); + } + + return array('commits' => $commits, 'files' => $files); + } + + /** + * getCommit + * + * @param int $sha + * @access public + * @return void + */ + public function getSingleCommit($sha) + { + if(!scm::checkRevision($sha)) return null; + $api = "commits/$sha"; + return $this->fetch($api); + } + + /** + * Get commits by path. + * + * @param string $path + * @access public + * @return array + */ + public function getCommitsByPath($path, $fromRevision = '', $toRevision = '') + { + $path = ltrim($path, DIRECTORY_SEPARATOR); + $api = "commits"; + + $param = new stdclass(); + $param->path = urldecode($path); + $param->ref_name = $this->branch; + + if($fromRevision) $fromRevision = $this->getSingleCommit($fromRevision); + if($toRevision) $toRevision = $this->getSingleCommit($toRevision); + + if(!$fromRevision) $since = ''; + if(!$toRevision) $until = ''; + if($fromRevision and $toRevision) + { + $since = min($fromRevision->committed_date, $toRevision->committed_date); + $until = max($fromRevision->committed_date, $toRevision->committed_date); + } + + $param->since = $since; + $param->until = $until; + + return $this->fetch($api, $param); + } + + /** + * Get files by commit. + * + * @param string $commit + * @access public + * @return void + */ + public function getFilesByCommit($revision) + { + if(!scm::checkRevision($revision)) return array(); + $api = "commits/{$revision}/diff"; + $params = new stdclass; + $params->page = 1; + $params->per_page = 200; + + $allResults = array(); + while($results = $this->fetch($api, $params)) + { + $params->page ++; + $allResults = $allResults + $results; + } + + $files = array(); + foreach($allResults as $row) + { + $file = new stdclass(); + $file->revision = $revision; + $file->path = '/' . $row->new_path; + $file->type = 'file'; + + $file->action = 'M'; + if($row->new_file) $file->action = 'A'; + if($row->renamed_file) $file->action = 'R'; + if($row->deleted_file) $file->action = 'D'; + $files[] = $file; + } + + return $files; + } + + /** + * Repository/tree api. + * + * @param string $path + * @param bool $recursive + * @access public + * @return void + */ + public function tree($path, $recursive = 1) + { + $api = "tree"; + + $params = array(); + $params['path'] = ltrim($path, '/'); + $params['ref'] = $this->branch; + $params['recursive'] = (int) $recursive; + return $this->fetch($api, $params); + } + + /** + * Fetch data from gitlab api. + * + * @param string $api + * @access public + * @return void + */ + public function fetch($api, $params = array()) + { + $params = (array) $params; + $params['private_token'] = $this->token; + + $api = ltrim($api, '/'); + $api = $this->root . $api . '?' . http_build_query($params); + + $response = file_get_contents($api); + return json_decode($response); + } + + /** + * Format bytes shown. + * + * @param int $size + * @static + * @access public + * @return string + */ + public static function formatBytes($size) + { + if($size < 1024) return $size . 'Bytes'; + if(round($size / (1024 * 1024), 2) > 1) return round($size / (1024 * 1024), 2) . 'G'; + if(round($size / 1024, 2) > 1) return round($size / 1024, 2) . 'M'; + return round($size, 2) . 'KB'; + } + + /** + * Parse log. + * + * @param array $logs + * @access public + * @return array + */ + public function parseLog($logs) + { + $parsedLogs = array(); + $i = 0; + foreach($logs as $commit) + { + $parsedLog = new stdclass(); + $parsedLog->revision = $commit->id; + $parsedLog->committer = $commit->committer_name; + $parsedLog->time = date('Y-m-d H:i:s', strtotime($commit->committed_date)); + $parsedLog->comment = $commit->message; + $parsedLog->change = array(); + foreach($commit->diffs as $diff) + { + $parsedLog->change[$diff->path] = array(); + $parsedLog->change[$diff->path]['action'] = $diff->action; + $parsedLog->change[$diff->path]['kind'] = $diff->type; + } + $parsedLogs[] = $parsedLog; + } + + return $parsedLogs; + } +} diff --git a/module/repo/js/edit.js b/module/repo/js/edit.js index 96fbc55790..cc79cbb2a5 100644 --- a/module/repo/js/edit.js +++ b/module/repo/js/edit.js @@ -6,9 +6,33 @@ $(function() $form = $(this).closest('form'); $form.css('min-height', $form.height()); }) + + $('#gitlabHost, #gitlabToken').change(function() + { + host = Base64.encode($('#gitlabHost').val()); + token = $('#gitlabToken').val(); + url = createLink('repo', 'ajaxgetgitlabprojects', "host=" + host + '&token=' + token); + if(host == '' || token == '') return false; + + $.get(url, function(response) + { + $('#gitlabProject').html('').append(response); + $('#gitlabProject').chosen().trigger("chosen:updated");; + }); + }); + + $('#gitlabProject').change(function() + { + $option = $(this).find('option:selected'); + if(!$option.data('name')) return false; + $('#name').val($option.data('name')); + $(this).chosen().trigger("chosen:updated"); + }); + }); -function scmChanged(scm) { +function scmChanged(scm) +{ if(scm == 'Git') { $('.account-fields').addClass('hidden'); @@ -23,4 +47,7 @@ function scmChanged(scm) { $('.tips-git').addClass('hidden'); $('.tips-svn').removeClass('hidden'); } + + $('tr.gitlab').toggle(scm == 'Gitlab'); + $('tr.hide-gitlab').toggle(scm != 'Gitlab'); } diff --git a/module/repo/lang/en.php b/module/repo/lang/en.php index a724d83b23..eee7437991 100644 --- a/module/repo/lang/en.php +++ b/module/repo/lang/en.php @@ -124,6 +124,14 @@ $lang->repo->encodingList['gbk'] = 'GBK'; $lang->repo->scmList['Git'] = 'Git'; $lang->repo->scmList['Subversion'] = 'SVN'; +$lang->repo->scmList['Gitlab'] = 'Gitlab'; + +$lang->repo->gitlabHost = 'Gitlab Host'; +$lang->repo->gitlabToken = 'Gitlab Token'; +$lang->repo->gitlabProject = 'Projects'; + +$lang->repo->placeholder = new stdclass; +$lang->repo->placeholder->gitlabHost = 'Input url of gitlab'; $lang->repo->notice = new stdclass(); $lang->repo->notice->syncing = 'Synchronizing. Please wait ...'; diff --git a/module/repo/lang/zh-cn.php b/module/repo/lang/zh-cn.php index eba6fe4af5..0eb819a7ce 100644 --- a/module/repo/lang/zh-cn.php +++ b/module/repo/lang/zh-cn.php @@ -124,6 +124,14 @@ $lang->repo->encodingList['gbk'] = 'GBK'; $lang->repo->scmList['Git'] = 'Git'; $lang->repo->scmList['Subversion'] = 'Subversion'; +$lang->repo->scmList['Gitlab'] = 'Gitlab'; + +$lang->repo->gitlabHost = 'Gitlab 地址'; +$lang->repo->gitlabToken = 'Gitlab Token'; +$lang->repo->gitlabProject = '项目'; + +$lang->repo->placeholder = new stdclass; +$lang->repo->placeholder->gitlabHost = '请填写gitlab访问地址'; $lang->repo->notice = new stdclass(); $lang->repo->notice->syncing = '正在同步中, 请稍等...'; diff --git a/module/repo/model.php b/module/repo/model.php index 41ebe4f62d..4079f8bb58 100644 --- a/module/repo/model.php +++ b/module/repo/model.php @@ -235,11 +235,20 @@ class repoModel extends model if(!$this->checkConnection()) return false; $data = fixer::input('post') + ->setIf($this->post->SCM == 'Gitlab', 'password', $this->post->gitlabToken) + ->setIf($this->post->SCM == 'Gitlab', 'client', $this->post->gitlabHost) ->skipSpecial('path,client,account,password') ->setDefault('product', '') ->join('product', ',') ->get(); + $data->path = sprintf($this->config->repo->gitlab->apiPath, $data->gitlabHost, $data->gitlabProject); + + unset($data->gitlabHost); + unset($data->gitlabToken); + unset($data->gitlabProject); + + $data->acl = empty($data->acl) ? '' : json_encode($data->acl); if($data->SCM == 'Subversion') @@ -1754,4 +1763,21 @@ class repoModel extends model return $buildedURL; } + + /** + * Get gitlab projects. + * + * @param string $host + * @param string $token + * @access public + * @return array + */ + public function getGitlabProjects($host, $token) + { + $host = rtrim($host, '/'); + $host .= '/api/v4/projects'; + + $projects = file_get_contents($host . "?private_token=$token"); + return json_decode($projects); + } } diff --git a/module/repo/view/create.html.php b/module/repo/view/create.html.php index b547e7e1fd..6af99a7663 100644 --- a/module/repo/view/create.html.php +++ b/module/repo/view/create.html.php @@ -10,6 +10,7 @@ ?> + @@ -31,12 +32,24 @@ repo->scmList, 'Git', "onchange='scmChanged(this.value)' class='form-control'"); ?> repo->syncTips; ?> + + repo->gitlabHost;?> + repo->placeholder}'");?> + + + repo->gitlabToken;?> + + + + repo->gitlabProject;?> + + repo->name; ?> - + repo->path; ?> @@ -49,7 +62,7 @@ repo->encodingsTips; ?> - + repo->client;?> @@ -57,11 +70,11 @@ repo->example->client->svn;?> - + repo->account;?> - + repo->password;?>
diff --git a/module/repo/view/edit.html.php b/module/repo/view/edit.html.php index 914b0715ca..272daa3d99 100644 --- a/module/repo/view/edit.html.php +++ b/module/repo/view/edit.html.php @@ -12,6 +12,7 @@ ?> + -session->docList ? $this->session->docList : inlink('browse', 'libID=0&browseTyp=byediteddate');?> +session->docList ? $this->session->docList : inlink('browse', 'libID=0&browseType=byediteddate');?> requestType == 'PATH_INFO' ? '?' : '&'; $sessionString .= session_name() . '=' . session_id();