diff --git a/dist/pvv.sql b/dist/pvv.sql index cc6a70c..d32c229 100644 --- a/dist/pvv.sql +++ b/dist/pvv.sql @@ -22,7 +22,5 @@ CREATE TABLE "users" ( "groups" INT DEFAULT 0 ); -CREATE TABLE "motd" ( -"title" TEXT, -"content" TEXT -); \ No newline at end of file +INSERT INTO users (uname, groups) +VALUES ("min_test_bruker", 1); diff --git a/dist/pvv_mysql.sql b/dist/pvv_mysql.sql new file mode 100644 index 0000000..24b98d8 --- /dev/null +++ b/dist/pvv_mysql.sql @@ -0,0 +1,23 @@ +CREATE TABLE events ( +`id` INTEGER PRIMARY KEY AUTO_INCREMENT, +`name` TEXT, +`start` TEXT, +`stop` TEXT, +`organiser` TEXT, +`location` TEXT, +`description` TEXT +); + +CREATE TABLE projects ( +`id` INTEGER PRIMARY KEY AUTO_INCREMENT, +`name` TEXT, +`owner` TEXT, +`owneruname` TEXT, +`description` TEXT, +`active` BOOLEAN +); + +CREATE TABLE users ( +`uname` TEXT, +`groups` INT DEFAULT 0 +); diff --git a/inc/agenda.php b/inc/agenda.php new file mode 100644 index 0000000..92e393c --- /dev/null +++ b/inc/agenda.php @@ -0,0 +1,11 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +$agenda = new \pvv\side\Agenda([ + new \pvv\side\social\NerdepitsaActivity, + new \pvv\side\social\AnimekveldActivity, + new \pvv\side\DBActivity($pdo), + ]); diff --git a/inc/include.php b/inc/include.php new file mode 100644 index 0000000..01d9a56 --- /dev/null +++ b/inc/include.php @@ -0,0 +1,33 @@ +setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); +$userManager = new \pvv\admin\UserManager($pdo); + +$sp = 'default-sp'; +$as = new SimpleSAML_Auth_Simple($sp); + +use \pvv\side\Agenda; +$agenda = new \pvv\side\Agenda([ + new \pvv\side\social\NerdepitsaActivity, + new \pvv\side\social\AnimekveldActivity, + new \pvv\side\DBActivity($pdo), + ]); + +$months_translations = ['januar', 'februar', 'mars', 'april', 'mai', 'juni', 'juli', 'august', 'september', 'oktober', 'november', 'desember']; diff --git a/inc/navbar.php b/inc/navbar.php index 84c0de1..c03e34c 100644 --- a/inc/navbar.php +++ b/inc/navbar.php @@ -1,60 +1,64 @@ \n"; - $result .= "\t\t\n"; } -function loginBar($sp = 'default-sp') { - require_once __DIR__ . '/../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php'; - +function loginBar($sp = null, $pdo = null) { + if (is_null($sp)) $sp = 'default-sp'; $result = "\n"; + require_once(__DIR__ . '/../vendor/simplesamlphp/simplesamlphp/lib/_autoload.php'); $as = new SimpleSAML_Auth_Simple($sp); + $svg = ' + + + +'; + $attr = $as->getAttributes(); if($attr) { $uname = $attr['uid'][0]; - $result .= "\t\t

Logget inn som: " . htmlspecialchars($uname) . "

