2017-10-28 16:44:56 +02:00
|
|
|
<?php
|
|
|
|
date_default_timezone_set('Europe/Oslo');
|
2018-02-10 18:08:53 +01:00
|
|
|
setlocale(LC_ALL, 'nb_NO');
|
2017-11-11 15:20:58 +01:00
|
|
|
require __DIR__ . '/../../../inc/navbar.php';
|
2017-10-28 16:44:56 +02:00
|
|
|
require __DIR__ . '/../../../src/_autoload.php';
|
2024-02-15 22:57:03 +01:00
|
|
|
require __DIR__ . '/../../../config.php';
|
2017-10-28 17:19:40 +02:00
|
|
|
|
2024-03-12 19:33:09 +01:00
|
|
|
$pdo = new \PDO($DB_DSN, $DB_USER, $DB_PASS);
|
2017-10-28 16:44:56 +02:00
|
|
|
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
2017-11-11 17:06:56 +01:00
|
|
|
$userManager = new \pvv\admin\UserManager($pdo);
|
|
|
|
|
|
|
|
require_once(__DIR__ . '/../../../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
|
|
|
|
$as = new SimpleSAML_Auth_Simple('default-sp');
|
|
|
|
$as->requireAuth();
|
|
|
|
$attrs = $as->getAttributes();
|
|
|
|
$uname = $attrs['uid'][0];
|
|
|
|
|
|
|
|
if(!$userManager->hasGroup($uname, 'prosjekt')){
|
2017-11-11 20:37:04 +01:00
|
|
|
echo 'Her har du ikke lov\'t\'å\'værra!!!';
|
2017-11-11 17:06:56 +01:00
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2017-10-28 16:44:56 +02:00
|
|
|
$projectManager = new \pvv\side\ProjectManager($pdo);
|
|
|
|
$projects = $projectManager->getAll();
|
|
|
|
|
|
|
|
$page = 1;
|
|
|
|
if(isset($_GET['page'])){
|
|
|
|
$page = $_GET['page'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$filterTitle = '';
|
|
|
|
if(isset($_POST['title'])){
|
|
|
|
$filterTitle = $_POST['title'];
|
|
|
|
}
|
|
|
|
|
2018-02-26 16:24:50 +01:00
|
|
|
/* Temporarily out of service :<
|
2017-10-28 16:44:56 +02:00
|
|
|
$filterOrganiser = '';
|
|
|
|
if(isset($_POST['organiser'])){
|
|
|
|
$filterOrganiser = $_POST['organiser'];
|
|
|
|
}
|
2018-02-26 16:24:50 +01:00
|
|
|
*/
|
2017-10-28 16:44:56 +02:00
|
|
|
|
|
|
|
// filter
|
|
|
|
$projects = array_values(array_filter(
|
|
|
|
$projects,
|
2018-02-26 16:24:50 +01:00
|
|
|
function($project) use ($filterTitle){
|
|
|
|
return (preg_match('/.*'.$filterTitle.'.*/i', $project->getName()));
|
2017-10-28 16:44:56 +02:00
|
|
|
}
|
|
|
|
));
|
|
|
|
?>
|
2018-08-14 02:09:32 +02:00
|
|
|
<!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/nav.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" />
|
2018-08-14 02:09:32 +02:00
|
|
|
<title>Prosjektadministrasjonsverkstedet</title>
|
2017-10-28 16:44:56 +02:00
|
|
|
|
2018-08-14 02:09:32 +02:00
|
|
|
<header>Prosjekt­administrasjons­verk­stedet</header>
|
2018-02-10 16:13:18 +01:00
|
|
|
|
|
|
|
<body>
|
|
|
|
<nav>
|
|
|
|
<?php echo navbar(2, 'admin'); ?>
|
2018-02-24 17:02:00 +01:00
|
|
|
<?php echo loginbar(null, $pdo); ?>
|
2018-02-10 16:13:18 +01:00
|
|
|
</nav>
|
|
|
|
|
|
|
|
<main>
|
|
|
|
<h2>Prosjektadministrasjon</h2>
|
|
|
|
<hr class="ruler">
|
|
|
|
|
|
|
|
<div class="gridsplit">
|
|
|
|
<div class="gridl">
|
|
|
|
<h2 class="no-chin">Prosjekter</h2>
|
|
|
|
|
|
|
|
<ul class="event-list">
|
|
|
|
<?php
|
|
|
|
$counter = 0;
|
|
|
|
$pageLimit = 4;
|
|
|
|
|
|
|
|
for($i = ($pageLimit * ($page - 1)); $i < count($projects); $i++){
|
|
|
|
if($counter == $pageLimit){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$project = $projects[$i];
|
|
|
|
$projectID = $project->getID();
|
2018-02-26 16:24:50 +01:00
|
|
|
$owner = $projectManager->getProjectOwner($projectID);
|
2018-02-10 16:13:18 +01:00
|
|
|
?>
|
|
|
|
|
|
|
|
<li>
|
|
|
|
<div class="event admin">
|
|
|
|
<div class="event-info">
|
|
|
|
<h3 class="no-chin"><?= $project->getName() . " (ID: " . $projectID . ")"; ?></h3>
|
2018-02-26 16:24:50 +01:00
|
|
|
<p class="subnote"><?= 'Organisert av: ' . $owner['name']; ?></p>
|
2018-08-12 03:52:55 +02:00
|
|
|
<?php
|
|
|
|
$Parsedown = new \Parsedown();
|
|
|
|
echo $Parsedown->text(implode("\n", $project->getDescription()));
|
|
|
|
?>
|
2018-02-10 16:13:18 +01:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="event-actions">
|
|
|
|
<?= '<a href="edit.php?id=' . $projectID . '">🖊</a>'; ?>
|
|
|
|
<?= '<a href="delete.php?id=' . $projectID . '" onclick="return confirm(\'Knallsikker? (ID: ' . $projectID . ')\');">🗑</a>'; ?>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
$counter++;
|
|
|
|
}
|
|
|
|
?>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<?php
|
|
|
|
if($page != 1){
|
|
|
|
echo '<a class="btn float-left" href="?page=' . ($page - 1) . '">Forrige side</a>';
|
|
|
|
}
|
2017-10-28 16:44:56 +02:00
|
|
|
|
2018-02-10 16:13:18 +01:00
|
|
|
if(($counter == $pageLimit) and (($pageLimit * $page) < count($projects))){
|
|
|
|
echo '<a class="btn float-right" href="?page=' . ($page + 1) . '">Neste side</a>';
|
2017-10-28 16:44:56 +02:00
|
|
|
}
|
2018-02-10 16:13:18 +01:00
|
|
|
?>
|
|
|
|
</div>
|
2017-10-28 16:44:56 +02:00
|
|
|
|
2018-02-10 16:13:18 +01:00
|
|
|
<div class="gridr">
|
|
|
|
<h2>Verktøy</h2>
|
|
|
|
<a class="btn adminbtn" href="edit.php?new=1">Legg inn nytt prosjekt</a>
|
|
|
|
<h2>Filter</h2>
|
|
|
|
<form action="." method="post">
|
|
|
|
<p class="no-chin">Prosjektnavn</p>
|
|
|
|
<?= '<input type="text" name="title" class="boxinput" value="' . $filterTitle . '">' ?><br>
|
|
|
|
<p class="no-chin">Leders brukernavn</p>
|
2018-02-26 16:24:50 +01:00
|
|
|
<?= '<input type="text" name="organiser" class="boxinput" value="">' ?><br>
|
2018-02-10 16:13:18 +01:00
|
|
|
|
|
|
|
<div style="margin-top: 2em;">
|
|
|
|
<input type="submit" class="btn" value="Filtrer"></input>
|
2017-10-28 16:44:56 +02:00
|
|
|
</div>
|
2018-02-10 16:13:18 +01:00
|
|
|
</form>
|
2017-10-28 16:44:56 +02:00
|
|
|
</div>
|
2018-02-10 16:13:18 +01:00
|
|
|
</div>
|
|
|
|
</main>
|
2017-11-11 15:20:58 +01:00
|
|
|
|
2018-08-12 03:52:55 +02:00
|
|
|
</body>
|