forked from Public/pics
61 lines
1.3 KiB
PHP
61 lines
1.3 KiB
PHP
|
<?php
|
||
|
/*****************************************************************************
|
||
|
* UserMenu.php
|
||
|
* Contains the user navigation logic.
|
||
|
*
|
||
|
* Global Data Lab code (C) Radboud University Nijmegen
|
||
|
* Programming (C) Aaron van Geffen, 2015-2022
|
||
|
*****************************************************************************/
|
||
|
|
||
|
class UserMenu extends Menu
|
||
|
{
|
||
|
public function __construct()
|
||
|
{
|
||
|
$user = Registry::has('user') ? Registry::get('user') : new Guest();
|
||
|
if ($user->isLoggedIn())
|
||
|
{
|
||
|
$this->items[] = [
|
||
|
'label' => $user->getFirstName(),
|
||
|
'icon' => 'person-circle',
|
||
|
'subs' => [
|
||
|
|
||
|
[
|
||
|
'label' => 'Settings',
|
||
|
'uri' => '/accountsettings/',
|
||
|
],
|
||
|
[
|
||
|
'label' => 'Log out',
|
||
|
'uri' => '/logout/',
|
||
|
],
|
||
|
],
|
||
|
];
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
$this->items[] = [
|
||
|
'label' => 'Log in',
|
||
|
'icon' => 'person-circle',
|
||
|
'uri' => '/login/',
|
||
|
];
|
||
|
}
|
||
|
|
||
|
$this->items[] = [
|
||
|
'label' => 'Home',
|
||
|
'icon' => 'house-door',
|
||
|
'uri' => '/',
|
||
|
];
|
||
|
|
||
|
foreach ($this->items as $i => $item)
|
||
|
{
|
||
|
if (isset($item['uri']))
|
||
|
$this->items[$i]['url'] = BASEURL . $item['uri'];
|
||
|
|
||
|
if (!isset($item['subs']))
|
||
|
continue;
|
||
|
|
||
|
foreach ($item['subs'] as $j => $subitem)
|
||
|
$this->items[$i]['subs'][$j]['url'] = BASEURL . $subitem['uri'];
|
||
|
}
|
||
|
}
|
||
|
}
|