* finish task #6561.

This commit is contained in:
wangyidong
2019-11-19 13:56:45 +08:00
parent 08146afd37
commit b4b96c2101
2 changed files with 64 additions and 2 deletions
+18 -2
View File
@@ -291,8 +291,24 @@ class groupModel extends model
$actions['actions'] = $dynamic;
/* If not select any projects or products, set it empty. */
if(isset($actions['products'][0]) && !$actions['products'][0]) $actions['products'] = array();
if(isset($actions['projects'][0]) && !$actions['projects'][0]) $actions['projects'] = array();
if(isset($actions['products']))
{
$isEmpty = true;
foreach($actions['products'] as $productID)
{
if(!empty($productID)) $isEmpty = false;
}
if($isEmpty) unset($actions['products']);
}
if(isset($actions['projects']))
{
$isEmpty = true;
foreach($actions['projects'] as $projectID)
{
if(!empty($projectID)) $isEmpty = false;
}
if($isEmpty) unset($actions['projects']);
}
$actions = empty($actions) ? '' : json_encode($actions);
$this->dao->update(TABLE_GROUP)->set('acl')->eq($actions)->where('id')->eq($groupID)->exec();
+46
View File
@@ -531,6 +531,11 @@ class upgradeModel extends model
$this->saveLogs('Execute 11_6_4');
$this->execSQL($this->getUpgradeFile('11.6.4'));
$this->appendExec('11_6_4');
case '11_6_5':
$this->saveLogs('Execute 11_6_5');
$this->execSQL($this->getUpgradeFile('11.6.5'));
$this->fixGroupAcl();
$this->appendExec('11_6_5');
}
$this->deletePatch();
@@ -3370,6 +3375,47 @@ class upgradeModel extends model
return true;
}
/**
* Fix group acl.
*
* @access public
* @return bool
*/
public function fixGroupAcl()
{
$groups = $this->dao->select('*')->from(TABLE_GROUP)->fetchAll();
foreach($groups as $group)
{
if(empty($group->acl)) continue;
$acl = json_decode($group->acl, true);
if(isset($acl['products']))
{
$isEmpty = true;
foreach($acl['products'] as $productID)
{
if(!empty($productID)) $isEmpty = false;
}
if($isEmpty) unset($acl['products']);
}
if(isset($acl['projects']))
{
$isEmpty = true;
foreach($acl['projects'] as $projectID)
{
if(!empty($projectID)) $isEmpty = false;
}
if($isEmpty) unset($acl['projects']);
}
$acl = json_encode($acl);
$this->dao->update(TABLE_GROUP)->set('acl')->eq($acl)->where('id')->eq($group->id)->exec();
}
return true;
}
/**
* Save Logs.
*