Browse Source

Adding LoginListener a hook when the 'login_as' process is called also adding the 'exit impersonate' message.

Julio Montoya 11 years ago
parent
commit
be8a07305e
2 changed files with 22 additions and 3 deletions
  1. 7 0
      main/template/default/layout/page_body.tpl
  2. 15 3
      src/ChamiloLMS/Component/Auth/Role.php

+ 7 - 0
main/template/default/layout/page_body.tpl

@@ -16,6 +16,13 @@
     </div>
 {% endif %}
 
+
+{% if is_granted('ROLE_PREVIOUS_ADMIN') %}
+    <div class="alert">
+        <a href="{{ path('index', {'_switch_user': '_exit'}) }}">{{ 'Exit impersonation' | trans }}</a>
+    </div>
+{% endif %}
+
 {#  Show messages #}
 {% if message != '' %}
     <section id="messages">

+ 15 - 3
src/ChamiloLMS/Component/Auth/Role.php

@@ -6,17 +6,29 @@ namespace ChamiloLMS\Component\Auth;
  */
 
 use Symfony\Component\Security\Core\Role\RoleInterface;
-use Symfony\Component\Security\Core\User\UserInterface;
+use Symfony\Component\Security\Core\User\AdvancedUserInterface;
 
 class Role implements RoleInterface
 {
-    public function __construct(UserInterface $user)
+    private $user;
+
+    /**
+     * @param AdvancedUserInterface $user
+     */
+    public function __construct(AdvancedUserInterface $user)
     {
         $this->user = $user;
     }
 
+    /**
+     * @return string
+     */
     public function getRole()
     {
-        //return 'ROLE_' . strtoupper($this->user->getUsername());
+        /*$globalPlatform = api_is_global_platform_admin($this->user->getUserId());
+        if ($globalPlatform) {
+            //return 'ROLE_GLOBAL_ADMIN';
+        }*/
+
     }
 }