Edgard 6 лет назад
Родитель
Сommit
f1af5c8238
2 измененных файлов с 25 добавлено и 2 удалено
  1. 11 1
      front/callback.php
  2. 14 1
      hook.php

+ 11 - 1
front/callback.php

@@ -98,6 +98,16 @@ Html::nullHeader("Login", $CFG_GLPI["root_doc"] . '/index.php');
 echo '<div class="center b">' . __('User not authorized to connect in GLPI') . '<br><br>';
 // Logout whit noAUto to manage auto_login with errors
 echo '<a href="' . $CFG_GLPI["root_doc"] . '/front/logout.php?noAUTO=1' .
- str_replace("?", "&", $REDIRECT) . '">' . __('Log in again') . '</a></div>';
+ str_replace("?", "&", $REDIRECT) . '" class="singlesignon">' . __('Log in again') . '</a></div>';
+echo '<script type="text/javascript">
+   if (window.opener) {
+      $(".singlesignon").on("click", function (e) {
+         e.preventDefault();
+         window.opener.location = $(this).attr("href");
+         window.focus();
+         window.close();
+      });
+   }
+</script>';
 Html::nullFooter();
 exit();

+ 14 - 1
hook.php

@@ -19,10 +19,23 @@ function plugin_singlesignon_display_login() {
    $html = array();
 
    foreach ($rows as $row) {
-      $html[] = '<a href="' . $url_prefix . '/provider/' . $row['id'] . $url_sufix . '" style="color: #CFCFCF">[ Login with ' . $row['name'] . ' ]</a>';
+      $html[] = '<a href="' . $url_prefix . '/provider/' . $row['id'] . $url_sufix . '" class="singlesignon" style="color: #CFCFCF">[ Login with ' . $row['name'] . ' ]</a>';
    }
 
    echo implode("<br />\n", $html);
+   echo '<script type="text/javascript">
+      $(".singlesignon").on("click", function (e) {
+         e.preventDefault();
+
+         var url   = $(this).attr("href");
+         var left  = ($(window).width()/2)-(600/2);
+         var top   = ($(window).height()/2)-(800/2);
+         var newWindow = window.open(url, "singlesignon", "width=600,height=800,left=" + left + ",top=" + top);
+         if (window.focus) {
+            newWindow.focus();
+         }
+      });
+       </script>';
 }
 
 function plugin_singlesignon_install() {