From 669d4f3b02ab252f862fc3a5063adf04163437f1 Mon Sep 17 00:00:00 2001 From: zenggang Date: Wed, 2 Aug 2023 08:39:24 +0000 Subject: [PATCH] * Fix import repo --- module/repo/ui/import.html.php | 6 ++++++ module/repo/zen.php | 17 +++++++++++------ 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/module/repo/ui/import.html.php b/module/repo/ui/import.html.php index b2c4ccf785..2508564171 100644 --- a/module/repo/ui/import.html.php +++ b/module/repo/ui/import.html.php @@ -48,6 +48,12 @@ featureBar formBatchPanel ( + h::input + ( + set::type('hidden'), + set::name('serviceHost'), + set::value($gitlab->id), + ), set::id('repoList'), set::back('repo-maintain'), set::mode(count($repoList) == 0 ? 'edit' : 'add'), diff --git a/module/repo/zen.php b/module/repo/zen.php index c9e9bfaa36..ce1f163719 100644 --- a/module/repo/zen.php +++ b/module/repo/zen.php @@ -267,17 +267,22 @@ class repoZen extends repo */ protected function prepareBatchCreate(): array|false { + $this->app->loadLang('testcase'); + $data = array(); - foreach($_POST as $key => $val) + foreach($_POST as $key => $vals) { if(strpos($key, 'serviceProject') === 0) { - $i = substr($key, 14); - if($this->post->{'product' . $i} == '') dao::$errors['product' . $i][] = sprintf($this->lang->error->notempty, $this->lang->repo->product); - if($this->post->{'name' . $i} == '') dao::$errors['name' . $i][] = sprintf($this->lang->error->notempty, $this->lang->repo->name); - if(dao::isError()) continue; + foreach($vals as $i => $project) + { + $products = array_filter($this->post->product[$i]); + if(empty($products)) dao::$errors['product'][] = sprintf($this->lang->testcase->whichLine . $this->lang->error->notempty, $i, $this->lang->repo->product); + if($this->post->name[$i] == '') dao::$errors['name'][] = sprintf($this->lang->testcase->whichLine . $this->lang->error->notempty, $i, $this->lang->repo->name); + if(dao::isError()) continue; - $data[] = array('serviceProject' => $this->post->{'serviceProject' . $i}, 'product' => implode(',', $this->post->{'product' . $i}), 'name' => $this->post->{'name' . $i}, 'projects' => empty($_POST['projects'][$i]) ? '' : implode(',', $this->post->projects[$i])); + $data[] = array('serviceProject' => $project, 'product' => implode(',', $this->post->product[$i]), 'name' => $this->post->name[$i], 'projects' => empty($_POST['projects'][$i]) ? '' : implode(',', $this->post->projects[$i])); + } } } if(dao::isError()) return false;