nettsiden/www/admin/brukere/index.php

100 lines
2.9 KiB
PHP
Raw Permalink Normal View History

2017-11-11 17:00:08 +01:00
<?php
ini_set('display_errors', '1');
date_default_timezone_set('Europe/Oslo');
2018-02-10 18:08:53 +01:00
setlocale(LC_ALL, 'nb_NO');
2017-11-11 17:00:08 +01:00
error_reporting(E_ALL);
2018-02-10 16:13:18 +01:00
require __DIR__ . '/../../../inc/navbar.php';
2017-11-11 17:00:08 +01:00
require __DIR__ . '/../../../src/_autoload.php';
2024-02-15 22:57:03 +01:00
require __DIR__ . '/../../../config.php';
2017-11-11 17:00:08 +01:00
require_once(__DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
2024-04-08 22:11:43 +02:00
$as = new \SimpleSAML\Auth\Simple('default-sp');
2017-11-11 17:00:08 +01:00
$attrs = $as->getAttributes();
2024-03-12 19:33:09 +01:00
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
2017-11-11 17:00:08 +01:00
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$userManager = new \pvv\admin\UserManager($pdo);
require_once(__DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
2024-04-08 22:11:43 +02:00
$as = new \SimpleSAML\Auth\Simple('default-sp');
2017-11-11 17:00:08 +01:00
$as->requireAuth();
$attrs = $as->getAttributes();
$uname = $attrs['uid'][0];
if(!$userManager->isAdmin($uname)){
echo 'Her har du ikke lov\'t\'å\'værra!!!';
2017-11-11 17:00:08 +01:00
exit();
}
$users = $userManager->getAllUserData();
?>
<!DOCTYPE html>
<html lang="no">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
<link rel="shortcut icon" href="favicon.ico">
<link rel="stylesheet" href="../../css/normalize.css">
<link rel="stylesheet" href="../../css/style.css">
<link rel="stylesheet" href="../../css/events.css">
<link rel="stylesheet" href="../../css/admin.css">
2018-08-14 03:29:10 +02:00
<meta name="theme-color" content="#024" />
<title>Brukeradministrasjonsverkstedet</title>
<header>Bruker&shy;administrasjons&shy;verk&shy;stedet</header>
2017-11-11 17:00:08 +01:00
2018-02-10 16:13:18 +01:00
<body>
<nav>
<?php echo navbar(2, 'admin'); ?>
<?php echo loginbar(null, $pdo); ?>
2018-02-10 16:13:18 +01:00
</nav>
2017-11-11 17:00:08 +01:00
2018-02-10 16:13:18 +01:00
<main>
<h2>Brukeradministrasjon</h2>
<hr class="ruler">
2017-11-11 17:00:08 +01:00
2018-02-10 16:13:18 +01:00
<form action="./update.php" method="post">
<table class="userlist">
<tr>
<th>Brukernavn</th>
<th>Brukergrupper</th>
</tr>
2017-11-11 17:00:08 +01:00
<?php
$users_to_update = array();
2018-02-10 16:13:18 +01:00
foreach($users as $i => $data){
$uname = $data['name'];
$groupFlag = $userManager->getUsergroups($uname);
array_push($users_to_update, $uname);
2017-11-11 17:00:08 +01:00
?>
2018-02-10 16:13:18 +01:00
<tr>
<td><?= $uname ?></td>
<?php
foreach($userManager->usergroups as $name => $group){
echo '<td><input type="checkbox" ' . (($groupFlag & $group) ? 'checked' : '') . ' name="' . $uname . '_' . $name . '" class="usergroupcheckbox">' . $name . '</td>';
}
?>
</tr>
2018-02-10 16:13:18 +01:00
<?php
}
foreach($users_to_update as $uname) {
echo '<input type="hidden" name="user_to_update" value="' . $uname . '" />';
}
2018-02-10 16:13:18 +01:00
?>
2017-11-11 17:00:08 +01:00
2018-02-10 16:13:18 +01:00
<tr class="newuserrow">
<td class="newuserelement"><input type="text" name="newuser" class="newuserinput"></td>
<?php
foreach($userManager->usergroups as $name => $group){
echo '<td><input type="checkbox" name="newuser_' . $name . '" class="usergroupcheckbox">' . $name . '</td>';
}
?>
</tr>
</table>
<input type="submit" class="btn" value="Lagre">
</form>
</main>
2018-02-24 16:53:17 +01:00
</body>