smart menu things
All checks were successful
Build and push / Pulling repo on server (push) Successful in 2s
All checks were successful
Build and push / Pulling repo on server (push) Successful in 2s
This commit is contained in:
parent
88ec74af75
commit
9f3aab4033
@ -199,6 +199,11 @@ class Model {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function exists($id)
|
||||||
|
{
|
||||||
|
return $GLOBALS['redis']->exists($this->dbTable.':'.$id);
|
||||||
|
}
|
||||||
|
|
||||||
function delete()
|
function delete()
|
||||||
{
|
{
|
||||||
return $GLOBALS['redis']->del($this->dbTable.':'.$this->id);
|
return $GLOBALS['redis']->del($this->dbTable.':'.$this->id);
|
||||||
|
@ -1,17 +1,31 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
class Dog extends Model {
|
class Dog extends Model
|
||||||
|
{
|
||||||
protected $dbTable = "dogs";
|
protected $dbTable = "dogs";
|
||||||
protected $dbFields = Array (
|
protected $dbFields = array(
|
||||||
'uuid' => ['type'=>'text','required','unique','autoValMethod'=>'gen_ulid'],
|
'uuid' => ['type' => 'text', 'required', 'unique', 'autoValMethod' => 'gen_ulid'],
|
||||||
'registered' => ['type'=>'datetime','required','unique','autoValMethod'=>'getDateTime'],
|
'registered' => ['type' => 'datetime', 'required', 'unique', 'autoValMethod' => 'getDateTime'],
|
||||||
'name' => ['type'=>'text'],
|
'name' => ['type' => 'text'],
|
||||||
'kennel_name' => ['type'=>'text'],
|
'kennel_name' => ['type' => 'text'],
|
||||||
'breed' => ['type'=>'text'],
|
'breed' => ['type' => 'text'],
|
||||||
'size' => ['type'=>'text'], //in cm
|
'size' => ['type' => 'text'], //in cm
|
||||||
'birthday' => ['type'=>'text'],
|
'birthday' => ['type' => 'text'],
|
||||||
'agility_size' => ['type'=>'text'], //S,M,I,L
|
'agility_size' => ['type' => 'text'], //S,M,I,L
|
||||||
'active' => ['type'=>'int','default'=>1]
|
'active' => ['type' => 'int', 'default' => 1]
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
function isMyDog($dog = false)
|
||||||
|
{
|
||||||
|
if ($dog == false)
|
||||||
|
$dog = $this->id;
|
||||||
|
|
||||||
|
if (!$this->exists($dog))
|
||||||
|
return false;
|
||||||
|
else {
|
||||||
|
if (in_array($dog, $_SESSION['user']->data['dogs']))
|
||||||
|
return true;
|
||||||
|
else return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -33,11 +33,6 @@ class User extends Model {
|
|||||||
unset($_SESSION['user']);
|
unset($_SESSION['user']);
|
||||||
}
|
}
|
||||||
|
|
||||||
function exists($id)
|
|
||||||
{
|
|
||||||
return $this->redis->exists($this->dbTable.':'.$id);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getAll($filtered = true)
|
function getAll($filtered = true)
|
||||||
{
|
{
|
||||||
$keys = $this->redis->keys($this->dbTable.':*');
|
$keys = $this->redis->keys($this->dbTable.':*');
|
||||||
|
@ -13,6 +13,17 @@ class Dogs extends Page {
|
|||||||
{
|
{
|
||||||
$this->addSubmenuItem('Hunde anzeigen','/dogs','far fa-list-alt');
|
$this->addSubmenuItem('Hunde anzeigen','/dogs','far fa-list-alt');
|
||||||
$this->addSubmenuItem('Hund hinzufügen','/dogs/add','fas fa-plus-circle');
|
$this->addSubmenuItem('Hund hinzufügen','/dogs/add','fas fa-plus-circle');
|
||||||
|
if($_SESSION['user']->data['dogs'] && count($_SESSION['user']->data['dogs']) > 0)
|
||||||
|
{
|
||||||
|
$this->addSubmenuItem('divider','');
|
||||||
|
foreach($_SESSION['user']->data['dogs'] as $dogid)
|
||||||
|
{
|
||||||
|
$dog = new Dog();
|
||||||
|
$dog->load($dogid);
|
||||||
|
$this->addSubmenuItem($dog->data['name'],'/dogs/overview/'.$dogid,'fas fa-dog');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function index() {
|
function index() {
|
||||||
@ -142,6 +153,16 @@ class Dogs extends Page {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function overview()
|
||||||
|
{
|
||||||
|
$dogid = $this->params[0];
|
||||||
|
$d = new Dog();
|
||||||
|
|
||||||
|
if(!$d->isMyDog($dogid))
|
||||||
|
return 'Not your dog :(';
|
||||||
|
return 'hier wird der hund angezeigt';
|
||||||
|
}
|
||||||
|
|
||||||
function maySeeThisPage() {
|
function maySeeThisPage() {
|
||||||
if($_SESSION['user']) //wenn eingeloggt, kein problem
|
if($_SESSION['user']) //wenn eingeloggt, kein problem
|
||||||
return true;
|
return true;
|
||||||
|
@ -20,15 +20,19 @@
|
|||||||
</a>
|
</a>
|
||||||
<ul class="dropdown-menu">
|
<ul class="dropdown-menu">
|
||||||
<?php foreach($item['submenu'] as $sub) : ?>
|
<?php foreach($item['submenu'] as $sub) : ?>
|
||||||
<li>
|
<?php if($sub['text']=='divider') : ?>
|
||||||
<a href="<?= $sub['action'] ?>" hx-push-url="<?= $sub['action'] ?>" hx-get="<?= $sub['action'] ?>" hx-target="#main" class="dropdown-item <?= $sub['classes']?:'' ?>">
|
<li><hr class="dropdown-divider"></li>
|
||||||
<?php if($sub['icon']) : ?>
|
<?php else : ?>
|
||||||
<i class="<?= $sub['icon'] ?>"></i>
|
<li>
|
||||||
<?php endif; ?>
|
<a href="<?= $sub['action'] ?>" hx-push-url="<?= $sub['action'] ?>" hx-get="<?= $sub['action'] ?>" hx-target="#main" class="dropdown-item <?= $sub['classes']?:'' ?>">
|
||||||
|
<?php if($sub['icon']) : ?>
|
||||||
|
<i class="<?= $sub['icon'] ?>"></i>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
<?= $sub['text'] ?>
|
<?= $sub['text'] ?>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<?php endif; ?>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
|
Reference in New Issue
Block a user