diff --git a/framework/base/router.class.php b/framework/base/router.class.php index 706aabcdc6..a9c4c6cd0a 100644 --- a/framework/base/router.class.php +++ b/framework/base/router.class.php @@ -140,6 +140,15 @@ class baseRouter */ public $clientLang; + /** + * 当前页面所在的group,用于左侧菜单栏判断。 + * The current group(url: '#open=?'), highlight left menu. + * + * @var string + * @access public + */ + public $openGroup; + /** * 用户使用的主题。 * The theme of the client user. @@ -373,6 +382,7 @@ class baseRouter $this->setTimezone(); $this->startSession(); $this->setPRJ(); + $this->setOpenGroup(); if($this->config->framework->multiSite) $this->setSiteCode() && $this->loadExtraConfig(); if($this->config->framework->autoConnectDB) $this->connectDB(); @@ -835,7 +845,9 @@ class baseRouter if($this->config->customSession) session_save_path($this->getTmpRoot() . 'session'); session_start(); - $this->sessionID = session_id(); + /* If request header has token, use it as session for authentication. */ + $this->sessionID = $_SERVER['HTTP_TOKEN'] ? session_id($_SERVER['HTTP_TOKEN']) : session_id(); + if(isset($_GET[$this->config->sessionVar])) helper::restartSession($_GET[$this->config->sessionVar]); define('SESSION_STARTED', true); @@ -854,6 +866,18 @@ class baseRouter if(isset($_GET['PRJ'])) $this->session->set('PRJ', $_GET['PRJ']); //Set PRJ id into session. } + /** + * 从cookie中获取当前的group, 即URL锚链接'#open=?'。 + * Get current group from cookie, original source is url '#open=?'. + * + * @access public + * @return void + */ + public function setOpenGroup() + { + if(isset($_COOKIE['openGroup'])) $this->openGroup = $_COOKIE['openGroup']; + } + /** * 根据用户浏览器的语言设置和服务器配置,选择显示的语言。 * 优先级:$lang参数 > session > cookie > 浏览器 > 配置文件。 diff --git a/module/common/model.php b/module/common/model.php index 575885da83..58e3654100 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -1055,6 +1055,10 @@ class commonModel extends model */ public static function printLink($module, $method, $vars = '', $label, $target = '', $misc = '', $newline = true, $onlyBody = false, $object = null) { + /* Add data-group attribute. */ + global $app; + if(strpos($misc, 'data-group') === false) $misc .= ' data-group="' . $app->openGroup . '"'; + if(!commonModel::hasPriv($module, $method, $object)) return false; echo html::a(helper::createLink($module, $method, $vars, '', $onlyBody), $label, $target, $misc, $newline); return true; @@ -1146,6 +1150,9 @@ EOD; global $app, $lang, $config; + /* Add data-group attribute. */ + if(strpos($misc, 'data-group') === false) $misc .= ' data-group="' . $app->openGroup . '"'; + /* Judge the $method of $module clickable or not, default is clickable. */ $clickable = true; if(is_object($object)) diff --git a/module/index/js/index.js b/module/index/js/index.js index 8c3d1b90db..bbe1de2407 100644 --- a/module/index/js/index.js +++ b/module/index/js/index.js @@ -165,6 +165,9 @@ } } + /* Set openGroup cookie */ + $.cookie('openGroup', group, {expires: config.cookieLife, path: config.webRoot}); + /* Highlight at main menu */ var $menuMainNav = $('#menuMainNav'); var $lastActiveNav = $menuMainNav.find('li.active'); diff --git a/module/project/view/story.html.php b/module/project/view/story.html.php index 8d84d217b3..84b6a2484d 100644 --- a/module/project/view/story.html.php +++ b/module/project/view/story.html.php @@ -151,7 +151,7 @@ $story):?> createLink('story', 'view', "storyID=$story->id&version=$story->version&from=project¶m=$project->id"); + $storyLink = $this->createLink('story', 'view', "storyID=$story->id&version=$story->version¶m=$project->id"); $totalEstimate += $story->estimate; ?> diff --git a/module/story/control.php b/module/story/control.php index c5e2788075..5d1f5964c3 100644 --- a/module/story/control.php +++ b/module/story/control.php @@ -25,6 +25,8 @@ class story extends control $this->loadModel('tree'); $this->loadModel('user'); $this->loadModel('action'); + + if($this->app->openGroup == 'project') $this->app->rawModule = 'projectstory'; } /** @@ -56,7 +58,7 @@ class story extends control if($project->type == 'project') { $this->app->rawModule = 'projectstory'; - $this->lang->navGroup->story = 'project'; + $this->lang->navGroup->projectstory = 'project'; $this->lang->product->menu = $this->lang->menu->{$project->model}; } else @@ -535,11 +537,10 @@ class story extends control * Edit a story. * * @param int $storyID - * @param string $from product|project * @access public * @return void */ - public function edit($storyID, $from = 'product') + public function edit($storyID) { if(!empty($_POST)) { @@ -560,23 +561,16 @@ class story extends control } else { - $module = $from == 'project' ? 'projectstory' : 'story'; - die(js::locate($this->createLink($module, 'view', "storyID=$storyID"), 'parent')); + die(js::locate($this->createLink($this->app->rawModule, 'view', "storyID=$storyID"), 'parent')); } } - if($from == 'project') - { - $this->app->rawModule = 'projectstory'; - $this->lang->navGroup->story = 'project'; - } - $this->commonAction($storyID); /* Assign. */ $story = $this->story->getById($storyID, 0, true); $product = $this->product->getById($story->product); - $stories = $this->story->getParentStoryPairs($story->product, $story->parent); + $stories = $this->story->getParentStoryPairs($story->product, $story->parent); if(isset($stories[$storyID])) unset($stories[$storyID]); $this->story->replaceURLang($story->type); @@ -775,12 +769,6 @@ class story extends control die(js::locate($this->createLink($module, 'view', "storyID=$storyID"), 'parent')); } - if($from == 'project') - { - $this->app->rawModule = 'projectstory'; - $this->lang->navGroup->story = 'project'; - } - $this->commonAction($storyID); $this->story->getAffectedScope($this->view->story); $this->app->loadLang('task'); @@ -836,10 +824,11 @@ class story extends control * * @param int $storyID * @param int $version + * @param int $param * @access public * @return void */ - public function view($storyID, $version = 0, $from = 'product', $param = 0) + public function view($storyID, $version = 0, $param = 0) { $storyID = (int)$storyID; $story = $this->story->getById($storyID, $version, true); @@ -858,12 +847,11 @@ class story extends control $users = $this->user->getPairs('noletter'); /* Set the menu. */ + $from = $this->app->openGroup; if($from == 'project') { $project = $this->dao->findById((int)$this->session->PRJ)->from(TABLE_PROJECT)->fetch(); - $this->app->rawModule = 'project'; - $this->lang->navGroup->story = 'project'; - $this->lang->product->menu = $this->lang->menu->{$project->model}; + $this->lang->product->menu = $this->lang->menu->{$project->model}; $this->project->setMenu($this->project->getExecutionPairs($this->session->PRJ, 'all', 'nodeleted'), $project->id); /* If status is done, can not create task from story. */ @@ -1321,11 +1309,11 @@ class story extends control if(!dao::isError()) $this->loadModel('score')->create('ajax', 'batchOther'); die(js::locate($this->session->storyList, 'parent')); } - + /** * Assign to. - * - * @param int $storyID + * + * @param int $storyID * @access public * @return void */ @@ -1592,15 +1580,15 @@ class story extends control * @return void */ public function processStoryChange($storyID, $result = 'yes') - { + { $this->commonAction($storyID); $story = $this->story->getByID($storyID); if($result == 'no') - { + { $this->dao->update(TABLE_STORY)->set('URChanged')->eq(0)->where('id')->eq($storyID)->exec(); die(js::closeModal('parent.parent', 'this')); - } + } $this->view->changedStories = $this->story->getChangedStories($story); $this->view->users = $this->loadModel('user')->getPairs('noletter'); @@ -1795,7 +1783,7 @@ class story extends control $this->story->replaceURLang($storyType); $this->products = $this->product->getPairs(); - $this->lang->product->switcherMenu = $this->product->getSwitcher($productID, $storyType, $branchID); + $this->lang->product->switcherMenu = $this->product->getSwitcher($productID, $storyType, $branchID); $this->lang->product->mainMenuAction = $this->product->getProductMainAction(); $this->product->setMenu($this->products, $productID, $branchID); @@ -2110,8 +2098,8 @@ class story extends control /** * Ajax get story status. * - * @param string $method - * @param string $params + * @param string $method + * @param string $params * @access public * @return void */ diff --git a/module/story/view/view.html.php b/module/story/view/view.html.php index 3fac5eb790..b1eeb9efbd 100644 --- a/module/story/view/view.html.php +++ b/module/story/view/view.html.php @@ -412,7 +412,7 @@ foreach($relations as $item) $relation[$item->id] = $item->title; foreach($relation as $id => $title) { - echo "
  • " . html::a($this->createLink('story', 'view', "id=$id", '', true), "#$id $title", '', "class='iframe' data-width='80%'"); + echo "
  • " . html::a($this->createLink('story', 'view', "id=$id", '', true), "#$id $title", '', "class='iframe' data-width='80%'"); echo html::a($this->createLink('story', 'linkStory', "storyID=$story->id&type=remove&linkedID=$id"), '', 'hiddenwin', "class='deleter hide removeButton'"); } ?>