From 584fb373ea5d820db91bc61df709d17da56314eb Mon Sep 17 00:00:00 2001 From: tianshujie Date: Mon, 9 Sep 2024 13:29:47 +0800 Subject: [PATCH] * [task#127527,done,2h] fix product ID error. --- module/story/control.php | 2 +- module/story/zen.php | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/module/story/control.php b/module/story/control.php index fe3da13e7e..df1483c1ef 100755 --- a/module/story/control.php +++ b/module/story/control.php @@ -56,7 +56,7 @@ class story extends control /* Set menu. */ $this->story->replaceURLang($storyType); $copyStoryID = $storyID; - list($productID, $objectID) = $this->storyZen->setMenuForCreate($productID, $objectID); + list($productID, $objectID) = $this->storyZen->setMenuForCreate($productID, $objectID, $extra); if($productID == 0 && $objectID == 0) return $this->locate($this->createLink('product', 'create')); if($productID == 0 && $objectID != 0) return $this->sendError($this->lang->execution->errorNoLinkedProducts, $this->createLink('execution', 'manageproducts', "executionID=$objectID")); diff --git a/module/story/zen.php b/module/story/zen.php index 398658dc94..f51095ac46 100644 --- a/module/story/zen.php +++ b/module/story/zen.php @@ -18,10 +18,11 @@ class storyZen extends story * * @param int $productID * @param int $objectID + * @param string $extra * @access protected * @return int[] */ - protected function setMenuForCreate(int $productID, int $objectID): array + protected function setMenuForCreate(int $productID, int $objectID, string $extra = ''): array { /* Get product id according to the project id when lite vision todo transfer story */ if($this->config->vision == 'lite' && $productID == 0) @@ -38,7 +39,23 @@ class storyZen extends story } /* Set menu by tab. */ - if($this->app->tab == 'product') $this->product->setMenu($productID); + if($this->app->tab == 'product') + { + $extra = str_replace(array(',', ' '), array('&', ''), $extra); + parse_str($extra, $output); + + if(!empty($output['from']) && $output['from'] == 'global') + { + $product = $this->product->getById($productID); + if(!$product || $product->deleted || $product->shadow) + { + $newProduct = $this->product->getOrderedProducts('noclosed'); + if(!empty($newProduct)) $productID = (int) key($newProduct); + } + } + + $this->product->setMenu($productID); + } if($this->app->tab == 'execution') { $this->execution->setMenu($objectID);