From 6574bd576ea5fc774cd73d0d0211dc9c13d66519 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=B8rn=20=C3=85ne?=
Date: Sat, 11 Nov 2017 15:20:58 +0100
Subject: [PATCH] Generalize navigation and PHP configuration
---
dev.sh | 2 +-
inc/navbar.php | 36 ++++++++++++++++++++++++++++++++
www/admin/aktiviteter/edit.php | 33 +++++++----------------------
www/admin/aktiviteter/index.php | 32 ++++++----------------------
www/admin/aktiviteter/update.php | 2 --
www/admin/index.php | 29 ++++++-------------------
www/admin/prosjekter/edit.php | 33 +++++++----------------------
www/admin/prosjekter/index.php | 32 ++++++----------------------
www/admin/prosjekter/update.php | 2 --
www/aktiviteter/index.php | 25 +++-------------------
www/index.php | 25 +++-------------------
www/kalender/index.php | 25 +++-------------------
www/kontakt/index.php | 25 +++-------------------
www/prosjekt/edit.php | 31 +++++++--------------------
www/prosjekt/index.php | 26 +++--------------------
www/prosjekt/mine.php | 30 +++++++-------------------
www/prosjekt/update.php | 2 --
17 files changed, 98 insertions(+), 292 deletions(-)
create mode 100644 inc/navbar.php
diff --git a/dev.sh b/dev.sh
index 77e9e95..d72cde1 100755
--- a/dev.sh
+++ b/dev.sh
@@ -14,4 +14,4 @@ if test \! -d vendor; then
ln -s ../vendor/simplesamlphp/simplesamlphp/www/ www/simplesaml
fi
-php -S [::1]:1080 -t www/
+php -S [::1]:1080 -d error_reporting=E_ALL -d display_errors=1 -t www/
diff --git a/inc/navbar.php b/inc/navbar.php
new file mode 100644
index 0000000..09ed144
--- /dev/null
+++ b/inc/navbar.php
@@ -0,0 +1,36 @@
+\n";
+ $menuItems = [
+ 'hjem' => '',
+ 'kalender' => 'kalender',
+ 'aktiviteter' => 'aktiviteter',
+ 'prosjekter' => 'prosjekt',
+ 'kontakt' => 'kontakt',
+ 'wiki' => 'pvv',
+ ];
+ foreach($menuItems as $caption => $link) {
+ $result .= "\t\t'
+ . ''
+ . $caption
+ . "\n"
+ ;
+ }
+ return $result . "\t\n";
+}
+
+function loginBar($sp = 'default-sp') {
+ $result = "\n";
+ require_once(__DIR__ . '/../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php');
+ $as = new SimpleSAML_Auth_Simple($sp);
+
+ $attr = $as->getAttributes();
+ if($attr) {
+ $uname = $attr['uid'][0];
+ $result .= "\tlogget inn som: " . htmlspecialchars($uname) . "
\n";
+ } else {
+ $result .= "\tgetLoginURL()) . "\">logg inn\n";
+ }
+
+ return $result;
+}
diff --git a/www/admin/aktiviteter/edit.php b/www/admin/aktiviteter/edit.php
index bc14ee4..ad6a8a9 100644
--- a/www/admin/aktiviteter/edit.php
+++ b/www/admin/aktiviteter/edit.php
@@ -1,13 +1,10 @@
getAttributes();
+
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$customActivity = new \pvv\side\DBActivity($pdo);
@@ -50,27 +47,6 @@ if($new == 0){
-
-
Aktivitetsadministrasjon
@@ -116,3 +92,8 @@ if($new == 0){
+
+
diff --git a/www/admin/aktiviteter/index.php b/www/admin/aktiviteter/index.php
index 4c3a9ad..15e8300 100644
--- a/www/admin/aktiviteter/index.php
+++ b/www/admin/aktiviteter/index.php
@@ -1,13 +1,9 @@
getAttributes();
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@@ -44,27 +40,6 @@ $events = array_values(array_filter(
-
-
Aktivitetsadministrasjon
@@ -141,3 +116,8 @@ $events = array_values(array_filter(
+
+
diff --git a/www/admin/aktiviteter/update.php b/www/admin/aktiviteter/update.php
index f1dc8fd..c137af3 100644
--- a/www/admin/aktiviteter/update.php
+++ b/www/admin/aktiviteter/update.php
@@ -1,8 +1,6 @@
getAttributes();
?>
@@ -10,28 +10,6 @@ $attrs = $as->getAttributes();
-
-
@@ -43,3 +21,8 @@ $attrs = $as->getAttributes();
+
+
diff --git a/www/admin/prosjekter/edit.php b/www/admin/prosjekter/edit.php
index c67b655..16ef6de 100644
--- a/www/admin/prosjekter/edit.php
+++ b/www/admin/prosjekter/edit.php
@@ -1,13 +1,10 @@
getAttributes();
+
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
$projectManager = new \pvv\side\ProjectManager($pdo);
$projects = $projectManager->getAll();
@@ -44,27 +41,6 @@ if($new == 0){
-
-
@@ -104,3 +80,8 @@ if($new == 0){
+
+
diff --git a/www/admin/prosjekter/index.php b/www/admin/prosjekter/index.php
index aad794a..dbe69ea 100644
--- a/www/admin/prosjekter/index.php
+++ b/www/admin/prosjekter/index.php
@@ -1,13 +1,9 @@
getAttributes();
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@@ -44,27 +40,6 @@ $projects = array_values(array_filter(
-
-
@@ -137,3 +112,8 @@ $projects = array_values(array_filter(
+
+
diff --git a/www/admin/prosjekter/update.php b/www/admin/prosjekter/update.php
index 1ce2be3..cfa57a5 100644
--- a/www/admin/prosjekter/update.php
+++ b/www/admin/prosjekter/update.php
@@ -1,8 +1,6 @@
getAttributes();
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
@@ -81,23 +79,6 @@ foreach($events as $event) {
diff --git a/www/index.php b/www/index.php
index 4cfbf8c..e0aa316 100644
--- a/www/index.php
+++ b/www/index.php
@@ -1,11 +1,9 @@
getAttributes();
$translation = ['i dag', 'i morgen', 'denne uka', 'neste uke', 'denne måneden', 'neste måned'];
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
@@ -94,23 +92,6 @@ For å bli med i våre prosjekter og komitéer må du søke.
diff --git a/www/kalender/index.php b/www/kalender/index.php
index dd00efb..765e6ae 100644
--- a/www/kalender/index.php
+++ b/www/kalender/index.php
@@ -1,11 +1,9 @@
getAttributes();
use \pvv\side\Agenda;
$months_translations = ['Januar', 'Februar', 'Mars', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Desember'];
@@ -103,23 +101,6 @@ $days_in_month = date('t', mktime(0, 0, 0, $month, 1, $year));
diff --git a/www/kontakt/index.php b/www/kontakt/index.php
index 2edc95d..c761a84 100755
--- a/www/kontakt/index.php
+++ b/www/kontakt/index.php
@@ -2,11 +2,9 @@
getAttributes();
?>
Kommunikasjonsverkstedet
@@ -40,23 +38,6 @@ Det er også mulig å ta i bruk analog kontakt ved å møte opp hjem
-
- kalender
- aktiviteter
- prosjekter
- kontakt
- wiki
-
-
- getAttributes();
- if($attr){
- $uname = $attr["uid"][0];
- echo 'logget inn som: ' . $uname . '
';
- }else{
- echo 'logg inn';
- }
- ?>
+ = navbar(1, 'kontakt'); ?>
+ = loginbar(); ?>
diff --git a/www/prosjekt/edit.php b/www/prosjekt/edit.php
index d8240fb..72ea662 100644
--- a/www/prosjekt/edit.php
+++ b/www/prosjekt/edit.php
@@ -1,12 +1,11 @@
requireAuth();
$attrs = $as->getAttributes();
@@ -53,27 +52,6 @@ if($new == 0){
-
';
- }else{
- echo 'logg inn';
- }
- ?>
-
-
-
@@ -101,3 +79,8 @@ if($new == 0){
+
+
diff --git a/www/prosjekt/index.php b/www/prosjekt/index.php
index dfd8aa8..1f66499 100644
--- a/www/prosjekt/index.php
+++ b/www/prosjekt/index.php
@@ -1,13 +1,9 @@
getAttributes();
$translation = ['i dag', 'i morgen', 'denne uka', 'neste uke', 'denne måneden', 'neste måned'];
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
@@ -72,22 +68,6 @@ $projects = $projectManager->getAll();
diff --git a/www/prosjekt/mine.php b/www/prosjekt/mine.php
index 27c656c..28244cf 100644
--- a/www/prosjekt/mine.php
+++ b/www/prosjekt/mine.php
@@ -1,10 +1,9 @@
requireAuth();
@@ -45,26 +44,6 @@ $projects = array_values(array_filter(
-
-
@@ -128,4 +107,9 @@ $projects = array_values(array_filter(
-
\ No newline at end of file
+
+
+
diff --git a/www/prosjekt/update.php b/www/prosjekt/update.php
index 22c8316..4ccfeb0 100644
--- a/www/prosjekt/update.php
+++ b/www/prosjekt/update.php
@@ -1,8 +1,6 @@