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
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(); -