diff --git a/module/doc/control.php b/module/doc/control.php index c71764533c..e68555c6c5 100644 --- a/module/doc/control.php +++ b/module/doc/control.php @@ -759,46 +759,18 @@ class doc extends control */ public function showFiles($type, $objectID, $viewType = '', $orderBy = 't1.id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1) { - $uri = $this->app->getURI(true); - $this->app->session->set('taskList', $uri); - $this->app->session->set('storyList', $uri); - $this->app->session->set('docList', $uri); - if(empty($viewType)) $viewType = !empty($_COOKIE['docFilesViewType']) ? $this->cookie->docFilesViewType : 'card'; setcookie('docFilesViewType', $viewType, $this->config->cookieLife, $this->config->webRoot, '', false, true); - $objects = $this->doc->getOrderedObjects($type); - if($type == 'product') - { - $objectID = $this->product->saveState($objectID, $objects); - $table = TABLE_PRODUCT; - - $libs = $this->doc->getLibsByObject('product', $objectID); - - $this->lang->modulePageNav = $this->doc->select($type, $objects, $objectID, $libs); - } - else if($type == 'project') - { - $objectID = $this->project->saveState($objectID, $objects); - $table = TABLE_PROJECT; - - $libs = $this->doc->getLibsByObject('project', $objectID); - - $this->lang->modulePageNav = $this->doc->select($type, $objects, $objectID, $libs); - } - else if($type == 'execution') - { - $objectID = $this->execution->saveState($objectID, $objects); - $table = TABLE_EXECUTION; - $libs = $this->doc->getLibsByObject('execution', $objectID); - - $this->lang->modulePageNav = $this->doc->select($type, $objects, $objectID, $libs); - } + $objects = $this->doc->getOrderedObjects($type); + $objectID = $this->{$type}->saveState($objectID, $objects); + $libs = $this->doc->getLibsByObject($type, $objectID); + $this->lang->modulePageNav = $this->doc->select($type, $objects, $objectID, $libs); $openApp = strpos('doc,product,project,execution', $this->app->openApp) !== false ? $this->app->openApp : 'doc'; if($openApp != 'doc') $this->loadModel($openApp)->setMenu($objectID); - $table = $type == 'product' ? TABLE_PRODUCT : TABLE_PROJECT; + $table = $this->config->objectTables[$type]; $object = $this->dao->select('id,name,status')->from($table)->where('id')->eq($objectID)->fetch(); $this->lang->TRActions = $this->doc->buildCollectButton4Doc(); diff --git a/module/doc/model.php b/module/doc/model.php index d2a768910d..2027313a9c 100644 --- a/module/doc/model.php +++ b/module/doc/model.php @@ -2288,41 +2288,14 @@ EOT; } else { - if($type == 'product') - { - $objectID = $this->product->saveState($objectID, $objects); - $table = TABLE_PRODUCT; + $objectID = $this->loadModel($type)->saveState($objectID, $objects); + $table = $this->config->objectTables[$type]; + $libs = $this->getLibsByObject($type, $objectID); - $libs = $this->getLibsByObject('product', $objectID); + if($libID == 0) $libID = key($libs); + $this->lang->modulePageNav = $this->select($type, $objects, $objectID, $libs, $libID); - if($libID == 0) $libID = key($libs); - $this->lang->modulePageNav = $this->select($type, $objects, $objectID, $libs, $libID); - - $this->app->rawMethod = 'product'; - } - else if($type == 'project') - { - $objectID = $this->loadModel('project')->saveState($objectID, $objects); - $table = TABLE_PROJECT; - - $libs = $this->getLibsByObject('project', $objectID); - - if($libID == 0) $libID = key($libs); - $this->lang->modulePageNav = $this->select($type, $objects, $objectID, $libs, $libID); - - $this->app->rawMethod = 'project'; - } - else if($type == 'execution') - { - $objectID = $this->loadModel('execution')->saveState($objectID, $objects); - $table = TABLE_EXECUTION; - $libs = $this->getLibsByObject('execution', $objectID); - - if($libID == 0) $libID = key($libs); - $this->lang->modulePageNav = $this->select($type, $objects, $objectID, $libs, $libID); - - $this->app->rawMethod = 'execution'; - } + $this->app->rawMethod = $type; $object = $this->dao->select('id,name,status')->from($table)->where('id')->eq($objectID)->fetch(); if(empty($object)) die(js::locate(helper::createLink($type, 'create')));