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

50 lines
1.3 KiB
PHP
Raw Permalink Normal View History

2023-10-18 22:42:01 +02:00
<?php
class Home extends Page
{
function setMenu()
{
2023-10-22 01:46:22 +02:00
$this->menu_text = 'Home';
$this->menu_image = 'far fa-home';
2023-10-18 22:42:01 +02:00
$this->menu_priority = 0;
}
function index()
{
2023-10-22 01:46:22 +02:00
$u = new User();
$this->set('userdata', $u->getAll());
//return $this->renderPagecontent();
2023-11-28 16:23:22 +01:00
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");
}
2023-10-18 22:42:01 +02:00
}
function maySeeThisPage(){return true;}
}