瀏覽代碼

Updated to PHP 5.6 requirement

Edgard 6 年之前
父節點
當前提交
1b4ad66ba7
共有 6 個文件被更改,包括 51 次插入56 次删除
  1. 0 3
      .phpcs.xml
  2. 6 6
      front/callback.php
  3. 6 6
      hook.php
  4. 33 33
      inc/provider.class.php
  5. 2 4
      locales/pt_BR.po
  6. 4 4
      setup.php

+ 0 - 3
.phpcs.xml

@@ -3,10 +3,7 @@
 
    <!-- rules -->
    <rule ref="./vendor/glpi-project/coding-standard/GlpiStandard">
-      <exclude name="Generic.Arrays.DisallowLongArraySyntax" />
    </rule>
-   <!-- keep support for php 5.3 -->
-   <rule ref="Generic.Arrays.DisallowShortArraySyntax" />
 
    <!-- files -->
    <file>.</file>

+ 6 - 6
front/callback.php

@@ -5,7 +5,7 @@
 
 include ('../../../inc/includes.php');
 
-$params = array();
+$params = [];
 
 if (isset($_SERVER['PATH_INFO'])) {
    $path_info = trim($_SERVER['PATH_INFO'], '/');
@@ -42,15 +42,15 @@ if (!$signon_provider->fields['is_active']) {
    Html::displayErrorAndDie(__sso("Provider not active."), true);
 }
 
-$httpClient = new GuzzleHttp\Client(array(
+$httpClient = new GuzzleHttp\Client([
    'verify' => false,
-      ));
+      ]);
 
-$collaborators = array(
+$collaborators = [
    'httpClient' => $httpClient,
-);
+];
 
-$signon_provider->prepareProviderInstance(array(), $collaborators);
+$signon_provider->prepareProviderInstance([], $collaborators);
 
 $signon_provider->checkAuthorization();
 

+ 6 - 6
hook.php

@@ -16,7 +16,7 @@ function plugin_singlesignon_display_login() {
 
    $rows = $signon_provider->find('`is_active` = 1');
 
-   $html = array();
+   $html = [];
 
    foreach ($rows as $row) {
       $html[] = '<a href="' . $url_prefix . '/provider/' . $row['id'] . $url_sufix . '" class="singlesignon" style="color: #CFCFCF">[ Login with ' . $row['name'] . ' ]</a>';
@@ -44,8 +44,8 @@ function plugin_singlesignon_install() {
 
    $currentVersion = '0.0.0';
 
-   $default = array(
-   );
+   $default = [
+   ];
 
    $current = Config::getConfigurationValues('singlesignon');
 
@@ -93,9 +93,9 @@ function plugin_singlesignon_install() {
       //      $DB->query($query) or die("error populate glpi_plugin_example " . $DB->error());
    }
 
-   Config::setConfigurationValues('singlesignon', array(
+   Config::setConfigurationValues('singlesignon', [
       'version' => PLUGIN_SINGLESIGNON_VERSION,
-   ));
+   ]);
    return true;
 }
 
@@ -106,7 +106,7 @@ function plugin_singlesignon_uninstall() {
    $rows = $config->find("`context` LIKE 'singlesignon%'");
 
    foreach ($rows as $id => $row) {
-      $config->delete(array('id' => $id));
+      $config->delete(['id' => $id]);
    }
 
    // Old version tables

+ 33 - 33
inc/provider.class.php

@@ -58,7 +58,7 @@ class PluginSinglesignonProvider extends CommonDBTM {
     * */
    static function getAdditionalMenuLinks() {
       global $CFG_GLPI;
-      $links = array();
+      $links = [];
 
       //      $links['add'] = '/plugins/singlesignon/front/provider.form.php';
       //      $links['config'] = '/plugins/singlesignon/index.php';
@@ -68,9 +68,9 @@ class PluginSinglesignonProvider extends CommonDBTM {
       return $links;
    }
 
-   function defineTabs($options = array()) {
+   function defineTabs($options = []) {
 
-      $ong = array();
+      $ong = [];
       $this->addDefaultFormTab($ong);
       $this->addStandardTab(__CLASS__, $ong, $options);
       $this->addStandardTab('Log', $ong, $options);
@@ -83,7 +83,7 @@ class PluginSinglesignonProvider extends CommonDBTM {
       $this->fields["is_active"] = 1;
    }
 
-   function showForm($ID, $options = array()) {
+   function showForm($ID, $options = []) {
       global $CFG_GLPI;
 
       $this->initForm($ID, $options);
@@ -107,7 +107,7 @@ class PluginSinglesignonProvider extends CommonDBTM {
 
       echo "<tr class='tab_bg_1'>";
       echo "<td>" . __sso('SSO Type') . "</td><td>";
-      self::dropdownType('type', array('value' => $this->fields["type"], 'on_change' => $on_change));
+      self::dropdownType('type', ['value' => $this->fields["type"], 'on_change' => $on_change]);
       echo "<td>" . __('Active') . "</td>";
       echo "<td>";
       Dropdown::showYesNo("is_active", $this->fields["is_active"]);
@@ -169,7 +169,7 @@ class PluginSinglesignonProvider extends CommonDBTM {
     * @return array
     */
    private function prepareInput($input) {
-      $error_detected = array();
+      $error_detected = [];
 
       $type = '';
       //check for requirements
@@ -231,7 +231,7 @@ class PluginSinglesignonProvider extends CommonDBTM {
 
    function getSearchOptions() {
 
-      $tab = array();
+      $tab = [];
       $tab['common'] = __('Characteristics');
 
       $tab[1]['table'] = $this->getTable();
@@ -293,10 +293,10 @@ class PluginSinglesignonProvider extends CommonDBTM {
       return $tab;
    }
 
-   static function getSpecificValueToDisplay($field, $values, array $options = array()) {
+   static function getSpecificValueToDisplay($field, $values, array $options = []) {
 
       if (!is_array($values)) {
-         $values = array($field => $values);
+         $values = [$field => $values];
       }
       switch ($field) {
          case 'type':
@@ -307,10 +307,10 @@ class PluginSinglesignonProvider extends CommonDBTM {
       return '';
    }
 
-   static function getSpecificValueToSelect($field, $name = '', $values = '', array $options = array()) {
+   static function getSpecificValueToSelect($field, $name = '', $values = '', array $options = []) {
 
       if (!is_array($values)) {
-         $values = array($field => $values);
+         $values = [$field => $values];
       }
       $options['display'] = false;
       switch ($field) {
@@ -361,10 +361,10 @@ class PluginSinglesignonProvider extends CommonDBTM {
     *
     * @return string id of the select
     * */
-   static function dropdownType($name, $options = array()) {
+   static function dropdownType($name, $options = []) {
 
       $params['value'] = 0;
-      $params['toadd'] = array();
+      $params['toadd'] = [];
       $params['on_change'] = '';
       $params['display'] = true;
 
@@ -374,7 +374,7 @@ class PluginSinglesignonProvider extends CommonDBTM {
          }
       }
 
-      $items = array();
+      $items = [];
       if (count($params['toadd']) > 0) {
          $items = $params['toadd'];
       }
@@ -431,11 +431,11 @@ class PluginSinglesignonProvider extends CommonDBTM {
       switch ($ma->getAction()) {
          case 'DoIt':
             echo "&nbsp;<input type='hidden' name='toto' value='1'>" .
-            Html::submit(_x('button', 'Post'), array('name' => 'massiveaction')) .
+            Html::submit(_x('button', 'Post'), ['name' => 'massiveaction']) .
             " " . __('Write in item history', 'example');
             return true;
          case 'do_nothing' :
-            echo "&nbsp;" . Html::submit(_x('button', 'Post'), array('name' => 'massiveaction')) .
+            echo "&nbsp;" . Html::submit(_x('button', 'Post'), ['name' => 'massiveaction']) .
             " " . __('but do nothing :)', 'example');
             return true;
       }
@@ -455,7 +455,7 @@ class PluginSinglesignonProvider extends CommonDBTM {
             if ($item->getType() == 'Computer') {
                Session::addMessageAfterRedirect(__("Right it is the type I want...", 'example'));
                Session::addMessageAfterRedirect(__('Write in item history', 'example'));
-               $changes = array(0, 'old value', 'new value');
+               $changes = [0, 'old value', 'new value'];
                foreach ($ids as $id) {
                   if ($item->getFromDB($id)) {
                      Session::addMessageAfterRedirect("- " . $item->getField("name"));
@@ -500,10 +500,10 @@ class PluginSinglesignonProvider extends CommonDBTM {
     * @param array $collaborators
     * @return \League\OAuth2\Client\Provider\AbstractProvider
     */
-   public static function createInstance($type = 'generic', array $options = array(), array $collaborators = array()) {
+   public static function createInstance($type = 'generic', array $options = [], array $collaborators = []) {
 
       if (!isset($options['scope'])) {
-         $options['scope'] = array();
+         $options['scope'] = [];
       }
 
       switch ($type) {
@@ -540,7 +540,7 @@ class PluginSinglesignonProvider extends CommonDBTM {
       return $currentURL;
    }
 
-   public function prepareProviderInstance(array $options = array(), array $collaborators = array()) {
+   public function prepareProviderInstance(array $options = [], array $collaborators = []) {
       global $CFG_GLPI;
 
       if ($this->_provider === null) {
@@ -548,11 +548,11 @@ class PluginSinglesignonProvider extends CommonDBTM {
          $redirect_uri = $this->getCurrentURL();
 
          $type = $this->fields['type'];
-         $default = array(
+         $default = [
             'clientId' => $this->fields['client_id'],
             'clientSecret' => $this->fields['client_secret'],
             'redirectUri' => $redirect_uri,
-         );
+         ];
 
          if ($type === 'generic') {
             $default['urlAuthorize'] = $this->fields['url_authorize'];
@@ -564,7 +564,7 @@ class PluginSinglesignonProvider extends CommonDBTM {
             try {
                $extra = json_decode($this->fields['extra_options'], true);
             } catch (Exception $ex) {
-               $extra = array();
+               $extra = [];
             }
 
             if (!empty($extra)) {
@@ -589,15 +589,15 @@ class PluginSinglesignonProvider extends CommonDBTM {
 
       if (!isset($_GET['code'])) {
 
-         $scope = array();
+         $scope = [];
          if (!empty($this->fields['scope'])) {
             $scope = explode(',', $this->fields['scope']);
          }
 
-         $options = array(
+         $options = [
             'scope' => $scope,
             'state' => Session::getNewCSRFToken(),
-         );
+         ];
 
          $this->_provider->authorize($options);
       }
@@ -605,9 +605,9 @@ class PluginSinglesignonProvider extends CommonDBTM {
       // Check given state against previously stored one to mitigate CSRF attack
       $state = isset($_GET['state']) ? $_GET['state'] : '';
 
-      Session::checkCSRF(array(
+      Session::checkCSRF([
          '_glpi_csrf_token' => $state,
-      ));
+      ]);
 
       $this->_code = $_GET['code'];
 
@@ -627,9 +627,9 @@ class PluginSinglesignonProvider extends CommonDBTM {
          return false;
       }
 
-      $this->_token = $this->_provider->getAccessToken('authorization_code', array(
+      $this->_token = $this->_provider->getAccessToken('authorization_code', [
          'code' => $this->_code
-      ));
+      ]);
 
       return $this->_token;
    }
@@ -662,7 +662,7 @@ class PluginSinglesignonProvider extends CommonDBTM {
       //First: check linked user
 
       $email = false;
-      $email_fields = array('email', 'e-mail', 'email-address');
+      $email_fields = ['email', 'e-mail', 'email-address'];
 
       foreach ($email_fields as $field) {
          if (isset($resource_array[$field]) && is_string($resource_array[$field])) {
@@ -674,7 +674,7 @@ class PluginSinglesignonProvider extends CommonDBTM {
       $default_condition = '';
 
       if (version_compare(GLPI_VERSION, '9.3', '>=')) {
-         $default_condition = array();
+         $default_condition = [];
       }
 
       if ($email && $user->getFromDBbyEmail($email, $default_condition)) {
@@ -682,7 +682,7 @@ class PluginSinglesignonProvider extends CommonDBTM {
       }
 
       $login = false;
-      $login_fields = array('login', 'username');
+      $login_fields = ['login', 'username'];
 
       foreach ($login_fields as $field) {
          if (isset($resource_array[$field]) && is_string($resource_array[$field])) {

+ 2 - 4
locales/pt_BR.po

@@ -5,7 +5,7 @@
 #
 msgid ""
 msgstr ""
-"Project-Id-Version: \n"
+"Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
 "POT-Creation-Date: 2019-04-26 10:56-0300\n"
 "PO-Revision-Date: 2019-04-26 11:04-0300\n"
@@ -14,9 +14,7 @@ msgstr ""
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=ISO-8859-1\n"
 "Content-Transfer-Encoding: 8bit\n"
-"Plural-Forms: nplurals=2; plural=(n != 1);\n"
-"Language: pt_BR\n"
-"X-Generator: Poedit 1.7.4\n"
+"Plural-Forms: nplurals=2; plural=(n > 1);\n"
 
 #: setup.php:29 front/provider.form.php:59 front/provider.form.php:61
 #: front/provider.php:6 front/provider.php:8 inc/provider.class.php:53

+ 4 - 4
setup.php

@@ -18,20 +18,20 @@ function plugin_init_singlesignon() {
 
    $PLUGIN_HOOKS['display_login']['singlesignon'] = "plugin_singlesignon_display_login";
 
-   $PLUGIN_HOOKS['menu_toadd']['singlesignon'] = array(
+   $PLUGIN_HOOKS['menu_toadd']['singlesignon'] = [
       'config'  => 'PluginSinglesignonProvider',
-   );
+   ];
 }
 
 // Get the name and the version of the plugin - Needed
 function plugin_version_singlesignon() {
-   return array(
+   return [
       'name'           => __sso('Single Sign-on'),
       'version'        => PLUGIN_SINGLESIGNON_VERSION,
       'author'         => 'Edgard Lorraine Messias',
       'homepage'       => 'https://github.com/edgardmessias/glpi-singlesignon',
       'minGlpiVersion' => '0.85'
-   );
+   ];
 }
 
 // Optional : check prerequisites before install : may print errors or add to message after redirect