Skip to content

Commit

Permalink
do not show dashboard if not available/allowed
Browse files Browse the repository at this point in the history
  • Loading branch information
razvancrainea committed Nov 7, 2024
1 parent 7cb9743 commit 690eab8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
29 changes: 24 additions & 5 deletions web/auth_login.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,37 @@
$_SESSION['user_tabs'] = $_SESSION['temp_user_tabs'];
$_SESSION['user_priv'] = $_SESSION['temp_user_priv'];


$dashboard = false;
$default_path = NULL;
foreach ($config_modules as $menuitem => $menuitem_config) {
if (!$menuitem_config['enabled'])
continue;
if (!isset($menuitem_config['modules']))
continue;
if (isset($menuitem_config['modules']['dashboard'])
&& $menuitem_config['modules']['dashboard']['enabled'])
&& $menuitem_config['modules']['dashboard']['enabled']
&& ($avail_tools == "all" || array_key_exists("dashboard", explode(",",$avail_tools))))
$dashboard = true;
else $dashboard = false;
foreach ($menuitem_config['modules'] as $module => $values) {
if (isset($values['enabled']) && !$values['enabled'])
continue;
if (isset($values['default']) && $values['default']) {
$default_path = 'tools/';
if (!isset($value['path']))
$default_path .= $menuitem . '/' . $module;
else
$default_path .= $value['path'];
$default_path .= '/index.php';
if (!file_exists($default_path))
$default_path = NULL;
}
}
}

if ($dashboard) {

if ($default_path != NULL) {
$_SESSION['path'] = $default_path;
} else if ($dashboard) {
$query = "SELECT COUNT(*) as panel_no FROM ocp_dashboard;";
$stmt = $link->prepare($query);
if (!$stmt->execute(array($name))) {
Expand All @@ -83,4 +102,4 @@
print_r("Incorrect code");
die;
}
?>
?>
3 changes: 2 additions & 1 deletion web/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,8 @@
if (!isset($menuitem_config['modules']))
continue;
if (isset($menuitem_config['modules']['dashboard'])
&& $menuitem_config['modules']['dashboard']['enabled'])
&& $menuitem_config['modules']['dashboard']['enabled']
&& ($avail_tools == "all" || array_key_exists("dashboard", explode(",",$avail_tools))))
$dashboard = true;
foreach ($menuitem_config['modules'] as $module => $values) {
if (isset($values['enabled']) && !$values['enabled'])
Expand Down

0 comments on commit 690eab8

Please sign in to comment.