Merge branch 'master' of https://git.zcorp.cc/easycorp/zentaopms
This commit is contained in:
+16
-16
@@ -57,10 +57,10 @@ class product extends control
|
||||
if($locate == 'yes') $this->locate($this->createLink($this->moduleName, 'browse'));
|
||||
|
||||
if($this->app->getViewType() != 'mhtml') unset($this->lang->product->menu->index);
|
||||
$productID = $this->productZen->saveVisitState($productID, $this->products);
|
||||
$productID = $this->product->saveVisitState($productID, $this->products);
|
||||
$branch = (int)$this->cookie->preBranch;
|
||||
|
||||
if($this->app->viewType == 'mhtml') $this->productZen->setMenu($productID, $branch);
|
||||
if($this->app->viewType == 'mhtml') $this->product->setMenu($productID, $branch);
|
||||
|
||||
if(common::hasPriv('product', 'create')) $this->lang->TRActions = html::a($this->createLink('product', 'create'), "<i class='icon icon-sm icon-plus'></i> " . $this->lang->product->create, '', "class='btn btn-primary'");
|
||||
|
||||
@@ -123,7 +123,7 @@ class product extends control
|
||||
$pageID = (int)$pageID;
|
||||
$projectID = (int)$projectID;
|
||||
|
||||
$productID = $this->app->tab != 'project' ? $this->saveVisitState($productID, $this->products) : $productID;
|
||||
$productID = $this->app->tab != 'project' ? $this->product->saveVisitState($productID, $this->products) : $productID;
|
||||
$product = $this->product->getById($productID);
|
||||
|
||||
if($product && !isset($this->products[$product->id])) $this->products[$product->id] = $product->name;
|
||||
@@ -150,7 +150,7 @@ class product extends control
|
||||
$this->session->set('storyList', $this->app->getURI(true), 'product');
|
||||
$this->session->set('productList', $this->app->getURI(true), 'product');
|
||||
|
||||
$this->productZen->setMenu($productID, $branch, 0, '', "storyType=$storyType");
|
||||
$this->product->setMenu($productID, $branch, 0, '', "storyType=$storyType");
|
||||
}
|
||||
|
||||
/* Lower browse type. */
|
||||
@@ -435,7 +435,7 @@ class product extends control
|
||||
$this->productZen->setEditMenu($productID, $programID);
|
||||
|
||||
$product = $this->product->getByID($productID);
|
||||
$productID = $this->productZen->saveVisitState($productID, $this->products);
|
||||
$productID = $this->product->saveVisitState($productID, $this->products);
|
||||
|
||||
$this->productZen->buildEditForm($product);
|
||||
}
|
||||
@@ -567,7 +567,7 @@ class product extends control
|
||||
return print(js::reload('parent.parent'));
|
||||
}
|
||||
|
||||
$this->productZen->setMenu($productID);
|
||||
$this->product->setMenu($productID);
|
||||
|
||||
$this->view->product = $product;
|
||||
$this->view->title = $this->view->product->name . $this->lang->colon .$this->lang->close;
|
||||
@@ -596,7 +596,7 @@ class product extends control
|
||||
}
|
||||
|
||||
$product->desc = $this->loadModel('file')->setImgSize($product->desc);
|
||||
$this->productZen->setMenu($productID);
|
||||
$this->product->setMenu($productID);
|
||||
|
||||
/* Load pager. */
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
@@ -655,7 +655,7 @@ class product extends control
|
||||
*/
|
||||
public function roadmap($productID, $branch = 'all')
|
||||
{
|
||||
$this->productZen->setMenu($productID, $branch);
|
||||
$this->product->setMenu($productID, $branch);
|
||||
|
||||
$this->session->set('releaseList', $this->app->getURI(true), 'product');
|
||||
$this->session->set('productPlanList', $this->app->getURI(true), 'product');
|
||||
@@ -701,7 +701,7 @@ class product extends control
|
||||
$this->session->set('caseList', $uri, 'qa');
|
||||
$this->session->set('testtaskList', $uri, 'qa');
|
||||
|
||||
$this->productZen->setMenu($productID, 0, 0, '', $type);
|
||||
$this->product->setMenu($productID, 0, 0, '', $type);
|
||||
|
||||
/* Append id for secend sort. */
|
||||
$orderBy = $direction == 'next' ? 'date_desc' : 'date_asc';
|
||||
@@ -757,12 +757,12 @@ class product extends control
|
||||
$this->session->set('productPlanList', $uri, 'product');
|
||||
$this->session->set('releaseList', $uri, 'product');
|
||||
|
||||
$productID = $this->productZen->saveVisitState($productID, $this->products);
|
||||
$productID = $this->product->saveVisitState($productID, $this->products);
|
||||
$product = $this->product->getStatByID($productID);
|
||||
if(!$product) return print(js::locate('product', 'all'));
|
||||
|
||||
$product->desc = $this->loadModel('file')->setImgSize($product->desc);
|
||||
$this->productZen->setMenu($productID);
|
||||
$this->product->setMenu($productID);
|
||||
|
||||
/* Load pager. */
|
||||
$this->app->loadClass('pager', $static = true);
|
||||
@@ -989,7 +989,7 @@ class product extends control
|
||||
*/
|
||||
public function whitelist($productID = 0, $module = 'product', $objectType = 'product', $orderBy = 'id_desc', $recTotal = 0, $recPerPage = 20, $pageID = 1)
|
||||
{
|
||||
$this->productZen->setMenu($productID, 0);
|
||||
$this->product->setMenu($productID, 0);
|
||||
$this->lang->modulePageNav = '';
|
||||
|
||||
echo $this->fetch('personnel', 'whitelist', "objectID=$productID&module=product&browseType=$objectType&orderBy=$orderBy&recTotal=$recTotal&recPerPage=$recPerPage&pageID=$pageID");
|
||||
@@ -1007,7 +1007,7 @@ class product extends control
|
||||
*/
|
||||
public function addWhitelist($productID = 0, $deptID = 0, $copyID = 0)
|
||||
{
|
||||
$this->productZen->setMenu($productID);
|
||||
$this->product->setMenu($productID);
|
||||
$this->lang->modulePageNav = '';
|
||||
|
||||
echo $this->fetch('personnel', 'addWhitelist', "objectID=$productID&dept=$deptID©ID=$copyID&objectType=product&module=product");
|
||||
@@ -1132,9 +1132,9 @@ class product extends control
|
||||
if(!$projectID)
|
||||
{
|
||||
$products = $this->product->getPairs();
|
||||
$productID = $this->productZen->saveVisitState($productID, $products);
|
||||
$this->product->products = $this->productZen->saveVisitState($productID, $products);
|
||||
$this->productZen->setMenu($productID, $branch);
|
||||
$productID = $this->product->saveVisitState($productID, $products);
|
||||
$this->product->products = $this->product->saveVisitState($productID, $products);
|
||||
$this->product->setMenu($productID, $branch);
|
||||
}
|
||||
|
||||
/* Save session. */
|
||||
|
||||
+129
-3
@@ -1162,7 +1162,6 @@ class productModel extends model
|
||||
if(empty($projects)) return array();
|
||||
|
||||
$projectKeys = array_keys($projects);
|
||||
$stats = array();
|
||||
|
||||
/* Get all tasks and compute totalEstimate, totalConsumed, totalLeft, progress according to them. */
|
||||
$tasks = $this->dao->select('id, project, estimate, consumed, `left`, status, closedReason')
|
||||
@@ -1181,8 +1180,7 @@ class productModel extends model
|
||||
->andWhere('t2.deleted')->eq(0)
|
||||
->fetchGroup('root', 'account');
|
||||
|
||||
$stats = $this->program->appendStatToProjects($projects, 'hours,teamCount', array('hours' => $hours, 'teams' => $teams));
|
||||
return $stats;
|
||||
return $this->program->appendStatToProjects($projects, 'hours,teamCount', array('hours' => $hours, 'teams' => $teams));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2231,4 +2229,132 @@ class productModel extends model
|
||||
|
||||
return $row;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把访问的产品ID等状态信息保存到session和cookie中。
|
||||
* Save the product id user last visited to session and cookie.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param array $products
|
||||
* @access protected
|
||||
* @return int
|
||||
*/
|
||||
protected function saveVisitState(int $productID, array $products): int
|
||||
{
|
||||
if(defined('TUTORIAL')) return $productID;
|
||||
|
||||
$productID = $this->getAccessableProductID($productID, $products);
|
||||
|
||||
$this->session->set('product', $productID, $this->app->tab);
|
||||
|
||||
setcookie('preProductID', (string)$productID, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
|
||||
/* If preProductID changed, then reset preBranch. */
|
||||
if($this->cookie->preProductID != $this->session->product)
|
||||
{
|
||||
$this->cookie->set('preBranch', 0);
|
||||
setcookie('preBranch', '0', $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
}
|
||||
|
||||
return $productID;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取可访问的产品ID。
|
||||
* Get accessable product ID.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param array $products
|
||||
* @access protected
|
||||
* @return int
|
||||
*/
|
||||
protected function getAccessableProductID(int $productID, array $products): int
|
||||
{
|
||||
if(empty($productID))
|
||||
{
|
||||
if($this->cookie->preProductID and isset($products[$this->cookie->preProductID])) $productID = $this->cookie->preProductID;
|
||||
if(empty($this->session->product)) $productID = (int)key($products);
|
||||
}
|
||||
|
||||
/* 产品ID已经被删除,不存在于产品列表中。*/
|
||||
/* Product ID does not exsit in products list, it may be deleted. */
|
||||
if(!isset($products[$productID]))
|
||||
{
|
||||
/* Confirm if product exist. */
|
||||
$product = $this->product->getById($productID);
|
||||
if(empty($product) or $product->deleted == 1) $productID = (int)key($products);
|
||||
/* If product is invisable for curren user, then response access denied message. */
|
||||
if($productID && strpos(",{$this->app->user->view->products},", ",{$productID},") === false)
|
||||
{
|
||||
$productID = (int)key($products);
|
||||
$this->accessDenied($this->lang->product->accessDenied);
|
||||
}
|
||||
}
|
||||
|
||||
return $productID;
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出访问被拒绝提示信息。
|
||||
* Show accessDenied response.
|
||||
*
|
||||
* @param string $tips
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
public function accessDenied($tips)
|
||||
{
|
||||
if(defined('TUTORIAL')) return true;
|
||||
|
||||
echo js::alert($tips);
|
||||
|
||||
if(!$this->server->http_referer) return print(js::locate(helper::createLink('product', 'index')));
|
||||
|
||||
$loginLink = $this->config->requestType == 'GET' ? "?{$this->config->moduleVar}=user&{$this->config->methodVar}=login" : "user{$this->config->requestFix}login";
|
||||
if(strpos($this->server->http_referer, $loginLink) !== false) return print(js::locate(helper::createLink('product', 'index')));
|
||||
|
||||
echo js::locate('back');
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置导航菜单。
|
||||
* Set menu.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param int|string $branch
|
||||
* @param int $module
|
||||
* @param string $moduleType
|
||||
* @param string $extra
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function setMenu($productID = 0, $branch = '', $module = 0, $moduleType = '', $extra = ''): void
|
||||
{
|
||||
if(!$this->app->user->admin and strpos(",{$this->app->user->view->products},", ",$productID,") === false and $productID != 0 and !defined('TUTORIAL'))
|
||||
{
|
||||
$this->accessDenied($this->lang->product->accessDenied);
|
||||
return;
|
||||
}
|
||||
|
||||
$product = $this->getByID($productID);
|
||||
|
||||
$params = array('branch' => $branch);
|
||||
common::setMenuVars('product', $productID, $params);
|
||||
if(!$product) return;
|
||||
|
||||
$this->lang->switcherMenu = $this->getSwitcher($productID, $extra, $branch);
|
||||
|
||||
if($product->type == 'normal')
|
||||
{
|
||||
unset($this->lang->product->menu->settings['subMenu']->branch);
|
||||
}
|
||||
else
|
||||
{
|
||||
$branchLink = $this->lang->product->menu->settings['subMenu']->branch['link'];
|
||||
$this->lang->product->menu->settings['subMenu']->branch['link'] = str_replace('@branch@', $this->lang->product->branchName[$product->type], $branchLink);
|
||||
$this->lang->product->branch = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]);
|
||||
}
|
||||
|
||||
if(strpos($extra, 'requirement') !== false) unset($this->lang->product->moreSelects['willclose']);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -596,132 +596,4 @@ class productZen extends product
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把访问的产品ID等状态信息保存到session和cookie中。
|
||||
* Save the product id user last visited to session and cookie.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param array $products
|
||||
* @access protected
|
||||
* @return int
|
||||
*/
|
||||
protected function saveVisitState(int $productID, array $products): int
|
||||
{
|
||||
if(defined('TUTORIAL')) return $productID;
|
||||
|
||||
$productID = $this->getAccessableProductID($productID, $products);
|
||||
|
||||
$this->session->set('product', $productID, $this->app->tab);
|
||||
|
||||
setcookie('preProductID', (string)$productID, $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
|
||||
/* If preProductID changed, then reset preBranch. */
|
||||
if($this->cookie->preProductID != $this->session->product)
|
||||
{
|
||||
$this->cookie->set('preBranch', 0);
|
||||
setcookie('preBranch', '0', $this->config->cookieLife, $this->config->webRoot, '', $this->config->cookieSecure, true);
|
||||
}
|
||||
|
||||
return $productID;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取可访问的产品ID。
|
||||
* Get accessable product ID.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param array $products
|
||||
* @access protected
|
||||
* @return int
|
||||
*/
|
||||
protected function getAccessableProductID(int $productID, array $products): int
|
||||
{
|
||||
if(empty($productID))
|
||||
{
|
||||
if($this->cookie->preProductID and isset($products[$this->cookie->preProductID])) $productID = $this->cookie->preProductID;
|
||||
if(empty($this->session->product)) $productID = (int)key($products);
|
||||
}
|
||||
|
||||
/* 产品ID已经被删除,不存在于产品列表中。*/
|
||||
/* Product ID does not exsit in products list, it may be deleted. */
|
||||
if(!isset($products[$productID]))
|
||||
{
|
||||
/* Confirm if product exist. */
|
||||
$product = $this->product->getById($productID);
|
||||
if(empty($product) or $product->deleted == 1) $productID = (int)key($products);
|
||||
/* If product is invisable for curren user, then response access denied message. */
|
||||
if($productID && strpos(",{$this->app->user->view->products},", ",{$productID},") === false)
|
||||
{
|
||||
$productID = (int)key($products);
|
||||
$this->accessDenied($this->lang->product->accessDenied);
|
||||
}
|
||||
}
|
||||
|
||||
return $productID;
|
||||
}
|
||||
|
||||
/**
|
||||
* 输出访问被拒绝提示信息。
|
||||
* Show accessDenied response.
|
||||
*
|
||||
* @param string $tips
|
||||
* @access private
|
||||
* @return void
|
||||
*/
|
||||
public function accessDenied($tips)
|
||||
{
|
||||
if(defined('TUTORIAL')) return true;
|
||||
|
||||
echo(js::alert($tips));
|
||||
|
||||
if(!$this->server->http_referer) return print(js::locate(helper::createLink('product', 'index')));
|
||||
|
||||
$loginLink = $this->config->requestType == 'GET' ? "?{$this->config->moduleVar}=user&{$this->config->methodVar}=login" : "user{$this->config->requestFix}login";
|
||||
if(strpos($this->server->http_referer, $loginLink) !== false) return print(js::locate(helper::createLink('product', 'index')));
|
||||
|
||||
echo js::locate('back');
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置导航菜单。
|
||||
* Set menu.
|
||||
*
|
||||
* @param int $productID
|
||||
* @param int|string $branch
|
||||
* @param int $module
|
||||
* @param string $moduleType
|
||||
* @param string $extra
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function setMenu($productID = 0, $branch = '', $module = 0, $moduleType = '', $extra = ''): void
|
||||
{
|
||||
if(!$this->app->user->admin and strpos(",{$this->app->user->view->products},", ",$productID,") === false and $productID != 0 and !defined('TUTORIAL'))
|
||||
{
|
||||
$this->accessDenied($this->lang->product->accessDenied);
|
||||
return;
|
||||
}
|
||||
|
||||
$product = $this->product->getByID($productID);
|
||||
|
||||
$params = array('branch' => $branch);
|
||||
common::setMenuVars('product', $productID, $params);
|
||||
if(!$product) return;
|
||||
|
||||
$this->lang->switcherMenu = $this->product->getSwitcher($productID, $extra, $branch);
|
||||
|
||||
if($product->type == 'normal')
|
||||
{
|
||||
unset($this->lang->product->menu->settings['subMenu']->branch);
|
||||
}
|
||||
else
|
||||
{
|
||||
$branchLink = $this->lang->product->menu->settings['subMenu']->branch['link'];
|
||||
$this->lang->product->menu->settings['subMenu']->branch['link'] = str_replace('@branch@', $this->lang->product->branchName[$product->type], $branchLink);
|
||||
$this->lang->product->branch = sprintf($this->lang->product->branch, $this->lang->product->branchName[$product->type]);
|
||||
}
|
||||
|
||||
if(strpos($extra, 'requirement') !== false) unset($this->lang->product->moreSelects['willclose']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user