load dashboard based on rolename(s)
We link the icingaweb (icingadb) to a Microsoft AD and there will be more than 500 possible users. In order not to have to create a dashboard for every user, I propose these modifications. If the user does not have his own dashboard, and the user is linked to a role(s) that has a dashboard folder based on the role name, he will load it. If there is no user or role dashboard and a default folder with a dashboard exists, it will use it.
This commit is contained in:
parent
4ccebb78b5
commit
aaf95c1083
|
@ -71,6 +71,37 @@ class DashboardConfig extends Config
|
||||||
}
|
}
|
||||||
closedir($handle);
|
closedir($handle);
|
||||||
}
|
}
|
||||||
|
if (empty($files)) {
|
||||||
|
$roles = $user->getRoles();
|
||||||
|
if (! empty($roles)) {
|
||||||
|
foreach($roles as $role) {
|
||||||
|
if ($handle = @opendir($dashboards)) {
|
||||||
|
while (false !== ($entry = readdir($handle))) {
|
||||||
|
if ($entry[0] === '.' || ! is_dir($dashboards . '/' . $entry)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (strtolower($entry) === strtolower($role->getName())) {
|
||||||
|
$files[] = $dashboards . '/' . $entry . '/dashboard.ini';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir($handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (empty($files)) {
|
||||||
|
if ($handle = @opendir($dashboards)) {
|
||||||
|
while (false !== ($entry = readdir($handle))) {
|
||||||
|
if ($entry[0] === '.' || ! is_dir($dashboards . '/' . $entry)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (strtolower($entry) === 'default') {
|
||||||
|
$files[] = $dashboards . '/default/dashboard.ini';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
closedir($handle);
|
||||||
|
}
|
||||||
|
}
|
||||||
return $files;
|
return $files;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue