Jelajahi Sumber

New visual style

Edgard 5 tahun lalu
induk
melakukan
739b73c02d
5 mengubah file dengan 218 tambahan dan 131 penghapusan
  1. 84 18
      hook.php
  2. 5 0
      inc/provider.class.php
  3. 44 40
      locales/en_GB.po
  4. 45 37
      locales/pt_BR.po
  5. 40 36
      locales/singlesignon.pot

+ 84 - 18
hook.php

@@ -21,25 +21,92 @@ function plugin_singlesignon_display_login() {
       }
 
       $url = PluginSinglesignonProvider::getCallbackUrl($row['id'], $query);
-
-      $html[] = '<a href="' . $url . '" class="singlesignon" style="color: #CFCFCF">' .
-      sprintf(__sso('[ Login with %s ]'), $row['name']) . '</a>';
+      $html[] = PluginSinglesignonProvider::renderButton($url, $row['name']);
    }
 
-   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();
+   if (!empty($html)) {
+      echo '<div class="singlesignon-box">';
+      echo implode(" \n", $html);
+      echo PluginSinglesignonProvider::renderButton('#', __('GLPI'), 'vsubmit old-login');
+      echo '</div>';
+      ?>
+      <style>
+         #display-login .singlesignon-box span {
+            display: inline-block;
+            margin: 5px;
+         }
+
+         #display-login .singlesignon-box .old-login {
+            display: none;
+         }
+
+         #boxlogin .singlesignon-box span {
+            display: block;
+         }
+
+         #boxlogin .singlesignon-box .vsubmit {
+            width: 100%;
+            height: 30px;
+            font-size: 1.3em !important;
+            text-align: center;
+            box-sizing: border-box;
          }
