* Adjust code

This commit is contained in:
zenggang
2022-03-28 09:53:17 +00:00
parent 39bf316b77
commit 16b0c95790
+59 -26
View File
@@ -125,6 +125,7 @@ class upgradeModel extends model
$maxVersion = array_search($openVersion, $this->config->upgrade->maxVersion);
$this->saveLogs("Execute $maxVersion");
$this->execSQL($this->getUpgradeFile(str_replace('_', '.', $maxVersion)));
$this->executeMax($maxVersion);
}
}
@@ -138,32 +139,6 @@ class upgradeModel extends model
$this->addSubStatus();
}
}
/* Fix bug #17954. */
if(($fromEdition == 'open' and version_compare(str_replace('_', '.', $fromVersion), '15.5') < 0) or ($fromEdition == 'pro' and version_compare(str_replace('_', '.', $fromVersion), 'pro10.2') < 0) or ($fromEdition == 'biz' and version_compare(str_replace('_', '.', $fromVersion), 'biz5.2') < 0) or ($fromEdition == 'max' and version_compare(str_replace('_', '.', $fromVersion), 'max2.2') < 0))
{
$hasKanbanPri = $this->dao->select('*')->from(TABLE_GROUPPRIV)->where('module')->eq('kanban')->fetch();
if(!$hasKanbanPri)
{
$this->app->loadLang('group');
$groups = $this->dao->select('id')->from(TABLE_GROUP)->where('role')->in('admin,pm,po')->fetchPairs('id');
foreach($groups as $groupID)
{
foreach($this->lang->resource->kanban as $method => $name)
{
if(stripos($method, 'delete') === false)
{
$groupPriv = new stdclass();
$groupPriv->group = $groupID;
$groupPriv->module = 'kanban';
$groupPriv->method = $method;
$this->dao->insert(TABLE_GROUPPRIV)->data($groupPriv)->exec();
}
}
}
}
}
}
/**
@@ -468,6 +443,9 @@ class upgradeModel extends model
}
}
break;
case '15_5':
$this->addDefaultKanbanPri();
break;
case '15_7_1':
$this->updateObjectBranch();
$this->updateProjectStories();
@@ -558,6 +536,9 @@ class upgradeModel extends model
case 'pro10_0_2':
$this->fixReportLang();
break;
case 'pro10_2':
$this->addDefaultKanbanPri();
break;
}
}
@@ -641,6 +622,9 @@ class upgradeModel extends model
case 'biz5_0_1':
$this->updateWorkflow4Execution();
break;
case 'biz5_2':
$this->addDefaultKanbanPri();
break;
case 'biz5_3_1':
$this->processFeedbackField();
$this->addFileFields();
@@ -652,6 +636,23 @@ class upgradeModel extends model
}
}
/**
* Process data for max.
*
* @param int $maxVersion
* @access public
* @return void
*/
public function executeMax($maxVersion)
{
switch($maxVersion)
{
case 'max2_2':
$this->addDefaultKanbanPri();
break;
}
}
/**
* Create the confirm contents.
*
@@ -6094,4 +6095,36 @@ class upgradeModel extends model
}
file_put_contents($filePath, $content);
}
/**
* Add groups default kanban private
*
* @access public
* @return void
*/
public function addDefaultKanbanPri()
{
/* Fix bug #17954. */
$hasKanbanPri = $this->dao->select('*')->from(TABLE_GROUPPRIV)->where('module')->eq('kanban')->fetch();
if(!$hasKanbanPri)
{
$this->app->loadLang('group');
$groups = $this->dao->select('id')->from(TABLE_GROUP)->where('role')->in('admin,pm,po')->fetchPairs('id');
foreach($groups as $groupID)
{
foreach($this->lang->resource->kanban as $method => $name)
{
if(stripos($method, 'delete') === false)
{
$groupPriv = new stdclass();
$groupPriv->group = $groupID;
$groupPriv->module = 'kanban';
$groupPriv->method = $method;
$this->dao->insert(TABLE_GROUPPRIV)->data($groupPriv)->exec();
}
}
}
}
}
}