This repository has been archived on 2023-12-29. You can view files and clone it, but cannot push or open issues or pull requests.
dogstats/web/pages/home/controller.php
piapassecker 44c0cfcfae
All checks were successful
Build and push / Pulling repo on server (push) Successful in 2s
separated home logged in and not
2023-11-28 16:23:22 +01:00

50 lines
1.3 KiB
PHP

<?php
class Home extends Page
{
function setMenu()
{
$this->menu_text = 'Home';
$this->menu_image = 'far fa-home';
$this->menu_priority = 0;
}
function index()
{
$u = new User();
$this->set('userdata', $u->getAll());
//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;}
}