Migrate project owners to the project member table
... to keep project membership tidy and centralized This puts organizer fitlers out of commission for now
This commit is contained in:
parent
54467ab9b9
commit
e60195d431
|
@ -12,18 +12,18 @@ CREATE TABLE "projects" (
|
|||
"id" INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
"name" TEXT,
|
||||
"description" TEXT,
|
||||
"owner" TEXT,
|
||||
"owneruname" TEXT,
|
||||
"owneremail" TEXT,
|
||||
"active" BOOLEAN
|
||||
);
|
||||
|
||||
CREATE TABLE "projectmembers" (
|
||||
"projectid" INTEGER,
|
||||
"membername" TEXT,
|
||||
"memberuname" TEXT,
|
||||
"role" TEXT
|
||||
)
|
||||
"name" TEXT,
|
||||
"uname" TEXT,
|
||||
"mail" TEXT,
|
||||
"role" TEXT,
|
||||
"lead" BOOLEAN DEFAULT 0,
|
||||
"owner" BOOLEAN DEFAULT 0
|
||||
);
|
||||
|
||||
CREATE TABLE "users" (
|
||||
"uname" TEXT,
|
||||
|
|
|
@ -12,9 +12,6 @@ CREATE TABLE projects (
|
|||
`id` INTEGER PRIMARY KEY AUTO_INCREMENT,
|
||||
`name` TEXT,
|
||||
`description` TEXT,
|
||||
`owner` TEXT,
|
||||
`owneruname` TEXT,
|
||||
`owneremail` TEXT,
|
||||
`active` BOOLEAN
|
||||
);
|
||||
|
||||
|
@ -22,8 +19,11 @@ CREATE TABLE projectmembers (
|
|||
`projectid` INTEGER,
|
||||
`name` TEXT,
|
||||
`uname` TEXT,
|
||||
`role` TEXT
|
||||
)
|
||||
`mail` TEXT,
|
||||
`role` TEXT,
|
||||
`lead` BOOLEAN DEFAULT 0,
|
||||
`owner` BOOLEAN DEFAULT 0
|
||||
);
|
||||
|
||||
CREATE TABLE users (
|
||||
`uname` TEXT,
|
||||
|
|
|
@ -2,15 +2,12 @@
|
|||
namespace pvv\side;
|
||||
|
||||
class Project{
|
||||
private $id, $name, $owner, $owneruname, $owneremail, $descr, $active;
|
||||
private $id, $name, $descr, $active;
|
||||
|
||||
public function __construct($id, $name, $descr, $owner, $owneruname, $owneremail, $active){
|
||||
public function __construct($id, $name, $descr, $active){
|
||||
$this->id = $id;
|
||||
$this->name = $name;
|
||||
$this->descr = explode("\n", $descr);
|
||||
$this->owner = $owner;
|
||||
$this->owneruname = $owneruname;
|
||||
$this->owneremail = $owneremail;
|
||||
$this->active = $active;
|
||||
}
|
||||
|
||||
|
@ -26,18 +23,6 @@ class Project{
|
|||
return $this->descr;
|
||||
}
|
||||
|
||||
public function getOwner(){
|
||||
return $this->owner;
|
||||
}
|
||||
|
||||
public function getOwnerUName(){
|
||||
return $this->owneruname;
|
||||
}
|
||||
|
||||
public function getOwnerEmail(){
|
||||
return $this->owneremail;
|
||||
}
|
||||
|
||||
public function getActive(){
|
||||
return $this->active;
|
||||
}
|
||||
|
|
|
@ -21,9 +21,6 @@ class ProjectManager{
|
|||
$dbProj['id'],
|
||||
$dbProj['name'],
|
||||
$dbProj['description'],
|
||||
$dbProj['owner'],
|
||||
$dbProj['owneruname'],
|
||||
$dbProj['owneremail'],
|
||||
$dbProj['active']
|
||||
);
|
||||
$projects[] = $project;
|
||||
|
@ -43,34 +40,38 @@ class ProjectManager{
|
|||
$dbProj['id'],
|
||||
$dbProj['name'],
|
||||
$dbProj['description'],
|
||||
$dbProj['owner'],
|
||||
$dbProj['owneruname'],
|
||||
$dbProj['owneremail'],
|
||||
$dbProj['active']
|
||||
);
|
||||
|
||||
return $project;
|
||||
}
|
||||
|
||||
public function getByUName($uname){
|
||||
$query = 'SELECT * FROM projects WHERE owneruname=:uname';
|
||||
public function getByOwner($uname){
|
||||
$query = 'SELECT projectid FROM projectmembers WHERE uname=:uname';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
|
||||
$projectIDs = $statement->fetchAll();
|
||||
$projects = [];
|
||||
foreach($projectIDs as $id){
|
||||
$id = $id['projectid'];
|
||||
|
||||
$query = 'SELECT * FROM projects WHERE id=:id';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
$statement->execute();
|
||||
|
||||
foreach($statement->fetchAll() as $dbProj){
|
||||
$project = new Project(
|
||||
$dbProj['id'],
|
||||
$dbProj['name'],
|
||||
$dbProj['description'],
|
||||
$dbProj['owner'],
|
||||
$dbProj['owneruname'],
|
||||
$dbProj['owneremail'],
|
||||
$dbProj['active']
|
||||
);
|
||||
$projects[] = $project;
|
||||
}
|
||||
}
|
||||
|
||||
return $projects;
|
||||
}
|
||||
|
@ -83,9 +84,35 @@ class ProjectManager{
|
|||
|
||||
$members = [];
|
||||
foreach($statement->fetchAll() as $dbUsr){
|
||||
$members[] = ['name' => $dbUsr['name'], 'uname' => $dbUsr['uname'], 'role' => $dbUsr['role']];
|
||||
$members[] = [
|
||||
'name' => $dbUsr['name'],
|
||||
'uname' => $dbUsr['uname'],
|
||||
'mail' => $dbUsr['mail'],
|
||||
'role' => $dbUsr['role'],
|
||||
'lead' => $dbUsr['lead'],
|
||||
'owner' => $dbUsr['owner']
|
||||
];
|
||||
}
|
||||
|
||||
return $members;
|
||||
}
|
||||
|
||||
public function getProjectOwner($id){
|
||||
$query = 'SELECT * FROM projectmembers WHERE (projectid=:id AND owner=1)';
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
|
||||
$dbOwner = $statement->fetch();
|
||||
$owner = [
|
||||
'name' => $dbOwner['name'],
|
||||
'uname' => $dbOwner['uname'],
|
||||
'mail' => $dbOwner['mail'],
|
||||
'role' => $dbOwner['role'],
|
||||
'lead' => $dbOwner['lead'],
|
||||
'owner' => $dbOwner['owner']
|
||||
];
|
||||
|
||||
return $owner;
|
||||
}
|
||||
}
|
|
@ -48,13 +48,24 @@ $project = new \pvv\side\Project(
|
|||
if($new == 0){
|
||||
$project = $projectManager->getByID($projectID);
|
||||
}
|
||||
|
||||
$members = $projectManager->getProjectMembers($projectID);
|
||||
$owner = [
|
||||
'name' => '',
|
||||
'uname' => '',
|
||||
'mail' => '',
|
||||
];
|
||||
foreach($members as $i => $data){
|
||||
if($data['owner']){
|
||||
$owner = $data;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<link rel="stylesheet" href="../../css/normalize.css">
|
||||
<link rel="stylesheet" href="../../css/style.css">
|
||||
<link rel="stylesheet" href="../../css/nav.css">
|
||||
<link rel="stylesheet" href="../../css/events.css">
|
||||
<link rel="stylesheet" href="../../css/admin.css">
|
||||
</head>
|
||||
|
@ -82,13 +93,13 @@ if($new == 0){
|
|||
|
||||
<div class="gridr noborder">
|
||||
<p class="subtitle">Prosjektleder (Brukernavn)</p>
|
||||
<?= '<input type="text" name="organiser" value="' . $project->getOwnerUName(). '" class="boxinput">' ?><br>
|
||||
<?= '<input type="text" name="organiser" value="' . $owner['uname'] . '" class="boxinput">' ?><br>
|
||||
|
||||
<p class="subtitle">Prosjektleder (Navn)</p>
|
||||
<?= '<input type="text" name="organisername" value="' . $project->getOwner(). '" class="boxinput">' ?>
|
||||
<?= '<input type="text" name="organisername" value="' . $owner['name'] . '" class="boxinput">' ?>
|
||||
|
||||
<p class="subtitle">Prosjektleder E-post</p>
|
||||
<?= '<input type="text" name="organiseremail" value="' . $project->getOwnerEmail(). '" class="boxinput">' ?><br>
|
||||
<?= '<input type="text" name="organiseremail" value="' . $owner['mail'] . '" class="boxinput">' ?><br>
|
||||
|
||||
<p class="subtitle">Aktiv</p>
|
||||
<?= '<input type="checkbox" '. ($project->getActive() ? 'checked' : '') . ' name="active"/>' ?>
|
||||
|
@ -96,6 +107,31 @@ if($new == 0){
|
|||
|
||||
<?= '<input type="hidden" name="id" value="' . $project->getID() . '" />' ?>
|
||||
|
||||
<?php if(!$new){ ?>
|
||||
<div style="grid-column: span 2;">
|
||||
<hr class="ruler">
|
||||
</div>
|
||||
|
||||
<h2 style="grid-column: span 2">Prosjektmedlemmer</h2>
|
||||
|
||||
<table class="userlist" style="grid-column: span 2;">
|
||||
<tr><th>Brukernavn</th><th>Navn</th><th>Rolle</th></tr>
|
||||
<?php foreach($members as $i => $data) { ?>
|
||||
<tr>
|
||||
<td><?= $data['uname']; ?></td>
|
||||
<td><?= $data['name']; ?></td>
|
||||
<td><?= $data['role']; ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
|
||||
<tr class="newuserrow">
|
||||
<td class="newuserelement"><input type="text" name="newuser_uname"></td>
|
||||
<td class="newuserelement"><input type="text" name="newuser_name"></td>
|
||||
<td class="newuserelement"><input type="text" name="newuser_role"></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php } ?>
|
||||
|
||||
<div class="allgrids" style="margin-top: 2em;">
|
||||
<hr class="ruler">
|
||||
|
||||
|
|
|
@ -33,16 +33,18 @@ if(isset($_POST['title'])){
|
|||
$filterTitle = $_POST['title'];
|
||||
}
|
||||
|
||||
/* Temporarily out of service :<
|
||||
$filterOrganiser = '';
|
||||
if(isset($_POST['organiser'])){
|
||||
$filterOrganiser = $_POST['organiser'];
|
||||
}
|
||||
*/
|
||||
|
||||
// filter
|
||||
$projects = array_values(array_filter(
|
||||
$projects,
|
||||
function($project) use ($filterTitle, $filterOrganiser){
|
||||
return (preg_match('/.*'.$filterTitle.'.*/i', $project->getName()) and preg_match('/.*'.$filterOrganiser.'.*/i', $project->getOwner()));
|
||||
function($project) use ($filterTitle){
|
||||
return (preg_match('/.*'.$filterTitle.'.*/i', $project->getName()));
|
||||
}
|
||||
));
|
||||
?>
|
||||
|
@ -82,13 +84,14 @@ $projects = array_values(array_filter(
|
|||
|
||||
$project = $projects[$i];
|
||||
$projectID = $project->getID();
|
||||
$owner = $projectManager->getProjectOwner($projectID);
|
||||
?>
|
||||
|
||||
<li>
|
||||
<div class="event admin">
|
||||
<div class="event-info">
|
||||
<h3 class="no-chin"><?= $project->getName() . " (ID: " . $projectID . ")"; ?></h3>
|
||||
<p class="subnote"><?= 'Organisert av: ' . $project->getOwner(); ?></p>
|
||||
<p class="subnote"><?= 'Organisert av: ' . $owner['name']; ?></p>
|
||||
<p><?= implode($project->getDescription(), "<br>"); ?></p>
|
||||
</div>
|
||||
|
||||
|
@ -124,7 +127,7 @@ $projects = array_values(array_filter(
|
|||
<p class="no-chin">Prosjektnavn</p>
|
||||
<?= '<input type="text" name="title" class="boxinput" value="' . $filterTitle . '">' ?><br>
|
||||
<p class="no-chin">Leders brukernavn</p>
|
||||
<?= '<input type="text" name="organiser" class="boxinput" value="' . $filterOrganiser . '">' ?><br>
|
||||
<?= '<input type="text" name="organiser" class="boxinput" value="">' ?><br>
|
||||
|
||||
<div style="margin-top: 2em;">
|
||||
<input type="submit" class="btn" value="Filtrer"></input>
|
||||
|
|
|
@ -30,36 +30,49 @@ if(isset($_POST['id'])){
|
|||
|
||||
$title = $_POST['title'];
|
||||
$desc = $_POST['desc'];
|
||||
$owner = $_POST['organisername'];
|
||||
$name = $_POST['organisername'];
|
||||
$uname = $_POST['organiser'];
|
||||
$email = $_POST['organiseremail'];
|
||||
$mail = $_POST['organiseremail'];
|
||||
$active = (isset($_POST['active']) ? $_POST['active'] : 0);
|
||||
|
||||
$statement;
|
||||
if($id == 0){
|
||||
$query = 'INSERT INTO projects (name, owner, owneruname, owneremail, description, active) VALUES (:title, :owner, :uname, :email, :desc, :active)';
|
||||
$query = 'INSERT INTO projects (name, description, active) VALUES (:title, :desc, :active)';
|
||||
$statement = $pdo->prepare($query);
|
||||
|
||||
$statement->bindParam(':title', $title, PDO::PARAM_STR);
|
||||
$statement->bindParam(':desc', $desc, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owner', $owner, PDO::PARAM_STR);
|
||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
||||
$statement->bindParam(':email', $email, PDO::PARAM_STR);
|
||||
$statement->bindParam(':active', $active, PDO::PARAM_INT);
|
||||
|
||||
$statement->execute();
|
||||
|
||||
$ownerQuery = 'INSERT INTO projectmembers (projectid, name, uname, mail, role, lead, owner) VALUES (last_insert_rowid(), :owner, :owneruname, :owneremail, \'Prosjektleder\', 1, 1)';
|
||||
$statement = $pdo->prepare($ownerQuery);
|
||||
$statement->bindParam(':owner', $name, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owneruname', $uname, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owneremail', $mail, PDO::PARAM_STR);
|
||||
|
||||
$statement->execute();
|
||||
}else{
|
||||
$query = 'UPDATE projects SET name=:title, owner=:owner, owneruname=:uname, owneremail=:email, description=:desc, active=:active WHERE id=:id';
|
||||
$query = 'UPDATE projects SET name=:title, description=:desc, active=:active WHERE id=:id';
|
||||
$statement = $pdo->prepare($query);
|
||||
|
||||
$statement->bindParam(':title', $title, PDO::PARAM_STR);
|
||||
$statement->bindParam(':desc', $desc, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owner', $owner, PDO::PARAM_STR);
|
||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
||||
$statement->bindParam(':email', $email, PDO::PARAM_STR);
|
||||
$statement->bindParam(':active', $active, PDO::PARAM_INT);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
}
|
||||
|
||||
$statement->execute();
|
||||
$statement->execute();
|
||||
|
||||
$query = 'UPDATE projectmembers SET name=:name, uname=:uname, mail=:mail';
|
||||
$statement = $pdo->prepare($query);
|
||||
|
||||
$statement->bindParam(':name', $name, PDO::PARAM_STR);
|
||||
$statement->bindParam(':uname', $uname, PDO::PARAM_STR);
|
||||
$statement->bindParam(':mail', $mail, PDO::PARAM_STR);
|
||||
|
||||
$statement->execute();
|
||||
}
|
||||
|
||||
header('Location: .');
|
||||
?>
|
||||
|
|
|
@ -33,13 +33,14 @@ $project = new \pvv\side\Project(
|
|||
'',
|
||||
$attrs["cn"][0],
|
||||
$attrs["uid"][0],
|
||||
$attrs["email"][0],
|
||||
$attrs["mail"][0],
|
||||
1
|
||||
);
|
||||
if($new == 0){
|
||||
$project = $projectManager->getByID($projectID);
|
||||
$owner = $projectManager->getProjectOwner($projectID);
|
||||
|
||||
if($project->getOwnerUName() != $attrs["uid"][0]){
|
||||
if($owner['uname'] != $attrs["uid"][0]){
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
echo "wrong user";
|
||||
exit();
|
||||
|
|
|
@ -49,6 +49,7 @@ $projects = $projectManager->getAll();
|
|||
};
|
||||
foreach($randProjects as $i) {
|
||||
$project = $projects[$i];
|
||||
$owner = $projectManager->getProjectOwner($project->getID());
|
||||
?>
|
||||
|
||||
<div class="project-card">
|
||||
|
@ -56,7 +57,7 @@ $projects = $projectManager->getAll();
|
|||
<h4 class="project-title"><?= $project->getName(); ?></h4>
|
||||
<p><?= $project->getDescription()[0]; ?></p>
|
||||
</div>
|
||||
<p class="project-organizer">Organisert av<br><?= $project->getOwner(); ?></p>
|
||||
<p class="project-organizer">Organisert av<br><?= $owner['name']; ?></p>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<?php
|
||||
|
|
|
@ -39,20 +39,27 @@ $members = $projectManager->getProjectMembers($projectID);
|
|||
<div class="projectlead">
|
||||
<h2>Prosjektledelse</h2>
|
||||
<div class="projectmember">
|
||||
<p>Prosjekteier</p>
|
||||
<p class="membername"><?= $project->getOwner() ?></p>
|
||||
<p class="memberuname"><?= $project->getOwnerUName(); ?></p>
|
||||
<p class="memberemail"><?= $project->getOwnerEmail(); ?></p>
|
||||
<?php foreach($members as $i => $data){
|
||||
if($data['lead']){
|
||||
?>
|
||||
<p><?= $data['role'] ?></p>
|
||||
<p class="membername"><?= $data['name']; ?></p>
|
||||
<p class="memberuname"><?= $data['uname']; ?></p>
|
||||
<p class="memberemail"><?= $data['mail']; ?></p>
|
||||
<?php }
|
||||
} ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="projectmembers">
|
||||
<h2>Medlemmer</h2>
|
||||
<?php foreach($members as $i => $data){ ?>
|
||||
<?php foreach($members as $i => $data){
|
||||
if($data['lead']){ continue; }
|
||||
?>
|
||||
<div class="projectmember">
|
||||
<p><?= $data['role'] ?></p>
|
||||
<p class="membername"><?= $data['name'] ?></p>
|
||||
<p class="memberuname"><?= $data['uname'] ?></p>
|
||||
<p><?= $data['role'] ? $data['role'] : 'Deltaker' ?></p>
|
||||
<p class="membername"><?= $data['name']; ?></p>
|
||||
<p class="memberuname"><?= $data['uname']; ?></p>
|
||||
</div>
|
||||
<?php } ?>
|
||||
</div>
|
||||
|
|
|
@ -13,7 +13,7 @@ $attrs = $as->getAttributes();
|
|||
$pdo = new \PDO($dbDsn, $dbUser, $dbPass);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$projectManager = new \pvv\side\ProjectManager($pdo);
|
||||
$projects = $projectManager->getByUName($attrs['uid'][0]);
|
||||
$projects = $projectManager->getByOwner($attrs['uid'][0]);
|
||||
|
||||
$page = 1;
|
||||
if(isset($_GET['page'])){
|
||||
|
@ -25,31 +25,37 @@ if(isset($_POST['title'])){
|
|||
$filterTitle = $_POST['title'];
|
||||
}
|
||||
|
||||
/*
|
||||
$filterOrganiser = '';
|
||||
if(isset($_POST['organiser'])){
|
||||
$filterOrganiser = $_POST['organiser'];
|
||||
}
|
||||
*/
|
||||
|
||||
// filter
|
||||
$projects = array_values(array_filter(
|
||||
$projects,
|
||||
function($project) use ($filterTitle, $filterOrganiser){
|
||||
return (preg_match('/.*'.$filterTitle.'.*/i', $project->getName()) and preg_match('/.*'.$filterOrganiser.'.*/i', $project->getOwner()));
|
||||
function($project) use ($filterTitle){
|
||||
return (preg_match('/.*'.$filterTitle.'.*/i', $project->getName()));
|
||||
}
|
||||
));
|
||||
?>
|
||||
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<link rel="stylesheet" href="../css/normalize.css">
|
||||
<link rel="stylesheet" href="../css/style.css">
|
||||
<link rel="stylesheet" href="../css/events.css">
|
||||
<link rel="stylesheet" href="../css/admin.css">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
<link rel="stylesheet" href="../css/normalize.css">
|
||||
<link rel="stylesheet" href="../css/style.css">
|
||||
<link rel="stylesheet" href="../css/events.css">
|
||||
<link rel="stylesheet" href="../css/admin.css">
|
||||
</head>
|
||||
|
||||
<header>Prosjekt­verkstedet</header>
|
||||
<body>
|
||||
<nav>
|
||||
<?= navbar(1, 'prosjekt'); ?>
|
||||
<?= loginbar(); ?>
|
||||
</nav>
|
||||
|
||||
<main>
|
||||
|
||||
<article class="gridsplit">
|
||||
<main class="gridsplit">
|
||||
<div class="gridl">
|
||||
<h2 class="no-chin">Mine Prosjekter</h2>
|
||||
|
||||
|
@ -106,11 +112,5 @@ $projects = array_values(array_filter(
|
|||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
</main>
|
||||
|
||||
<nav>
|
||||
<?= navbar(1, 'prosjekt'); ?>
|
||||
<?= loginbar(); ?>
|
||||
</nav>
|
||||
</main>
|
||||
</body>
|
|
@ -21,33 +21,38 @@ $active = $_POST['active'];
|
|||
|
||||
$title = $_POST['title'];
|
||||
$desc = $_POST['desc'];
|
||||
$owner = $attrs['cn'][0];
|
||||
$owneruname = $attrs['uid'][0];
|
||||
$owneremail = $attrs['mail'][0];
|
||||
$name = $attrs['cn'][0];
|
||||
$uname = $attrs['uid'][0];
|
||||
$mail = $attrs['mail'][0];
|
||||
|
||||
$statement;
|
||||
if($id == 0){
|
||||
$query = 'INSERT INTO projects (name, owner, owneruname, owneremail, description, active) VALUES (:title, :owner, :owneruname, :owneremail, :desc, 1)';
|
||||
$query = 'INSERT INTO projects (name, description, active) VALUES (:title, :desc, 1)';
|
||||
$statement = $pdo->prepare($query);
|
||||
|
||||
$statement->bindParam(':title', $title, PDO::PARAM_STR);
|
||||
$statement->bindParam(':desc', $desc, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owner', $owner, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owneruname', $owneruname, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owneremail', $owneremail, PDO::PARAM_STR);
|
||||
|
||||
$statement->execute();
|
||||
|
||||
// there's a better way to do this. i just don't know it right now
|
||||
$ownerQuery = 'INSERT INTO projectmembers (projectid, name, uname, mail, role, lead, owner) VALUES (last_insert_rowid(), :owner, :owneruname, :owneremail, \'Prosjektleder\', 1, 1)';
|
||||
$statement = $pdo->prepare($ownerQuery);
|
||||
$statement->bindParam(':owner', $name, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owneruname', $uname, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owneremail', $mail, PDO::PARAM_STR);
|
||||
|
||||
$statement->execute();
|
||||
}else{
|
||||
$query = 'UPDATE projects SET name=:title, owner=:owner, owneruname=:owneruname, owneremail=:owneremail, description=:desc WHERE id=:id';
|
||||
$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(':owner', $owner, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owneruname', $owneruname, PDO::PARAM_STR);
|
||||
$statement->bindParam(':owneremail', $owneremail, PDO::PARAM_STR);
|
||||
$statement->bindParam(':id', $id, PDO::PARAM_INT);
|
||||
}
|
||||
|
||||
$statement->execute();
|
||||
$statement->execute();
|
||||
}
|
||||
|
||||
header('Location: ./mine.php');
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue