Browse Source

Fix for the top-bar navigation. Now the security check made to know if the user has roles with the 'is_granted' twig function.

Aitor Suso 13 years ago
parent
commit
19468f7a42
1 changed files with 19 additions and 20 deletions
  1. 19 20
      Resources/views/standard_layout.html.twig

+ 19 - 20
Resources/views/standard_layout.html.twig

@@ -76,26 +76,25 @@ file that was distributed with this source code.
                                 {{ admin_pool.title }}
                                 {{ admin_pool.title }}
                             </a>
                             </a>
                         {% endblock %}
                         {% endblock %}
-                        {% if app.user %}
-                            <ul class="nav">
-                                {% block sonata_top_bar_nav %}
-                                    {% block top_bar_before_nav %} {% endblock %}
-                                    {% for group in admin_pool.dashboardgroups %}
-                                        <li class="dropdown">
-                                            <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ group.label|trans({}, group.label_catalogue) }} <span class="caret"></span></a>
-                                            <ul class="dropdown-menu">
-                                                {% for admin in group.items %}
-                                                    {% if admin.hasroute('create') and admin.isGranted('CREATE') or admin.hasroute('list') and admin.isGranted('LIST') %}
-                                                        <li><a href="{{ admin.generateUrl('list')}}">{{ admin.label|trans({}, admin.translationdomain) }}</a></li>
-                                                    {% endif %}
-                                                {% endfor %}
-                                            </ul>
-                                        </li>
-                                    {% endfor %}
-                                    {% block top_bar_after_nav %} {% endblock %}
-                                {% endblock %}
-                            </ul>
-                        {% endif %}
+
+                        <ul class="nav">
+                            {% block top_bar_before_nav %} {% endblock %}
+                            {% if app.security and is_granted('ROLE_SONATA_ADMIN') %}
+                                {% for group in admin_pool.dashboardgroups %}
+                                    <li class="dropdown">
+                                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">{{ group.label|trans({}, group.label_catalogue) }} <span class="caret"></span></a>
+                                        <ul class="dropdown-menu">
+                                            {% for admin in group.items %}
+                                                {% if admin.hasroute('create') and admin.isGranted('CREATE') or admin.hasroute('list') and admin.isGranted('LIST') %}
+                                                    <li><a href="{{ admin.generateUrl('list')}}">{{ admin.label|trans({}, admin.translationdomain) }}</a></li>
+                                                {% endif %}
+                                            {% endfor %}
+                                        </ul>
+                                    </li>
+                                {% endfor %}
+                            {% endif %}
+                            {% block top_bar_after_nav %} {% endblock %}
+                        </ul>
 
 
                         <p class="navbar-text pull-right">{% include admin_pool.getTemplate('user_block') %}</p>
                         <p class="navbar-text pull-right">{% include admin_pool.getTemplate('user_block') %}</p>
                     {% endif %}
                     {% endif %}