separated home logged in and not
All checks were successful
Build and push / Pulling repo on server (push) Successful in 2s

This commit is contained in:
piapassecker
2023-11-28 16:23:22 +01:00
parent ffb8e552d2
commit 44c0cfcfae
4 changed files with 200 additions and 168 deletions

View File

@ -13,8 +13,37 @@ class Home extends Page
{
$u = new User();
$this->set('userdata', $u->getAll());
$this->set('template', "home.html");
//return $this->renderPagecontent();
if(!$_SESSION['user'])
{
$this->set('template', 'home-nouser.html');
return;
}
else {
$dogs = $_SESSION['user']->data['dogs'];
$doggos = [];
foreach($dogs as $key => $dogid)
{
$dog = new Dog();
try{
$dog->load($dogid);
}
catch(Exception $e)
{
error_log("Dog $dogid not found. Deleting from user");
unset($_SESSION['user']->data['dogs'][$key]);
$_SESSION['user']->save();
continue;
}
if($dog->data)
$doggos[] = array_merge($dog->data,['id'=>$dogid]);
$this->set('doggos',$doggos);
}
//var_dump($doggos);
$this->set('template', "home.html");
}
}
function maySeeThisPage(){return true;}