diff --git a/module/build/control.php b/module/build/control.php index 520e2a6073..0c49f66a62 100644 --- a/module/build/control.php +++ b/module/build/control.php @@ -21,10 +21,14 @@ class build extends control */ public function create($executionID = 0, $productID = 0, $projectID = 0) { + /* Load these models. */ + $this->loadModel('execution'); + $this->loadModel('user'); + if($this->app->openApp == 'project') { commonModel::setAppObjectID('project', $projectID); - $executions = $this->loadModel('execution')->getPairs($projectID); + $executions = $this->execution->getPairs($projectID); $executionID = key($executions); } @@ -41,18 +45,18 @@ class build extends control $this->send(array('result' => 'success', 'message' => $this->lang->saveSuccess, 'locate' => $this->createLink('build', 'view', "buildID=$buildID"))); } - /* Load these models. */ - $this->loadModel('execution'); - $this->loadModel('user'); - - /* Set session and get execution by id. */ - $this->session->set('buildCreate', $this->app->getURI(true)); $execution = $this->execution->getByID($executionID); + if($this->app->openApp == 'execution') + { + /* Set session and get execution by id. */ + $this->session->set('buildCreate', $this->app->getURI(true)); + + /* Set menu. */ + $executions = $this->execution->getPairs($execution->project); + $this->execution->setMenu($executions, $executionID); + commonModel::setAppObjectID('execution', $executionID); + } - /* Set menu. */ - $executions = $this->execution->getPairs($execution->project); - $this->execution->setMenu($executions, $executionID); - commonModel::setAppObjectID('execution', $executionID); $productGroups = $this->execution->getProducts($executionID); $productID = $productID ? $productID : key($productGroups); diff --git a/module/execution/control.php b/module/execution/control.php index 982ddc00c3..4b183d3423 100644 --- a/module/execution/control.php +++ b/module/execution/control.php @@ -1181,6 +1181,11 @@ class execution extends control */ public function create($productID = '', $executionID = '', $copyExecutionID = '', $planID = 0, $confirm = 'no', $projectID = 0) { + if($this->app->openApp == 'project') + { + commonModel::setAppobjectID('project', $projectID); + } + $this->app->loadLang('program'); $this->app->loadLang('stage'); $this->app->loadLang('programplan');