* Fix bug of search privs.

This commit is contained in:
liumengyi
2023-03-21 07:37:50 +00:00
parent 6a5ecd7b3f
commit 32232268a6
+16 -9
View File
@@ -1202,10 +1202,11 @@ class groupModel extends model
$privQuery = preg_replace(array('/`recommendPrivs`[ ]+=/', '/`recommendPrivs`[ ]+LIKE/', '/`recommendPrivs`[ ]+=/', '/`recommendPrivs`[ ]+!=/', '/`recommendPrivs`[ ]+NOT LIKE/'), array('`recommendPrivs` IN', '`recommendPrivs` IN', '`recommendPrivs` IN', '`recommendPrivs` NOT IN', '`recommendPrivs` NOT IN'), $privQuery);
foreach($out[1] as $priv)
{
$priv = str_replace('%', '', $priv);
$privs = $this->dao->select('priv,priv')->from(TABLE_PRIVRELATION)->where('relationPriv')->eq($priv)->andWhere('type')->eq('recommend')->fetchPairs();
$privs = implode("','", $privs);
$privQuery = preg_replace("/`recommendPrivs`([^']+)'([%]?{$priv}[%]?)'/Ui", (!empty($privs) ? "t1.`id`$1('{$privs}')" : '0=1'), $privQuery);
$priv = str_replace('%', '', $priv);
$privs = $this->dao->select('priv,priv')->from(TABLE_PRIVRELATION)->where('relationPriv')->eq($priv)->andWhere('type')->eq('recommend')->fetchPairs();
$privs = implode("','", $privs);
$privs = !empty($privs) ? $privs : 0;
$privQuery = preg_replace("/`recommendPrivs`([^']+)'([%]?{$priv}[%]?)'/Ui", "t1.`id`$1('{$privs}')", $privQuery);
}
}
if(strpos($privQuery, '`dependPrivs`') !== false)
@@ -1214,10 +1215,11 @@ class groupModel extends model
$privQuery = preg_replace(array('/`dependPrivs`[ ]+=/', '/`dependPrivs`[ ]+LIKE/', '/`dependPrivs`[ ]+=/', '/`dependPrivs`[ ]+!=/', '/`dependPrivs`[ ]+NOT LIKE/'), array('`dependPrivs` IN', '`dependPrivs` IN', '`dependPrivs` IN', '`dependPrivs` NOT IN', '`dependPrivs` NOT IN'), $privQuery);
foreach($out[1] as $priv)
{
$priv = str_replace('%', '', $priv);
$privs = $this->dao->select('priv,priv')->from(TABLE_PRIVRELATION)->where('relationPriv')->eq($priv)->andWhere('type')->eq('depend')->fetchPairs();
$privs = implode("','", $privs);
$privQuery = preg_replace("/`dependPrivs`([^']+)'([%]?{$priv}[%]?)'/Ui", (!empty($privs) ? "t1.`id`$1('{$privs}')" : '0=1'), $privQuery);
$priv = str_replace('%', '', $priv);
$privs = $this->dao->select('priv,priv')->from(TABLE_PRIVRELATION)->where('relationPriv')->eq($priv)->andWhere('type')->eq('depend')->fetchPairs();
$privs = implode("','", $privs);
$privs = !empty($privs) ? $privs : 0;
$privQuery = preg_replace("/`dependPrivs`([^']+)'([%]?{$priv}[%]?)'/Ui", "t1.`id`$1('{$privs}')", $privQuery);
}
}
if(strpos($privQuery, '`name`') !== false) $privQuery = str_replace('`name`', 't2.`name`', $privQuery);
@@ -1557,7 +1559,12 @@ class groupModel extends model
$packages[$packageID] = $modules[$packageModules[$packageID]] . '/' . $package;
}
$privs = $this->getPrivLangPairs();
$privs = array();
$privList = $this->getPrivsListByView();
foreach($privList as $privID => $priv)
{
$privs[$privID] = $modules[$priv->module] . '/' . $priv->name;
}
$this->config->group->priv->search['params']['view']['values'] = array('' => '') + $views;
$this->config->group->priv->search['params']['module']['values'] = array('' => '') + $modules;