fixup! WIP: revamp projects: redesign webpage
This commit is contained in:
@@ -68,10 +68,16 @@ class Project {
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getDescriptionEn(): array {
|
||||
return $this->description_en;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getDescriptionNo(): array {
|
||||
return $this->description_no;
|
||||
}
|
||||
@@ -88,14 +94,23 @@ class Project {
|
||||
return $this->wiki_link;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getProgrammingLanguages(): array {
|
||||
return $this->programming_languages;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getTechnologies(): array {
|
||||
return $this->technologies;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getKeywords(): array {
|
||||
return $this->keywords;
|
||||
}
|
||||
|
||||
@@ -142,4 +142,33 @@ class ProjectManager {
|
||||
|
||||
return $maintainers;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{name:string,uname:string,link:string,mail:string}|null
|
||||
*/
|
||||
public function getProjectOwner(int $id): ?array {
|
||||
$query = '
|
||||
SELECT name, uname, link, mail FROM project
|
||||
JOIN project__project_maintainer ON project.id = project__project_maintainer.project_id
|
||||
JOIN project_maintainer ON project__project_maintainer.uname = project_maintainer.uname
|
||||
WHERE project.id = :id AND project__project_maintainer.owner = TRUE
|
||||
LIMIT 1
|
||||
';
|
||||
|
||||
$statement = $this->pdo->prepare($query);
|
||||
$statement->bindParam(':id', $id, \PDO::PARAM_STR);
|
||||
$statement->execute();
|
||||
|
||||
$owner = $statement->fetch();
|
||||
if (!$owner) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
'name' => $owner['name'],
|
||||
'uname' => $owner['uname'],
|
||||
'link' => $owner['link'],
|
||||
'mail' => $owner['mail'],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,38 +14,45 @@ $pdo = new PDO($DB_DSN, $DB_USER, $DB_PASS);
|
||||
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$projectManager = new pvv\side\ProjectManager($pdo);
|
||||
|
||||
$new = 0;
|
||||
$project_is_new = false;
|
||||
if (isset($_GET['new'])) {
|
||||
$new = $_GET['new'];
|
||||
$project_is_new = $_GET['new'];
|
||||
}
|
||||
|
||||
$projectID = 0;
|
||||
if (isset($_GET['id'])) {
|
||||
$projectID = $_GET['id'];
|
||||
} elseif ($new == 0) {
|
||||
} elseif (!$project_is_new) {
|
||||
echo "\nID not set";
|
||||
exit;
|
||||
}
|
||||
|
||||
$project = new pvv\side\Project(
|
||||
0,
|
||||
'Nytt Prosjekt',
|
||||
'',
|
||||
$attrs['cn'][0],
|
||||
$attrs['uid'][0],
|
||||
$attrs['mail'][0],
|
||||
1
|
||||
id: 0,
|
||||
title: 'Nytt Prosjekt',
|
||||
description_en: null,
|
||||
description_no: null,
|
||||
gitea_link: null,
|
||||
issue_board_link: null,
|
||||
wiki_link: null,
|
||||
programming_languages: null,
|
||||
technologies: null,
|
||||
keywords: null,
|
||||
license: null,
|
||||
logo_url: null
|
||||
);
|
||||
// if ($new == 0) {
|
||||
// $project = $projectManager->getByID($projectID);
|
||||
// $maintainers = $projectManager->getProjectMaintainers($projectID);
|
||||
|
||||
// if ($owner['uname'] != $attrs['uid'][0]) {
|
||||
// header('HTTP/1.0 403 Forbidden');
|
||||
// echo 'wrong user';
|
||||
// exit;
|
||||
// }
|
||||
// }
|
||||
if (!$project_is_new) {
|
||||
$project = $projectManager->getByID($projectID);
|
||||
$maintainers = $projectManager->getProjectMaintainers($projectID);
|
||||
|
||||
if ($owner['uname'] != $attrs['uid'][0]) {
|
||||
header('HTTP/1.0 403 Forbidden');
|
||||
echo 'wrong user';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="no">
|
||||
@@ -87,11 +94,11 @@ $project = new pvv\side\Project(
|
||||
|
||||
<p class="subtitle no-chin">Gitea-link</p>
|
||||
<p class="subnote">Link til prosjektet på Gitea</p>
|
||||
<input class="wide" type="text" name="gitea" value="<?php echo $project->getGiteaLink(); ?>" class="boxinput" required><br>
|
||||
<input class="wide" type="text" name="gitea" value="<?php echo $project->getGiteaLink(); ?>" class="boxinput"><br>
|
||||
|
||||
<p class="subtitle no-chin">Issue board-link</p>
|
||||
<p class="subnote">Link til issue board på Gitea</p>
|
||||
<input class="wide" type="text" name="issue" value="<?php echo $project->getIssueBoardLink(); ?>" class="boxinput" required><br>
|
||||
<input class="wide" type="text" name="issue" value="<?php echo $project->getIssueBoardLink(); ?>" class="boxinput"><br>
|
||||
|
||||
<p class="subtitle no-chin">Wiki-link</p>
|
||||
<p class="subnote">Link til wiki-side</p>
|
||||
@@ -99,15 +106,15 @@ $project = new pvv\side\Project(
|
||||
|
||||
<p class="subtitle no-chin">Programmeringsspråk</p>
|
||||
<p class="subnote">Hvilke programmeringsspråk brukes i prosjektet?</p>
|
||||
<input class="wide" type="text" name="langs" value="<?php echo $project->getProgrammingLanguages(); ?>" class="boxinput"><br>
|
||||
<input class="wide" type="text" name="langs" value="<?php echo implode("\n", $project->getProgrammingLanguages()); ?>" class="boxinput"><br>
|
||||
|
||||
<p class="subtitle no-chin">Teknologier</p>
|
||||
<p class="subnote">Hvilke teknologier brukes i prosjektet?</p>
|
||||
<input class="wide" type="text" name="techs" value="<?php echo $project->getTechnologies(); ?>" class="boxinput"><br>
|
||||
<input class="wide" type="text" name="techs" value="<?php echo implode("\n", $project->getTechnologies()); ?>" class="boxinput"><br>
|
||||
|
||||
<p class="subtitle no-chin">Nøkkelord</p>
|
||||
<p class="subnote">Nøkkelord som beskriver prosjektet</p>
|
||||
<input class="wide" type="text" name="keywords" value="<?php echo $project->getKeywords(); ?>" class="boxinput"><br>
|
||||
<input class="wide" type="text" name="keywords" value="<?php echo implode("\n", $project->getKeywords()); ?>" class="boxinput"><br>
|
||||
|
||||
<p class="subtitle no-chin">Lisens</p>
|
||||
<p class="subnote">Hvilken lisens bruker prosjektet?</p>
|
||||
@@ -122,8 +129,8 @@ $project = new pvv\side\Project(
|
||||
|
||||
<div style="margin-top: 0.2em;">
|
||||
<hr class="ruler">
|
||||
<input type="submit" class="btn" value="<?php echo $new ? 'Opprett prosjekt' : 'Lagre endringer'; ?>"></input>
|
||||
<?php if (!$new) {?><input type="submit" class="btn" name="delete" value="Slett"></input><?php } ?>
|
||||
<input type="submit" class="btn" value="<?php echo $project_is_new ? 'Opprett prosjekt' : 'Lagre endringer'; ?>"></input>
|
||||
<?php if (!$project_is_new) {?><input type="submit" class="btn" name="delete" value="Slett"></input><?php } ?>
|
||||
</div>
|
||||
</form>
|
||||
</main>
|
||||
|
||||
@@ -92,16 +92,28 @@ $projects = $projectManager->getAll();
|
||||
$owner = $projectManager->getProjectOwner($project->getID());
|
||||
?>
|
||||
|
||||
<a class="nostyle" href="info.php?id=<?php echo $project->getID(); ?>"><div class="project-card">
|
||||
<a class="nostyle" href="info.php?id=<?php echo $project->getID(); ?>">
|
||||
<div class="project-card">
|
||||
<div class="card-content">
|
||||
<h4 class="project-title"><?php echo $project->getName(); ?></h4>
|
||||
<h4 class="project-title"><?php echo $project->getTitle(); ?></h4>
|
||||
<p>
|
||||
<?php
|
||||
$Parsedown = new Parsedown();
|
||||
echo $Parsedown->text(implode("\n", array_slice($project->getDescription(), 0, 2)));
|
||||
echo $Parsedown->text(implode("\n", array_slice($project->getDescriptionNo(), 0, 2)));
|
||||
?>
|
||||
</p>
|
||||
<?php echo $project->getGiteaLink() ?>
|
||||
<?php echo $project->getIssueBoardLink() ?>
|
||||
<?php echo $project->getLogoURL() ?>
|
||||
<?php echo $project->getProgrammingLanguages() ?>
|
||||
<?php echo $project->getTechnologies() ?>
|
||||
<?php echo $project->getKeywords() ?>
|
||||
<?php echo $project->getLicense() ?>
|
||||
<?php echo $project->getWikiLink() ?>
|
||||
</div>
|
||||
<p class="project-organizer">Organisert av <?php echo $owner['name']; ?></p>
|
||||
</div></a>
|
||||
</div>
|
||||
</a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<center>
|
||||
|
||||
@@ -29,8 +29,14 @@ $uname = $attrs['uid'][0];
|
||||
$mail = $attrs['mail'][0];
|
||||
|
||||
|
||||
if ($id == 0) {
|
||||
$query = 'INSERT INTO projects (name, description, active) VALUES (:title, :desc, TRUE)';
|
||||
|
||||
if ($id == 0) { // Create new project
|
||||
$query = <<<END
|
||||
INSERT INTO
|
||||
project(name, description, active)
|
||||
VALUES
|
||||
(:title, :desc, :active)
|
||||
END;
|
||||
$statement = $pdo->prepare($query);
|
||||
|
||||
$statement->bindParam(':title', $title, PDO::PARAM_STR);
|
||||
@@ -39,7 +45,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', TRUE, TRUE)";
|
||||
$ownerQuery = "INSERT INTO project_maintainer (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);
|
||||
@@ -47,7 +53,7 @@ if ($id == 0) {
|
||||
$statement->bindParam(':owneremail', $mail, PDO::PARAM_STR);
|
||||
|
||||
$statement->execute();
|
||||
} else {
|
||||
} else { // Update existing project
|
||||
$projectManager = new pvv\side\ProjectManager($pdo);
|
||||
$owner = $projectManager->getProjectOwner($id);
|
||||
$members = $projectManager->getProjectMembers($id);
|
||||
|
||||
Reference in New Issue
Block a user