diff --git a/module/product/control.php b/module/product/control.php
index 16386b0d63..fce5845b9d 100644
--- a/module/product/control.php
+++ b/module/product/control.php
@@ -211,7 +211,7 @@ class product extends control
$this->view->productName = $this->products[$productID];
$this->view->moduleID = $moduleID;
$this->view->stories = $stories;
- $this->view->plans = $this->loadModel('productplan')->getPairs($productID, $branch);
+ $this->view->plans = $this->loadModel('productplan')->getPairs($productID, $branch, '', true);
$this->view->summary = $this->product->summary($stories, $storyType);
$this->view->moduleTree = $moduleTree;
$this->view->parentModules = $this->tree->getParents($moduleID);
diff --git a/module/productplan/model.php b/module/productplan/model.php
index df8f58ea1b..7b15c399e4 100644
--- a/module/productplan/model.php
+++ b/module/productplan/model.php
@@ -157,10 +157,11 @@ class productplanModel extends model
* @param array|int $product
* @param int $branch
* @param string $expired
+ * @param bool $skipParent
* @access public
* @return array
*/
- public function getPairs($product = 0, $branch = 0, $expired = '')
+ public function getPairs($product = 0, $branch = 0, $expired = '', $skipParent = false)
{
$date = date('Y-m-d');
$plans = $this->dao->select('id,title,parent,begin,end')->from(TABLE_PRODUCTPLAN)
@@ -168,6 +169,7 @@ class productplanModel extends model
->andWhere('deleted')->eq(0)
->beginIF($branch)->andWhere("branch")->in("0,$branch")->fi()
->beginIF($expired == 'unexpired')->andWhere('end')->ge($date)->fi()
+ ->beginIF($skipParent)->andWhere('parent')->ne(-1)->fi()
->orderBy('begin desc')
->fetchAll('id');
@@ -179,6 +181,7 @@ class productplanModel extends model
->andWhere('end')->lt($date)
->beginIF($branch)->andWhere("branch")->in("0,$branch")->fi()
->beginIF($plans)->andWhere("id")->notIN(array_keys($plans))->fi()
+ ->beginIF($skipParent)->andWhere('parent')->ne(-1)->fi()
->orderBy('begin desc')
->limit(5)
->fetchAll('id');
@@ -207,10 +210,11 @@ class productplanModel extends model
*
* @param array|int $product
* @param int $branch
+ * @param bool $skipParent
* @access public
* @return array
*/
- public function getPairsForStory($product = 0, $branch = 0)
+ public function getPairsForStory($product = 0, $branch = 0, $skipParent = false)
{
$date = date('Y-m-d');
$plans = $this->dao->select('id,title,parent,begin,end')->from(TABLE_PRODUCTPLAN)
@@ -218,6 +222,7 @@ class productplanModel extends model
->andWhere('deleted')->eq(0)
->andWhere('end')->ge($date)
->beginIF($branch)->andWhere("branch")->in("0,$branch")->fi()
+ ->beginIF($skipParent)->andWhere('parent')->ne(-1)->fi()
->orderBy('begin desc')
->fetchAll('id');
@@ -228,6 +233,7 @@ class productplanModel extends model
->andWhere('deleted')->eq(0)
->andWhere('end')->lt($date)
->beginIF($branch)->andWhere("branch")->in("0,$branch")->fi()
+ ->beginIF($skipParent)->andWhere('parent')->ne(-1)->fi()
->orderBy('begin desc')
->limit(5)
->fetchAll('id');
diff --git a/module/productplan/view/browse.html.php b/module/productplan/view/browse.html.php
index 8e4db5e8cc..b2b3345ef7 100644
--- a/module/productplan/view/browse.html.php
+++ b/module/productplan/view/browse.html.php
@@ -126,7 +126,7 @@
id"), '', '', "class='btn' title='{$lang->project->create}'");
- if(common::hasPriv('productplan', 'linkStory', $plan)) echo html::a(inlink('view', "planID=$plan->id&type=story&orderBy=id_desc&link=true"), '', '', "class='btn' title='{$lang->productplan->linkStory}'");
+ if(common::hasPriv('productplan', 'linkStory', $plan) and $plan->parent >= 0) echo html::a(inlink('view', "planID=$plan->id&type=story&orderBy=id_desc&link=true"), '', '', "class='btn' title='{$lang->productplan->linkStory}'");
if(common::hasPriv('productplan', 'linkBug', $plan) and $config->global->flow != 'onlyStory') echo html::a(inlink('view', "planID=$plan->id&type=bug&orderBy=id_desc&link=true"), '', '', "class='btn' title='{$lang->productplan->linkBug}'");
common::printIcon('productplan', 'edit', "planID=$plan->id", $plan, 'list');
if(common::hasPriv('productplan', 'create', $plan))
diff --git a/module/productplan/view/view.html.php b/module/productplan/view/view.html.php
index 4769816169..094cdb4773 100644
--- a/module/productplan/view/view.html.php
+++ b/module/productplan/view/view.html.php
@@ -62,7 +62,7 @@
'>
- deleted):?>
+ deleted and $plan->parent >= 0):?>
- id, \"story\")", ' ' . $lang->productplan->linkStory, '', "class='btn btn-primary'");?>
+ parent >= 0) echo html::a("javascript:showLink($plan->id, \"story\")", ' ' . $lang->productplan->linkStory, '', "class='btn btn-primary'");?>
diff --git a/module/story/control.php b/module/story/control.php
index 705ab7653e..5bb2aaf09c 100644
--- a/module/story/control.php
+++ b/module/story/control.php
@@ -256,7 +256,7 @@ class story extends control
$this->view->users = $users;
$this->view->moduleID = $moduleID ? $moduleID : (int)$this->cookie->lastStoryModule;
$this->view->moduleOptionMenu = $moduleOptionMenu;
- $this->view->plans = $this->loadModel('productplan')->getPairsForStory($productID, $branch);
+ $this->view->plans = $this->loadModel('productplan')->getPairsForStory($productID, $branch, true);
$this->view->planID = $planID;
$this->view->source = $source;
$this->view->sourceNote = $sourceNote;
@@ -367,7 +367,7 @@ class story extends control
}
$moduleOptionMenu['ditto'] = $this->lang->story->ditto;
- $plans = $this->loadModel('productplan')->getPairsForStory($productID, $branch);
+ $plans = $this->loadModel('productplan')->getPairsForStory($productID, $branch, true);
$plans['ditto'] = $this->lang->story->ditto;
$priList = (array)$this->lang->story->priList;
$priList['ditto'] = $this->lang->story->ditto;
@@ -442,7 +442,7 @@ class story extends control
$this->view->products = $products;
$this->view->story = $story;
$this->view->moduleOptionMenu = $moduleOptionMenu;
- $this->view->plans = $this->loadModel('productplan')->getPairs($product->id);
+ $this->view->plans = $this->loadModel('productplan')->getPairs($product->id, 0, '', true);
$this->view->actions = $this->action->getList('story', $storyID);
}
@@ -542,7 +542,7 @@ class story extends control
/* Set modules and productPlans. */
$modules = $this->tree->getOptionMenu($productID, $viewType = 'story', 0, $branch);
$modules = array('ditto' => $this->lang->story->ditto) + $modules;
- $productPlans = $this->productplan->getPairs($productID, $branch);
+ $productPlans = $this->productplan->getPairs($productID, $branch, '', true);
$productPlans = array('' => '', 'ditto' => $this->lang->story->ditto) + $productPlans;
|