* Add method to Check whether a story can be subdivided in storyTao.
This commit is contained in:
@@ -227,7 +227,8 @@ class story extends control
|
||||
if($storyID)
|
||||
{
|
||||
$story = $this->story->getById($storyID);
|
||||
if(($story->status != 'active' or (empty($product->shadow) && $story->stage != 'wait') or (!empty($product->shadow) && $story->stage != 'projected') or $story->parent > 0) and $this->config->vision != 'lite') return print(js::alert($this->lang->story->errorNotSubdivide) . js::locate('back'));
|
||||
$isShadowProduct = !empty($product->shadow);
|
||||
if(!$this->storyTao->checkCanSubdivide($story, $isShadowProduct)) return print(js::alert($this->lang->story->errorNotSubdivide) . js::locate('back'));
|
||||
}
|
||||
|
||||
if(!empty($_POST))
|
||||
|
||||
@@ -881,4 +881,24 @@ class storyTao extends storyModel
|
||||
parse_str($extra, $output);
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check whether a story can be subdivided.
|
||||
*
|
||||
* @param object $story
|
||||
* @param bool $isShadowProduct
|
||||
* @access protected
|
||||
* @return bool
|
||||
*/
|
||||
protected function checkCanSubdivide($story, $isShadowProduct): bool
|
||||
{
|
||||
if($this->config->vision == 'lite') return true;
|
||||
|
||||
if($story->status != 'active') return false;
|
||||
if(!$isShadowProduct && $story->stage != 'wait') return false;
|
||||
if($isShadowProduct && $story->stage != 'projected') return false;
|
||||
if($story->parent > 0) return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user