2017-10-07 23:12:10 +02:00
|
|
|
<?php
|
|
|
|
date_default_timezone_set('Europe/Oslo');
|
|
|
|
setlocale(LC_ALL, 'no_NO');
|
2017-11-11 15:20:58 +01:00
|
|
|
require __DIR__ . '/../../../inc/navbar.php';
|
2017-10-07 23:12:10 +02:00
|
|
|
require __DIR__ . '/../../../src/_autoload.php';
|
|
|
|
require __DIR__ . '/../../../sql_config.php';
|
2017-10-28 17:19:40 +02:00
|
|
|
|
2017-10-07 23:12:10 +02:00
|
|
|
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
|
|
|
$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, 'aktiviteter')){
|
|
|
|
echo 'Ingen tilgang';
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2017-10-07 23:12:10 +02:00
|
|
|
$customActivity = new \pvv\side\DBActivity($pdo);
|
2017-10-28 16:11:36 +02:00
|
|
|
$events = $customActivity->getAllEvents();
|
2017-10-08 03:33:42 +02:00
|
|
|
|
2017-10-12 00:38:28 +02:00
|
|
|
$page = 1;
|
|
|
|
if(isset($_GET['page'])){
|
|
|
|
$page = $_GET['page'];
|
|
|
|
}
|
2017-10-28 16:11:36 +02:00
|
|
|
|
|
|
|
$filterTitle = '';
|
|
|
|
if(isset($_POST['title'])){
|
|
|
|
$filterTitle = $_POST['title'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$filterOrganiser = '';
|
|
|
|
if(isset($_POST['organiser'])){
|
|
|
|
$filterOrganiser = $_POST['organiser'];
|
|
|
|
}
|
|
|
|
|
|
|
|
// filter
|
|
|
|
$events = array_values(array_filter(
|
|
|
|
$events,
|
|
|
|
function($event) use ($filterTitle, $filterOrganiser){
|
|
|
|
return (preg_match('/.*'.$filterTitle.'.*/i', $event->getName()) and preg_match('/.*'.$filterOrganiser.'.*/i', $event->getOrganiser()));
|
|
|
|
}
|
|
|
|
));
|
2017-10-07 23:12:10 +02:00
|
|
|
?>
|
|
|
|
|
2017-10-08 03:33:42 +02:00
|
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
2017-10-07 23:12:10 +02:00
|
|
|
<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">
|
|
|
|
|
|
|
|
<header class="admin">Aktivitets­administrasjon</header>
|
|
|
|
|
|
|
|
<main>
|
|
|
|
|
|
|
|
<article class="gridsplit">
|
|
|
|
<div class="gridl">
|
|
|
|
<h2 class="no-chin">Aktive aktiviteter</h2>
|
|
|
|
<p class="subnote">Gjentagende aktiviteter vises ikke</p>
|
|
|
|
|
|
|
|
<ul class="event-list">
|
2017-10-08 03:33:42 +02:00
|
|
|
<?php
|
|
|
|
$counter = 0;
|
|
|
|
$pageLimit = 4;
|
|
|
|
|
|
|
|
for($i = ($pageLimit * ($page - 1)); $i < count($events) ;$i++){
|
|
|
|
if($counter == $pageLimit){
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
$event = $events[$i];
|
|
|
|
$eventID = $event->getID();
|
2017-10-07 23:12:10 +02:00
|
|
|
?>
|
2017-10-12 00:38:28 +02:00
|
|
|
|
2017-10-07 23:12:10 +02:00
|
|
|
<li>
|
|
|
|
<div class="event admin">
|
|
|
|
<div class="event-info">
|
2017-10-08 03:33:42 +02:00
|
|
|
<h3 class="no-chin"><?= $event->getName() . " (ID: " . $eventID . ")"; ?></h3>
|
2017-10-22 17:57:55 +02:00
|
|
|
<p class="subnote">
|
|
|
|
<?= $event->getStart()->format("(Y-m-d H:i:s)") . " - " . $event->getStop()->format("(Y-m-d H:i:s)"); ?>
|
|
|
|
</p>
|
2017-10-07 23:12:10 +02:00
|
|
|
<p><?= implode($event->getDescription(), "</p>\n<p>"); ?></p>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="event-actions">
|
2017-10-12 00:38:28 +02:00
|
|
|
<!-- emojis are for big boys -->
|
|
|
|
<?= '<a href="edit.php?id=' . $eventID . '">🖊</a>'; ?>
|
|
|
|
<?= '<a href="delete.php?id=' . $eventID . '" onclick="return confirm(\'Knallsikker? (ID: ' . $eventID . ')\');">🗑</a>'; ?>
|
2017-10-07 23:12:10 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</li>
|
2017-10-12 00:38:28 +02:00
|
|
|
|
|
|
|
<?php
|
|
|
|
$counter++;
|
|
|
|
}
|
|
|
|
?>
|
2017-10-07 23:12:10 +02:00
|
|
|
</ul>
|
2017-10-08 03:33:42 +02:00
|
|
|
|
|
|
|
<?php
|
|
|
|
if($page != 1){
|
|
|
|
echo '<a class="btn float-left" href="?page=' . ($page - 1) . '">Forrige side</a>';
|
|
|
|
}
|
|
|
|
|
|
|
|
if(($counter == $pageLimit) and (($pageLimit * $page) < count($events))){
|
|
|
|
echo '<a class="btn float-right" href="?page=' . ($page + 1) . '">Neste side</a>';
|
|
|
|
}
|
|
|
|
?>
|
2017-10-07 23:12:10 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="gridr">
|
|
|
|
<h2>Verktøy</h2>
|
2017-10-12 00:38:28 +02:00
|
|
|
<a class="btn adminbtn" href="edit.php?new=1">Legg inn ny aktivitet</a>
|
2017-10-28 16:11:36 +02:00
|
|
|
<h2>Filter</h2>
|
|
|
|
<form action="." method="post">
|
|
|
|
<p class="no-chin">Navn</p>
|
|
|
|
<?= '<input type="text" name="title" class="boxinput" value="' . $filterTitle . '">' ?><br>
|
|
|
|
<p class="no-chin">Organisator</p>
|
|
|
|
<?= '<input type="text" name="organiser" class="boxinput" value="' . $filterOrganiser . '">' ?><br>
|
|
|
|
|
|
|
|
<div style="margin-top: 2em;">
|
|
|
|
<input type="submit" class="btn" value="Filtrer"></input>
|
|
|
|
</div>
|
|
|
|
</form>
|
2017-10-07 23:12:10 +02:00
|
|
|
</div>
|
|
|
|
</article>
|
|
|
|
|
2017-10-28 20:55:24 +02:00
|
|
|
</main>
|
2017-11-11 15:20:58 +01:00
|
|
|
|
|
|
|
<nav>
|
|
|
|
<?= navbar(2); ?>
|
|
|
|
<?= loginbar(); ?>
|
|
|
|
</nav>
|