Rev 1545 | Rev 2899 | Ir a la última revisión | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |
<?php
use LeadersLinked\Model\UserType;
$currentUser = $this->currentUserHelper();
if( $currentUser->hasIdentity() ) {
$session_user_id = $currentUser->getUserId();
$session_usertype_id = $currentUser->getUserTypeId();
$user = $currentUser->getUser();
$link_admin = $session_usertype_id == UserType::ADMIN ? 1 : 0;
$container = $this->navigation('menuNavigation')->getContainer();
$acl = $this->viewModel()->getCurrent()->getVariable('acl');
$menu = [];
foreach($container as $page) {
if(!$page || !$page->getRoute() || !$acl->isAllowed($session_usertype_id , $page->getRoute())) {
continue;
}
$option = [
'label' => $page->getLabel(),
'href' => $page->getHref(),
'img' => $page->getClass(),
'childs' => [],
];
$childs = $page->getPages();
if($childs) {
foreach($childs as $child) {
if(!$acl->isAllowed($session_usertype_id , $child->getRoute())) {
continue;
}
array_push($option['childs'], [
'label' => $child->getLabel(),
'href' => $child->getHref(),
]);
}
}
array_push($menu, $option);
}
$menu = json_encode($menu);
$image = $this->url('storage', ['type' => 'user', 'code' => $user->uuid, 'filename' => $user->image ]);
$isChatPage = $this->viewModel()->getCurrent()->getVariable('is_chat');
$routeCheckSession = $this->url('check-session');
$currentUser = $this->currentUserHelper();
$js = <<<JS
const navbarVars={
menu: '$menu',
isChatPage: '$isChatPage' === '1',
routeCheckSession: '$routeCheckSession',
link_admin : '$link_admin',
image: '$image',
fullName: '$fullname',
country: '$country',
visits: '$visits',
connections: '$connections'
}
//TODO is_chat
JS;
$this->inlineScript()->appendScript($js);
$this->inlineScript()->appendFile('/react-bundles/navbar/navbarBundle.js');
echo <<<EOT
<link rel="stylesheet" href="/react-bundles/navbar/main.css">
<div id="react_navbar"></div>
<div id="react_navbar_2"></div>
EOT;
} else {
}