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;
case 'list':
if (isset($_SESSION['user']))
echo displaySpaceList();
else
echo displaySpace(2025);
break;
default:
echo displaySpaceList();
break;
}
} else {
echo displaySpace(2025);
}
if (isset($_SESSION['user']))
echo actionBar();
if (isset($_GET['id']))
echo backButton();
require_once 'components/core/foot.php';
function backButton()
{
$html = '
';
return $html;
}
function actionBar()
{
$user = unserialize($_SESSION['user']);
$html = '
';
return $html;
}
function errorScreen(String $heading, String $msg)
{
$html = '
' . $heading . '
' . $msg . '
';
return $html;
}
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 = '
' . $parsedown->parse($e->getMarkdown()) . '
';
return $html;
}
function displaySpaceList()
{
$user = unserialize($_SESSION['user']);
$html = '
Spaces
';
$spaces = $user->getSpaces();
foreach ($spaces as $s)
$html .= $s->getCardHTML();
$html .= '
';
return $html;
}
function displaySpace($id = 2025)
{
$space = Space::retrieveFromDB($id);
if ($space) {
$html = '
' . $space->getName() . '
' . $space->getDescription() . '
';
$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) {
foreach ($post as $p) {
$html .= $p->getCardHTML();
}
}
$html .= '
';
return $html;
}
}