implemented spaces, fixed login and signup, thought creation and space creation.

This commit is contained in:
2025-05-26 13:00:12 -06:00
parent 54a01f0f1f
commit d3fa1733f4
32 changed files with 1499 additions and 1132 deletions
+80 -34
View File
@@ -12,15 +12,11 @@ if (isset($_GET['view'])) {
case 'essay':
if (isset($_GET['id'])) {
// TODO: Need another check here to verify the user is in the Essay's space.
$essay = Essay::retrieveFromDB($_GET['id']);
$space = $essay->getSpace();
if (isset($_SESSION['user']) && $space->allowUser($_SESSION['user']))
echo displayEssay($essay);
else if ($space->getVisibility() == 1)
$essay = Post::retrieveFromDB($_GET['id']);
if ($essay)
echo displayEssay($essay);
else
echo displaySpace(2025);
echo errorScreen('Essay does not exist!', 'The Essay ID provided does not exist in the database.');
} else
echo displaySpace(2025);
break;
@@ -28,19 +24,22 @@ if (isset($_GET['view'])) {
// TODO: After implementing the notification modal, notify the user on success/fail auth events.
if (isset($_GET['id'])) {
$space = Space::retrieveFromDB($_GET['id']);
if (isset($_SESSION['user']))
if ($space->allowUser(unserialize($_SESSION['user'])))
echo displaySpace($_GET['id']);
else if ($space->getVisibility() == 1)
echo displaySpace($_GET['id']);
else
echo 'TODO: Notification Modal -> User not a member';
else {
if ($space->getVisibility() == 1)
echo displaySpace($_GET['id']);
else
echo 'TODO: Notification Modal -> Space is not Open';
}
if ($space) {
if (isset($_SESSION['user']))
if ($space->allowUser(unserialize($_SESSION['user'])))
echo displaySpace($_GET['id']);
else if ($space->getVisibility() == 1)
echo displaySpace($_GET['id']);
else
echo 'TODO: Notification Modal -> User not a member';
else {
if ($space->getVisibility() == 1)
echo displaySpace($_GET['id']);
else
echo 'TODO: Notification Modal -> Space is not Open';
}
} else
echo errorScreen('Space does not exist!', 'The Space ID provided does not exist in the database.');
} else
echo displaySpaceList();
break;
@@ -60,19 +59,55 @@ if (isset($_GET['view'])) {
}
if (isset($_SESSION['user']))
echo actionButton();
echo actionBar();
if (isset($_GET['id']))
echo backButton();
require_once 'components/core/foot.php';
function actionButton()
function backButton()
{
// TODO: Position these on the arc of a circle.
$html = '
<div class="circleLayout">
<div id="newPost" class="actionButton" style="display: none;"><i class="nf nf-cod-new_file"></i></div>
<div id="newSpace" class="actionButton" style="display: none;"><i class="nf nf-cod-new_folder"></i></div>
<div id="filterSort" class="actionButton" style="display: none;"><i class="nf nf-oct-filter"></i></div>
<div id="actionButton" class="actionButton"><i class="nf nf-cod-symbol_property"></i></div>
<div class="link" id="backButton">
<i class="nf nf-fa-arrow_left"></i>
</div>
';
return $html;
}
function actionBar()
{
$user = unserialize($_SESSION['user']);
$html = '
<div class="std_border med_width padding glass" id="actionBar">
<div class="row space_between" id="primaryActions">
<div class="column center link med_width" id="actionSpace"><i class="nf nf-md-layers_outline"></i><p class="link">Space</p></div>
<div class="column center link med_width" id="actionPost"><i class="nf nf-md-text"></i><p class="link">Post</p></div>
</div>
<div class="row space_between" id="postActions" style="display: none;">
<div class="column center link med_width" id="postBack"><i class="nf nf-cod-arrow_circle_left"></i><p class="link">Back</p></div>
<div class="column center link med_width" id="postNew"><i class="nf nf-md-chat_plus"></i><p class="link">New</p></div>
</div>
<div class="row space_between" id="spaceActions" style="display: none;">
<div class="column center link med_width" id="spaceBack"><i class="nf nf-cod-arrow_circle_left"></i><p class="link">Back</p></div>
<div class="column center link med_width" id="spaceHome" href="spaces.php?view=show&id=' . $user->getId() . '"><i class="nf nf-fa-home"></i><p class="link">Home</p></div>
<div class="column center link med_width" id="spaceNew"><i class="nf nf-md-layers_plus"></i><p class="link">New</p></div>
</div>
</div>
';
return $html;
}
function errorScreen(String $heading, String $msg)
{
$html = '
<div class="column std_border med_width padding center top_margin">
<h1>' . $heading . '</h1>
<p>' . $msg . '</p>
</div>
';
@@ -81,9 +116,16 @@ function actionButton()
function displayEssay(Essay $e)
{
/* if (isset($_SESSION['user'])) */
/* if ($e->allowUser(unserialize($_SESSION['user'])) || $e->getSpace()->getVisibility() != 1) */
/* return errorScreen('Access Denied!', 'You do not have access to the Space that this Essay is in.'); */
$parsedown = new Parsedown();
$parsedown->setSafeMode(true);
$html = '
<div class="std_width std_border padding center top_margin" style="height: 87%; overflow-y: auto;">
' . $e->getHTML() . '
<div class="std_width std_border padding center top_margin" style="height: 77vh; overflow-y: auto;">
' . $parsedown->parse($e->getMarkdown()) . '
</div>
';
@@ -95,7 +137,7 @@ function displaySpaceList()
$user = unserialize($_SESSION['user']);
$html = '
<div class="std_width std_border padding center top_margin" style="height: 87%; overflow-y: auto;">
<div class="std_width std_border padding center top_margin" style="height: 77vh; overflow-y: auto;">
<div class="column space_between full_width">
<h1>Spaces</h4>
</div>
@@ -103,9 +145,8 @@ function displaySpaceList()
';
$spaces = $user->getSpaces();
foreach ($spaces as $s) {
foreach ($spaces as $s)
$html .= $s->getCardHTML();
}
$html .= '
</div>
@@ -119,7 +160,7 @@ function displaySpace($id = 2025)
$space = Space::retrieveFromDB($id);
if ($space) {
$html = '
<div class="std_width std_border padding center top_margin" style="max-height: 89vh; overflow-y: auto;">
<div class="std_width std_border padding center top_margin" style="height: 77vh; overflow-y: auto;">
<div class="column space_between full_width">
<h1>' . $space->getName() . '</h4>
<p>' . $space->getDescription() . '</p>
@@ -127,6 +168,11 @@ function displaySpace($id = 2025)
<div class="line"></div>
';
$subspaces = $space->getSubSpaces();
foreach ($subspaces as $ss) {
$html .= $ss->getCardHTML();
}
// TODO: Need to investigate this bug in Posts
$posts = $space->getPosts();
foreach ($posts as $post) {