From 69e8548c1bf5e4634f608b6d7377264e594011e0 Mon Sep 17 00:00:00 2001 From: tianshujie98 Date: Thu, 10 Dec 2020 08:27:42 +0800 Subject: [PATCH 1/5] * Adjust code style. --- module/productplan/control.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/module/productplan/control.php b/module/productplan/control.php index 5889abdb73..881ef9acb8 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -503,7 +503,7 @@ class productplan extends control $this->loadModel('bug'); $plan = $this->productplan->getByID($planID); $this->commonAction($plan->product, $plan->branch); - $products = $this->product->getPairs('nocode'); + $products = $this->product->getPairs('nocode'); $productID = $plan->product; $queryID = ($browseType == 'bysearch') ? (int)$param : 0; From 4b95dd37d9d489e163cf21f9ad5c850d09f9b16d Mon Sep 17 00:00:00 2001 From: tianshujie98 Date: Thu, 10 Dec 2020 09:30:42 +0800 Subject: [PATCH 2/5] * Adjust code style. --- module/build/control.php | 9 +++++++-- module/build/model.php | 8 +++++--- module/issue/control.php | 1 + module/issue/model.php | 5 +++-- module/productplan/control.php | 1 - module/project/model.php | 4 ++-- 6 files changed, 18 insertions(+), 10 deletions(-) diff --git a/module/build/control.php b/module/build/control.php index b3e7630709..5deb4f5750 100644 --- a/module/build/control.php +++ b/module/build/control.php @@ -21,6 +21,7 @@ class build extends control */ public function create($executionID, $productID = 0) { + /* Create execution if no execution. */ if($executionID == 0) { die(js::locate($this->createLink('project', 'create'), 'parent')); @@ -34,7 +35,7 @@ class build extends control $this->executeHooks($buildID); - if(isonlybody()) $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true, 'callback' => "parent.loadProjectBuilds($executionID)"));//Code for task #5126. + if(isonlybody()) $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'closeModal' => true, 'callback' => "parent.loadProjectBuilds($executionID)")); // Code for task #5126. $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('build', 'view', "buildID=$buildID"))); } @@ -42,6 +43,7 @@ class build extends control $this->loadModel('project'); $this->loadModel('user'); + /* Set session and get execution by id. */ $this->session->set('buildCreate', $this->app->getURI(true)); $execution = $this->loadModel('project')->getExecutionById($executionID); @@ -162,6 +164,7 @@ class build extends control */ public function view($buildID, $type = 'story', $link = 'false', $param = '', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 100, $pageID = 1) { + /* Set session and load modules. */ if($type == 'story')$this->session->set('storyList', $this->app->getURI(true)); if($type == 'bug') $this->session->set('bugList', $this->app->getURI(true)); @@ -172,7 +175,7 @@ class build extends control $this->app->loadClass('pager', $static = true); if($this->app->getViewType() == 'mhtml') $recPerPage = 10; - /* Set menu. */ + /* Get build, product and bugs. */ $build = $this->build->getByID((int)$buildID, true); if(!$build) die(js::error($this->lang->notFound) . js::locate('back')); @@ -185,6 +188,7 @@ class build extends control ->page($bugPager) ->fetchAll(); + /* Get stories and stages. */ $storyPager = new pager($type == 'story' ? $recTotal : 0, $recPerPage, $type == 'story' ? $pageID : 1); $stories = $this->dao->select('*')->from(TABLE_STORY)->where('id')->in($build->stories)->andWhere('deleted')->eq(0) ->beginIF($type == 'story')->orderBy($orderBy)->fi() @@ -193,6 +197,7 @@ class build extends control $stages = $this->dao->select('*')->from(TABLE_STORYSTAGE)->where('story')->in($build->stories)->andWhere('branch')->eq($build->branch)->fetchPairs('story', 'stage'); foreach($stages as $storyID => $stage)$stories[$storyID]->stage = $stage; + /* Set menu. */ $this->loadModel('project')->setMenu($this->project->getExecutionPairs($this->session->PRJ), $build->project, $buildID); $projects = $this->project->getExecutionPairs($this->session->PRJ, 'all', 'empty'); diff --git a/module/build/model.php b/module/build/model.php index 1a635f60be..537280924c 100644 --- a/module/build/model.php +++ b/module/build/model.php @@ -19,7 +19,7 @@ class buildModel extends model * @param int $buildID * @param bool $setImgSize * @access public - * @return object + * @return object|bool */ public function getByID($buildID, $setImgSize = false) { @@ -495,9 +495,10 @@ class buildModel extends model */ public function unlinkStory($buildID, $storyID) { - $build = $this->getByID($buildID); + $build = $this->getByID($buildID); $build->stories = trim(str_replace(",$storyID,", ',', ",$build->stories,"), ','); if($build->stories) $build->stories = ',' . $build->stories; + $this->dao->update(TABLE_BUILD)->set('stories')->eq($build->stories)->where('id')->eq((int)$buildID)->exec(); $this->loadModel('action')->create('story', $storyID, 'unlinkedfrombuild', '', $buildID, '', false); } @@ -558,9 +559,10 @@ class buildModel extends model */ public function unlinkBug($buildID, $bugID) { - $build = $this->getByID($buildID); + $build = $this->getByID($buildID); $build->bugs = trim(str_replace(",$bugID,", ',', ",$build->bugs,"), ','); if($build->bugs) $build->bugs = ',' . $build->bugs; + $this->dao->update(TABLE_BUILD)->set('bugs')->eq($build->bugs)->where('id')->eq((int)$buildID)->exec(); $this->loadModel('action')->create('bug', $bugID, 'unlinkedfrombuild', '', $buildID, '', false); } diff --git a/module/issue/control.php b/module/issue/control.php index 7225f6d590..83f51fa803 100644 --- a/module/issue/control.php +++ b/module/issue/control.php @@ -443,6 +443,7 @@ class issue extends control */ public function view($issueID) { + /* Set actions and get issue by id. */ $this->commonAction($issueID, 'issue'); $issue = $this->issue->getByID($issueID); if(!$issue) die(js::error($this->lang->notFound) . js::locate('back')); diff --git a/module/issue/model.php b/module/issue/model.php index 380f1e92dd..7f30bc1282 100644 --- a/module/issue/model.php +++ b/module/issue/model.php @@ -66,12 +66,13 @@ class issueModel extends model * * @param int $issueID * @access public - * @return object + * @return object|bool */ public function getByID($issueID) { - $issue = $this->dao->select('*')->from(TABLE_ISSUE)->where('id')->eq($issueID)->andWhere('deleted')->eq('0')->fetch(); + $issue = $this->dao->select('*')->from(TABLE_ISSUE)->where('id')->eq($issueID)->andWhere('deleted')->eq('0')->fetch(); if(!$issue) return false; + $issue->files = $this->loadModel('file')->getByObject('issue', $issue->id); return $issue; } diff --git a/module/productplan/control.php b/module/productplan/control.php index 881ef9acb8..d11104e680 100644 --- a/module/productplan/control.php +++ b/module/productplan/control.php @@ -485,7 +485,6 @@ class productplan extends control * @param int $recTotal * @param int $recPerPage * @param int $pageID - * * @access public * @return void */ diff --git a/module/project/model.php b/module/project/model.php index 8230abfc11..33f59129dc 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -58,7 +58,7 @@ class projectModel extends model * @param int $buildID * @param string $extra * @access public - * @return void + * @return bool */ public function setMenu($projects, $projectID, $buildID = 0, $extra = '') { @@ -125,7 +125,7 @@ class projectModel extends model /* Set project module page nav. */ $label = $this->lang->project->index; - if($methodName == 'all') $label = $this->lang->project->allProjects; + if($methodName == 'all') $label = $this->lang->project->allProjects; if($methodName == 'create' and $moduleName == 'project') $label = $this->lang->project->create; $projectIndex = '
'; From 5d2180de9048a63d684397ebb1cc594f7e71ac97 Mon Sep 17 00:00:00 2001 From: qiyu-xie Date: Wed, 9 Dec 2020 16:39:59 +0800 Subject: [PATCH 3/5] * Fix lang. --- module/program/lang/de.php | 2 +- module/program/lang/en.php | 2 +- module/program/lang/fr.php | 2 +- module/program/lang/vi.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/module/program/lang/de.php b/module/program/lang/de.php index d105f0b0ef..2155fcef32 100644 --- a/module/program/lang/de.php +++ b/module/program/lang/de.php @@ -143,7 +143,7 @@ $lang->program->scrum = 'Scrum'; $lang->program->waterfall = 'CMMI'; $lang->program->waterfallTitle = 'CMMI'; $lang->program->cannotCreateChild = 'It is not empty, so you cannot add a child. You can add a parent for it, and then create a child.'; -$lang->program->hasChildren = 'It has child projects or child programs. You cannot delete it.'; +$lang->program->hasChildren = 'It has child programs or projects. You cannot delete it.'; $lang->program->confirmDelete = "Do you want to delete [%s]?"; $lang->program->emptyPM = 'No manager'; $lang->program->cannotChangeToCat = "It is not empty, so you cannot change it to a parent."; diff --git a/module/program/lang/en.php b/module/program/lang/en.php index 0fb452f63a..da9b51a290 100644 --- a/module/program/lang/en.php +++ b/module/program/lang/en.php @@ -143,7 +143,7 @@ $lang->program->scrum = 'Scrum'; $lang->program->waterfall = 'CMMI'; $lang->program->waterfallTitle = 'CMMI'; $lang->program->cannotCreateChild = 'It is not empty, so you cannot add a child. You can add a parent for it, and then create a child.'; -$lang->program->hasChildren = 'It has child projects or child programs. You cannot delete it.'; +$lang->program->hasChildren = 'It has child programs or projects. You cannot delete it.'; $lang->program->confirmDelete = "Do you want to delete [%s]?"; $lang->program->emptyPM = 'No manager'; $lang->program->cannotChangeToCat = "It is not empty, so you cannot change it to a parent."; diff --git a/module/program/lang/fr.php b/module/program/lang/fr.php index d105f0b0ef..2155fcef32 100644 --- a/module/program/lang/fr.php +++ b/module/program/lang/fr.php @@ -143,7 +143,7 @@ $lang->program->scrum = 'Scrum'; $lang->program->waterfall = 'CMMI'; $lang->program->waterfallTitle = 'CMMI'; $lang->program->cannotCreateChild = 'It is not empty, so you cannot add a child. You can add a parent for it, and then create a child.'; -$lang->program->hasChildren = 'It has child projects or child programs. You cannot delete it.'; +$lang->program->hasChildren = 'It has child programs or projects. You cannot delete it.'; $lang->program->confirmDelete = "Do you want to delete [%s]?"; $lang->program->emptyPM = 'No manager'; $lang->program->cannotChangeToCat = "It is not empty, so you cannot change it to a parent."; diff --git a/module/program/lang/vi.php b/module/program/lang/vi.php index d105f0b0ef..2155fcef32 100644 --- a/module/program/lang/vi.php +++ b/module/program/lang/vi.php @@ -143,7 +143,7 @@ $lang->program->scrum = 'Scrum'; $lang->program->waterfall = 'CMMI'; $lang->program->waterfallTitle = 'CMMI'; $lang->program->cannotCreateChild = 'It is not empty, so you cannot add a child. You can add a parent for it, and then create a child.'; -$lang->program->hasChildren = 'It has child projects or child programs. You cannot delete it.'; +$lang->program->hasChildren = 'It has child programs or projects. You cannot delete it.'; $lang->program->confirmDelete = "Do you want to delete [%s]?"; $lang->program->emptyPM = 'No manager'; $lang->program->cannotChangeToCat = "It is not empty, so you cannot change it to a parent."; From b117ab60d202910b66fd6a54cfc578a2c95bf06f Mon Sep 17 00:00:00 2001 From: qiyu-xie Date: Thu, 10 Dec 2020 09:23:19 +0800 Subject: [PATCH 4/5] * Finish task#8602. --- module/program/js/prjcreate.js | 4 ++-- module/program/model.php | 7 +++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/module/program/js/prjcreate.js b/module/program/js/prjcreate.js index 9f4fdc26ee..f3d5b6440e 100644 --- a/module/program/js/prjcreate.js +++ b/module/program/js/prjcreate.js @@ -36,13 +36,13 @@ function addNewProduct(obj) { $('#productName').closest('tr').removeClass('hidden'); $('#plans').closest('tr').addClass('hidden'); - $('#productsBox .chosen-container').attr('disabled',true); + $(obj).closest('.input-group').find('select').attr('disabled', true).trigger("chosen:updated"); } else { $('#productName').closest('tr').addClass('hidden'); $('#plans').closest('tr').removeClass('hidden'); - $('#productsBox .chosen-container').removeAttr('disabled',true); + $(obj).closest('.input-group').find('select').removeAttr('disabled').trigger("chosen:updated"); } } diff --git a/module/program/model.php b/module/program/model.php index 220559f8cc..22b6d838b5 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -1222,9 +1222,12 @@ class programModel extends model /* Judge products not empty. */ $linkedProductsCount = 0; - foreach($_POST['products'] as $product) + if(isset($_POST['products'])) { - if(!empty($product)) $linkedProductsCount++; + foreach($_POST['products'] as $product) + { + if(!empty($product)) $linkedProductsCount++; + } } if(empty($linkedProductsCount) and !isset($_POST['newProduct'])) From 55e7a7c316139beb3e560e8efde6a0c90b1b63ef Mon Sep 17 00:00:00 2001 From: qiyu-xie Date: Thu, 10 Dec 2020 09:54:00 +0800 Subject: [PATCH 5/5] * When select create new product, product name cannot be empty. --- module/program/model.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/module/program/model.php b/module/program/model.php index 22b6d838b5..35a59b5180 100644 --- a/module/program/model.php +++ b/module/program/model.php @@ -1237,6 +1237,13 @@ class programModel extends model } } + /* When select create new product, product name cannot be empty. */ + if(isset($_POST['newProduct']) and empty($_POST['productName'])) + { + dao::$errors[] = sprintf($this->lang->error->notempty, $this->app->loadLang('product')->product->name); + return false; + } + $requiredFields = $this->config->program->PRJCreate->requiredFields; if($this->post->delta == 999) $requiredFields = trim(str_replace(',end,', ',', ",{$requiredFields},"), ',');