-      });
-       </script>';
+      </style>
+      <script type="text/javascript">
+         $(document).ready(function() {
+
+            // On click, open a popup
+            $(document).on("click", ".singlesignon.oauth-login", 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();
+               }
+            });
+
+            var $boxLogin = $('#boxlogin');
+            var $form = $boxLogin.find('form');
+            var $boxButtons = $('.singlesignon-box');
+
+            // Move the buttons to before form
+            $boxButtons.prependTo($boxLogin);
+            $boxButtons.find('span').addClass('login_input');
+
+            // Show old form
+            $(document).on("click", ".singlesignon.old-login", function(e) {
+               e.preventDefault();
+               $boxButtons.slideToggle();
+               $form.slideToggle(function() {
+                  $('#login_name').focus();
+               });
+            });
+
+            var $line = $('<p />', {
+               class: 'login_input'
+            }).prependTo($form);
+
+            var $backLogin = $('<label />', {
+               css: {
+                  cursor: 'pointer'
+               },
+               text: "<< " + <?php echo json_encode(__('Back')) ?>,
+            }).appendTo($line);
+
+            $backLogin.on('click', function(e) {
+               e.preventDefault();
+               $boxButtons.slideToggle();
+               $form.slideToggle();
+            });
+
+            $form.hide();
+         });
+      </script>
+      <?php
+   }
 }
 
 function plugin_singlesignon_install() {
@@ -48,8 +115,7 @@ function plugin_singlesignon_install() {
 
    $currentVersion = '0.0.0';
 
-   $default = [
-   ];
+   $default = [];
 
    $current = Config::getConfigurationValues('singlesignon');
 

+ 5 - 0
inc/provider.class.php

@@ -1014,4 +1014,9 @@ class PluginSinglesignonProvider extends CommonDBTM {
       return $data;
    }
 
+   public static function renderButton($url, $name, $class = 'oauth-login') {
+      return '<span><a href="' . $url . '" class="singlesignon vsubmit ' . $class . '">' .
+      sprintf(__sso('Login with %s'), $name) . '</a></span>';
+   }
+
 }

+ 44 - 40
locales/en_GB.po

@@ -1,15 +1,15 @@
 # English translations for singlesignon package.
-# Copyright (C) 2019 THE singlesignon'S COPYRIGHT HOLDER
+# Copyright (C) 2021 THE singlesignon'S COPYRIGHT HOLDER
 # This file is distributed under the same license as the singlesignon package.
-# Automatically generated, 2019.
+# Automatically generated, 2021.
 #
 msgid ""
 msgstr ""
 "Project-Id-Version: singlesignon 1.0.0\n"
 "Report-Msgid-Bugs-To: https://github.com/edgardmessias/glpi-singlesignon/"
 "issues\n"
-"POT-Creation-Date: 2019-04-29 09:32-0300\n"
-"PO-Revision-Date: 2019-04-29 09:32-0300\n"
+"POT-Creation-Date: 2021-01-12 13:25-0300\n"
+"PO-Revision-Date: 2021-01-12 13:25-0300\n"
 "Last-Translator: Automatically generated\n"
 "Language-Team: none\n"
 "Language: en_GB\n"
@@ -18,10 +18,10 @@ msgstr ""
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
 
-#: hook.php:22
+#: hook.php:27 hook.php:75
 #, php-format
-msgid "[ Login with %s ]"
-msgstr "[ Login with %s ]"
+msgid "Login with %s"
+msgstr "Login with %s"
 
 #: setup.php:8
 #, php-format
@@ -29,127 +29,131 @@ msgid "Please, rename the plugin folder \"%s\" to \"singlesignon\""
 msgstr "Please, rename the plugin folder \"%s\" to \"singlesignon\""
 
 #: setup.php:36 front/provider.form.php:59 front/provider.form.php:61
-#: front/provider.php:6 front/provider.php:8 inc/provider.class.php:53
+#: front/provider.php:6 front/provider.php:8 inc/provider.class.php:57
 msgid "Single Sign-on"
 msgstr "Single Sign-on"
 
-#: setup.php:49
-msgid "Run first: composer install"
-msgstr "Run first: composer install"
-
 #: setup.php:53
 msgid "This plugin requires GLPI >= 0.85"
 msgstr "This plugin requires GLPI >= 0.85"
 
-#: front/callback.php:11
+#: front/callback.php:15
 msgid "Provider not defined."
 msgstr "Provider not defined."
 
-#: front/callback.php:17
+#: front/callback.php:21
 msgid "Provider not found."
 msgstr "Provider not found."
 
-#: front/callback.php:21
+#: front/callback.php:25
 msgid "Provider not active."
 msgstr "Provider not active."
 
-#: inc/provider.class.php:46
+#: inc/provider.class.php:50
 msgid "Single Sign-on Provider"
 msgstr "Single Sign-on Provider"
 
-#: inc/provider.class.php:94
+#: inc/provider.class.php:98
 msgid "SSO Type"
 msgstr "SSO Type"
 
-#: inc/provider.class.php:102 inc/provider.class.php:267
+#: inc/provider.class.php:106 inc/provider.class.php:298
 msgid "Client ID"
 msgstr "Client ID"
 
-#: inc/provider.class.php:104 inc/provider.class.php:275
+#: inc/provider.class.php:108 inc/provider.class.php:306
 msgid "Client Secret"
 msgstr "Client Secret"
 
-#: inc/provider.class.php:109 inc/provider.class.php:283
+#: inc/provider.class.php:113 inc/provider.class.php:314
 msgid "Scope"
 msgstr "Scope"
 
-#: inc/provider.class.php:111 inc/provider.class.php:291
+#: inc/provider.class.php:115 inc/provider.class.php:322
 msgid "Extra Options"
 msgstr "Extra Options"
 
-#: inc/provider.class.php:122 inc/provider.class.php:299
+#: inc/provider.class.php:126 inc/provider.class.php:330
 msgid "Authorize URL"
 msgstr "Authorize URL"
 
-#: inc/provider.class.php:127 inc/provider.class.php:307
+#: inc/provider.class.php:131 inc/provider.class.php:338
 msgid "Access Token URL"
 msgstr "Access Token URL"
 
-#: inc/provider.class.php:132 inc/provider.class.php:315
+#: inc/provider.class.php:136 inc/provider.class.php:346
 msgid "Resource Owner Details URL"
 msgstr "Resource Owner Details URL"
 
-#: inc/provider.class.php:166
+#: inc/provider.class.php:144
+msgid "Callback URL"
+msgstr "Callback URL"
+
+#: inc/provider.class.php:148
+msgid "Test Single Sign-on"
+msgstr "Test Single Sign-on"
+
+#: inc/provider.class.php:197
 msgid "A Name is required"
 msgstr "A Name is required"
 
-#: inc/provider.class.php:172
+#: inc/provider.class.php:203
 #, php-format
 msgid "The \"%s\" is a Invalid type"
 msgstr "The \"%s\" is a Invalid type"
 
-#: inc/provider.class.php:176
+#: inc/provider.class.php:207
 msgid "A Client ID is required"
 msgstr "A Client ID is required"
 
-#: inc/provider.class.php:180
+#: inc/provider.class.php:211
 msgid "A Client Secret is required"
 msgstr "A Client Secret is required"
 
-#: inc/provider.class.php:185
+#: inc/provider.class.php:216
 msgid "An Authorize URL is required"
 msgstr "An Authorize URL is required"
 
-#: inc/provider.class.php:187
+#: inc/provider.class.php:218
 msgid "The Authorize URL is invalid"
 msgstr "The Authorize URL is invalid"
 
-#: inc/provider.class.php:191
+#: inc/provider.class.php:222
 msgid "An Access Token URL is required"
 msgstr "An Access Token URL is required"
 
-#: inc/provider.class.php:193
+#: inc/provider.class.php:224
 msgid "The Access Token URL is invalid"
 msgstr "The Access Token URL is invalid"
 
-#: inc/provider.class.php:197
+#: inc/provider.class.php:228
 msgid "A Resource Owner Details URL is required"
 msgstr "A Resource Owner Details URL is required"
 
-#: inc/provider.class.php:199
+#: inc/provider.class.php:230
 msgid "The Resource Owner Details URL is invalid"
 msgstr "The Resource Owner Details URL is invalid"
 
-#: inc/provider.class.php:374
+#: inc/provider.class.php:405
 msgid "Generic"
 msgstr "Generic"
 
-#: inc/provider.class.php:375
+#: inc/provider.class.php:406
 msgid "Facebook"
 msgstr "Facebook"
 
-#: inc/provider.class.php:376
+#: inc/provider.class.php:407
 msgid "GitHub"
 msgstr "GitHub"
 
-#: inc/provider.class.php:377
+#: inc/provider.class.php:408
 msgid "Google"
 msgstr "Google"
 
-#: inc/provider.class.php:378
+#: inc/provider.class.php:409
 msgid "Instagram"
 msgstr "Instagram"
 
-#: inc/provider.class.php:379
+#: inc/provider.class.php:410
 msgid "LinkdeIn"
 msgstr "LinkdeIn"

+ 45 - 37
locales/pt_BR.po

@@ -8,7 +8,7 @@ msgstr ""
 "Project-Id-Version: singlesignon 1.0.0\n"
 "Report-Msgid-Bugs-To: https://github.com/edgardmessias/glpi-singlesignon/"
 "issues\n"
-"POT-Creation-Date: 2019-04-26 15:28-0300\n"
+"POT-Creation-Date: 2021-01-12 13:25-0300\n"
 "PO-Revision-Date: 2019-04-26 11:04-0300\n"
 "Last-Translator: Edgard Lorraine Messias <edgardmessias@gmail.com>\n"
 "Language-Team: none\n"
@@ -18,10 +18,10 @@ msgstr ""
 "Content-Transfer-Encoding: 8bit\n"
 "Plural-Forms: nplurals=2; plural=(n > 1);\n"
 
-#: hook.php:22
+#: hook.php:27 hook.php:75
 #, php-format
-msgid "[ Login with %s ]"
-msgstr "[ Entrar com %s ]"
+msgid "Login with %s"
+msgstr "Entrar com %s"
 
 #: setup.php:8
 #, php-format
@@ -29,127 +29,135 @@ msgid "Please, rename the plugin folder \"%s\" to \"singlesignon\""
 msgstr "Por favor, renomeie a pasta do plugin \"%s\" para \"singlesignon\""
 
 #: setup.php:36 front/provider.form.php:59 front/provider.form.php:61
-#: front/provider.php:6 front/provider.php:8 inc/provider.class.php:53
+#: front/provider.php:6 front/provider.php:8 inc/provider.class.php:57
 msgid "Single Sign-on"
 msgstr "Single Sign-on"
 
-#: setup.php:49
-msgid "Run first: composer install"
-msgstr "Execute primeiro: composer install"
-
 #: setup.php:53
 msgid "This plugin requires GLPI >= 0.85"
 msgstr "Este plugin requer GLPI >= 0.85"
 
-#: front/callback.php:11
+#: front/callback.php:15
 msgid "Provider not defined."
 msgstr "Provedor não definido."
 
-#: front/callback.php:17
+#: front/callback.php:21
 msgid "Provider not found."
 msgstr "Provedor não encontrado."
 
-#: front/callback.php:21
+#: front/callback.php:25
 msgid "Provider not active."
 msgstr "Provedor não ativo."
 
-#: inc/provider.class.php:46
+#: inc/provider.class.php:50
 msgid "Single Sign-on Provider"
 msgstr "Provedor Single Sign-on"
 
-#: inc/provider.class.php:94
+#: inc/provider.class.php:98
 msgid "SSO Type"
 msgstr "Tipo SSO"
 
-#: inc/provider.class.php:102 inc/provider.class.php:267
+#: inc/provider.class.php:106 inc/provider.class.php:298
 msgid "Client ID"
 msgstr "ID de Cliente"
 
-#: inc/provider.class.php:104 inc/provider.class.php:275
+#: inc/provider.class.php:108 inc/provider.class.php:306
 msgid "Client Secret"
 msgstr "Segredo do Cliente"
 
-#: inc/provider.class.php:109 inc/provider.class.php:283
+#: inc/provider.class.php:113 inc/provider.class.php:314
 msgid "Scope"
 msgstr "Escopo"
 
-#: inc/provider.class.php:111 inc/provider.class.php:291
+#: inc/provider.class.php:115 inc/provider.class.php:322
 msgid "Extra Options"
 msgstr "Opções Extras"
 
-#: inc/provider.class.php:122 inc/provider.class.php:299
+#: inc/provider.class.php:126 inc/provider.class.php:330
 msgid "Authorize URL"
 msgstr "URL de Autorização"
 
-#: inc/provider.class.php:127 inc/provider.class.php:307
+#: inc/provider.class.php:131 inc/provider.class.php:338
 msgid "Access Token URL"
 msgstr "URL de Token de Acesso"
 
-#: inc/provider.class.php:132 inc/provider.class.php:315
+#: inc/provider.class.php:136 inc/provider.class.php:346
 msgid "Resource Owner Details URL"
 msgstr "URL de Detalhes do Proprietário do Recurso"
 
-#: inc/provider.class.php:166
+#: inc/provider.class.php:144
+msgid "Callback URL"
+msgstr ""
+
+#: inc/provider.class.php:148
+#, fuzzy
+msgid "Test Single Sign-on"
+msgstr "Single Sign-on"
+
+#: inc/provider.class.php:197
 msgid "A Name is required"
 msgstr "Nome é obrigatório"
 
-#: inc/provider.class.php:172
+#: inc/provider.class.php:203
 #, php-format
 msgid "The \"%s\" is a Invalid type"
 msgstr "O \"%s\" é um tipo inválido"
 
-#: inc/provider.class.php:176
+#: inc/provider.class.php:207
 msgid "A Client ID is required"
 msgstr "ID de cliente é obrigatório"
 
-#: inc/provider.class.php:180
+#: inc/provider.class.php:211
 msgid "A Client Secret is required"
 msgstr "Segredo do Cliente é obrigatório"
 
-#: inc/provider.class.php:185
+#: inc/provider.class.php:216
 msgid "An Authorize URL is required"
 msgstr "URL de Autorização é obrigatório"
 
-#: inc/provider.class.php:187
+#: inc/provider.class.php:218
 msgid "The Authorize URL is invalid"
 msgstr "A URL de Autorização é inválida"
 
-#: inc/provider.class.php:191
+#: inc/provider.class.php:222
 msgid "An Access Token URL is required"
 msgstr "URL de Token de Acesso é obrigatório"
 
-#: inc/provider.class.php:193
+#: inc/provider.class.php:224
 msgid "The Access Token URL is invalid"
 msgstr "A URL de Token de Acesso é inválida"
 
-#: inc/provider.class.php:197
+#: inc/provider.class.php:228
 msgid "A Resource Owner Details URL is required"
 msgstr "URL de Detalhes do Proprietário do Recurso é obrigatório"
 
-#: inc/provider.class.php:199
+#: inc/provider.class.php:230
 msgid "The Resource Owner Details URL is invalid"
 msgstr "A URL de Detalhes do Proprietário do Recurso é inválida"
 
-#: inc/provider.class.php:374
+#: inc/provider.class.php:405
 msgid "Generic"
 msgstr "Generic"
 
-#: inc/provider.class.php:375
+#: inc/provider.class.php:406
 msgid "Facebook"
 msgstr "Facebook"
 
-#: inc/provider.class.php:376
+#: inc/provider.class.php:407
 msgid "GitHub"
 msgstr "GitHub"
 
-#: inc/provider.class.php:377
+#: inc/provider.class.php:408
 msgid "Google"
 msgstr "Google"
 
-#: inc/provider.class.php:378
+#: inc/provider.class.php:409
 msgid "Instagram"
 msgstr "Instagram"
 
-#: inc/provider.class.php:379
+#: inc/provider.class.php:410
 msgid "LinkdeIn"
 msgstr "LinkdeIn"
+
+#~ msgid "Run first: composer install"
+#~ msgstr "Execute primeiro: composer install"

+ 40 - 36
locales/singlesignon.pot

@@ -9,7 +9,7 @@ msgstr ""
 "Project-Id-Version: singlesignon 1.0.0\n"
 "Report-Msgid-Bugs-To: https://github.com/edgardmessias/glpi-singlesignon/"
 "issues\n"
-"POT-Creation-Date: 2019-04-29 09:32-0300\n"
+"POT-Creation-Date: 2021-01-12 13:25-0300\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
@@ -18,9 +18,9 @@ msgstr ""
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
 
-#: hook.php:22
+#: hook.php:27 hook.php:75
 #, php-format
-msgid "[ Login with %s ]"
+msgid "Login with %s"
 msgstr ""
 
 #: setup.php:8
@@ -29,127 +29,131 @@ msgid "Please, rename the plugin folder \"%s\" to \"singlesignon\""
 msgstr ""
 
 #: setup.php:36 front/provider.form.php:59 front/provider.form.php:61
-#: front/provider.php:6 front/provider.php:8 inc/provider.class.php:53
+#: front/provider.php:6 front/provider.php:8 inc/provider.class.php:57
 msgid "Single Sign-on"
 msgstr ""
 
-#: setup.php:49
-msgid "Run first: composer install"
-msgstr ""
-
 #: setup.php:53
 msgid "This plugin requires GLPI >= 0.85"
 msgstr ""
 
-#: front/callback.php:11
+#: front/callback.php:15
 msgid "Provider not defined."
 msgstr ""
 
-#: front/callback.php:17
+#: front/callback.php:21
 msgid "Provider not found."
 msgstr ""
 
-#: front/callback.php:21
+#: front/callback.php:25
 msgid "Provider not active."
 msgstr ""
 
-#: inc/provider.class.php:46
+#: inc/provider.class.php:50
 msgid "Single Sign-on Provider"
 msgstr ""
 
-#: inc/provider.class.php:94
+#: inc/provider.class.php:98
 msgid "SSO Type"
 msgstr ""
 
-#: inc/provider.class.php:102 inc/provider.class.php:267
+#: inc/provider.class.php:106 inc/provider.class.php:298
 msgid "Client ID"
 msgstr ""
 
-#: inc/provider.class.php:104 inc/provider.class.php:275
+#: inc/provider.class.php:108 inc/provider.class.php:306
 msgid "Client Secret"
 msgstr ""
 
-#: inc/provider.class.php:109 inc/provider.class.php:283
+#: inc/provider.class.php:113 inc/provider.class.php:314
 msgid "Scope"
 msgstr ""
 
-#: inc/provider.class.php:111 inc/provider.class.php:291
+#: inc/provider.class.php:115 inc/provider.class.php:322
 msgid "Extra Options"
 msgstr ""
 
-#: inc/provider.class.php:122 inc/provider.class.php:299
+#: inc/provider.class.php:126 inc/provider.class.php:330
 msgid "Authorize URL"
 msgstr ""
 
-#: inc/provider.class.php:127 inc/provider.class.php:307
+#: inc/provider.class.php:131 inc/provider.class.php:338
 msgid "Access Token URL"
 msgstr ""
 
-#: inc/provider.class.php:132 inc/provider.class.php:315
+#: inc/provider.class.php:136 inc/provider.class.php:346
 msgid "Resource Owner Details URL"
 msgstr ""
 
-#: inc/provider.class.php:166
+#: inc/provider.class.php:144
+msgid "Callback URL"
+msgstr ""
+
+#: inc/provider.class.php:148
+msgid "Test Single Sign-on"
+msgstr ""
+
+#: inc/provider.class.php:197
 msgid "A Name is required"
 msgstr ""
 
-#: inc/provider.class.php:172
+#: inc/provider.class.php:203
 #, php-format
 msgid "The \"%s\" is a Invalid type"
 msgstr ""
 
-#: inc/provider.class.php:176
+#: inc/provider.class.php:207
 msgid "A Client ID is required"
 msgstr ""
 
-#: inc/provider.class.php:180
+#: inc/provider.class.php:211
 msgid "A Client Secret is required"
 msgstr ""
 
-#: inc/provider.class.php:185
+#: inc/provider.class.php:216
 msgid "An Authorize URL is required"
 msgstr ""
 
-#: inc/provider.class.php:187
+#: inc/provider.class.php:218
 msgid "The Authorize URL is invalid"
 msgstr ""
 
-#: inc/provider.class.php:191
+#: inc/provider.class.php:222
 msgid "An Access Token URL is required"
 msgstr ""
 
-#: inc/provider.class.php:193
+#: inc/provider.class.php:224
 msgid "The Access Token URL is invalid"
 msgstr ""
 
-#: inc/provider.class.php:197
+#: inc/provider.class.php:228
 msgid "A Resource Owner Details URL is required"
 msgstr ""
 
-#: inc/provider.class.php:199
+#: inc/provider.class.php:230
 msgid "The Resource Owner Details URL is invalid"
 msgstr ""
 
-#: inc/provider.class.php:374
+#: inc/provider.class.php:405
 msgid "Generic"
 msgstr ""
 
-#: inc/provider.class.php:375
+#: inc/provider.class.php:406
 msgid "Facebook"
 msgstr ""
 
-#: inc/provider.class.php:376
+#: inc/provider.class.php:407
 msgid "GitHub"
 msgstr ""
 
-#: inc/provider.class.php:377
+#: inc/provider.class.php:408
 msgid "Google"
 msgstr ""
 
-#: inc/provider.class.php:378
+#: inc/provider.class.php:409
 msgid "Instagram"
 msgstr ""
 
-#: inc/provider.class.php:379
+#: inc/provider.class.php:410
 msgid "LinkdeIn"
 msgstr ""