still some bugs and auth issues to iron out. need to implement a new action button/bar, the card for moments in a space, creating new moments and essays, dynamically refreshing the spaces view when a new post is created.

This commit is contained in:
2025-05-20 19:46:09 -06:00
parent a93c30c40f
commit 54a01f0f1f
20 changed files with 1018 additions and 1191 deletions
+122 -25
View File
@@ -1,47 +1,144 @@
<?php
require_once 'functions/init.php';
require_once 'functions/core.php';
require_once 'functions/space.php';
// UI Components
foreach (glob('components/core/*.php') as $file)
require_once $file;
foreach (glob('components/spaces/*.php') as $file)
require_once $file;
include_once 'components/core/head.php';
/* foreach (glob('components/spaces/*.php') as $file) */
/* require_once $file; */
/* if (!isset($_SESSION['role_id'])) { */
/* $redirect = 'todo.php?view=display'; */
/* header('Location: user.php?view=login&redirect=' . urlencode($redirect)); */
/* } */
require_once 'components/core/head.php';
// Display user's spaces
if (isset($_SESSION['user'])) {
if (isset($_GET['view'])) {
switch ($_GET['view']) {
case 'displaySpaces':
echo displaySpace();
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)
echo displayEssay($essay);
else
echo displaySpace(2025);
} else
echo displaySpace(2025);
break;
case 'displaySpace':
case 'show':
// 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';
}
} else
echo displaySpaceList();
break;
case 'displayFeed':
/* if (isset($_GET['space_id']) || isset($_GET['user_id'])) */
case 'list':
if (isset($_SESSION['user']))
echo displaySpaceList();
else
echo displaySpace(2025);
break;
case 'displaySpacePosts':
default:
echo displaySpaceList();
break;
}
} else {
// Treat as displaySpacePosts
echo displaySpace();
echo displaySpace(2025);
}
include_once 'components/core/foot.php';
if (isset($_SESSION['user']))
echo actionButton();
function displaySpace($spaceId = 2025)
require_once 'components/core/foot.php';
function actionButton()
{
$space = Space::retrieveFromDB($spaceId, null);
// TODO: Position these on the arc of a circle.
$html = '
<p>' . $space->getId() . '</p>
<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>
';
return $html;
}
function displayEssay(Essay $e)
{
$html = '
<div class="std_width std_border padding center top_margin" style="height: 87%; overflow-y: auto;">
' . $e->getHTML() . '
</div>
';
return $html;
}
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="column space_between full_width">
<h1>Spaces</h4>
</div>
<div class="line"></div>
';
$spaces = $user->getSpaces();
foreach ($spaces as $s) {
$html .= $s->getCardHTML();
}
$html .= '
</div>
';
return $html;
}
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="column space_between full_width">
<h1>' . $space->getName() . '</h4>
<p>' . $space->getDescription() . '</p>
</div>
<div class="line"></div>
';
// TODO: Need to investigate this bug in Posts
$posts = $space->getPosts();
foreach ($posts as $post) {
foreach ($post as $p) {
$html .= $p->getCardHTML();
}
}
$html .= '
</div>
';
return $html;
}
}