This commit is contained in:
tianshujie98
2021-03-02 09:26:41 +08:00
6 changed files with 56 additions and 34 deletions
+25 -1
View File
@@ -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 > 浏览器 > 配置文件。
+7
View File
@@ -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))
+3
View File
@@ -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');
+1 -1
View File
@@ -151,7 +151,7 @@
<tbody id='storyTableList' class='sortable'>
<?php foreach($stories as $key => $story):?>
<?php
$storyLink = $this->createLink('story', 'view', "storyID=$story->id&version=$story->version&from=project&param=$project->id");
$storyLink = $this->createLink('story', 'view', "storyID=$story->id&version=$story->version&param=$project->id");
$totalEstimate += $story->estimate;
?>
<tr id="story<?php echo $story->id;?>" data-id='<?php echo $story->id;?>' data-order='<?php echo $story->order ?>' data-estimate='<?php echo $story->estimate?>' data-cases='<?php echo zget($storyCases, $story->id, 0)?>'>
+19 -31
View File
@@ -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
*/
+1 -1
View File
@@ -412,7 +412,7 @@
foreach($relations as $item) $relation[$item->id] = $item->title;
foreach($relation as $id => $title)
{
echo "<li title='$title'>" . html::a($this->createLink('story', 'view', "id=$id", '', true), "#$id $title", '', "class='iframe' data-width='80%'");
echo "<li title='$title'>" . 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"), '<i class="icon icon-close"></i>', 'hiddenwin', "class='deleter hide removeButton'");
}
?>