diff --git a/module/execution/model.php b/module/execution/model.php index fc50fb6297..59aaaf7b91 100644 --- a/module/execution/model.php +++ b/module/execution/model.php @@ -2925,6 +2925,13 @@ class executionModel extends model $objectType = $execution->type == 'project' ? 'unlinkedfromproject' : 'unlinkedfromexecution'; if($execution->multiple or $execution->type == 'project') $this->loadModel('action')->create('story', $storyID, $objectType, '', $executionID); + /* Sync unlink story in no multiple execution. */ + if(empty($execution->multiple) and $execution->type != 'project') + { + $this->dao->delete()->from(TABLE_PROJECTSTORY)->where('project')->eq($execution->project)->andWhere('story')->eq($storyID)->limit(1)->exec(); + $this->loadModel('action')->create('story', $storyID, 'unlinkedfromproject', '', $execution->project); + } + $tasks = $this->dao->select('id')->from(TABLE_TASK)->where('story')->eq($storyID)->andWhere('execution')->eq($executionID)->andWhere('status')->in('wait,doing')->fetchPairs('id'); foreach($tasks as $taskID) { @@ -2953,6 +2960,13 @@ class executionModel extends model $this->dao->delete()->from(TABLE_PROJECTCASE)->where('project')->eq($executionID)->andWhere('`case`')->eq($caseID)->limit(1)->exec(); $action = $execution->type == 'project' ? 'unlinkedfromproject' : 'unlinkedfromexecution'; if($execution->multiple or $execution->type == 'project') $this->action->create('case', $caseID, $action, '', $executionID); + + /* Sync unlink case in no multiple execution. */ + if(empty($execution->multiple) and $execution->type != 'project') + { + $this->dao->delete()->from(TABLE_PROJECTCASE)->where('project')->eq($execution->project)->andWhere('`case`')->eq($caseID)->limit(1)->exec(); + $this->loadModel('action')->create('case', $caseID, 'unlinkedfromproject', '', $execution->project); + } } $order = 1;