diff --git a/module/story/control.php b/module/story/control.php index 4fa3ee6bb1..91e0983f46 100755 --- a/module/story/control.php +++ b/module/story/control.php @@ -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)) diff --git a/module/story/tao.php b/module/story/tao.php index 2619c6cce9..486bf2040a 100644 --- a/module/story/tao.php +++ b/module/story/tao.php @@ -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; + } }