diff --git a/module/block/control.php b/module/block/control.php index 5c1cb2aab7..6d40914e2e 100644 --- a/module/block/control.php +++ b/module/block/control.php @@ -679,8 +679,7 @@ class block extends control $type = isset($this->params->type) ? $this->params->type : 'assignedTo'; $orderBy = isset($this->params->type) ? $this->params->orderBy : 'id_asc'; - $programID = $this->view->block->module == 'my' ? 0 : (int)$this->session->PRJ; - $this->view->stories = $this->loadModel('story')->getUserStories($this->app->user->account, $type, $orderBy, $this->viewType != 'json' ? $pager : '', 'story', $programID); + $this->view->stories = $this->loadModel('story')->getUserStories($this->app->user->account, $type, $orderBy, $this->viewType != 'json' ? $pager : '', 'story'); } /** diff --git a/module/product/model.php b/module/product/model.php index 8178dfea6b..dca679db20 100644 --- a/module/product/model.php +++ b/module/product/model.php @@ -32,11 +32,7 @@ class productModel extends model $product = $this->getByID($productID); if($product) { - $project = $this->loadModel('project')->getByID($product->program); - - if(isset($project->id)) $this->loadModel('project')->setMenu($products, $project->id); - - $this->lang->modulePageNav = $this->getModuleNav($products, $project, $product, $extra, $branch, $module, $moduleType); + $this->lang->modulePageNav = $this->getModuleNav($products, '', $product, $extra, $branch, $module, $moduleType); } $pageActions = ''; diff --git a/module/project/model.php b/module/project/model.php index 75e7caf336..3e6de92af8 100644 --- a/module/project/model.php +++ b/module/project/model.php @@ -954,7 +954,7 @@ class projectModel extends model /* In case of a waterfall model, obtain sub-stage data. */ $PRJData = $this->getById($this->session->PRJ); - if($PRJData->model == 'waterfall') + if($PRJData and $PRJData->model == 'waterfall') { $childrens = $this->dao->select('*')->from(TABLE_PROJECT) ->where('parent')->in(array_keys($projects)) @@ -1059,7 +1059,7 @@ class projectModel extends model } /* In the case of the waterfall model, calculate the sub-stage. */ - if($PRJData->model == 'waterfall') + if($PRJData and $PRJData->model == 'waterfall') { foreach($parents as $id => $project) $project->children = isset($children[$id]) ? $children[$id] : array(); } diff --git a/module/story/model.php b/module/story/model.php index b4f554b7ae..8602ad892e 100644 --- a/module/story/model.php +++ b/module/story/model.php @@ -189,7 +189,6 @@ class storyModel extends model ->add('assignedDate', 0) ->add('version', 1) ->add('status', 'draft') - ->setDefault('program', $this->session->PRJ) ->setDefault('plan,verify', '') ->setDefault('openedBy', $this->app->user->account) ->setDefault('openedDate', $now) @@ -383,7 +382,6 @@ class storyModel extends model $story->keywords = $stories->keywords[$i]; $story->sourceNote = $stories->sourceNote[$i]; $story->product = $productID; - $story->program = $this->session->PRJ; $story->openedBy = $this->app->user->account; $story->openedDate = $now; $story->version = 1; @@ -2119,7 +2117,7 @@ class storyModel extends model } else { - $products = $this->loadModel('product')->getPairs('', $this->session->PRJ); + $products = $this->loadModel('product')->getPairs(); } $query = $queryID ? $this->loadModel('search')->getQuery($queryID) : ''; @@ -2419,13 +2417,12 @@ class storyModel extends model * @access public * @return array */ - public function getUserStories($account, $type = 'assignedTo', $orderBy = 'id_desc', $pager = null, $storyType = 'story', $programID = 0) + public function getUserStories($account, $type = 'assignedTo', $orderBy = 'id_desc', $pager = null, $storyType = 'story') { $stories = $this->dao->select('t1.*, t2.name as productTitle')->from(TABLE_STORY)->alias('t1') ->leftJoin(TABLE_PRODUCT)->alias('t2')->on('t1.product = t2.id') ->where('t1.deleted')->eq(0) ->andWhere('t1.type')->eq($storyType) - ->beginIF($programID)->andWhere('t1.PRJ')->eq($programID)->fi() ->beginIF($type != 'closedBy' and $this->app->moduleName == 'block')->andWhere('t1.status')->ne('closed')->fi() ->beginIF($type != 'all') ->beginIF($type == 'assignedTo')->andWhere('assignedTo')->eq($account)->fi() @@ -2734,7 +2731,7 @@ class storyModel extends model ->where($this->reportCondition()) ->groupBy('product')->orderBy('value DESC')->fetchAll('name'); if(!$datas) return array(); - $products = $this->loadModel('product')->getPairs('', $this->session->PRJ); + $products = $this->loadModel('product')->getPairs(); foreach($datas as $productID => $data) $data->name = isset($products[$productID]) ? $products[$productID] : $this->lang->report->undefined; return $datas; } @@ -3633,8 +3630,6 @@ class storyModel extends model { $requirement = $this->getByID($id); $data = new stdclass(); - $data->program = $this->session->PRJ; - $data->product = $this->session->product; $data->AType = 'requirement'; $data->BType = 'story'; $data->relation = 'subdivideinto'; diff --git a/module/testcase/model.php b/module/testcase/model.php index 65de5ea150..cc0c8ace7b 100644 --- a/module/testcase/model.php +++ b/module/testcase/model.php @@ -133,7 +133,7 @@ class testcaseModel extends model ->add('status', $status) ->add('version', 1) ->add('fromBug', $bugID) - ->add('program', $this->session->PRJ) + ->add('PRJ', $this->session->PRJ) ->setDefault('openedBy', $this->app->user->account) ->setDefault('openedDate', $now) ->setIF($this->post->story != false, 'storyVersion', $this->loadModel('story')->getVersion((int)$this->post->story)) @@ -227,7 +227,7 @@ class testcaseModel extends model $data[$i] = new stdclass(); $data[$i]->product = $productID; - $data[$i]->program = $this->session->PRJ; + $data[$i]->PRJ = $this->session->PRJ; $data[$i]->branch = $cases->branch[$i]; $data[$i]->module = $cases->module[$i]; $data[$i]->type = $cases->type[$i]; diff --git a/module/upgrade/control.php b/module/upgrade/control.php index 459667fb79..455e0e09d0 100644 --- a/module/upgrade/control.php +++ b/module/upgrade/control.php @@ -305,7 +305,7 @@ class upgrade extends control $productlines = $this->dao->select('*')->from(TABLE_MODULE)->where('type')->eq('line')->orderBy('id_desc')->fetchAll('id'); $noMergedProducts = $this->dao->select('*')->from(TABLE_PRODUCT)->where('line')->in(array_keys($productlines))->orderBy('id_desc')->fetchAll('id'); - if(empty($productlines)) $this->locate($this->createLink('upgrade', 'mergeProgram', 'type=product')); + if(empty($productlines) || empty($noMergedProducts)) $this->locate($this->createLink('upgrade', 'mergeProgram', 'type=product')); $noMergedSprints = $this->dao->select('t1.*')->from(TABLE_PROJECT)->alias('t1') ->leftJoin(TABLE_PROJECTPRODUCT)->alias('t2')->on('t1.id=t2.project') diff --git a/module/upgrade/model.php b/module/upgrade/model.php index 30fb47b70c..918a255adc 100644 --- a/module/upgrade/model.php +++ b/module/upgrade/model.php @@ -4003,6 +4003,16 @@ class upgradeModel extends model */ public function processMergedData($programID, $projectID, $productIdList = array(), $sprintIdList = array()) { + /* Product linked objects. */ + $this->dao->update(TABLE_STORY)->set('PRJ')->eq($programID)->where('product')->in($productIdList)->exec(); + $this->dao->update(TABLE_RELEASE)->set('PRJ')->eq($programID)->where('product')->in($productIdList)->exec(); + $this->dao->update(TABLE_BUG)->set('PRJ')->eq($projectID)->where('product')->in($productIdList)->exec(); + $this->dao->update(TABLE_CASE)->set('PRJ')->eq($projectID)->where('product')->in($productIdList)->exec(); + $this->dao->update(TABLE_TESTREPORT)->set('PRJ')->eq($projectID)->where('product')->in($productIdList)->exec(); + $this->dao->update(TABLE_TESTSUITE)->set('PRJ')->eq($projectID)->where('product')->in($productIdList)->exec(); + $this->dao->update(TABLE_BUILD)->set('PRJ')->eq($projectID)->where('product')->in($productIdList)->exec(); + $this->dao->update(TABLE_DOC)->set('PRJ')->eq($projectID)->where("lib IN(SELECT id from " . TABLE_DOCLIB . " WHERE type = 'product' and product " . helper::dbIN($productIdList) . ')')->exec(); + /* Project linked objects. */ $this->dao->update(TABLE_TASK)->set('PRJ')->eq($projectID)->where('project')->in($sprintIdList)->exec(); $this->dao->update(TABLE_DOC)->set('PRJ')->eq($projectID)->where("lib IN(SELECT id from " . TABLE_DOCLIB . " WHERE type = 'project' and project " . helper::dbIN($sprintIdList) . ')')->exec();