changed how a few code snippets work and added in all projects section to view all the current projects includig <div class="grid__item"></div>
<div class="grid__item"></div>
<div class="grid__item"></div>
<div class="grid__item"></div>the one as the main
Signed-off-by: rodude123 <rodude123@gmail.com>
This commit is contained in:
Vendored
+11
-2
@@ -225,10 +225,19 @@ $app->patch("/projectData/{id}", function (Request $request, Response $response,
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
if (!$projectData->updateProjectData($args["id"], $data["title"], $data["isMainProject"], $data["information"], $data["projectLink"], $data["gitLink"]))
|
||||
$update = $projectData->updateProjectData($args["id"], $data["title"], $data["isMainProject"], $data["information"], $data["projectLink"], $data["gitLink"]);
|
||||
|
||||
if ($update === "unset main project")
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Something went wrong", "data" => $projectData->updateProjectData($args["id"], $data["title"], $data["isMainProject"], $data["information"], $data["projectLink"], $data["gitLink"]))));
|
||||
$response->getBody()->write(json_encode(array("error" => "Can't unset project as main project, try updating another project as the main project")));
|
||||
return $response->withStatus(400);
|
||||
}
|
||||
|
||||
if (!$update)
|
||||
{
|
||||
// uh oh something went wrong
|
||||
$response->getBody()->write(json_encode(array("error" => "Something went wrong")));
|
||||
return $response->withStatus(500);
|
||||
}
|
||||
return $response;
|
||||
|
||||
Vendored
+17
-4
@@ -41,12 +41,25 @@ class projectData
|
||||
* @param string $information - Information about the project
|
||||
* @param string $projectLink - Link to the project
|
||||
* @param string $gitLink - Link to the git repository
|
||||
* @return bool - True if project was updated, false if not and there was an error
|
||||
* @return bool|string - True if project was updated, false if not and there was an error, or an error string
|
||||
*/
|
||||
function updateProjectData(string $ID, string $title, string $isMainProject, string $information, string $projectLink, string $gitLink): bool
|
||||
function updateProjectData(string $ID, string $title, string $isMainProject, string $information, string $projectLink, string $gitLink): bool | string
|
||||
{
|
||||
$conn = dbConn();
|
||||
|
||||
if ($isMainProject === "false")
|
||||
{
|
||||
$stmtMainProject = $conn->prepare("SELECT isMainProject FROM projects WHERE ID = :ID");
|
||||
$stmtMainProject->bindParam(":ID", $ID);
|
||||
$stmtMainProject->execute();
|
||||
$result = $stmtMainProject->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if ($result["isMainProject"] === "1")
|
||||
{
|
||||
return "unset main project";
|
||||
}
|
||||
}
|
||||
|
||||
if ($isMainProject === "true")
|
||||
{
|
||||
$stmtMainProject = $conn->prepare("UPDATE projects SET isMainProject = 0;");
|
||||
@@ -55,7 +68,7 @@ class projectData
|
||||
|
||||
$stmt = $conn->prepare("UPDATE projects SET title = :title, isMainProject = :isMainProject, information = :information, projectLink = :projectLink, gitLink = :gitLink WHERE ID = :ID");
|
||||
$stmt->bindParam(":title", $title);
|
||||
$isMainProj = ($isMainProject) ? 1 : 0;
|
||||
$isMainProj = ($isMainProject === "true") ? 1 : 0;
|
||||
$stmt->bindParam(":isMainProject", $isMainProj);
|
||||
$stmt->bindParam(":information", $information);
|
||||
$stmt->bindParam(":projectLink", $projectLink);
|
||||
@@ -120,7 +133,7 @@ class projectData
|
||||
|
||||
$stmt = $conn->prepare("INSERT INTO projects (title, isMainProject, information, projectLink, gitLink) VALUES (:title, :isMainProject, :information, :projectLink, :gitLink)");
|
||||
$stmt->bindParam(":title", $title);
|
||||
$isMainProj = ($isMainProject) ? 1 : 0;
|
||||
$isMainProj = ($isMainProject === "true") ? 1 : 0;
|
||||
$stmt->bindParam(":isMainProject", $isMainProj);
|
||||
$stmt->bindParam(":information", $information);
|
||||
$stmt->bindParam(":projectLink", $projectLink);
|
||||
|
||||
Reference in New Issue
Block a user