From e5dcb076591779728688bf5883e6cf57bc469513 Mon Sep 17 00:00:00 2001 From: halworsen Date: Sat, 28 Oct 2017 20:09:54 +0200 Subject: [PATCH] My projects page --- src/pvv/side/projectmanager.php | 22 +++++ www/css/admin.css | 9 ++ www/prosjekt/{ny.php => edit.php} | 26 +++++- www/prosjekt/index.php | 6 +- www/prosjekt/mine.php | 131 ++++++++++++++++++++++++++++++ www/prosjekt/update.php | 2 +- 6 files changed, 192 insertions(+), 4 deletions(-) rename www/prosjekt/{ny.php => edit.php} (78%) create mode 100644 www/prosjekt/mine.php diff --git a/src/pvv/side/projectmanager.php b/src/pvv/side/projectmanager.php index 9df3360..79e9132 100644 --- a/src/pvv/side/projectmanager.php +++ b/src/pvv/side/projectmanager.php @@ -49,4 +49,26 @@ class ProjectManager{ return $project; } + + public function getByUName($uname){ + $query = 'SELECT * FROM projects WHERE owneruname=:uname'; + $statement = $this->pdo->prepare($query); + $statement->bindParam(':uname', $uname, PDO::PARAM_STR); + $statement->execute(); + + $projects = []; + foreach($statement->fetchAll() as $dbProj){ + $project = new Project( + $dbProj['id'], + $dbProj['name'], + $dbProj['description'], + $dbProj['owner'], + $dbProj['owneruname'], + $dbProj['active'] + ); + $projects[] = $project; + } + + return $projects; + } } \ No newline at end of file diff --git a/www/css/admin.css b/www/css/admin.css index 6773c48..a542e4d 100644 --- a/www/css/admin.css +++ b/www/css/admin.css @@ -37,6 +37,15 @@ header.admin { word-wrap: break-word; } +.event-info a { + color: black; + text-decoration: none; +} + +.event-info a:hover { + text-decoration: underline; +} + .event-actions { grid-column: 2; text-align: center; diff --git a/www/prosjekt/ny.php b/www/prosjekt/edit.php similarity index 78% rename from www/prosjekt/ny.php rename to www/prosjekt/edit.php index 6b032a4..1215cd2 100644 --- a/www/prosjekt/ny.php +++ b/www/prosjekt/edit.php @@ -15,6 +15,19 @@ $pdo = new \PDO($dbDsn, $dbUser, $dbPass); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $projectManager = new \pvv\side\ProjectManager($pdo); +$new = 0; +if(isset($_GET['new'])){ + $new = $_GET['new']; +} + +$projectID = 0; +if(isset($_GET['id'])){ + $projectID = $_GET['id']; +}else if($new == 0){ + echo "\nID not set"; + exit(); +} + $project = new \pvv\side\Project( 0, 'Nytt Prosjekt', @@ -23,6 +36,15 @@ $project = new \pvv\side\Project( $attrs["uid"][0], 1 ); +if($new == 0){ + $project = $projectManager->getByID($projectID); + + if($project->getOwnerUName() != $attrs["uid"][0]){ + header('HTTP/1.0 403 Forbidden'); + echo "wrong user"; + exit(); + } +} ?> @@ -68,10 +90,12 @@ $project = new \pvv\side\Project(

Hva går prosjektet ditt ut på?

+ getID() . '" />' ?> +

- + '; ?>
diff --git a/www/prosjekt/index.php b/www/prosjekt/index.php index a33a11e..79f64ac 100644 --- a/www/prosjekt/index.php +++ b/www/prosjekt/index.php @@ -35,12 +35,14 @@ $projects = $projectManager->getAll(); ?>

PVV har for øyeblikket ingen aktive prosjekter. Tenker du at noe bør gjøres? Har du en kul ide for noe PVV kan samarbeide om? Sett opp et prosjekt!


- Lag prosjekt + Lag prosjekt + Mine prosjekter

Lyst til å gjøre noe kult? Her er et utvalg av de prosjektene som PVVere har laget. Mangler det noe, eller brenner du for noe annet? Sett opp et eget prosjekt!

- Lag prosjekt + Lag prosjekt + Mine prosjekter