diff --git a/dist/sql/pvv_mysql.sql b/dist/sql/pvv_mysql.sql index f8ab9d0..948d2b2 100644 --- a/dist/sql/pvv_mysql.sql +++ b/dist/sql/pvv_mysql.sql @@ -12,7 +12,7 @@ CREATE TABLE projects ( `id` INTEGER PRIMARY KEY AUTO_INCREMENT, `name` TEXT, `description` TEXT, - `active` BOOLEAN + `active` BOOLEAN DEFAULT TRUE ); CREATE TABLE projectmembers ( @@ -21,8 +21,8 @@ CREATE TABLE projectmembers ( `uname` TEXT, `mail` TEXT, `role` TEXT, - `lead` BOOLEAN DEFAULT 0, - `owner` BOOLEAN DEFAULT 0 + `lead` BOOLEAN DEFAULT FALSE, + `owner` BOOLEAN DEFAULT FALSE ); CREATE TABLE users (`uname` TEXT, `groups` INT DEFAULT 0); diff --git a/dist/sql/pvv_sqlite.sql b/dist/sql/pvv_sqlite.sql index 9a24889..58099fd 100644 --- a/dist/sql/pvv_sqlite.sql +++ b/dist/sql/pvv_sqlite.sql @@ -12,7 +12,7 @@ CREATE TABLE "projects" ( "id" INTEGER PRIMARY KEY AUTOINCREMENT, "name" TEXT, "description" TEXT, - "active" BOOLEAN + "active" BOOLEAN DEFAULT TRUE ); CREATE TABLE "projectmembers" ( @@ -21,8 +21,8 @@ CREATE TABLE "projectmembers" ( "uname" TEXT, "mail" TEXT, "role" TEXT, - "lead" BOOLEAN DEFAULT 0, - "owner" BOOLEAN DEFAULT 0 + "lead" BOOLEAN DEFAULT FALSE, + "owner" BOOLEAN DEFAULT FALSE ); CREATE TABLE "users" ("uname" TEXT, "groups" INT DEFAULT 0); diff --git a/src/pvv/side/door.php b/src/pvv/side/door.php index 85c37e9..d1680a8 100644 --- a/src/pvv/side/door.php +++ b/src/pvv/side/door.php @@ -78,7 +78,7 @@ class Door { $query = 'INSERT INTO door(time, open) VALUES (:time, :open)'; $statement = $this->pdo->prepare($query); $statement->bindParam(':time', $time, \PDO::PARAM_STR); - $statement->bindParam(':open', $open, \PDO::PARAM_STR); + $statement->bindParam(':open', $open, \PDO::PARAM_BOOL); $statement->execute(); $this->removeOld(); diff --git a/src/pvv/side/projectmanager.php b/src/pvv/side/projectmanager.php index 77dc702..fe9407c 100644 --- a/src/pvv/side/projectmanager.php +++ b/src/pvv/side/projectmanager.php @@ -25,7 +25,7 @@ class ProjectManager { $dbProj['id'], $dbProj['name'], $dbProj['description'], - $dbProj['active'], + (bool) $dbProj['active'], ); $projects[] = $project; } @@ -48,7 +48,7 @@ class ProjectManager { $dbProj['id'], $dbProj['name'], $dbProj['description'], - $dbProj['active'], + (bool) $dbProj['active'], ); } @@ -76,7 +76,7 @@ class ProjectManager { $dbProj['id'], $dbProj['name'], $dbProj['description'], - $dbProj['active'], + (bool) $dbProj['active'], ); $projects[] = $project; } @@ -101,8 +101,8 @@ class ProjectManager { 'uname' => $dbUsr['uname'], 'mail' => $dbUsr['mail'], 'role' => $dbUsr['role'], - 'lead' => $dbUsr['lead'], - 'owner' => $dbUsr['owner'], + 'lead' => (bool) $dbUsr['lead'], + 'owner' => (bool) $dbUsr['owner'], ]; } @@ -125,8 +125,8 @@ class ProjectManager { 'uname' => $dbOwner['uname'], 'mail' => $dbOwner['mail'], 'role' => $dbOwner['role'], - 'lead' => $dbOwner['lead'], - 'owner' => $dbOwner['owner'], + 'lead' => (bool) $dbOwner['lead'], + 'owner' => (bool) $dbOwner['owner'], ]; } } diff --git a/www/admin/prosjekter/update.php b/www/admin/prosjekter/update.php index 0faaa55..a6cfd44 100644 --- a/www/admin/prosjekter/update.php +++ b/www/admin/prosjekter/update.php @@ -33,7 +33,7 @@ $desc = $_POST['desc']; $name = $_POST['organisername']; $uname = $_POST['organiser']; $mail = $_POST['organiseremail']; -$active = ($_POST['active'] ?? 0); +$active = ($_POST['active'] ?? false); if ($id == 0) { @@ -42,7 +42,7 @@ if ($id == 0) { $statement->bindParam(':title', $title, PDO::PARAM_STR); $statement->bindParam(':desc', $desc, PDO::PARAM_STR); - $statement->bindParam(':active', $active, PDO::PARAM_INT); + $statement->bindParam(':active', $active, PDO::PARAM_BOOL); $statement->execute(); @@ -59,7 +59,7 @@ if ($id == 0) { $statement->bindParam(':title', $title, PDO::PARAM_STR); $statement->bindParam(':desc', $desc, PDO::PARAM_STR); - $statement->bindParam(':active', $active, PDO::PARAM_INT); + $statement->bindParam(':active', $active, PDO::PARAM_BOOL); $statement->bindParam(':id', $id, PDO::PARAM_INT); $statement->execute(); diff --git a/www/prosjekt/update.php b/www/prosjekt/update.php index 471ccef..bedd19a 100644 --- a/www/prosjekt/update.php +++ b/www/prosjekt/update.php @@ -30,7 +30,7 @@ $mail = $attrs['mail'][0]; if ($id == 0) { - $query = 'INSERT INTO projects (name, description, active) VALUES (:title, :desc, 1)'; + $query = 'INSERT INTO projects (name, description, active) VALUES (:title, :desc, TRUE)'; $statement = $pdo->prepare($query); $statement->bindParam(':title', $title, PDO::PARAM_STR); @@ -39,7 +39,7 @@ if ($id == 0) { $statement->execute(); $new_id = $pdo->lastInsertId(); - $ownerQuery = "INSERT INTO projectmembers (projectid, name, uname, mail, role, lead, owner) VALUES (:id, :owner, :owneruname, :owneremail, 'Prosjektleder', 1, 1)"; + $ownerQuery = "INSERT INTO projectmembers (projectid, name, uname, mail, role, lead, owner) VALUES (:id, :owner, :owneruname, :owneremail, 'Prosjektleder', TRUE, TRUE)"; $statement = $pdo->prepare($ownerQuery); $statement->bindParam(':id', $new_id, PDO::PARAM_STR); $statement->bindParam(':owner', $name, PDO::PARAM_STR); @@ -62,7 +62,7 @@ if ($id == 0) { } } if ($is_member) {// leave - $query = 'DELETE FROM projectmembers WHERE projectid=:id AND uname=:uname and lead=0 and owner=0;'; + $query = 'DELETE FROM projectmembers WHERE projectid=:id AND uname=:uname and lead=FALSE and owner=FALSE;'; $statement = $pdo->prepare($query); $statement->bindParam(':id', $id, PDO::PARAM_STR); $statement->bindParam(':uname', $uname, PDO::PARAM_STR); @@ -70,7 +70,7 @@ if ($id == 0) { $statement->execute(); echo 'leave'; } else {// join - $query = "INSERT INTO projectmembers (projectid, name, uname, mail, role, lead, owner) VALUES (:id, :name, :uname, :mail, 'Medlem', 0, 0)"; + $query = "INSERT INTO projectmembers (projectid, name, uname, mail, role, lead, owner) VALUES (:id, :name, :uname, :mail, 'Medlem', FALSE, FALSE)"; $statement = $pdo->prepare($query); $statement->bindParam(':id', $id, PDO::PARAM_STR); $statement->bindParam(':name', $name, PDO::PARAM_STR);