<?php
use Jet\UI;
use Jet\Auth;
use Jet\Tr;
use Jet\MVC;

?>

<li class="nav-item dropdown">
	<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown"
	   aria-haspopup="true" aria-expanded="false">
		<?= UI::icon( 'user' ) ?>
		<?= Auth::getCurrentUser()->getUsername() ?>
	</a>
	<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdown">
		
		<?php if(
			($change_password_page = MVC::getPage('change-password')) &&
			$change_password_page->accessAllowed()
		): ?>
			<a class="dropdown-item" href="<?=$change_password_page->getURL() ?>">
				<?= UI::icon( 'cog' ) ?>
				<?= Tr::_( 'Change password' ) ?>
			</a>
			<div class="dropdown-divider"></div>
		<?php endif; ?>
		
		<a class="dropdown-item"
		   href="<?= MVC::getHomePage()->getURL( [], ['logout' => 'logout'] ) ?>">
			<?= UI::icon( 'sign-out-alt' ) ?>
			<?= Tr::_( 'Logout' ) ?>
		</a>
	</div>
</li>
