diff --git a/api/v1/entries/bug.php b/api/v1/entries/bug.php index 2f95a39998..26db63629b 100644 --- a/api/v1/entries/bug.php +++ b/api/v1/entries/bug.php @@ -20,9 +20,7 @@ class bugEntry extends entry */ public function get($bugID) { - $tab = $this->param('tab', 'product'); - $this->app->tab = $tab; - $this->app->session->tab = $tab; + $this->resetOpenApp($this->param('tab', 'product')); $control = $this->loadController('bug', 'view'); $control->view($bugID); diff --git a/api/v1/entries/doc.php b/api/v1/entries/doc.php index 96ef6ebc71..be2309917a 100644 --- a/api/v1/entries/doc.php +++ b/api/v1/entries/doc.php @@ -20,9 +20,7 @@ class docEntry extends entry */ public function get($docID) { - $tab = $this->param('tab', 'doc'); - $this->app->tab = $tab; - $this->app->session->tab = $tab; + $this->resetOpenApp($this->param('tab', 'doc')); $control = $this->loadController('doc', 'view'); $control->view($docID); diff --git a/api/v1/entries/projectcases.php b/api/v1/entries/projectcases.php index efdbde7ba0..e96f69196a 100644 --- a/api/v1/entries/projectcases.php +++ b/api/v1/entries/projectcases.php @@ -23,7 +23,7 @@ class projectCasesEntry extends entry if(!$projectID) $projectID = $this->param('project', 0); if(empty($projectID)) return $this->sendError(400, 'Need project id.'); - $this->app->tab = 'project'; + $this->resetOpenApp('project'); $this->app->session->set('project', $projectID, $this->app->tab); $control = $this->loadController('project', 'testcase'); diff --git a/api/v1/entries/story.php b/api/v1/entries/story.php index cabcc51130..457d41bb1b 100644 --- a/api/v1/entries/story.php +++ b/api/v1/entries/story.php @@ -20,9 +20,7 @@ class storyEntry extends Entry */ public function get($storyID) { - $tab = $this->param('tab', 'product'); - $this->app->tab = $tab; - $this->app->session->tab = $tab; + $this->resetOpenApp($this->param('tab', 'product')); $control = $this->loadController('story', 'view'); $control->view($storyID); diff --git a/api/v1/entries/task.php b/api/v1/entries/task.php index aec089fbe9..a25b2787b3 100644 --- a/api/v1/entries/task.php +++ b/api/v1/entries/task.php @@ -20,9 +20,7 @@ class taskEntry extends Entry */ public function get($taskID) { - $tab = $this->param('tab', 'execution'); - $this->app->tab = $tab; - $this->app->session->tab = $tab; + $this->resetOpenApp($this->param('tab', 'execution')); $control = $this->loadController('task', 'view'); $control->view($taskID); diff --git a/framework/api/entry.class.php b/framework/api/entry.class.php index 08a140f4a5..7e67f1203b 100644 --- a/framework/api/entry.class.php +++ b/framework/api/entry.class.php @@ -654,4 +654,18 @@ class baseEntry $this->send(403, array('error' => 'Access not allowed')); } } + + /** + * Reset open app. + * + * @param string $tab + * @access public + * @return void + */ + public function resetOpenApp($tab) + { + $_COOKIE['tab'] = $tab; + $this->app->tab = $tab; + $this->app->session->tab = $tab; + } }