* Adjust linked products issues when creating independent projects.
This commit is contained in:
+12
-15
@@ -1187,7 +1187,7 @@ class programModel extends model
|
||||
* Create a project.
|
||||
*
|
||||
* @access public
|
||||
* @return void
|
||||
* @return int
|
||||
*/
|
||||
public function PRJCreate()
|
||||
{
|
||||
@@ -1206,6 +1206,15 @@ class programModel extends model
|
||||
->remove('products,branch,plans,delta,newProduct,productName')
|
||||
->get();
|
||||
|
||||
$linkedProductsCount = 0;
|
||||
if(isset($_POST['products']))
|
||||
{
|
||||
foreach($_POST['products'] as $product)
|
||||
{
|
||||
if(!empty($product)) $linkedProductsCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if($project->parent)
|
||||
{
|
||||
$parentProgram = $this->dao->select('*')->from(TABLE_PROGRAM)->where('id')->eq($project->parent)->fetch();
|
||||
@@ -1221,15 +1230,6 @@ class programModel extends model
|
||||
}
|
||||
|
||||
/* Judge products not empty. */
|
||||
$linkedProductsCount = 0;
|
||||
if(isset($_POST['products']))
|
||||
{
|
||||
foreach($_POST['products'] as $product)
|
||||
{
|
||||
if(!empty($product)) $linkedProductsCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($linkedProductsCount) and !isset($_POST['newProduct']))
|
||||
{
|
||||
dao::$errors[] = $this->lang->program->productNotEmpty;
|
||||
@@ -1271,12 +1271,9 @@ class programModel extends model
|
||||
$this->loadModel('personnel')->updateWhitelist($whitelist, 'project', $projectID);
|
||||
if($project->acl != 'open') $this->loadModel('user')->updateUserView($projectID, 'project');
|
||||
|
||||
if($project->parent)
|
||||
{
|
||||
$this->loadModel('project')->updateProducts($projectID);
|
||||
}
|
||||
$this->loadModel('project')->updateProducts($projectID);
|
||||
|
||||
if(isset($_POST['newProduct']) || !$project->parent)
|
||||
if(isset($_POST['newProduct']) || (!$project->parent && empty($linkedProductsCount)))
|
||||
{
|
||||
/* If parent not empty, link products or create products. */
|
||||
$product = new stdclass();
|
||||
|
||||
Reference in New Issue
Block a user