From 76eea1f5d9520d7c7f7b2b126efe02c5c50f794b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E6=80=A1=E6=A0=8B?= Date: Wed, 2 Mar 2022 10:06:19 +0800 Subject: [PATCH] * adjust for global create. --- module/common/model.php | 32 ++++++++++++++++++-------- module/doc/view/selectlibtype.html.php | 2 +- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/module/common/model.php b/module/common/model.php index 0694bbb2bf..65c4ecc1ac 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -512,16 +512,16 @@ class commonModel extends model $showCreateList = $needPrintDivider = false; /* Get default product id. */ - $deletedProducts = $app->dbh->query("SELECT id FROM " . TABLE_PRODUCT . " WHERE `deleted` = '1'")->fetchAll(); - $deletedProductIds = array(); - foreach($deletedProducts as $product) $deletedProductIds[] = $product->id; - - $productID = (isset($_SESSION['product']) and !in_array($_SESSION['product'], $deletedProductIds)) ? $_SESSION['product'] : 0; + $productID = isset($_SESSION['product']) ? $_SESSION['product'] : 0; + if($productID) + { + $product = $app->dbh->query("SELECT id FROM " . TABLE_PRODUCT . " WHERE `deleted` = '0' and vision = '{$config->vision}' and id = '{$productID}'")->fetch(); + if(empty($product)) $productID = 0; + } if(!$productID and $app->user->view->products) { - $viewProducts = explode(',', $app->user->view->products); - $viewProducts = array_diff($viewProducts, $deletedProductIds); - $productID = current($viewProducts); + $product = $app->dbh->query("SELECT id FROM " . TABLE_PRODUCT . " WHERE `deleted` = '0' and vision = '{$config->vision}' and id " . helper::dbIN($app->user->view->products) . " order by `order` desc limit 1")->fetch(); + if($product) $productID = $product->id; } /* Check whether the creation permission is available, and print create buttons. */ @@ -587,12 +587,24 @@ class commonModel extends model case 'story': if(!$productID and $config->vision == 'lite') { - $module = 'project'; - $params = "model=kanban"; + $module = 'project'; + $params = "model=kanban"; } else { $params = "productID=$productID&branch=0&moduleID=0&storyID=0&objectID=0&bugID=0&planID=0&todoID=0&extra=from=global"; + if($config->vision == 'lite') + { + $projectID = isset($_SESSION['project']) ? $_SESSION['project'] : 0; + $projects = $app->dbh->query("SELECT t2.id FROM " . TABLE_PROJECTPRODUCT . " AS t1 LEFT JOIN " . TABLE_PROJECT . " AS t2 ON t1.project = t2.id WHERE t1.`product` = '{$productID}' and t2.`type` = 'project' ORDER BY `order` desc")->fetchAll(); + + $projectIdList = array(); + foreach($projects as $project) $projectIdList[$project->id] = $project->id; + if($projectID and !isset($projectIdList[$projectID])) $projectID = 0; + if(empty($projectID)) $projectID = key($projectIdList); + + $params = "productID={$productID}&branch=0&moduleID=0&storyID=0&objectID={$projectID}&bugID=0&planID=0&todoID=0&extra=from=global"; + } } break; diff --git a/module/doc/view/selectlibtype.html.php b/module/doc/view/selectlibtype.html.php index aca2049cc9..13712afe88 100644 --- a/module/doc/view/selectlibtype.html.php +++ b/module/doc/view/selectlibtype.html.php @@ -21,7 +21,7 @@ - +
doc->libType;?>doc->libTypeList, 'product');?>doc->libTypeList, key($lang->doc->libTypeList));?>
confirm);?>