diff --git a/inc/navbar.php b/inc/navbar.php
index 2401b46..84c0de1 100644
--- a/inc/navbar.php
+++ b/inc/navbar.php
@@ -1,5 +1,9 @@
\n";
$result .= "\t\t
\n";
$menuItems = [
@@ -10,6 +14,25 @@ function navbar($depth, $active = NULL) {
'Kontakt' => 'kontakt',
'Wiki' => 'pvv'
];
+
+ $as = new SimpleSAML_Auth_Simple($sp);
+ $attr = $as->getAttributes();
+ if($attr) {
+ $uname = $attr['uid'][0];
+
+ $pdo = new \PDO($dbDsn, $dbUser, $dbPass);
+ $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
+ $userManager = new \pvv\admin\UserManager($pdo);
+
+ $isAdmin = $userManager->isAdmin($uname);
+ $projectGroup = $userManager->hasGroup($uname, 'prosjekt');
+ $activityGroup = $userManager->hasGroup($uname, 'aktiviteter');
+
+ if($isAdmin | $projectGroup | $activityGroup) {
+ $menuItems['Admin'] = 'admin';
+ }
+ }
+
foreach($menuItems as $caption => $link) {
$result .= "\t\t\t"
. "- " . $caption . "
\n"
@@ -20,8 +43,9 @@ function navbar($depth, $active = NULL) {
}
function loginBar($sp = 'default-sp') {
+ require_once __DIR__ . '/../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php';
+
$result = "\n";
- require_once(__DIR__ . '/../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
$as = new SimpleSAML_Auth_Simple($sp);
$attr = $as->getAttributes();