* adjust for set lastExecution.

This commit is contained in:
wangyidong
2022-09-21 11:23:44 +08:00
parent a6bed96839
commit ecbd0e415f
2 changed files with 83 additions and 34 deletions
+8 -5
View File
@@ -138,8 +138,12 @@ class execution extends control
array_unshift($recentExecutions, $executionID);
$recentExecutions = array_unique($recentExecutions);
$recentExecutions = array_slice($recentExecutions, 0, 5);
$this->setting->setItem($this->app->user->account . 'common.execution.recentExecutions', implode(',', $recentExecutions));
$this->setting->setItem($this->app->user->account . 'common.execution.lastExecution', $executionID);
$recentExecutions = join(',', $recentExecutions);
if(empty($this->config->projectMode))
{
if(!isset($this->config->execution->recentExecutions) or $this->config->execution->recentExecutions != $recentExecutions) $this->setting->updateItem($this->app->user->account . 'common.execution.recentExecutions', $recentExecutions);
if(!isset($this->config->execution->lastExecution) or $this->config->execution->lastExecution != $executionID) $this->setting->updateItem($this->app->user->account . 'common.execution.lastExecution', $executionID);
}
if($this->cookie->preExecutionID != $executionID)
{
@@ -181,9 +185,7 @@ class execution extends control
$sort = common::appendOrder($orderBy);
/* Header and position. */
$this->view->title = $execution->name . $this->lang->colon . $this->lang->execution->task;
$this->view->position[] = html::a($this->createLink('execution', 'browse', "executionID=$executionID"), $execution->name);
$this->view->position[] = $this->lang->execution->task;
$this->view->title = $execution->name . $this->lang->colon . $this->lang->execution->task;
/* Load pager and get tasks. */
$this->app->loadClass('pager', $static = true);
@@ -3515,6 +3517,7 @@ class execution extends control
$projects = $this->loadModel('program')->getProjectList(0, 'all', 0, 'order_asc', null, 0, 0, true);
$executionGroups = $this->dao->select('*')->from(TABLE_EXECUTION)
->where('deleted')->eq(0)
->andWhere('noSprint')->eq('0')
->andWhere('type')->in('sprint,stage,kanban')
->beginIF(!$this->app->user->admin)->andWhere('id')->in($this->app->user->view->sprints)->fi()
->andWhere('project')->in(array_keys($projects))
+75 -29
View File
@@ -49,36 +49,10 @@ class settingModel extends model
*/
public function setItem($path, $value = '')
{
/* Determine vision of config item. */
$pathVision = explode('@', $path);
$vision = isset($pathVision[1]) ? $pathVision[1] : '';
$path = $pathVision[0];
/* fix bug when account has dot. */
$account = isset($this->app->user->account) ? $this->app->user->account : '';
$replace = false;
if($account and strpos($path, $account) === 0)
{
$replace = true;
$path = preg_replace("/^{$account}/", 'account', $path);
}
$level = substr_count($path, '.');
$section = '';
if($level <= 1) return false;
if($level == 2) list($owner, $module, $key) = explode('.', $path);
if($level == 3) list($owner, $module, $section, $key) = explode('.', $path);
if($replace) $owner = $account;
$item = new stdclass();
$item->owner = $owner;
$item->module = $module;
$item->section = $section;
$item->key = $key;
$item->value = $value;
if(!empty($vision)) $item->vision = $vision;
$item = $this->parseItemPath($path);
if(empty($item)) return false;
$item->value = $value;
$this->dao->replace(TABLE_CONFIG)->data($item)->exec();
}
@@ -121,6 +95,37 @@ class settingModel extends model
return false;
}
/**
* When exists this item then update it. No exists then insert this item.
*
* @param string $path
* @param string $value
* @access public
* @return void
*/
public function updateItem($path, $value = '')
{
$item = $this->parseItemPath($path);
if(empty($item)) return false;
if(!isset($item->vision)) $item->vision = '';
$updateID = $this->dao->select('id')->from(TABLE_CONFIG)
->where('owner')->eq($item->owner)
->andWhere('vision')->eq($item->vision)
->andWhere('module')->eq($item->module)
->andWhere('section')->eq($item->section)
->andWhere('`key`')->eq($item->key)
->fetch('id');
if($updateID)
{
$this->dao->update(TABLE_CONFIG)->set('value')->eq($value)->where('id')->eq($updateID)->exec();
return true;
}
$item->value = $value;
$this->dao->insert(TABLE_CONFIG)->data($item)->exec();
}
/**
* Delete items.
*
@@ -133,6 +138,47 @@ class settingModel extends model
$this->createDAO($this->parseItemParam($paramString), 'delete')->exec();
}
/**
* Parse item path
*
* @param string $path system.common.global.sn | system.common.sn | system.common.global.sn@rnd
* @access public
* @return object
*/
public function parseItemPath($path)
{
/* Determine vision of config item. */
$pathVision = explode('@', $path);
$vision = isset($pathVision[1]) ? $pathVision[1] : '';
$path = $pathVision[0];
/* fix bug when account has dot. */
$account = isset($this->app->user->account) ? $this->app->user->account : '';
$replace = false;
if($account and strpos($path, $account) === 0)
{
$replace = true;
$path = preg_replace("/^{$account}/", 'account', $path);
}
$level = substr_count($path, '.');
$section = '';
if($level <= 1) return false;
if($level == 2) list($owner, $module, $key) = explode('.', $path);
if($level == 3) list($owner, $module, $section, $key) = explode('.', $path);
if($replace) $owner = $account;
$item = new stdclass();
$item->owner = $owner;
$item->module = $module;
$item->section = $section;
$item->key = $key;
if(!empty($vision)) $item->vision = $vision;
return $item;
}
/**
* Parse the param string for select or delete items.
*