\n"; + $isAdmin = false; + if (isset($pdo)) { + $userManager = new \pvv\admin\UserManager($pdo); + $isAdmin = $userManager->isAdmin($uname); + } + $result .= "\n\t\n"; + + $result .= "\t${svg}" . htmlspecialchars($uname) . "\n"; } else { - $result .= "\t\tgetLoginURL()) . "\">Logg inn\n"; + $result .= "\tgetLoginURL()) . "\">${svg}Logg inn\n"; } + $result .= "\n\t☰ MENU\n"; + return $result; } diff --git a/src/pvv/side/dbactivity.php b/src/pvv/side/dbactivity.php index 0a90f70..ea6ebdd 100644 --- a/src/pvv/side/dbactivity.php +++ b/src/pvv/side/dbactivity.php @@ -54,12 +54,12 @@ class DBActivity implements Activity { public function getNextEventFrom(DateTimeImmutable $date) { - $query = 'SELECT name,start,stop,organiser,location,description FROM events WHERE start > :date ORDER BY start ASC LIMIT 1'; + $query = 'SELECT id,name,start,stop,organiser,location,description FROM events WHERE start > :date ORDER BY start ASC LIMIT 1'; return $this->retrieve($date, $query); } public function getPreviousEventFrom(DateTimeImmutable $date) { - $query = 'SELECT name,start,stop,organiser,location,description FROM events WHERE start < :date ORDER BY start DESC LIMIT 1'; + $query = 'SELECT id,name,start,stop,organiser,location,description FROM events WHERE start < :date ORDER BY start DESC LIMIT 1'; return $this->retrieve($date, $query); } diff --git a/src/pvv/side/event.php b/src/pvv/side/event.php index c7b635a..05f7c5f 100644 --- a/src/pvv/side/event.php +++ b/src/pvv/side/event.php @@ -49,4 +49,5 @@ abstract class Event { public abstract function getDescription(); /* : string */ + public abstract function getColor(); /* : string */ } diff --git a/src/pvv/side/simpleevent.php b/src/pvv/side/simpleevent.php index b23edea..dc151ac 100644 --- a/src/pvv/side/simpleevent.php +++ b/src/pvv/side/simpleevent.php @@ -49,11 +49,15 @@ class SimpleEvent extends Event { } public function getDescription() { - return $this->descr; + return array_map(function ($item) {return "

".$item;}, $this->descr); } public function isDBEvent() { return $this->isDBEvent; } + public function getColor() { + return "#3b7"; + } + } diff --git a/src/pvv/side/social/animekveldevent.php b/src/pvv/side/social/animekveldevent.php index 09a9d91..01c28fc 100644 --- a/src/pvv/side/social/animekveldevent.php +++ b/src/pvv/side/social/animekveldevent.php @@ -41,4 +41,8 @@ class AnimekveldEvent extends Event { ]; } + public function getColor() { + return "#35a"; + } + } diff --git a/src/pvv/side/social/brettspillevent.php b/src/pvv/side/social/brettspillevent.php index d01d29e..41137b5 100644 --- a/src/pvv/side/social/brettspillevent.php +++ b/src/pvv/side/social/brettspillevent.php @@ -60,4 +60,8 @@ class BrettspillEvent extends Event { ]; } + public function getColor() { + return "#000"; + } + } diff --git a/src/pvv/side/social/nerdepitsaevent.php b/src/pvv/side/social/nerdepitsaevent.php index 1c3a2ad..a1566f1 100644 --- a/src/pvv/side/social/nerdepitsaevent.php +++ b/src/pvv/side/social/nerdepitsaevent.php @@ -43,4 +43,8 @@ class NerdepitsaEvent extends Event { ]; } + public function getColor() { + return "#c35"; + } + } diff --git a/www/admin/aktiviteter/edit.php b/www/admin/aktiviteter/edit.php index 4edb47a..58562eb 100644 --- a/www/admin/aktiviteter/edit.php +++ b/www/admin/aktiviteter/edit.php @@ -1,6 +1,6 @@ getAllUserData(); - @@ -90,4 +89,4 @@ $users = $userManager->getAllUserData(); - \ No newline at end of file + diff --git a/www/admin/brukere/update.php b/www/admin/brukere/update.php index 149f4af..7b9a4d1 100644 --- a/www/admin/brukere/update.php +++ b/www/admin/brukere/update.php @@ -1,7 +1,7 @@ setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); @@ -18,7 +15,8 @@ $projectGroup = $userManager->hasGroup($uname, 'prosjekt'); $activityGroup = $userManager->hasGroup($uname, 'aktiviteter'); if(!($isAdmin | $projectGroup | $activityGroup)){ - echo 'Her har du ikke lov\'t\'å\'værra!!!'; + header('Content-Type: text/plain', true, 403); + echo "Her har du ikke lov't'å'værra!!!\r\n"; exit(); } ?> @@ -27,7 +25,6 @@ if(!($isAdmin | $projectGroup | $activityGroup)){ - @@ -35,7 +32,7 @@ if(!($isAdmin | $projectGroup | $activityGroup)){

@@ -60,4 +57,4 @@ if(!($isAdmin | $projectGroup | $activityGroup)){ ?>
- \ No newline at end of file + diff --git a/www/admin/prosjekter/edit.php b/www/admin/prosjekter/edit.php index d7baf17..8adec7e 100644 --- a/www/admin/prosjekter/edit.php +++ b/www/admin/prosjekter/edit.php @@ -1,6 +1,6 @@ setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); -use \pvv\side\Agenda; -$agenda = new \pvv\side\Agenda([ - new \pvv\side\social\NerdepitsaActivity, - new \pvv\side\social\AnimekveldActivity, - new \pvv\side\DBActivity($pdo), - ]); + - @@ -46,6 +32,7 @@ $day = (isset($_GET['day']))
getNextOfEach(new \DateTimeImmutable) : $agenda->getEventsBetween( diff --git a/www/anime/index.php b/www/anime/index.php index 169d4c7..52759c1 100755 --- a/www/anime/index.php +++ b/www/anime/index.php @@ -1,11 +1,8 @@ - + Sosialverkstedet @@ -46,12 +43,7 @@ $nextEvent = $activity->getNextEventFrom(new DateTimeImmutable);
- - +

Aktiviteter for

- +

&month=">Forrige måned Neste måned

- - + +
- + + ">
+ . + +
getName()?>
+ +
+ + . + + + +
-
- + diff --git a/www/kontakt/index.php b/www/kontakt/index.php index 254f7c2..ae0ec4c 100755 --- a/www/kontakt/index.php +++ b/www/kontakt/index.php @@ -1,11 +1,7 @@ - + @@ -14,7 +10,6 @@ require __DIR__ . '/../../sql_config.php'; - @@ -24,7 +19,6 @@ require __DIR__ . '/../../sql_config.php'; -

Kommunikasjon

@@ -40,4 +34,4 @@ require __DIR__ . '/../../sql_config.php'; Det er også mulig å ta i bruk analog kontakt ved å møte opp på stripa.

- \ No newline at end of file + diff --git a/www/kurs/linuxfix.jpg b/www/kurs/linuxfix.jpg deleted file mode 100644 index 7f12fed..0000000 Binary files a/www/kurs/linuxfix.jpg and /dev/null differ diff --git a/www/nerdepitsa/index.php b/www/nerdepitsa/index.php index d7f08c1..fe9c073 100755 --- a/www/nerdepitsa/index.php +++ b/www/nerdepitsa/index.php @@ -1,11 +1,8 @@ - + Sosialverkstedet @@ -25,8 +22,6 @@ $nextEvent = $activity->getNextEventFrom(new DateTimeImmutable); ?>
- -

getRelativeDate()?> Nerdepitsa

+ + + + diff --git a/www/prosjekt/update.php b/www/prosjekt/update.php index 4ccfeb0..7b07284 100644 --- a/www/prosjekt/update.php +++ b/www/prosjekt/update.php @@ -1,6 +1,6 @@