parent
							
								
									ba300d0421
								
							
						
					
					
						commit
						c5033bd6b1
					
				@ -1,440 +0,0 @@ | 
				
			|||||||
<?php | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* For licensing terms, see /license.txt */ | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace Chamilo\CoreBundle\Menu; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
use Knp\Menu\FactoryInterface; | 
					 | 
				
			||||||
use Knp\Menu\ItemInterface; | 
					 | 
				
			||||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface; | 
					 | 
				
			||||||
use Symfony\Component\DependencyInjection\ContainerAwareTrait; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Class LeftMenuBuilder. | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
class LeftMenuBuilder implements ContainerAwareInterface | 
					 | 
				
			||||||
{ | 
					 | 
				
			||||||
    use ContainerAwareTrait; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /** | 
					 | 
				
			||||||
     * Course menu. | 
					 | 
				
			||||||
     * | 
					 | 
				
			||||||
     * @return ItemInterface | 
					 | 
				
			||||||
     */ | 
					 | 
				
			||||||
    public function courseMenu(FactoryInterface $factory, array $options) | 
					 | 
				
			||||||
    { | 
					 | 
				
			||||||
        $menu = $factory->createItem('root'); | 
					 | 
				
			||||||
        $translator = $this->container->get('translator'); | 
					 | 
				
			||||||
        $checked = $this->container->get('session')->get('IS_AUTHENTICATED_FULLY'); | 
					 | 
				
			||||||
        //$settingsManager = $this->container->get('chamilo.settings.manager'); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if ($checked) { | 
					 | 
				
			||||||
            $menu->setChildrenAttribute('class', 'nav nav-pills nav-stacked'); | 
					 | 
				
			||||||
            $menu->addChild( | 
					 | 
				
			||||||
                $translator->trans('My courses'), | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'route' => 'userportal', | 
					 | 
				
			||||||
                    'routeParameters' => ['type' => 'courses'], | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            ); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            return $menu; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (api_is_allowed_to_create_course()) { | 
					 | 
				
			||||||
                $lang = $translator->trans('Create course'); | 
					 | 
				
			||||||
                if ('true' == $settingsManager->getSetting('course.course_validation')) { | 
					 | 
				
			||||||
                    $lang = $translator->trans('CreateCourseRequest'); | 
					 | 
				
			||||||
                } | 
					 | 
				
			||||||
                $menu->addChild( | 
					 | 
				
			||||||
                    $lang, | 
					 | 
				
			||||||
                    ['route' => 'add_course'] | 
					 | 
				
			||||||
                ); | 
					 | 
				
			||||||
            } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $link = $this->container->get('router')->generate('web_main'); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $menu->addChild( | 
					 | 
				
			||||||
                $translator->trans('ManageCourses'), | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'uri' => $link.'auth/courses.php?action=sortmycourses', | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            ); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $browse = $settingsManager->getSetting('display.allow_students_to_browse_courses'); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if ('true' == $browse) { | 
					 | 
				
			||||||
                if ($checker->isGranted('ROLE_STUDENT') && !api_is_drh( | 
					 | 
				
			||||||
                    ) && !api_is_session_admin() | 
					 | 
				
			||||||
                ) { | 
					 | 
				
			||||||
                    $menu->addChild( | 
					 | 
				
			||||||
                        $translator->trans('CourseCatalog'), | 
					 | 
				
			||||||
                        [ | 
					 | 
				
			||||||
                            'uri' => $link.'auth/courses.php', | 
					 | 
				
			||||||
                        ] | 
					 | 
				
			||||||
                    ); | 
					 | 
				
			||||||
                } else { | 
					 | 
				
			||||||
                    $menu->addChild( | 
					 | 
				
			||||||
                        $translator->trans('Dashboard'), | 
					 | 
				
			||||||
                        [ | 
					 | 
				
			||||||
                            'uri' => $link.'dashboard/index.php', | 
					 | 
				
			||||||
                        ] | 
					 | 
				
			||||||
                    ); | 
					 | 
				
			||||||
                } | 
					 | 
				
			||||||
            } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            /** @var \Knp\Menu\MenuItem $menu */ | 
					 | 
				
			||||||
            $menu->addChild( | 
					 | 
				
			||||||
                $translator->trans('History'), | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'route' => 'userportal', | 
					 | 
				
			||||||
                    'routeParameters' => [ | 
					 | 
				
			||||||
                        'type' => 'sessions', | 
					 | 
				
			||||||
                        'filter' => 'history', | 
					 | 
				
			||||||
                    ], | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            ); | 
					 | 
				
			||||||
        } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $menu; | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /** | 
					 | 
				
			||||||
     * Course menu. | 
					 | 
				
			||||||
     * | 
					 | 
				
			||||||
     * @return ItemInterface | 
					 | 
				
			||||||
     */ | 
					 | 
				
			||||||
    public function sessionMenu(FactoryInterface $factory, array $options) | 
					 | 
				
			||||||
    { | 
					 | 
				
			||||||
        $checker = $this->container->get('security.authorization_checker'); | 
					 | 
				
			||||||
        $menu = $factory->createItem('root'); | 
					 | 
				
			||||||
        $translator = $this->container->get('translator'); | 
					 | 
				
			||||||
        //$settingsManager = $this->container->get('chamilo.settings.manager'); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if ($checker->isGranted('IS_AUTHENTICATED_FULLY')) { | 
					 | 
				
			||||||
            $menu->setChildrenAttribute('class', 'nav nav-pills nav-stacked'); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $menu->addChild( | 
					 | 
				
			||||||
                $translator->trans('My sessions'), | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'route' => 'userportal', | 
					 | 
				
			||||||
                    'routeParameters' => ['type' => 'sessions'], | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            ); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if ($checker->isGranted('ROLE_ADMIN')) { | 
					 | 
				
			||||||
                $menu->addChild( | 
					 | 
				
			||||||
                    $translator->trans('Add a training session'), | 
					 | 
				
			||||||
                    [ | 
					 | 
				
			||||||
                        'route' => 'legacy_main', | 
					 | 
				
			||||||
                        'routeParameters' => ['name' => 'session/session_add.php'], | 
					 | 
				
			||||||
                    ] | 
					 | 
				
			||||||
                ); | 
					 | 
				
			||||||
            } | 
					 | 
				
			||||||
        } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $menu; | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /** | 
					 | 
				
			||||||
     * @return ItemInterface | 
					 | 
				
			||||||
     */ | 
					 | 
				
			||||||
    public function profileMenu(FactoryInterface $factory, array $options) | 
					 | 
				
			||||||
    { | 
					 | 
				
			||||||
        $menu = $factory->createItem('root'); | 
					 | 
				
			||||||
        $security = $this->container->get('security.authorization_checker'); | 
					 | 
				
			||||||
        $translator = $this->container->get('translator'); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if ($security->isGranted('IS_AUTHENTICATED_FULLY')) { | 
					 | 
				
			||||||
            $menu->setChildrenAttribute('class', 'navbar-nav'); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $menu->addChild( | 
					 | 
				
			||||||
                $translator->trans('Inbox'), | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'route' => 'legacy_main', | 
					 | 
				
			||||||
                    'routeParameters' => [ | 
					 | 
				
			||||||
                        'name' => 'messages/inbox.php', | 
					 | 
				
			||||||
                    ], | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            ); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $menu->addChild( | 
					 | 
				
			||||||
                $translator->trans('Compose'), | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'route' => 'legacy_main', | 
					 | 
				
			||||||
                    'routeParameters' => [ | 
					 | 
				
			||||||
                        'name' => 'messages/new_message.php', | 
					 | 
				
			||||||
                    ], | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            ); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $menu->addChild( | 
					 | 
				
			||||||
                $translator->trans('Pending invitations'), | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'route' => 'legacy_main', | 
					 | 
				
			||||||
                    'routeParameters' => [ | 
					 | 
				
			||||||
                        'name' => 'social/invitations.php', | 
					 | 
				
			||||||
                    ], | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            ); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            /*$menu->addChild( | 
					 | 
				
			||||||
                $translator->trans('My files'), | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'route' => 'legacy_main', | 
					 | 
				
			||||||
                    'routeParameters' => [ | 
					 | 
				
			||||||
                        'name' => 'social/myfiles.php', | 
					 | 
				
			||||||
                    ], | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            );*/ | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $menu->addChild( | 
					 | 
				
			||||||
                $translator->trans('Edit profile'), | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'route' => 'legacy_main', | 
					 | 
				
			||||||
                    'routeParameters' => [ | 
					 | 
				
			||||||
                        'name' => 'messages/inbox.php', | 
					 | 
				
			||||||
                    ], | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            ); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $menu->addChild( | 
					 | 
				
			||||||
                $translator->trans('Inbox'), | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'route' => 'legacy_main', | 
					 | 
				
			||||||
                    'routeParameters' => [ | 
					 | 
				
			||||||
                        'name' => 'messages/inbox.php', | 
					 | 
				
			||||||
                    ], | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            ); | 
					 | 
				
			||||||
        } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Set CSS classes for the items | 
					 | 
				
			||||||
        foreach ($menu->getChildren() as $child) { | 
					 | 
				
			||||||
            $child | 
					 | 
				
			||||||
                ->setLinkAttribute('class', 'nav-link') | 
					 | 
				
			||||||
                ->setAttribute('class', 'nav-item'); | 
					 | 
				
			||||||
        } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $menu; | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /** | 
					 | 
				
			||||||
     * @todo add validations | 
					 | 
				
			||||||
     * | 
					 | 
				
			||||||
     * @return ItemInterface | 
					 | 
				
			||||||
     */ | 
					 | 
				
			||||||
    public function socialMenu(FactoryInterface $factory, array $options) | 
					 | 
				
			||||||
    { | 
					 | 
				
			||||||
        $menu = $factory->createItem('root'); | 
					 | 
				
			||||||
        $security = $this->container->get('security.authorization_checker'); | 
					 | 
				
			||||||
        $translator = $this->container->get('translator'); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if ($security->isGranted('IS_AUTHENTICATED_FULLY')) { | 
					 | 
				
			||||||
            $menu->setChildrenAttribute('class', 'nav nav-pills nav-stacked'); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $menu->addChild( | 
					 | 
				
			||||||
                $translator->trans('Home'), | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'route' => 'legacy_main', | 
					 | 
				
			||||||
                    'routeParameters' => [ | 
					 | 
				
			||||||
                        'name' => 'social/home.php', | 
					 | 
				
			||||||
                    ], | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            ); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $menu->addChild( | 
					 | 
				
			||||||
                $translator->trans('Messages'), | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'route' => 'legacy_main', | 
					 | 
				
			||||||
                    'routeParameters' => [ | 
					 | 
				
			||||||
                        'name' => 'messages/inbox.php', | 
					 | 
				
			||||||
                    ], | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            ); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $menu->addChild( | 
					 | 
				
			||||||
                $translator->trans('Invitations'), | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'route' => 'legacy_main', | 
					 | 
				
			||||||
                    'routeParameters' => [ | 
					 | 
				
			||||||
                        'name' => 'social/invitations.php', | 
					 | 
				
			||||||
                    ], | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            ); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $menu->addChild( | 
					 | 
				
			||||||
                $translator->trans('My shared profile'), | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'route' => 'legacy_main', | 
					 | 
				
			||||||
                    'routeParameters' => [ | 
					 | 
				
			||||||
                        'name' => 'social/profile.php', | 
					 | 
				
			||||||
                    ], | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            ); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $menu->addChild( | 
					 | 
				
			||||||
                $translator->trans('Friends'), | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'route' => 'legacy_main', | 
					 | 
				
			||||||
                    'routeParameters' => [ | 
					 | 
				
			||||||
                        'name' => 'social/friends.php', | 
					 | 
				
			||||||
                    ], | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            ); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $menu->addChild( | 
					 | 
				
			||||||
                $translator->trans('Social groups'), | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'route' => 'legacy_main', | 
					 | 
				
			||||||
                    'routeParameters' => [ | 
					 | 
				
			||||||
                        'name' => 'social/groups.php', | 
					 | 
				
			||||||
                    ], | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            ); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $menu->addChild( | 
					 | 
				
			||||||
                $translator->trans('Search'), | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'route' => 'legacy_main', | 
					 | 
				
			||||||
                    'routeParameters' => [ | 
					 | 
				
			||||||
                        'name' => 'social/search.php', | 
					 | 
				
			||||||
                    ], | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            ); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            /*$menu->addChild( | 
					 | 
				
			||||||
                $translator->trans('My files'), | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'route' => 'legacy_main', | 
					 | 
				
			||||||
                    'routeParameters' => [ | 
					 | 
				
			||||||
                        'name' => 'social/myfiles.php', | 
					 | 
				
			||||||
                    ], | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            );*/ | 
					 | 
				
			||||||
        } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $menu; | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /** | 
					 | 
				
			||||||
     * Skills menu. | 
					 | 
				
			||||||
     * | 
					 | 
				
			||||||
     * @return ItemInterface | 
					 | 
				
			||||||
     */ | 
					 | 
				
			||||||
    public function skillsMenu(FactoryInterface $factory, array $options) | 
					 | 
				
			||||||
    { | 
					 | 
				
			||||||
        $checker = $this->container->get('security.authorization_checker'); | 
					 | 
				
			||||||
        $translator = $this->container->get('translator'); | 
					 | 
				
			||||||
        $settingsManager = $this->container->get('chamilo.settings.manager'); | 
					 | 
				
			||||||
        $allow = $settingsManager->getSetting('certificate.hide_my_certificate_link'); | 
					 | 
				
			||||||
        $menu = $factory->createItem('root'); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if ($checker->isGranted('IS_AUTHENTICATED_FULLY')) { | 
					 | 
				
			||||||
            $menu->setChildrenAttribute('class', 'nav nav-pills nav-stacked'); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if ('false' === $allow) { | 
					 | 
				
			||||||
                $menu->addChild( | 
					 | 
				
			||||||
                    $translator->trans('My certificates'), | 
					 | 
				
			||||||
                    [ | 
					 | 
				
			||||||
                        'route' => 'legacy_main', | 
					 | 
				
			||||||
                        'routeParameters' => ['name' => 'gradebook/my_certificates.php'], | 
					 | 
				
			||||||
                    ] | 
					 | 
				
			||||||
                ); | 
					 | 
				
			||||||
            } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if ('true' === $settingsManager->getSetting('allow_public_certificates')) { | 
					 | 
				
			||||||
                $menu->addChild( | 
					 | 
				
			||||||
                    $translator->trans('Search'), | 
					 | 
				
			||||||
                    [ | 
					 | 
				
			||||||
                        'route' => 'legacy_main', | 
					 | 
				
			||||||
                        'routeParameters' => ['name' => 'gradebook/search.php'], | 
					 | 
				
			||||||
                    ] | 
					 | 
				
			||||||
                ); | 
					 | 
				
			||||||
            } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if ('true' === $settingsManager->getSetting('allow_skills_tool')) { | 
					 | 
				
			||||||
                $menu->addChild( | 
					 | 
				
			||||||
                    $translator->trans('MySkills'), | 
					 | 
				
			||||||
                    [ | 
					 | 
				
			||||||
                        'route' => 'legacy_main', | 
					 | 
				
			||||||
                        'routeParameters' => ['name' => 'social/my_skills_report.php'], | 
					 | 
				
			||||||
                    ] | 
					 | 
				
			||||||
                ); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if ($checker->isGranted('ROLE_TEACHER')) { | 
					 | 
				
			||||||
                    $menu->addChild( | 
					 | 
				
			||||||
                        $translator->trans('ManageSkills'), | 
					 | 
				
			||||||
                        [ | 
					 | 
				
			||||||
                            'route' => 'legacy_main', | 
					 | 
				
			||||||
                            'routeParameters' => ['name' => 'admin/skills_wheel.php'], | 
					 | 
				
			||||||
                        ] | 
					 | 
				
			||||||
                    ); | 
					 | 
				
			||||||
                } | 
					 | 
				
			||||||
            } | 
					 | 
				
			||||||
        } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $menu; | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /** | 
					 | 
				
			||||||
     * Register/reset password menu. | 
					 | 
				
			||||||
     * | 
					 | 
				
			||||||
     * @return ItemInterface | 
					 | 
				
			||||||
     */ | 
					 | 
				
			||||||
    public function loginMenu(FactoryInterface $factory, array $options) | 
					 | 
				
			||||||
    { | 
					 | 
				
			||||||
        $menu = $factory->createItem('legacy_main'); | 
					 | 
				
			||||||
        $translator = $this->container->get('translator'); | 
					 | 
				
			||||||
        $settingManager = $this->container->get('chamilo.settings.manager'); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if ('true' === $settingManager->getSetting('allow_registration')) { | 
					 | 
				
			||||||
            $menu->addChild( | 
					 | 
				
			||||||
                $translator->trans( | 
					 | 
				
			||||||
                    'registration.submit', | 
					 | 
				
			||||||
                    [], | 
					 | 
				
			||||||
                    'FOSUserBundle' | 
					 | 
				
			||||||
                ), | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'route' => 'legacy_main', | 
					 | 
				
			||||||
                    'routeParameters' => ['name' => 'auth/inscription.php'], | 
					 | 
				
			||||||
                    ['attributes' => ['id' => 'nav']], | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            ); | 
					 | 
				
			||||||
        } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if ('true' === $settingManager->getSetting('allow_lostpassword')) { | 
					 | 
				
			||||||
            $menu->addChild( | 
					 | 
				
			||||||
                $translator->trans( | 
					 | 
				
			||||||
                    'resetting.request.submit', | 
					 | 
				
			||||||
                    [], | 
					 | 
				
			||||||
                    'FOSUserBundle' | 
					 | 
				
			||||||
                ), | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'route' => 'legacy_main', | 
					 | 
				
			||||||
                    'routeParameters' => ['name' => 'auth/lostPassword.php'], | 
					 | 
				
			||||||
                    ['attributes' => ['id' => 'nav']], | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            ); | 
					 | 
				
			||||||
        } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $menu; | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /** | 
					 | 
				
			||||||
     * @return ItemInterface | 
					 | 
				
			||||||
     */ | 
					 | 
				
			||||||
    public function helpMenu(FactoryInterface $factory, array $options) | 
					 | 
				
			||||||
    { | 
					 | 
				
			||||||
        $translator = $this->container->get('translator'); | 
					 | 
				
			||||||
        $menu = $factory->createItem('legacy_main'); | 
					 | 
				
			||||||
        $menu->addChild( | 
					 | 
				
			||||||
            $translator->trans('Forum'), | 
					 | 
				
			||||||
            [ | 
					 | 
				
			||||||
                'uri' => 'https://chamilo.org/forum/', | 
					 | 
				
			||||||
                ['attributes' => ['id' => 'nav']], | 
					 | 
				
			||||||
            ] | 
					 | 
				
			||||||
        ); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $menu; | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,60 +0,0 @@ | 
				
			|||||||
<?php | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* For licensing terms, see /license.txt */ | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace Chamilo\CoreBundle\Menu; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
use Knp\Menu\ItemInterface; | 
					 | 
				
			||||||
use Knp\Menu\Matcher\Voter\VoterInterface; | 
					 | 
				
			||||||
use Symfony\Component\HttpFoundation\RequestStack; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Class NavBuilder. | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
class MenuVoter implements VoterInterface | 
					 | 
				
			||||||
{ | 
					 | 
				
			||||||
    /** | 
					 | 
				
			||||||
     * @var RequestStack | 
					 | 
				
			||||||
     */ | 
					 | 
				
			||||||
    private $requestStack; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function __construct(RequestStack $requestStack) | 
					 | 
				
			||||||
    { | 
					 | 
				
			||||||
        $this->requestStack = $requestStack; | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function matchItem(ItemInterface $item): ?bool | 
					 | 
				
			||||||
    { | 
					 | 
				
			||||||
        $request = $this->requestStack->getCurrentRequest(); | 
					 | 
				
			||||||
        $currentUri = $item->getUri(); | 
					 | 
				
			||||||
        $currentUrl = $request->getUri(); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (null !== $item->getExtra('routes') && | 
					 | 
				
			||||||
            in_array($request->attributes->get('_route'), $item->getExtra('routes')) | 
					 | 
				
			||||||
        ) { | 
					 | 
				
			||||||
            return true; | 
					 | 
				
			||||||
        } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (false !== strpos($currentUri, 'user_portal.php') && | 
					 | 
				
			||||||
            false !== strpos($currentUrl, 'user_portal.php') | 
					 | 
				
			||||||
        ) { | 
					 | 
				
			||||||
            return true; | 
					 | 
				
			||||||
        } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if (false !== strpos($currentUri, '/main/')) { | 
					 | 
				
			||||||
            $pos = strpos($currentUri, '/main/'); | 
					 | 
				
			||||||
            $partSelected = substr($currentUri, $pos); | 
					 | 
				
			||||||
            $partSelected = str_replace('/%2E%2E/', '', $partSelected); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $pos = strpos($currentUrl, '/main/'); | 
					 | 
				
			||||||
            $partCurrent = substr($currentUrl, $pos); | 
					 | 
				
			||||||
            $partCurrent = rtrim($partCurrent, '/'); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if ($partSelected === $partCurrent) { | 
					 | 
				
			||||||
                return true; | 
					 | 
				
			||||||
            } | 
					 | 
				
			||||||
        } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return false; | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,498 +0,0 @@ | 
				
			|||||||
<?php | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/* For licensing terms, see /license.txt */ | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace Chamilo\CoreBundle\Menu; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
use Chamilo\FaqBundle\Entity\Category; | 
					 | 
				
			||||||
use Chamilo\PageBundle\Entity\Page; | 
					 | 
				
			||||||
use Chamilo\PageBundle\Entity\Site; | 
					 | 
				
			||||||
use Knp\Menu\FactoryInterface; | 
					 | 
				
			||||||
use Knp\Menu\ItemInterface; | 
					 | 
				
			||||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface; | 
					 | 
				
			||||||
use Symfony\Component\DependencyInjection\ContainerAwareTrait; | 
					 | 
				
			||||||
use Symfony\Component\Security\Core\Authorization\AuthorizationChecker; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
/** | 
					 | 
				
			||||||
 * Class NavBuilder. | 
					 | 
				
			||||||
 */ | 
					 | 
				
			||||||
class NavBuilder implements ContainerAwareInterface | 
					 | 
				
			||||||
{ | 
					 | 
				
			||||||
    use ContainerAwareTrait; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    private $factory; | 
					 | 
				
			||||||
    private $checker; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    public function __construct(FactoryInterface $factory, AuthorizationChecker $checker) | 
					 | 
				
			||||||
    { | 
					 | 
				
			||||||
        $this->factory = $factory; | 
					 | 
				
			||||||
        $this->checker = $checker; | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /** | 
					 | 
				
			||||||
     * @param array  $itemOptions The options given to the created menuItem | 
					 | 
				
			||||||
     * @param string $currentUri  The current URI | 
					 | 
				
			||||||
     * | 
					 | 
				
			||||||
     * @return ItemInterface | 
					 | 
				
			||||||
     */ | 
					 | 
				
			||||||
    public function createCategoryMenu(array $itemOptions = [], $currentUri = null) | 
					 | 
				
			||||||
    { | 
					 | 
				
			||||||
        $factory = $this->container->get('knp_menu.factory'); | 
					 | 
				
			||||||
        $menu = $factory->createItem('categories', $itemOptions); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $this->buildCategoryMenu($menu, $itemOptions, $currentUri); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $menu; | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /** | 
					 | 
				
			||||||
     * @param ItemInterface $menu       The item to fill with $routes | 
					 | 
				
			||||||
     * @param array         $options    The item options | 
					 | 
				
			||||||
     * @param string        $currentUri The current URI | 
					 | 
				
			||||||
     */ | 
					 | 
				
			||||||
    public function buildCategoryMenu(ItemInterface $menu, array $options = [], $currentUri = null) | 
					 | 
				
			||||||
    { | 
					 | 
				
			||||||
        //$categories = $this->categoryManager->getCategoryTree(); | 
					 | 
				
			||||||
        //$this->fillMenu($menu, $categories, $options, $currentUri); | 
					 | 
				
			||||||
        $menu->addChild('home', ['route' => 'home']); | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /** | 
					 | 
				
			||||||
     * Top menu left. | 
					 | 
				
			||||||
     */ | 
					 | 
				
			||||||
    public function menuApp(array $options): ItemInterface | 
					 | 
				
			||||||
    { | 
					 | 
				
			||||||
        $container = $this->container; | 
					 | 
				
			||||||
        $checker = $this->checker; | 
					 | 
				
			||||||
        $translator = $container->get('translator'); | 
					 | 
				
			||||||
        $router = $container->get('router'); | 
					 | 
				
			||||||
        $factory = $this->factory; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $menu = $factory->createItem('root', ['childrenAttributes' => ['class' => 'navbar-nav']]); | 
					 | 
				
			||||||
        $settingsManager = $container->get('chamilo.settings.manager'); | 
					 | 
				
			||||||
        $rootWeb = $router->generate('home'); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $menu->addChild( | 
					 | 
				
			||||||
            'home', | 
					 | 
				
			||||||
            [ | 
					 | 
				
			||||||
                'label' => $translator->trans('Home'), | 
					 | 
				
			||||||
                'route' => 'home', | 
					 | 
				
			||||||
                'icon' => 'home', | 
					 | 
				
			||||||
            ] | 
					 | 
				
			||||||
        ); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if ($checker && $checker->isGranted('IS_AUTHENTICATED_FULLY')) { | 
					 | 
				
			||||||
            $menu->addChild( | 
					 | 
				
			||||||
                'courses', | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'label' => $translator->trans('Courses'), | 
					 | 
				
			||||||
                    'route' => 'legacy_main', | 
					 | 
				
			||||||
                    'routeParameters' => ['name' => 'index/user_portal.php'], | 
					 | 
				
			||||||
                    'icon' => 'book', | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            )->setLinkAttribute('class', 'jui'); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $menu['courses']->addChild( | 
					 | 
				
			||||||
                'courses', | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'label' => $translator->trans('My courses'), | 
					 | 
				
			||||||
                    'route' => 'legacy_main', | 
					 | 
				
			||||||
                    'routeParameters' => ['name' => 'index/user_portal.php'], | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            ); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $browse = $settingsManager->getSetting('display.allow_students_to_browse_courses'); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if ('true' === $browse) { | 
					 | 
				
			||||||
                if ($checker->isGranted('ROLE_STUDENT') && !api_is_drh() && !api_is_session_admin()) { | 
					 | 
				
			||||||
                    $menu['courses']->addChild( | 
					 | 
				
			||||||
                        'catalog', | 
					 | 
				
			||||||
                        [ | 
					 | 
				
			||||||
                            'label' => $translator->trans('Course catalog'), | 
					 | 
				
			||||||
                            'route' => 'legacy_main', | 
					 | 
				
			||||||
                            'routeParameters' => ['name' => 'auth/courses.php'], | 
					 | 
				
			||||||
                        ] | 
					 | 
				
			||||||
                    ); | 
					 | 
				
			||||||
                } | 
					 | 
				
			||||||
            } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            /*$menu['courses']->addChild( | 
					 | 
				
			||||||
                $translator->trans('Course history'), | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'route' => 'legacy_main', | 
					 | 
				
			||||||
                    'routeParameters' => ['name' => '../user_portal.php'], | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            );*/ | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (api_is_allowed_to_create_course()) { | 
					 | 
				
			||||||
                $lang = $translator->trans('Create course'); | 
					 | 
				
			||||||
                if ('true' === $settingsManager->getSetting('course.course_validation')) { | 
					 | 
				
			||||||
                    $lang = $translator->trans('Create course request'); | 
					 | 
				
			||||||
                } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                $menu['courses']->addChild( | 
					 | 
				
			||||||
                    'create-course', | 
					 | 
				
			||||||
                    [ | 
					 | 
				
			||||||
                        'label' => $lang, | 
					 | 
				
			||||||
                        'route' => 'legacy_main', | 
					 | 
				
			||||||
                        'routeParameters' => ['name' => 'create_course/add_course.php'], | 
					 | 
				
			||||||
                    ] | 
					 | 
				
			||||||
                ); | 
					 | 
				
			||||||
            } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if ($checker->isGranted('ROLE_ADMIN')) { | 
					 | 
				
			||||||
                $menu['courses']->addChild( | 
					 | 
				
			||||||
                    $translator->trans('Create session'), | 
					 | 
				
			||||||
                    [ | 
					 | 
				
			||||||
                        'route' => 'legacy_main', | 
					 | 
				
			||||||
                        'routeParameters' => ['name' => 'session/session_add.php'], | 
					 | 
				
			||||||
                    ] | 
					 | 
				
			||||||
                ); | 
					 | 
				
			||||||
            } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $menu->addChild( | 
					 | 
				
			||||||
                'calendar', | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'label' => $translator->trans('Calendar'), | 
					 | 
				
			||||||
                    'route' => 'legacy_main', | 
					 | 
				
			||||||
                    'routeParameters' => ['name' => 'calendar/agenda_js.php'], | 
					 | 
				
			||||||
                    'icon' => 'calendar-alt', | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            ); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $menu->addChild( | 
					 | 
				
			||||||
                'reports', | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'label' => $translator->trans('Reporting'), | 
					 | 
				
			||||||
                    'route' => 'legacy_main', | 
					 | 
				
			||||||
                    'routeParameters' => ['name' => 'mySpace/index.php'], | 
					 | 
				
			||||||
                    'icon' => 'chart-bar', | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            ); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if ('true' === $settingsManager->getSetting('social.allow_social_tool')) { | 
					 | 
				
			||||||
                $menu->addChild( | 
					 | 
				
			||||||
                    'social', | 
					 | 
				
			||||||
                    [ | 
					 | 
				
			||||||
                        'label' => $translator->trans('Social'), | 
					 | 
				
			||||||
                        'route' => 'legacy_main', | 
					 | 
				
			||||||
                        'routeParameters' => ['name' => 'social/home.php'], | 
					 | 
				
			||||||
                        'icon' => 'heart', | 
					 | 
				
			||||||
                    ] | 
					 | 
				
			||||||
                ); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                /*$menu['social']->addChild( | 
					 | 
				
			||||||
                    $translator->trans('My profile'), | 
					 | 
				
			||||||
                    [ | 
					 | 
				
			||||||
                        'route' => 'legacy_main', | 
					 | 
				
			||||||
                        'routeParameters' => ['name' => 'social/home.php'], | 
					 | 
				
			||||||
                    ] | 
					 | 
				
			||||||
                ); | 
					 | 
				
			||||||
                $menu['social']->addChild( | 
					 | 
				
			||||||
                    $translator->trans('My shared profile'), | 
					 | 
				
			||||||
                    [ | 
					 | 
				
			||||||
                        'route' => 'legacy_main', | 
					 | 
				
			||||||
                        'routeParameters' => ['name' => 'social/profile.php'], | 
					 | 
				
			||||||
                    ] | 
					 | 
				
			||||||
                );*/ | 
					 | 
				
			||||||
                $menu['social']->addChild( | 
					 | 
				
			||||||
                    $translator->trans('Friends'), | 
					 | 
				
			||||||
                    [ | 
					 | 
				
			||||||
                        'route' => 'legacy_main', | 
					 | 
				
			||||||
                        'routeParameters' => ['name' => 'social/friends.php'], | 
					 | 
				
			||||||
                    ] | 
					 | 
				
			||||||
                ); | 
					 | 
				
			||||||
                $menu['social']->addChild( | 
					 | 
				
			||||||
                    $translator->trans('Groups'), | 
					 | 
				
			||||||
                    [ | 
					 | 
				
			||||||
                        'route' => 'legacy_main', | 
					 | 
				
			||||||
                        'routeParameters' => ['name' => 'social/groups.php'], | 
					 | 
				
			||||||
                    ] | 
					 | 
				
			||||||
                ); | 
					 | 
				
			||||||
                /*$menu['social']->addChild( | 
					 | 
				
			||||||
                    $translator->trans('My Files'), | 
					 | 
				
			||||||
                    [ | 
					 | 
				
			||||||
                        'route' => 'legacy_main', | 
					 | 
				
			||||||
                        'routeParameters' => ['name' => 'social/myfiles.php'], | 
					 | 
				
			||||||
                    ] | 
					 | 
				
			||||||
                );*/ | 
					 | 
				
			||||||
            } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if ($checker->isGranted('ROLE_ADMIN')) { | 
					 | 
				
			||||||
                $menu->addChild( | 
					 | 
				
			||||||
                    'administrator', | 
					 | 
				
			||||||
                    [ | 
					 | 
				
			||||||
                        'label' => $translator->trans('Administration'), | 
					 | 
				
			||||||
                        'route' => 'legacy_main', | 
					 | 
				
			||||||
                        'routeParameters' => ['name' => 'admin/index.php'], | 
					 | 
				
			||||||
                        'icon' => 'cogs', | 
					 | 
				
			||||||
                    ] | 
					 | 
				
			||||||
                ); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                $menu['administrator']->addChild( | 
					 | 
				
			||||||
                    'options', | 
					 | 
				
			||||||
                    [ | 
					 | 
				
			||||||
                        'label' => $translator->trans('All options'), | 
					 | 
				
			||||||
                        'route' => 'legacy_main', | 
					 | 
				
			||||||
                        'routeParameters' => ['name' => 'admin/index.php'], | 
					 | 
				
			||||||
                    ] | 
					 | 
				
			||||||
                ); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                $menu['administrator']->addChild( | 
					 | 
				
			||||||
                    'userlist', | 
					 | 
				
			||||||
                    [ | 
					 | 
				
			||||||
                        'label' => $translator->trans('Users'), | 
					 | 
				
			||||||
                        'route' => 'legacy_main', | 
					 | 
				
			||||||
                        'routeParameters' => ['name' => 'admin/user_list.php'], | 
					 | 
				
			||||||
                    ] | 
					 | 
				
			||||||
                ); | 
					 | 
				
			||||||
                $menu['administrator']->addChild( | 
					 | 
				
			||||||
                    'courselist', | 
					 | 
				
			||||||
                    [ | 
					 | 
				
			||||||
                        'label' => $translator->trans('Courses'), | 
					 | 
				
			||||||
                        'route' => 'legacy_main', | 
					 | 
				
			||||||
                        'routeParameters' => ['name' => 'admin/course_list.php'], | 
					 | 
				
			||||||
                    ] | 
					 | 
				
			||||||
                ); | 
					 | 
				
			||||||
                $menu['administrator']->addChild( | 
					 | 
				
			||||||
                    'sessionlist', | 
					 | 
				
			||||||
                    [ | 
					 | 
				
			||||||
                        'label' => $translator->trans('Sessions'), | 
					 | 
				
			||||||
                        'route' => 'legacy_main', | 
					 | 
				
			||||||
                        'routeParameters' => ['name' => 'session/session_list.php'], | 
					 | 
				
			||||||
                    ] | 
					 | 
				
			||||||
                ); | 
					 | 
				
			||||||
                /*$menu['administrator']->addChild( | 
					 | 
				
			||||||
                    'languages', | 
					 | 
				
			||||||
                    [ | 
					 | 
				
			||||||
                        'label' => $translator->trans('Languages'), | 
					 | 
				
			||||||
                        'route' => 'legacy_main', | 
					 | 
				
			||||||
                        'routeParameters' => ['name' => 'admin/languages.php'], | 
					 | 
				
			||||||
                    ] | 
					 | 
				
			||||||
                );*/ | 
					 | 
				
			||||||
                $menu['administrator']->addChild( | 
					 | 
				
			||||||
                    'plugins', | 
					 | 
				
			||||||
                    [ | 
					 | 
				
			||||||
                        'label' => $translator->trans('Plugins'), | 
					 | 
				
			||||||
                        'route' => 'legacy_main', | 
					 | 
				
			||||||
                        'routeParameters' => ['name' => 'admin/settings.php', 'category' => 'Plugins'], | 
					 | 
				
			||||||
                    ] | 
					 | 
				
			||||||
                ); | 
					 | 
				
			||||||
                $menu['administrator']->addChild( | 
					 | 
				
			||||||
                    'settings', | 
					 | 
				
			||||||
                    [ | 
					 | 
				
			||||||
                        'label' => $translator->trans('Settings'), | 
					 | 
				
			||||||
                        'uri' => $rootWeb.'admin/settings/platform', | 
					 | 
				
			||||||
                    ] | 
					 | 
				
			||||||
                ); | 
					 | 
				
			||||||
            } | 
					 | 
				
			||||||
        } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        $categories = $container->get('doctrine')->getRepository('ChamiloFaqBundle:Category')->retrieveActive(); | 
					 | 
				
			||||||
        if ($categories) { | 
					 | 
				
			||||||
            $faq = $menu->addChild('FAQ', ['route' => 'faq_index']); | 
					 | 
				
			||||||
            /** @var Category $category */ | 
					 | 
				
			||||||
            foreach ($categories as $category) { | 
					 | 
				
			||||||
                $faq->addChild( | 
					 | 
				
			||||||
                    $category->getHeadline(), | 
					 | 
				
			||||||
                    [ | 
					 | 
				
			||||||
                        'route' => 'faq', | 
					 | 
				
			||||||
                        'routeParameters' => [ | 
					 | 
				
			||||||
                            'categorySlug' => $category->getSlug(), | 
					 | 
				
			||||||
                            'questionSlug' => '', | 
					 | 
				
			||||||
                        ], | 
					 | 
				
			||||||
                    ] | 
					 | 
				
			||||||
                )->setAttribute('divider_append', true); | 
					 | 
				
			||||||
            } | 
					 | 
				
			||||||
        } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Getting site information | 
					 | 
				
			||||||
        $site = $container->get('sonata.page.site.selector'); | 
					 | 
				
			||||||
        $host = $site->getRequestContext()->getHost(); | 
					 | 
				
			||||||
        $siteManager = $container->get('sonata.page.manager.site'); | 
					 | 
				
			||||||
        /** @var Site $site */ | 
					 | 
				
			||||||
        $site = $siteManager->findOneBy([ | 
					 | 
				
			||||||
            'host' => [$host, 'localhost'], | 
					 | 
				
			||||||
            'enabled' => true, | 
					 | 
				
			||||||
        ]); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Needed when loading legacy pages (inside main) | 
					 | 
				
			||||||
        //$isLegacy = $container->get('request_stack')->getCurrentRequest()->get('load_legacy'); | 
					 | 
				
			||||||
        $legacyIndex = ''; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if ($site) { | 
					 | 
				
			||||||
            $pageManager = $container->get('sonata.page.manager.page'); | 
					 | 
				
			||||||
            // Parents only of homepage | 
					 | 
				
			||||||
            $criteria = ['site' => $site, 'enabled' => true, 'parent' => 1]; | 
					 | 
				
			||||||
            $pages = $pageManager->findBy($criteria); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            //$pages = $pageManager->loadPages($site); | 
					 | 
				
			||||||
            /** @var Page $page */ | 
					 | 
				
			||||||
            foreach ($pages as $page) { | 
					 | 
				
			||||||
                /*if ($page->getRouteName() !== 'page_slug') { | 
					 | 
				
			||||||
                    continue; | 
					 | 
				
			||||||
                }*/ | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                // Avoid home | 
					 | 
				
			||||||
                if ('/' === $page->getUrl()) { | 
					 | 
				
			||||||
                    continue; | 
					 | 
				
			||||||
                } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                if (!$page->isCms()) { | 
					 | 
				
			||||||
                    continue; | 
					 | 
				
			||||||
                } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                $url = $legacyIndex.$page->getUrl(); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                $subMenu = $menu->addChild( | 
					 | 
				
			||||||
                    $page->getName(), | 
					 | 
				
			||||||
                    [ | 
					 | 
				
			||||||
                        'route' => $page->getRouteName(), | 
					 | 
				
			||||||
                        'routeParameters' => [ | 
					 | 
				
			||||||
                            'path' => $url, | 
					 | 
				
			||||||
                        ], | 
					 | 
				
			||||||
                    ] | 
					 | 
				
			||||||
                ); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                /** @var Page $child */ | 
					 | 
				
			||||||
                foreach ($page->getChildren() as $child) { | 
					 | 
				
			||||||
                    $url = $legacyIndex.$child->getUrl(); | 
					 | 
				
			||||||
                    $subMenu->addChild( | 
					 | 
				
			||||||
                        $child->getName(), | 
					 | 
				
			||||||
                        [ | 
					 | 
				
			||||||
                            'route' => $page->getRouteName(), | 
					 | 
				
			||||||
                            'routeParameters' => [ | 
					 | 
				
			||||||
                                'path' => $url, | 
					 | 
				
			||||||
                            ], | 
					 | 
				
			||||||
                        ] | 
					 | 
				
			||||||
                    )->setAttribute('divider_append', true); | 
					 | 
				
			||||||
                } | 
					 | 
				
			||||||
            } | 
					 | 
				
			||||||
        } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        //$menu->setLinkAttribute('ancestorClass', 'julio'); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        // Set CSS classes for the items | 
					 | 
				
			||||||
        foreach ($menu->getChildren() as $child) { | 
					 | 
				
			||||||
            $childClass = ''; | 
					 | 
				
			||||||
            $hasChildren = $child->hasChildren(); | 
					 | 
				
			||||||
            if ($hasChildren) { | 
					 | 
				
			||||||
                $childClass = 'nav-dropdown'; | 
					 | 
				
			||||||
                $child->setChildrenAttribute('class', 'nav-dropdown-items'); | 
					 | 
				
			||||||
                if ($child->isCurrent()) { | 
					 | 
				
			||||||
                    $child->setChildrenAttribute('style', 'display:block'); | 
					 | 
				
			||||||
                } | 
					 | 
				
			||||||
            } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $child | 
					 | 
				
			||||||
                ->setLinkAttribute('class', 'nav-link') | 
					 | 
				
			||||||
                ->setAttribute('class', 'nav-item '.$childClass) | 
					 | 
				
			||||||
            ; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if ($child->isCurrent()) { | 
					 | 
				
			||||||
                $child->setAttribute('class', 'nav-item '.$childClass); | 
					 | 
				
			||||||
            } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if ($hasChildren) { | 
					 | 
				
			||||||
                $child | 
					 | 
				
			||||||
                    ->setLinkAttribute('class', 'nav-link nav-dropdown-toggle ') //dropdown-toggle | 
					 | 
				
			||||||
                    //->setLinkAttribute('data-toggle', 'dropdown') | 
					 | 
				
			||||||
                    //->setLinkAttribute('role', 'button') | 
					 | 
				
			||||||
                    //->setLinkAttribute('aria-haspopup', 'true') | 
					 | 
				
			||||||
                    //->setLinkAttribute('aria-expanded', 'false') | 
					 | 
				
			||||||
                ; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
                $children = $child->getChildren(); | 
					 | 
				
			||||||
                foreach ($children as $subChild) { | 
					 | 
				
			||||||
                    $subChild | 
					 | 
				
			||||||
                        ->setLinkAttribute('class', 'nav-link ') | 
					 | 
				
			||||||
                        ->setAttribute('class', 'nav-item '); | 
					 | 
				
			||||||
                } | 
					 | 
				
			||||||
            } | 
					 | 
				
			||||||
        } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $menu; | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    /** | 
					 | 
				
			||||||
     * Course menu. | 
					 | 
				
			||||||
     * | 
					 | 
				
			||||||
     * @return ItemInterface | 
					 | 
				
			||||||
     */ | 
					 | 
				
			||||||
    public function courseMenu(FactoryInterface $factory, array $options) | 
					 | 
				
			||||||
    { | 
					 | 
				
			||||||
        $checker = $this->container->get('security.authorization_checker'); | 
					 | 
				
			||||||
        $menu = $factory->createItem('root'); | 
					 | 
				
			||||||
        $translator = $this->container->get('translator'); | 
					 | 
				
			||||||
        $checked = $this->container->get('session')->get('IS_AUTHENTICATED_FULLY'); | 
					 | 
				
			||||||
        $settingsManager = $this->container->get('chamilo.settings.manager'); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        if ($checked) { | 
					 | 
				
			||||||
            $menu->setChildrenAttribute('class', 'nav nav-pills nav-stacked'); | 
					 | 
				
			||||||
            $menu->addChild( | 
					 | 
				
			||||||
                $translator->trans('MyCourses'), | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'route' => 'userportal', | 
					 | 
				
			||||||
                    'routeParameters' => ['type' => 'courses'], | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            ); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            return $menu; | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if (api_is_allowed_to_create_course()) { | 
					 | 
				
			||||||
                $lang = $translator->trans('CreateCourse'); | 
					 | 
				
			||||||
                if ('true' == $settingsManager->getSetting('course.course_validation')) { | 
					 | 
				
			||||||
                    $lang = $translator->trans('CreateCourseRequest'); | 
					 | 
				
			||||||
                } | 
					 | 
				
			||||||
                $menu->addChild( | 
					 | 
				
			||||||
                    $lang, | 
					 | 
				
			||||||
                    ['route' => 'add_course'] | 
					 | 
				
			||||||
                ); | 
					 | 
				
			||||||
            } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $link = $this->container->get('router')->generate('web_main'); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $menu->addChild( | 
					 | 
				
			||||||
                $translator->trans('ManageCourses'), | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'uri' => $link.'auth/courses.php?action=sortmycourses', | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            ); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            $browse = $settingsManager->getSetting('display.allow_students_to_browse_courses'); | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            if ('true' == $browse) { | 
					 | 
				
			||||||
                if ($checker->isGranted('ROLE_STUDENT') && !api_is_drh() && !api_is_session_admin() | 
					 | 
				
			||||||
                ) { | 
					 | 
				
			||||||
                    $menu->addChild( | 
					 | 
				
			||||||
                        $translator->trans('CourseCatalog'), | 
					 | 
				
			||||||
                        [ | 
					 | 
				
			||||||
                            'uri' => $link.'auth/courses.php', | 
					 | 
				
			||||||
                        ] | 
					 | 
				
			||||||
                    ); | 
					 | 
				
			||||||
                } else { | 
					 | 
				
			||||||
                    $menu->addChild( | 
					 | 
				
			||||||
                        $translator->trans('Dashboard'), | 
					 | 
				
			||||||
                        [ | 
					 | 
				
			||||||
                            'uri' => $link.'dashboard/index.php', | 
					 | 
				
			||||||
                        ] | 
					 | 
				
			||||||
                    ); | 
					 | 
				
			||||||
                } | 
					 | 
				
			||||||
            } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
            /** @var \Knp\Menu\MenuItem $menu */ | 
					 | 
				
			||||||
            $menu->addChild( | 
					 | 
				
			||||||
                $translator->trans('History'), | 
					 | 
				
			||||||
                [ | 
					 | 
				
			||||||
                    'route' => 'userportal', | 
					 | 
				
			||||||
                    'routeParameters' => [ | 
					 | 
				
			||||||
                        'type' => 'sessions', | 
					 | 
				
			||||||
                        'filter' => 'history', | 
					 | 
				
			||||||
                    ], | 
					 | 
				
			||||||
                ] | 
					 | 
				
			||||||
            ); | 
					 | 
				
			||||||
        } | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        return $menu; | 
					 | 
				
			||||||
    } | 
					 | 
				
			||||||
} | 
					 | 
				
			||||||
@ -1,46 +0,0 @@ | 
				
			|||||||
<!-- @todo add permissions for each menu sidebar menu: : style can be found in sidebar.less --> | 
					 | 
				
			||||||
{% import '@ChamiloCore/Macros/box.html.twig' as macro %} | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
{% autoescape false %} | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
{% if is_granted('IS_AUTHENTICATED_FULLY') %} | 
					 | 
				
			||||||
{#    {{ macro.panel(#} | 
					 | 
				
			||||||
{#        'Profile' | trans,#} | 
					 | 
				
			||||||
{#        mopa_bootstrap_menu('ChamiloCoreBundle:LeftMenuBuilder:profileMenu', {'automenu': 'navbar', 'stacked':false})#} | 
					 | 
				
			||||||
{#    ) }}#} | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
{#    {{ macro.panel(#} | 
					 | 
				
			||||||
{#        'Courses' | trans,#} | 
					 | 
				
			||||||
{#        mopa_bootstrap_menu('ChamiloCoreBundle:LeftMenuBuilder:courseMenu', {'automenu': 'navbar', 'stacked':false})#} | 
					 | 
				
			||||||
{#    ) }}#} | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
{#    {{ macro.panel(#} | 
					 | 
				
			||||||
{#        'Sessions' | trans,#} | 
					 | 
				
			||||||
{#        mopa_bootstrap_menu('ChamiloCoreBundle:LeftMenuBuilder:sessionMenu', {'automenu': 'navbar', 'stacked':false})#} | 
					 | 
				
			||||||
{#    ) }}#} | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
{#    {{ macro.panel(#} | 
					 | 
				
			||||||
{#        'Skills' | trans,#} | 
					 | 
				
			||||||
{#        mopa_bootstrap_menu('ChamiloCoreBundle:LeftMenuBuilder:skillsMenu', {'automenu': 'navbar', 'stacked':false})#} | 
					 | 
				
			||||||
{#    ) }}#} | 
					 | 
				
			||||||
{% else %} | 
					 | 
				
			||||||
    {# Plugin login before/after tpls #} | 
					 | 
				
			||||||
    {% if plugin_login_top is not null %} | 
					 | 
				
			||||||
        <div id="plugin_login_top"> | 
					 | 
				
			||||||
            {{ plugin_login_top }} | 
					 | 
				
			||||||
        </div> | 
					 | 
				
			||||||
    {% endif %} | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    {% include '@ChamiloCore/Sidebar/login.html.twig' %} | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    {% if plugin_login_bottom is not null %} | 
					 | 
				
			||||||
        <div id="plugin_login_bottom"> | 
					 | 
				
			||||||
            {{ plugin_login_bottom }} | 
					 | 
				
			||||||
        </div> | 
					 | 
				
			||||||
    {% endif %} | 
					 | 
				
			||||||
{% endif %} | 
					 | 
				
			||||||
    {{ macro.panel( | 
					 | 
				
			||||||
    'Help' | trans, | 
					 | 
				
			||||||
    mopa_bootstrap_menu('ChamiloCoreBundle:LeftMenuBuilder:helpMenu', {'automenu': 'pills', 'stacked':true}) | 
					 | 
				
			||||||
    ) }} | 
					 | 
				
			||||||
{% endautoescape %} | 
					 | 
				
			||||||
@ -1,35 +0,0 @@ | 
				
			|||||||
{#<!-- sidebar menu: : style can be found in sidebar.less -->#} | 
					 | 
				
			||||||
{#{% import '@ChamiloCore/Macros/box.html.twig' as macro %}#} | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
{#{% autoescape false %}#} | 
					 | 
				
			||||||
{#{% if is_granted('IS_AUTHENTICATED_FULLY') %}#} | 
					 | 
				
			||||||
{#    #}{#'Profile' | trans,#} | 
					 | 
				
			||||||
{#    #}{#mopa_bootstrap_menu('ChamiloCoreBundle:SimpleMenuBuilder:mainMenu', {'automenu': 'pills', 'stacked':true})) }}#} | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
{#    {{ macro.panel(#} | 
					 | 
				
			||||||
{#    'Courses' | trans,#} | 
					 | 
				
			||||||
{#    mopa_bootstrap_menu('ChamiloCoreBundle:CourseMenuBuilder:courseMenu', {'automenu': 'pills', 'stacked':true})) }}#} | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
{#    {{ macro.panel(#} | 
					 | 
				
			||||||
{#    'Skills' | trans,#} | 
					 | 
				
			||||||
{#    mopa_bootstrap_menu('ChamiloCoreBundle:CourseMenuBuilder:skillsMenu', {'automenu': 'pills', 'stacked':true})) }}#} | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
{#{% else %}#} | 
					 | 
				
			||||||
{#    <div class="user-panel">switcher#} | 
					 | 
				
			||||||
{#    </div>#} | 
					 | 
				
			||||||
{#    <form action="{{ path("fos_user_security_check") }}" method="post" role="form" class="sidebar-form">#} | 
					 | 
				
			||||||
{#        <input type="hidden" name="_csrf_token" value="{{ csrf_token('authenticate') }}"/>#} | 
					 | 
				
			||||||
{#        <div class="form-group">#} | 
					 | 
				
			||||||
{#            <label for="username">{{ 'security.login.username' | trans({}, 'FOSUserBundle') }}</label>#} | 
					 | 
				
			||||||
{#            <input type="text" class="form-control" id="username" name="_username" >#} | 
					 | 
				
			||||||
{#        </div>#} | 
					 | 
				
			||||||
{#        <div class="form-group">#} | 
					 | 
				
			||||||
{#            <label for="password">{{ 'security.login.password' | trans({}, 'FOSUserBundle') }}</label>#} | 
					 | 
				
			||||||
{#            <input type="password" class="form-control" id="password" name="_password">#} | 
					 | 
				
			||||||
{#        </div>#} | 
					 | 
				
			||||||
{#        <button type="submit" class="btn btn-default">{{ 'security.login.submit' | trans({}, 'FOSUserBundle') }}</button>#} | 
					 | 
				
			||||||
{#    </form>#} | 
					 | 
				
			||||||
{#    {{ mopa_bootstrap_menu('ChamiloCoreBundle:SimpleMenuBuilder:notLoginMenu', {'automenu': 'pills', 'stacked':true}) }}#} | 
					 | 
				
			||||||
{#{% endif %}#} | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
{#{% endautoescape %}#} | 
					 | 
				
			||||||
@ -1,12 +0,0 @@ | 
				
			|||||||
<!-- @todo search form --> | 
					 | 
				
			||||||
<form action="#" method="get" class="sidebar-form"> | 
					 | 
				
			||||||
    <div class="input-group"> | 
					 | 
				
			||||||
        <input type="text" name="q" class="form-control" placeholder="Search..."/> | 
					 | 
				
			||||||
            <span class="input-group-btn"> | 
					 | 
				
			||||||
                <button type='submit' name='seach' id='search-btn' class="btn btn-flat"> | 
					 | 
				
			||||||
                    <i class="fa fa-search"></i> | 
					 | 
				
			||||||
                </button> | 
					 | 
				
			||||||
            </span> | 
					 | 
				
			||||||
    </div> | 
					 | 
				
			||||||
</form> | 
					 | 
				
			||||||
<!-- /.search form --> | 
					 | 
				
			||||||
@ -1,11 +0,0 @@ | 
				
			|||||||
{% set pathInfo = path( | 
					 | 
				
			||||||
    app.request.attributes.get('_route'), | 
					 | 
				
			||||||
    app.request.attributes.get('_route_params')) | 
					 | 
				
			||||||
%} | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
{# Profile block #} | 
					 | 
				
			||||||
{% if is_granted('IS_AUTHENTICATED_FULLY') %} | 
					 | 
				
			||||||
    {{ render(controller('ChamiloCoreBundle:Sidebar:userPanel', {'pathInfo': pathInfo })) }} | 
					 | 
				
			||||||
    {#{{ render(controller('ChamiloCoreBundle:Sidebar:searchForm')) }}#} | 
					 | 
				
			||||||
    {{ render(controller('ChamiloCoreBundle:Sidebar:socialPanel', {'pathInfo': pathInfo })) }} | 
					 | 
				
			||||||
{% endif %} | 
					 | 
				
			||||||
@ -1,9 +0,0 @@ | 
				
			|||||||
{% import '@ChamiloCore/Macros/box.html.twig' as macro %} | 
					 | 
				
			||||||
{% import '@ChamiloCore/Macros/image.html.twig' as macro_image %} | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
{{ | 
					 | 
				
			||||||
    macro.panel( | 
					 | 
				
			||||||
        'SocialNetwork' | trans, | 
					 | 
				
			||||||
        mopa_bootstrap_menu('ChamiloCoreBundle:LeftMenuBuilder:socialMenu', {'automenu': 'pills', 'stacked':true}) | 
					 | 
				
			||||||
    ) | 
					 | 
				
			||||||
}} | 
					 | 
				
			||||||
@ -1,24 +0,0 @@ | 
				
			|||||||
{% import '@ChamiloCore/Macros/box.html.twig' as macro %} | 
					 | 
				
			||||||
{% import '@ChamiloCore/Macros/image.html.twig' as macro_image %} | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
<!-- Sidebar user panel --> | 
					 | 
				
			||||||
<div style="text-align:center;" id="user_image_block" class="panel panel-default"> | 
					 | 
				
			||||||
    <div class="panel-body"> | 
					 | 
				
			||||||
    {% if user.avatar %} | 
					 | 
				
			||||||
        {{ macro_image.avatar_from_media(user.avatar, user.username) }} | 
					 | 
				
			||||||
    {% else %} | 
					 | 
				
			||||||
        {{ macro_image.avatar('img/icons/128/unknown.png', user.username)  }} | 
					 | 
				
			||||||
    {% endif %} | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    <p>{{ 'Hello, %user%'| trans( {'%user%': user.username }, 'ChamiloCoreBundle') }}</p> | 
					 | 
				
			||||||
    <a href="#"> | 
					 | 
				
			||||||
        <i class="fa fa-circle text-success"></i> {{ 'Online' | trans }} | 
					 | 
				
			||||||
    </a> | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    {% if is_granted('ROLE_PREVIOUS_ADMIN') %} | 
					 | 
				
			||||||
        <a href="{{ path('home', {'_switch_user': '_exit'}) }}"> | 
					 | 
				
			||||||
            {{ 'Exit impersonation' | trans }} | 
					 | 
				
			||||||
        </a> | 
					 | 
				
			||||||
    {% endif %} | 
					 | 
				
			||||||
    </div> | 
					 | 
				
			||||||
</div> | 
					 | 
				
			||||||
					Loading…
					
					
				
		Reference in new issue