From d12b6b47c947df0a927b75a09edb72b08baeda52 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Thu, 31 Jul 2014 18:45:23 +0200 Subject: [PATCH] Fixing classic admin. --- app/Resources/views/layout.html.twig | 3 +- app/config/routing.yml | 2 +- app/config/sonata/sonata_page.yml | 4 +- .../Controller/Admin/AdminController.php | 11 +- .../CoreBundle/Menu/SimpleMenuBuilder.php | 63 ++++++++- .../Resources/views/Admin/index.html.twig | 129 ++++++++---------- web/app_dev.php | 2 +- 7 files changed, 132 insertions(+), 82 deletions(-) diff --git a/app/Resources/views/layout.html.twig b/app/Resources/views/layout.html.twig index ce1b640106..83b8228330 100644 --- a/app/Resources/views/layout.html.twig +++ b/app/Resources/views/layout.html.twig @@ -42,7 +42,8 @@ {{ mopa_bootstrap_menu('ChamiloLMSCoreBundle:SimpleMenuBuilder:loginMenu', {'automenu': 'pills', 'stacked':true}) }} {% endif %} - {{ mopa_bootstrap_menu('ChamiloLMSCoreBundle:SimpleMenuBuilder:helpMenu', {'automenu': 'pills', 'stacked':true}) }} + {#{{ mopa_bootstrap_menu('ChamiloLMSCoreBundle:SimpleMenuBuilder:helpMenu', {'automenu': 'pills', 'stacked':true}) }}#} + {% endblock %} {% block javascripts_head %} diff --git a/app/config/routing.yml b/app/config/routing.yml index d252699aeb..31af0e7426 100644 --- a/app/config/routing.yml +++ b/app/config/routing.yml @@ -10,7 +10,7 @@ _front: _admin: resource: routing_admin.yml - prefix: /admin + prefix: /administration _api: resource: routing_api.yml diff --git a/app/config/sonata/sonata_page.yml b/app/config/sonata/sonata_page.yml index 12debf8862..95fa4cf278 100644 --- a/app/config/sonata/sonata_page.yml +++ b/app/config/sonata/sonata_page.yml @@ -14,11 +14,11 @@ sonata_page: use_streamed_response: false # set the value to false in debug mode or if the reverse proxy does not handle streamed response ignore_uri_patterns: - - ^/admin(.*) + - ^/administration(.*) # sonata admin - ^/api/(.*) ignore_route_patterns: - - (.*)admin(.*) # ignore admin route, ie route containing 'admin' + - (.*)administration(.*) # ignore admin route, ie route containing 'admin' # sonata admin - ^_(.*) # ignore symfony routes - login - home diff --git a/src/ChamiloLMS/CoreBundle/Controller/Admin/AdminController.php b/src/ChamiloLMS/CoreBundle/Controller/Admin/AdminController.php index a70d06c47b..27f4ec7c32 100644 --- a/src/ChamiloLMS/CoreBundle/Controller/Admin/AdminController.php +++ b/src/ChamiloLMS/CoreBundle/Controller/Admin/AdminController.php @@ -24,12 +24,11 @@ class AdminController extends BaseController */ public function indexAction() { - $template = $this->getTemplate(); $security = $this->getSecurity(); - - if (!$security->isGranted('ROLE_ADMIN')) { - //return $this->abort(403, 'Access denied'); - } + // Already filter by the router + /*if (!$security->isGranted('ROLE_ADMIN')) { + return $this->abort(403, 'Access denied'); + }*/ if ($security->isGranted('ROLE_ADMIN')) { return $this->loadAdminMenu(); @@ -214,7 +213,7 @@ class AdminController extends BaseController $items[] = array('url' => $adminUrl.'filler.php', 'label' => get_lang('DataFiller')); } $items[] = array('url' => $adminUrl.'archive_cleanup.php', 'label' => get_lang('ArchiveDirCleanup')); - $items[] = array('url' => $adminUrl.'system_management.php', 'label' => get_lang('SystemManagement')); + //$items[] = array('url' => $adminUrl.'system_management.php', 'label' => get_lang('SystemManagement')); $blocks['settings']['items'] = $items; $blocks['settings']['extra'] = null; diff --git a/src/ChamiloLMS/CoreBundle/Menu/SimpleMenuBuilder.php b/src/ChamiloLMS/CoreBundle/Menu/SimpleMenuBuilder.php index 667eacee40..23a256fc75 100644 --- a/src/ChamiloLMS/CoreBundle/Menu/SimpleMenuBuilder.php +++ b/src/ChamiloLMS/CoreBundle/Menu/SimpleMenuBuilder.php @@ -91,7 +91,68 @@ class SimpleMenuBuilder extends ContainerAware ) ); - $menu->addChild('Administration',array('route' => 'administration')); + /*$menu->addChild( + 'Plugins', + array( + 'route' => 'main', + 'routeParameters' => array('name' => urlencode('admin/plugins.php')), + array("attributes" => array("id" => 'nav')) + ) + );*/ + + /*$menu->addChild( + 'Sonata Admin', + array( + 'route' => 'admin' + ) + );*/ + + + + $admin = $menu->addChild( + 'Administration', + array( + 'route' => 'administration', + + ) + ); + + $admin->addChild( + 'Users', + array( + 'route' => 'main', + 'routeParameters' => array('name' => 'admin/user_list.php'), + array("attributes" => array("id" => 'nav')) + ) + ); + + $admin->addChild( + 'Courses', + array( + 'route' => 'main', + 'routeParameters' => array('name' => 'admin/course_list.php'), + array("attributes" => array("id" => 'nav')) + ) + ); + + $admin->addChild( + 'Sessions', + array( + 'route' => 'main', + 'routeParameters' => array('name' => 'session/session_list.php'), + array("attributes" => array("id" => 'nav')) + ) + ); + + $menu->addChild( + 'Sonata Admin', + array( + 'route' => 'sonata_admin_dashboard' + ) + ); + + // Sonata admin + //$menu->addChild('Administration', array('route' => 'administration')); /* $dropdownExtrasOptions = $isFooter ? array( diff --git a/src/ChamiloLMS/CoreBundle/Resources/views/Admin/index.html.twig b/src/ChamiloLMS/CoreBundle/Resources/views/Admin/index.html.twig index f892a7d7ab..15fc82528c 100644 --- a/src/ChamiloLMS/CoreBundle/Resources/views/Admin/index.html.twig +++ b/src/ChamiloLMS/CoreBundle/Resources/views/Admin/index.html.twig @@ -1,78 +1,67 @@ -{% extends '::Themes/page.html.twig' %} - -{% block layout %} - {% embed '::Layouts/3-9.html.twig' %} - {% block content %} - {% autoescape false %} - -
- - {% for block_item in blocks %} -
-
-

{{ block_item.icon }} {{ block_item.label }}

-
- {{ block_item.search_form }} -
- {% if block_item.items is not empty %} -
    - {% for url in block_item.items %} - {% if url.url is not empty %} -
  • - - {{ url.label }} - -
  • - {% endif %} - {% endfor %} -
- {% endif %} - - {% if block_item.extra is not null %} -
- {{ block_item.extra }} -
- {% endif %} -
+{% extends "::layout.html.twig" %} +{% block page_content %} + {% autoescape false %} +
+ {% for block_item in blocks %} +
+
+

{{ block_item.icon }} {{ block_item.label }}

+
+ {{ block_item.search_form }}
- {% endfor %} + {% if block_item.items is not empty %} +
    + {% for url in block_item.items %} + {% if url.url is not empty %} +
  • + + {{ url.label }} + +
  • + {% endif %} + {% endfor %} +
+ {% endif %} + {% if block_item.extra is not null %} +
+ {{ block_item.extra }} +
+ {% endif %} +
+
+ {% endfor %} +
+ {% for role in app.user.roles %} + {% set role = role | lower | replace ({ 'role_' : ''}) %} -
- {% for role in app.user.roles %} - {% set role = role.role | lower | replace ({ 'role_' : ''}) %} + {% if role in ['global_admin'] %} + {% include "ChamiloLMSCoreBundle:Admin:" ~ role ~ "/role_index.html.twig" %} + {% endif %} + {% endfor %} +
+
- {% if role in ['global_admin'] %} - {% include "ChamiloLMSCoreBundle:Admin:" ~ role ~ "/role_index.html.twig" %} - {% endif %} - {% endfor %} + {% if is_granted('ROLE_ADMIN') %} + +
+
+
+

{{ 'VersionCheck' | trans }}

+
- - {% if is_granted('ROLE_ADMIN') %} - -
-
-
-

{{ 'VersionCheck' | trans }}

-
-
-
-
- {% endif %} - {% endautoescape %} - {% endblock %} - {% endembed %} +
+ {% endif %} + {% endautoescape %} {% endblock %} - - diff --git a/web/app_dev.php b/web/app_dev.php index 3d7bb0ab1a..d883bfd904 100644 --- a/web/app_dev.php +++ b/web/app_dev.php @@ -22,7 +22,7 @@ require_once __DIR__.'/legacy.php'; // using different relative paths, you must change the request // object to use the SiteRequest //$request = Request::createFromGlobals('host_with_path'); -$request = Sonata\PageBundle\Request\RequestFactory::createFromGlobals('host_with_path'); +$request = Sonata\PageBundle\Request\RequestFactory::createFromGlobals('host_with_path_by_locale'); $kernel = new AppKernel('dev', true);