* Finish task#36079.

This commit is contained in:
leiyong
2021-02-20 10:58:08 +08:00
parent 6c7d50e989
commit 5579ce6db4
2 changed files with 17 additions and 9 deletions
+9 -7
View File
@@ -117,17 +117,11 @@ class project extends control
if(!$projectID) $this->locate($this->createLink('program', 'PRJbrowse'));
setCookie("lastPRJ", $projectID, $this->config->cookieLife, $this->config->webRoot, '', false, true);
/* Save the recently five executions visited in the cookie. */
$recentExecutions = $this->cookie->recentExecutions ? explode('join', $this->cookie->recentExecutions) : array();
array_unshift($recentExecutions, $executionID);
$recentExecutions = array_unique($recentExecutions);
$recentExecutions = array_slice($recentExecutions, 0, 5);
setcookie("recentExecutions", implode('join', $recentExecutions), $this->config->cookieLife, $this->config->webRoot, '', false, true);
$this->loadModel('tree');
$this->loadModel('search');
$this->loadModel('task');
$this->loadModel('datatable');
$this->loadModel('setting');
if(common::hasPriv('project', 'create')) $this->lang->TRActions = html::a($this->createLink('project', 'create', ''), "<i class='icon icon-sm icon-plus'></i> " . $this->lang->project->create, '', "class='btn btn-primary'");
@@ -140,6 +134,14 @@ class project extends control
$products = $this->loadModel('product')->getProductPairsByProject($executionID);
setcookie('preProjectID', $executionID, $this->config->cookieLife, $this->config->webRoot, '', false, true);
/* Save the recently five executions visited in the cookie. */
$recentExecutions = isset($this->config->project->recentExecutions) ? explode(',', $this->config->project->recentExecutions) : array();
array_unshift($recentExecutions, $executionID);
$recentExecutions = array_unique($recentExecutions);
$recentExecutions = array_slice($recentExecutions, 0, 5);
$this->setting->setItem($this->app->user->account . 'common.project.recentExecutions', implode(',', $recentExecutions));
$this->setting->setItem($this->app->user->account . 'common.project.lastExecution', $executionID);
if($this->cookie->preProjectID != $executionID)
{
$_COOKIE['moduleBrowseParam'] = $_COOKIE['productBrowseParam'] = 0;
+8 -2
View File
@@ -276,12 +276,18 @@ class projectModel extends model
*/
public function saveState($executionID, $executions)
{
/* When the cookie and session do not exist, get it from the database. */
if(empty($executionID) && isset($this->config->project->lastExecution) && isset($executions[$this->config->project->lastExecution]))
{
$this->session->set('project', $this->config->project->lastExecution);
return $this->session->project;
}
if($executionID > 0) $this->session->set('project', (int)$executionID);
if($executionID == 0 and $this->cookie->lastProject)
{
/* Project link is project-task. */
$executionID = (int)$this->cookie->lastProject;
$executions = $this->getExecutionPairs($this->session->PRJ);
$executionID = in_array($executionID, array_keys($executions)) ? $executionID : key($executions);
$this->session->set('project', $executionID);
}
@@ -3608,7 +3614,7 @@ class projectModel extends model
$projectPairs = $this->loadModel('program')->getPRJPairsByIdList($projectIdList);
$productPairs = $this->getStageLinkProductPairs($stageIdList);
$recentExecutions = explode('join', $this->cookie->recentExecutions);
$recentExecutions = isset($this->config->project->recentExecutions) ? explode(',', $this->config->project->recentExecutions) : array();
$allExecution = array('recent' => array(), 'mine' => array());
foreach($executions as $execution)
{