From a63bc3e6a98f306705e321581a4c9e3dd9968e2a Mon Sep 17 00:00:00 2001 From: Peder Bergebakken Sundt Date: Thu, 9 Aug 2018 00:48:53 +0200 Subject: [PATCH] Fix the project editor and a delete feature --- www/css/style.css | 5 ++++- www/prosjekt/edit.php | 11 ++++++----- www/prosjekt/update.php | 41 ++++++++++++++++++++++++++++++----------- 3 files changed, 40 insertions(+), 17 deletions(-) diff --git a/www/css/style.css b/www/css/style.css index 9559917..7dcff4d 100644 --- a/www/css/style.css +++ b/www/css/style.css @@ -221,7 +221,6 @@ article { } .gridsplit { - padding-top: 1.3em; display: grid; grid-template-columns: 3fr 1fr; } @@ -293,3 +292,7 @@ article { border: none; border-bottom: 1px dotted rgba(0,0,0,.5); } + +textarea.boxinput { + resize: vertical; +} diff --git a/www/prosjekt/edit.php b/www/prosjekt/edit.php index 2ef1268..94a3955 100644 --- a/www/prosjekt/edit.php +++ b/www/prosjekt/edit.php @@ -47,7 +47,8 @@ if($new == 0){ } } ?> - + + @@ -72,7 +73,7 @@ if($new == 0){

Beskrivelse

Hva går prosjektet ditt ut på?

-

Den første linjen blir vist på prosjektkortet, prøv å holde den kort!

+

De første to linjene blir vist på prosjektkortet, prøv å gjøre de til et fint sammendrag eller intro!

getID() . '" />' ?> @@ -80,9 +81,9 @@ if($new == 0){

- - '; ?> + +
- \ No newline at end of file + diff --git a/www/prosjekt/update.php b/www/prosjekt/update.php index 4cac4c7..b9a3eb7 100644 --- a/www/prosjekt/update.php +++ b/www/prosjekt/update.php @@ -6,7 +6,7 @@ require __DIR__ . '/../../sql_config.php'; $pdo = new \PDO($dbDsn, $dbUser, $dbPass); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); -if(!isset($_POST['title']) or !isset($_POST['desc'])){ +if(!isset($_POST['title']) or !isset($_POST['desc']) or !isset($_POST['active'])){ header('Location: ' . $_SERVER['HTTP_REFERER']); exit(); } @@ -17,6 +17,8 @@ $as->requireAuth(); $attrs = $as->getAttributes(); $id = $_POST['id']; +$do_delete = isset($_POST['delete']); + $active = $_POST['active']; $title = $_POST['title']; @@ -49,21 +51,38 @@ if($id == 0){ if($uname != $owner['uname']){ header('Content-Type: text/plain', true, 403); - echo "Not project owner for project with ID " . $id . "\r\n"; + echo "Illegal action, you're not the project owner for project with ID " . $id . "\r\n"; exit(); } + + if ($do_delete) { + // this should be done as a transaction... + $pdo->beginTransaction(); + + $query = 'DELETE FROM projects WHERE id=:id'; + $statement = $pdo->prepare($query); + $statement->bindParam(':id', $id, PDO::PARAM_INT); + $statement->execute(); + + $query = 'DELETE FROM projectmembers WHERE projectid=:id'; + $statement = $pdo->prepare($query); + $statement->bindParam(':id', $id, PDO::PARAM_INT); + $statement->execute(); + + $pdo->commit(); + }else{ + $query = 'UPDATE projects SET name=:title, description=:desc WHERE id=:id'; + $statement = $pdo->prepare($query); - $query = 'UPDATE projects SET name=:title, description=:desc WHERE id=:id'; - $statement = $pdo->prepare($query); - - $statement->bindParam(':title', $title, PDO::PARAM_STR); - $statement->bindParam(':desc', $desc, PDO::PARAM_STR); - $statement->bindParam(':id', $id, PDO::PARAM_INT); - - $statement->execute(); + $statement->bindParam(':title', $title, PDO::PARAM_STR); + $statement->bindParam(':desc', $desc, PDO::PARAM_STR); + $statement->bindParam(':id', $id, PDO::PARAM_INT); + + $statement->execute(); + } } header('Location: ./mine.php'); ?> -Om du ikke ble omdirigert tilbake klikk her \ No newline at end of file +Om du ikke ble omdirigert tilbake klikk her