Proyectos de Subversion LeadersLinked - Antes de SPA

Rev

Rev 6159 | Autoría | Comparar con el anterior | Ultima modificación | Ver Log |

<?php

use LeadersLinked\Model\UserType;
use LeadersLinked\Model\User;
use LeadersLinked\Model\Theme;
use LeadersLinked\Model\Network;

$currentUser = $this->currentUserHelper();

$currentNetworkHelper = $this->currentNetworkHelper();
$currentNetwork = $currentNetworkHelper->getNetwork();

$logoForNavbar = $this->networkNavbarHelper();

if ($currentUser->hasIdentity()) {
    $session_user_id        = $currentUser->getUserId();
    $session_usertype_id    = $currentUser->getUserTypeId();
    $user = $currentUser->getUser();


    $acl = $this->viewModel()->getCurrent()->getVariable('acl');

    $link_admin = $session_usertype_id == UserType::ADMIN ? 1 : 0;

    $link_impersonate = $user->is_super_user == User::IS_SUPER_USER_YES ? 1 : 0;

    if ($acl->isAllowed($session_usertype_id,  'knowledge-area')) {
        $route_knowledge_area = $this->url('knowledge-area');
        $link_knowledge_area = 1;
    } else {

        $route_knowledge_area = '';
        $link_knowledge_area = 0;
    }
    
    if ($acl->isAllowed($session_usertype_id,  'my-coach')) {
        $route_my_coach = $this->url('my-coach');
        $link_my_coach = 1;
    } else {
        
        $route_my_coach = '';
        $link_my_coach = 0;
    }

    //$container = $this->navigation('menuNavigation')->getContainer();


    $menu = [];
    foreach ($pages as $page) {

        if (!$page || empty($page['route']) || !$acl->isAllowed($session_usertype_id, $page['route'])) {
            continue;
        }

        $ajax = false;
        if ($page['route'] == 'company' && $currentNetwork->default == Network::DEFAULT_NO) {

            if ($link_company) {
                $page['route'] = $this->url($link_company['route'], ['id' => $link_company['id']]);
                $ajax = true;
            } else {
                continue;
            }
        }

        $option = [
            'label' => $page['label'],
            'href' => $page['route'],
            'img' => empty($page['class']) ? '' : $page['class'],
            'ajax' => $ajax ? 1 : 0,
            'childs' => [],
        ];

        $childs = empty($page['pages']) ? [] : $page['pages'];
        if ($childs) {
            foreach ($childs as $child) {
                if (!$acl->isAllowed($session_usertype_id,  $child['route'])) {
                    continue;
                }

                $childs_level2 = [];

                $childsLevel2 = empty($child['pages']) ? [] : $child['pages'];

                if ($childsLevel2) {
                    foreach ($childsLevel2 as $childLevel2) {
                        if (!$acl->isAllowed($session_usertype_id,  $childLevel2['route'])) {
                            continue;
                        }

                        array_push($childs_level2, [
                            'label' => $childLevel2['label'],
                            'href' => $childLevel2['route'],

                        ]);
                    }
                }

                array_push($option['childs'], [
                    'label' => $child['label'],
                    'href' => $child['route'],
                    'childs' => $childs_level2,
                ]);
            }
        }

        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',
  linkAdmin : '$link_admin' === '1',
  linkImpersonate : '$link_impersonate' === '1',
  image: '$image',
  fullName: '$fullname',
  country: '$country',
  visits: '$visits',
  connections: '$connections',
  logoForNavbar: '$logoForNavbar',
  defaultNetwork: '$currentNetwork->default',
  linkKnowledgeArea: $link_knowledge_area === 1,
  routeKnowledgeArea: '$route_knowledge_area',
  linkMyCoach: $link_my_coach === 1,
  routeMyCoach: '$route_my_coach',
}

const MENU_LABELS = {
  MY_GROUPS: 'LABEL_MY_GROUPS',
  GROUPS: 'LABEL_GROUPS',
  WHAT_ARE_YOU_THINKING: 'LABEL_WHAT_ARE_YOU_THINKING',
  GROUP_VIEW: 'LABEL_GROUP_VIEW',
  VIEW_MORE: 'LABEL_VIEW_MORE',
  VIEW_LESS: 'LABEL_VIEW_LESS',
  WHO_HAS_SEEN_MY_PROFILE: 'LABEL_WHO_HAS_SEEN_MY_PROFILE',
  CONNECT_WITH: 'LABEL_CONNECT_WITH',
  POSTS: 'LABEL_POSTS',
  DATATABLE_EMPTY: 'LABEL_DATATABLE_EMPTY',
  CONNECT: 'LABEL_CONNECT',
  CANCEL: 'LABEL_CANCEL',
  NOT_AVAILABLE_POSTS: 'LABEL_NOT_AVAILABLE_POSTS',
  MICRO_LEARNING: 'LABEL_MICRO_LEARNING',
  NOT_AVAILABLE_FEEDS: 'LABEL_NOT_AVAILABLE_FEEDS',
  SEND: 'LABEL_SEND',
  SHARE_A_POST: 'LABEL_SHARE_A_POST',
  SHARE_WITH: 'LABEL_SHARE_WITH',
  CONNECTIONS: 'LABEL_CONNECTIONS',
  PUBLIC: 'LABEL_PUBLIC',
  SUGGEST_GROUPS: 'LABEL_SUGGEST_GROUPS',
  VIEW_RECOMMENDATIONS: 'LABEL_VIEW_RECOMMENDATIONS',
  IMAGE: 'LABEL_IMAGE',
  DOCUMENT: 'LABEL_DOCUMENT',
  AUDIO: 'LABEL_AUDIO',
  VIDEO: 'LABEL_VIDEO',
  WRITE_A_POST: 'LABEL_WRITE_A_POST',
  DELETE: 'LABEL_DELETE',
  DOWNLOAD: 'LABEL_DOWNLOAD',
  READ_MORE: 'LABEL_READ_MORE',
  READ_LESS: 'LABEL_READ_LESS',
  LIKE: 'LABEL_LIKE',
  COMMENT: 'LABEL_COMMENT',
  SHARE: 'LABEL_SHARE',
  SHARED: 'LABEL_SHARED',
  COMMENTS: 'LABEL_COMMENTS',
  SENDS: 'LABEL_SENDS',
  WRITE_A_COMMENT: 'LABEL_WRITE_A_COMMENT'
}

//TODO is_chat
JS;
    $this->inlineScript()->appendScript($js);

    if ($currentNetwork->theme_id == Theme::THEME_LEADERSLINKED_LINKEDIN) {
        $this->inlineScript()->appendFile('/react-bundles/navbar/linkedin/navbarBundle.js');
    } else {
        $this->inlineScript()->appendFile('/react-bundles/navbar/default/navbarBundle.js');
    }

    echo <<<EOT
        <div id="react_navbar"></div>
    EOT;
} else {
}