Commit c115e0a6 authored by Franco Fichtner's avatar Franco Fichtner

inc: map_page_privname is only ever used once so make it inline

parent dc5789c6
...@@ -29,24 +29,6 @@ ...@@ -29,24 +29,6 @@
require_once('rrd.inc'); require_once('rrd.inc');
function map_page_privname($page) {
global $priv_list;
foreach ($priv_list as $pname => $pdata) {
if (strncmp($pname, "page-", 5))
continue;
$fullwc = false;
if (!strcasecmp($page,"any")||!strcmp($page,"*"))
$fullwc = true;
if (cmp_page_matches($page, $pdata['match'], $fullwc))
return $pname;
}
return false;
}
/* /*
* Upgrade functions must be named: * Upgrade functions must be named:
* upgrade_XXX_to_YYY * upgrade_XXX_to_YYY
...@@ -1335,11 +1317,33 @@ function upgrade_048_to_049() { ...@@ -1335,11 +1317,33 @@ function upgrade_048_to_049() {
} }
function upgrade_049_to_050() { function upgrade_049_to_050()
{
global $config; global $config;
if (!is_array($config['system']['user'])) $map_page_privname = function ($page) {
global $priv_list;
foreach ($priv_list as $pname => $pdata) {
if (strncmp($pname, 'page-', 5)) {
continue;
}
$fullwc = false;
if (!strcasecmp($page, 'any') || !strcmp($page, '*')) {
$fullwc = true;
}
if (cmp_page_matches($page, $pdata['match'], $fullwc)) {
return $pname;
}
}
return false;
};
if (!is_array($config['system']['user'])) {
$config['system']['user'] = array(); $config['system']['user'] = array();
}
/* update user privileges */ /* update user privileges */
foreach ($config['system']['user'] as & $user) { foreach ($config['system']['user'] as & $user) {
$privs = array(); $privs = array();
...@@ -1368,9 +1372,10 @@ function upgrade_049_to_050() { ...@@ -1368,9 +1372,10 @@ function upgrade_049_to_050() {
continue; continue;
} }
foreach ($group['pages'] as $page) { foreach ($group['pages'] as $page) {
$priv = map_page_privname($page); $priv = $map_page_privname($page);
if ($priv) if ($priv) {
$privs[] = $priv; $privs[] = $priv;
}
} }
unset($group['pages']); unset($group['pages']);
$group['priv'] = $privs; $group['priv'] = $privs;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment