From 30c8aa2032fa8c37add5042688a9f7e6d8bc18a8 Mon Sep 17 00:00:00 2001 From: Markus Date: Sat, 24 Feb 2018 21:09:15 +0100 Subject: [PATCH] Groundwork for project members Tools for adding/removing members are coming soon (tm) --- dist/pvv.sql | 9 ++++++++- dist/pvv_mysql.sql | 9 ++++++++- src/pvv/side/projectmanager.php | 14 ++++++++++++++ www/css/projects.css | 15 ++++++++------- www/prosjekt/edit.php | 1 + www/prosjekt/info.php | 21 ++++++++++++++++----- www/prosjekt/update.php | 9 +++------ 7 files changed, 58 insertions(+), 20 deletions(-) diff --git a/dist/pvv.sql b/dist/pvv.sql index 1b8eb04..8d43130 100644 --- a/dist/pvv.sql +++ b/dist/pvv.sql @@ -11,13 +11,20 @@ CREATE TABLE "events" ( CREATE TABLE "projects" ( "id" INTEGER PRIMARY KEY AUTOINCREMENT, "name" TEXT, +"description" TEXT, "owner" TEXT, "owneruname" TEXT, "owneremail" TEXT, -"description" TEXT, "active" BOOLEAN ); +CREATE TABLE "projectmembers" ( +"projectid" INTEGER, +"membername" TEXT, +"memberuname" TEXT, +"role" TEXT +) + CREATE TABLE "users" ( "uname" TEXT, "groups" INT DEFAULT 0 diff --git a/dist/pvv_mysql.sql b/dist/pvv_mysql.sql index dd051e8..66084ab 100644 --- a/dist/pvv_mysql.sql +++ b/dist/pvv_mysql.sql @@ -11,13 +11,20 @@ CREATE TABLE events ( CREATE TABLE projects ( `id` INTEGER PRIMARY KEY AUTO_INCREMENT, `name` TEXT, +`description` TEXT, `owner` TEXT, `owneruname` TEXT, `owneremail` TEXT, -`description` TEXT, `active` BOOLEAN ); +CREATE TABLE projectmembers ( +`projectid` INTEGER, +`name` TEXT, +`uname` TEXT, +`role` TEXT +) + CREATE TABLE users ( `uname` TEXT, `groups` INT DEFAULT 0 diff --git a/src/pvv/side/projectmanager.php b/src/pvv/side/projectmanager.php index db4bab0..38996a3 100644 --- a/src/pvv/side/projectmanager.php +++ b/src/pvv/side/projectmanager.php @@ -74,4 +74,18 @@ class ProjectManager{ return $projects; } + + public function getProjectMembers($id){ + $query = 'SELECT * FROM projectmembers WHERE projectid=:id'; + $statement = $this->pdo->prepare($query); + $statement->bindParam(':id', $id, PDO::PARAM_STR); + $statement->execute(); + + $members = []; + foreach($statement->fetchAll() as $dbUsr){ + $members[] = ['name' => $dbUsr['name'], 'uname' => $dbUsr['uname'], 'role' => $dbUsr['role']]; + } + + return $members; + } } \ No newline at end of file diff --git a/www/css/projects.css b/www/css/projects.css index f66f8a3..31c168d 100644 --- a/www/css/projects.css +++ b/www/css/projects.css @@ -65,35 +65,36 @@ border-left: 0; } -.projectowner { +.projectmember { + margin-bottom: 1em; padding: 0 .5em 0 .5em; overflow: hidden; border-left: 4px solid #35a; } -.projectowner p { +.projectmember p { margin: 0; } -.projectowner p { +.projectmember p { font-size: .8em; } -.projectowner p:first-child { +.projectmember p:first-child { font-size: 1em; margin-bottom: .2em; } -.owneruname, .owneremail { +.memberuname, .memberemail { display: inline-block; color: #888; } -.owneruname { +.memberuname { float: left; } -.owneremail { +.memberemail { float: right; } diff --git a/www/prosjekt/edit.php b/www/prosjekt/edit.php index f6a83bb..4ab9a40 100644 --- a/www/prosjekt/edit.php +++ b/www/prosjekt/edit.php @@ -75,6 +75,7 @@ if($new == 0){ getID() . '" />' ?> +

diff --git a/www/prosjekt/info.php b/www/prosjekt/info.php index a042323..1d40f84 100644 --- a/www/prosjekt/info.php +++ b/www/prosjekt/info.php @@ -11,6 +11,8 @@ if(isset($_GET['id'])){ $projectManager = new \pvv\side\ProjectManager($pdo); $project = $projectManager->getByID($projectID); + +$members = $projectManager->getProjectMembers($projectID); ?> @@ -36,15 +38,24 @@ $project = $projectManager->getByID($projectID);

Prosjektledelse

-
+

Prosjekteier

-

getOwner() ?>

-

getOwnerUName(); ?>

-

getOwnerEmail(); ?>

+

getOwner() ?>

+

getOwnerUName(); ?>

+

getOwnerEmail(); ?>

-

Medlemmer

+
+

Medlemmer

+ $data){ ?> +
+

+

+

+
+ +
\ No newline at end of file diff --git a/www/prosjekt/update.php b/www/prosjekt/update.php index d924f14..27583de 100644 --- a/www/prosjekt/update.php +++ b/www/prosjekt/update.php @@ -16,11 +16,8 @@ $as = new SimpleSAML_Auth_Simple('default-sp'); $as->requireAuth(); $attrs = $as->getAttributes(); -$id = 0; -if(isset($_POST['id'])){ - $id = $_POST['id']; - $active = $_POST['active']; -} +$id = $_POST['id']; +$active = $_POST['active']; $title = $_POST['title']; $desc = $_POST['desc']; @@ -30,7 +27,7 @@ $owneremail = $attrs['mail'][0]; $statement; if($id == 0){ - $query = 'INSERT INTO projects (name, owner, owneruname, owneremail, description, active) VALUES (:title, :owner, :owneruname, :desc, 1)'; + $query = 'INSERT INTO projects (name, owner, owneruname, owneremail, description, active) VALUES (:title, :owner, :owneruname, :owneremail, :desc, 1)'; $statement = $pdo->prepare($query); $statement->bindParam(':title', $title, PDO::PARAM_STR);