Commit ee7be889 authored by Ad Schellevis's avatar Ad Schellevis

fix getAllowedPages / privileges

parent b7959258
...@@ -536,7 +536,7 @@ function local_user_get_groups($user, $all = false) ...@@ -536,7 +536,7 @@ function local_user_get_groups($user, $all = false)
} }
foreach ($config['system']['group'] as $group) { foreach ($config['system']['group'] as $group) {
if (is_array($group['member'])) { if (isset($group['member'])) {
if (in_array($user['uid'], $group['member']) || ($group['name'] == "all" && $all)) { if (in_array($user['uid'], $group['member']) || ($group['name'] == "all" && $all)) {
$groups[] = $group['name']; $groups[] = $group['name'];
} }
......
...@@ -1462,3 +1462,9 @@ $priv_list['user-pptp-dialin']['descr'] = "Indicates whether the user is allowed ...@@ -1462,3 +1462,9 @@ $priv_list['user-pptp-dialin']['descr'] = "Indicates whether the user is allowed
$priv_list['user-pppoe-dialin'] = array(); $priv_list['user-pppoe-dialin'] = array();
$priv_list['user-pppoe-dialin']['name'] = "User - VPN - PPPOE Dialin"; $priv_list['user-pppoe-dialin']['name'] = "User - VPN - PPPOE Dialin";
$priv_list['user-pppoe-dialin']['descr'] = "Indicates whether the user is allowed to dial in via PPPOE"; $priv_list['user-pppoe-dialin']['descr'] = "Indicates whether the user is allowed to dial in via PPPOE";
// sort by name ( case insensitive )
uasort($priv_list,function($a,$b) {
return strcasecmp($a["name"], $b["name"]) ;
});
...@@ -32,12 +32,6 @@ ...@@ -32,12 +32,6 @@
require_once 'priv.defs.inc'; require_once 'priv.defs.inc';
if (is_array($priv_list)) {
usort($priv_list, function($a, $b) {
return strcasecmp($a['name'], $b['name']);
});
}
function cmp_page_matches($page, & $matches, $fullwc = true) { function cmp_page_matches($page, & $matches, $fullwc = true) {
// $dbg_matches = implode(",", $matches); // $dbg_matches = implode(",", $matches);
...@@ -172,7 +166,7 @@ function isAllowedPage($page) ...@@ -172,7 +166,7 @@ function isAllowedPage($page)
function getPrivPages(& $entry, & $allowed_pages) { function getPrivPages(& $entry, & $allowed_pages) {
global $priv_list; global $priv_list;
if (!is_array($entry['priv'])) if (!isset($entry['priv']) || !is_array($entry['priv']))
return; return;
foreach ($entry['priv'] as $pname) { foreach ($entry['priv'] as $pname) {
...@@ -198,7 +192,11 @@ function getAllowedPages($username) { ...@@ -198,7 +192,11 @@ function getAllowedPages($username) {
$allowed_pages = array(); $allowed_pages = array();
$allowed_groups = array(); $allowed_groups = array();
$authcfg = auth_get_authserver($config['system']['webgui']['authmode']); if (isset($config['system']['webgui']['authmode'])) {
$authcfg = auth_get_authserver($config['system']['webgui']['authmode']);
} else {
$authcfg['type'] = 'local';
}
// obtain ldap groups if we are in ldap mode // obtain ldap groups if we are in ldap mode
if ($authcfg['type'] == "ldap") if ($authcfg['type'] == "ldap")
$allowed_groups = @ldap_get_groups($username, $authcfg); $allowed_groups = @ldap_get_groups($username, $authcfg);
...@@ -208,15 +206,17 @@ function getAllowedPages($username) { ...@@ -208,15 +206,17 @@ function getAllowedPages($username) {
getPrivPages($local_user, $allowed_pages); getPrivPages($local_user, $allowed_pages);
// obtain local groups if we have a local user // obtain local groups if we have a local user
if ($local_user) $allowed_groups = local_user_get_groups($local_user);
$allowed_groups = local_user_get_groups($local_user);
} }
// build a list of allowed pages // build a list of allowed pages
if (is_array($config['system']['group']) && is_array($allowed_groups)) if (is_array($config['system']['group']) && is_array($allowed_groups)) {
foreach ($config['system']['group'] as $group) foreach ($config['system']['group'] as $group) {
if (in_array($group['name'], $allowed_groups)) if (in_array($group['name'], $allowed_groups)) {
getPrivPages($group, $allowed_pages); getPrivPages($group, $allowed_pages);
}
}
}
// $dbg_pages = implode(",", $allowed_pages); // $dbg_pages = implode(",", $allowed_pages);
// $dbg_groups = implode(",", $allowed_groups); // $dbg_groups = implode(",", $allowed_groups);
......
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