diff --git a/module/branch/model.php b/module/branch/model.php index c365bb7f00..dc74dd3f6c 100644 --- a/module/branch/model.php +++ b/module/branch/model.php @@ -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 * diff --git a/module/product/model.php b/module/product/model.php index ac18b4f688..f3a729e875 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -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; } diff --git a/module/project/control.php b/module/project/control.php index 1a78c40116..98c80ebd46 100644 --- a/module/project/control.php +++ b/module/project/control.php @@ -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(); }