* Fix error of manage product.

This commit is contained in:
liyuchun
2021-11-12 15:07:42 +08:00
parent 89396523ad
commit 0c7bcaf928
3 changed files with 24 additions and 2 deletions
+15
View File
@@ -312,6 +312,21 @@ class branchModel extends model
return $branches;
}
/**
* Unlink branches for projects when product type is normal.
*
* @param int $productIDList
* @access public
* @return void
*/
public function unlinkBranch4Project($productIDList)
{
$this->dao->delete()->from(TABLE_PROJECTPRODUCT)
->where('product')->in($productIDList)
->andWhere('branch')->gt(0)
->exec();
}
/**
* Get branch group by products
*
+7
View File
@@ -642,6 +642,8 @@ class productModel extends model
$whitelist = explode(',', $product->whitelist);
$this->loadModel('personnel')->updateWhitelist($whitelist, 'product', $productID);
if($product->acl != 'open') $this->loadModel('user')->updateUserView($productID, 'product');
if($product->type == 'normal' and $oldProduct->type != 'normal') $this->loadModel('branch')->unlinkBranch4Project($productID);
return common::createChanges($oldProduct, $product);
}
}
@@ -682,6 +684,7 @@ class productModel extends model
}
if(dao::isError()) die(js::error(dao::getError()));
$unlinkProducts = array();
foreach($products as $productID => $product)
{
$oldProduct = $oldProducts[$productID];
@@ -698,9 +701,13 @@ class productModel extends model
/* When acl is open, white list set empty. When acl is private,update user view. */
if($product->acl == 'open') $this->loadModel('personnel')->updateWhitelist('', 'product', $productID);
if($product->acl != 'open') $this->loadModel('user')->updateUserView($productID, 'product');
if($product->type == 'normal' and $oldProduct->type != 'normal') $unlinkProducts[] = $productID;
$allChanges[$productID] = common::createChanges($oldProduct, $product);
}
if(!empty($unlinkProducts)) $this->loadModel('branch')->unlinkBranch4Project($unlinkProducts);
return $allChanges;
}
+2 -2
View File
@@ -272,7 +272,7 @@ class project extends control
$this->view->title = $this->lang->project->browse;
$this->view->position[] = $this->lang->project->browse;
$this->view->projectStats = $projectStats;
$this->view->pager = $pager;
$this->view->programID = $programID;
@@ -1738,7 +1738,7 @@ class project extends control
$this->view->branches = $branches;
$this->view->unmodifiableProducts = $unmodifiableProducts;
$this->view->unmodifiableBranches = $unmodifiableBranches;
$this->view->branchGroups = $this->loadModel('branch')->getByProducts(array_keys($allProducts), 'noclosed');
$this->view->branchGroups = $this->loadModel('branch')->getByProducts(array_keys($allProducts), 'ignoreNormal,noclosed');
$this->display();
}