* Add method to Check whether a story can be subdivided in storyTao.

This commit is contained in:
zhouxin
2023-05-30 13:14:26 +08:00
parent ab6f1a65a6
commit 06e0b6942a
2 changed files with 22 additions and 1 deletions
+2 -1
View File
@@ -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))
+20
View File
@@ -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;
}
}