diff --git a/datamodels/2.x/itop-hub-connector/datamodel.itop-hub-connector.xml b/datamodels/2.x/itop-hub-connector/datamodel.itop-hub-connector.xml index b28f107b7d..65b2cbb126 100644 --- a/datamodels/2.x/itop-hub-connector/datamodel.itop-hub-connector.xml +++ b/datamodels/2.x/itop-hub-connector/datamodel.itop-hub-connector.xml @@ -15,12 +15,13 @@ https://www.itophub.io - /my-instances/landing-from-remote - /stateless-remote-itop/landing-from-remote-stateless - /api/messages - /api/messages/mark-all-as-read - /messages + /my-instances/landing-from-remote + /stateless-remote-itop/landing-from-remote-stateless + /api/messages + /api/messages/mark-all-as-read + /messages ../pages/exec.php?exec_module=itop-hub-connector&exec_page=launch.php&target=inform_after_setup + https://www.itophub.io/page/data-privacy diff --git a/dictionaries/cs.dictionary.itop.ui.php b/dictionaries/cs.dictionary.itop.ui.php index 4ef65dfbd2..5eb2c94449 100755 --- a/dictionaries/cs.dictionary.itop.ui.php +++ b/dictionaries/cs.dictionary.itop.ui.php @@ -472,6 +472,8 @@ We hope you’ll enjoy this version as much as we enjoyed imagining and creating 'UI:Error:MaintenanceTitle' => 'Maintenance~~', 'UI:Error:InvalidToken' => 'Error: the requested operation has already been performed (CSRF token not found)~~', + 'UI:Error:SMTP:UnknownVendor' => 'OAuth SMTP provider %1$s does not exist (email_transport_smtp.oauth.provider)~~', + 'UI:GroupBy:Count' => 'Množství', 'UI:GroupBy:Count+' => 'Množství prvků', 'UI:CountOfObjects' => 'Počet objektů odpovídajícíh ktritériím: %1$d', diff --git a/dictionaries/da.dictionary.itop.ui.php b/dictionaries/da.dictionary.itop.ui.php index 0de5a64fb6..e0f6d77b7c 100644 --- a/dictionaries/da.dictionary.itop.ui.php +++ b/dictionaries/da.dictionary.itop.ui.php @@ -461,6 +461,8 @@ We hope you’ll enjoy this version as much as we enjoyed imagining and creating 'UI:Error:MaintenanceTitle' => 'Maintenance~~', 'UI:Error:InvalidToken' => 'Error: the requested operation has already been performed (CSRF token not found)~~', + 'UI:Error:SMTP:UnknownVendor' => 'OAuth SMTP provider %1$s does not exist (email_transport_smtp.oauth.provider)~~', + 'UI:GroupBy:Count' => 'Antal', 'UI:GroupBy:Count+' => 'Antal af elementer', 'UI:CountOfObjects' => '%1$d objekter opfylder kriteriet.', diff --git a/dictionaries/de.dictionary.itop.ui.php b/dictionaries/de.dictionary.itop.ui.php index f8523f883b..6a188cda62 100644 --- a/dictionaries/de.dictionary.itop.ui.php +++ b/dictionaries/de.dictionary.itop.ui.php @@ -461,6 +461,8 @@ We hope you’ll enjoy this version as much as we enjoyed imagining and creating 'UI:Error:MaintenanceTitle' => 'Wartung', 'UI:Error:InvalidToken' => 'Error: The angeforderte Operation wurde bereits ausgeführt (CSRF-Token nicht gefunden)', + 'UI:Error:SMTP:UnknownVendor' => 'OAuth SMTP provider %1$s does not exist (email_transport_smtp.oauth.provider)~~', + 'UI:GroupBy:Count' => 'Anzahl', 'UI:GroupBy:Count+' => 'Anzahl der Elemente', 'UI:CountOfObjects' => '%1$d Objekte, die das Kriterium erfüllen.', diff --git a/dictionaries/en.dictionary.itop.ui.php b/dictionaries/en.dictionary.itop.ui.php index 843197999b..f9d07c0a52 100644 --- a/dictionaries/en.dictionary.itop.ui.php +++ b/dictionaries/en.dictionary.itop.ui.php @@ -483,6 +483,8 @@ We hope you’ll enjoy this version as much as we enjoyed imagining and creating 'UI:Error:MaintenanceTitle' => 'Maintenance', 'UI:Error:InvalidToken' => 'Error: the requested operation has already been performed (CSRF token not found)', + 'UI:Error:SMTP:UnknownVendor' => 'OAuth SMTP provider %1$s does not exist (email_transport_smtp.oauth.provider)', + 'UI:GroupBy:Count' => 'Count', 'UI:GroupBy:Count+' => 'Number of elements', 'UI:CountOfObjects' => '%1$d objects matching the criteria.', diff --git a/dictionaries/es_cr.dictionary.itop.ui.php b/dictionaries/es_cr.dictionary.itop.ui.php index 628eeb5cf4..31ccb483de 100644 --- a/dictionaries/es_cr.dictionary.itop.ui.php +++ b/dictionaries/es_cr.dictionary.itop.ui.php @@ -473,6 +473,8 @@ We hope you’ll enjoy this version as much as we enjoyed imagining and creating 'UI:Error:MaintenanceTitle' => 'Mantenimiento', 'UI:Error:InvalidToken' => 'Error: the requested operation has already been performed (CSRF token not found)~~', + 'UI:Error:SMTP:UnknownVendor' => 'OAuth SMTP provider %1$s does not exist (email_transport_smtp.oauth.provider)~~', + 'UI:GroupBy:Count' => 'Cuenta', 'UI:GroupBy:Count+' => 'Número de Elementos', 'UI:CountOfObjects' => '%1$d Elementos cumplen Criterio.', diff --git a/dictionaries/fr.dictionary.itop.ui.php b/dictionaries/fr.dictionary.itop.ui.php index c483bec278..92112c4018 100644 --- a/dictionaries/fr.dictionary.itop.ui.php +++ b/dictionaries/fr.dictionary.itop.ui.php @@ -467,6 +467,8 @@ Nous espérons que vous aimerez cette version autant que nous avons eu du plaisi 'UI:Error:MaintenanceTitle' => 'Maintenance', 'UI:Error:InvalidToken' => 'Erreur: l\'opération a déjà été effectuée (CSRF token not found)', + 'UI:Error:SMTP:UnknownVendor' => 'Le provider SMTP Oauth 2.0 %1$s n\'existe pas', + 'UI:GroupBy:Count' => 'Nombre', 'UI:GroupBy:Count+' => 'Nombre d\'éléments', 'UI:CountOfObjects' => '%1$d objets correspondants aux critères.', diff --git a/dictionaries/hu.dictionary.itop.ui.php b/dictionaries/hu.dictionary.itop.ui.php index d9ca1cc94f..8a1514f103 100755 --- a/dictionaries/hu.dictionary.itop.ui.php +++ b/dictionaries/hu.dictionary.itop.ui.php @@ -461,6 +461,8 @@ We hope you’ll enjoy this version as much as we enjoyed imagining and creating 'UI:Error:MaintenanceTitle' => 'Maintenance~~', 'UI:Error:InvalidToken' => 'Error: the requested operation has already been performed (CSRF token not found)~~', + 'UI:Error:SMTP:UnknownVendor' => 'OAuth SMTP provider %1$s does not exist (email_transport_smtp.oauth.provider)~~', + 'UI:GroupBy:Count' => 'Számossága', 'UI:GroupBy:Count+' => '', 'UI:CountOfObjects' => '%1$d darab objektum felel meg a kritériumoknak.', diff --git a/dictionaries/it.dictionary.itop.ui.php b/dictionaries/it.dictionary.itop.ui.php index 2b2476f3ff..855282309c 100644 --- a/dictionaries/it.dictionary.itop.ui.php +++ b/dictionaries/it.dictionary.itop.ui.php @@ -472,6 +472,8 @@ We hope you’ll enjoy this version as much as we enjoyed imagining and creating 'UI:Error:MaintenanceTitle' => 'Maintenance~~', 'UI:Error:InvalidToken' => 'Error: the requested operation has already been performed (CSRF token not found)~~', + 'UI:Error:SMTP:UnknownVendor' => 'OAuth SMTP provider %1$s does not exist (email_transport_smtp.oauth.provider)~~', + 'UI:GroupBy:Count' => 'Conteggio', 'UI:GroupBy:Count+' => '', 'UI:CountOfObjects' => '%1$d oggetti corrispondenti ai criteri.', diff --git a/dictionaries/ja.dictionary.itop.ui.php b/dictionaries/ja.dictionary.itop.ui.php index 6f8c193001..463eb43def 100644 --- a/dictionaries/ja.dictionary.itop.ui.php +++ b/dictionaries/ja.dictionary.itop.ui.php @@ -461,6 +461,8 @@ We hope you’ll enjoy this version as much as we enjoyed imagining and creating 'UI:Error:MaintenanceTitle' => 'Maintenance~~', 'UI:Error:InvalidToken' => 'Error: the requested operation has already been performed (CSRF token not found)~~', + 'UI:Error:SMTP:UnknownVendor' => 'OAuth SMTP provider %1$s does not exist (email_transport_smtp.oauth.provider)~~', + 'UI:GroupBy:Count' => 'カウント', 'UI:GroupBy:Count+' => '要素数', 'UI:CountOfObjects' => '%1$d 個のオブジェクトが条件にマッチしました。', diff --git a/dictionaries/nl.dictionary.itop.ui.php b/dictionaries/nl.dictionary.itop.ui.php index 3988f291b9..4aca724853 100644 --- a/dictionaries/nl.dictionary.itop.ui.php +++ b/dictionaries/nl.dictionary.itop.ui.php @@ -472,6 +472,8 @@ We hope you’ll enjoy this version as much as we enjoyed imagining and creating 'UI:Error:MaintenanceTitle' => 'Onderhoud', 'UI:Error:InvalidToken' => 'Error: the requested operation has already been performed (CSRF token not found)~~', + 'UI:Error:SMTP:UnknownVendor' => 'OAuth SMTP provider %1$s does not exist (email_transport_smtp.oauth.provider)~~', + 'UI:GroupBy:Count' => 'Aantal', 'UI:GroupBy:Count+' => 'Aantal objecten', 'UI:CountOfObjects' => '%1$d objecten voldoen aan de criteria.', diff --git a/dictionaries/pt_br.dictionary.itop.ui.php b/dictionaries/pt_br.dictionary.itop.ui.php index a6ff0e28ce..cb0b57fbb7 100644 --- a/dictionaries/pt_br.dictionary.itop.ui.php +++ b/dictionaries/pt_br.dictionary.itop.ui.php @@ -472,6 +472,8 @@ We hope you’ll enjoy this version as much as we enjoyed imagining and creating 'UI:Error:MaintenanceTitle' => 'Manutenção', 'UI:Error:InvalidToken' => 'Error: the requested operation has already been performed (CSRF token not found)~~', + 'UI:Error:SMTP:UnknownVendor' => 'OAuth SMTP provider %1$s does not exist (email_transport_smtp.oauth.provider)~~', + 'UI:GroupBy:Count' => 'Número', 'UI:GroupBy:Count+' => 'Número de elementos', 'UI:CountOfObjects' => '%1$d objetos correspondem aos critérios.', diff --git a/dictionaries/ru.dictionary.itop.ui.php b/dictionaries/ru.dictionary.itop.ui.php index 51a3e0d810..384fb5a9f2 100644 --- a/dictionaries/ru.dictionary.itop.ui.php +++ b/dictionaries/ru.dictionary.itop.ui.php @@ -473,6 +473,8 @@ Dict::Add('RU RU', 'Russian', 'Русский', array( 'UI:Error:MaintenanceTitle' => 'Техническое обслуживание', 'UI:Error:InvalidToken' => 'Error: the requested operation has already been performed (CSRF token not found)~~', + 'UI:Error:SMTP:UnknownVendor' => 'OAuth SMTP provider %1$s does not exist (email_transport_smtp.oauth.provider)~~', + 'UI:GroupBy:Count' => 'Количество', 'UI:GroupBy:Count+' => 'Количество элементов', 'UI:CountOfObjects' => '%1$d объектов соответствует критериям.', diff --git a/dictionaries/sk.dictionary.itop.ui.php b/dictionaries/sk.dictionary.itop.ui.php index 300d084cb9..a0ef197eb7 100644 --- a/dictionaries/sk.dictionary.itop.ui.php +++ b/dictionaries/sk.dictionary.itop.ui.php @@ -462,6 +462,8 @@ We hope you’ll enjoy this version as much as we enjoyed imagining and creating 'UI:Error:MaintenanceTitle' => 'Maintenance~~', 'UI:Error:InvalidToken' => 'Error: the requested operation has already been performed (CSRF token not found)~~', + 'UI:Error:SMTP:UnknownVendor' => 'OAuth SMTP provider %1$s does not exist (email_transport_smtp.oauth.provider)~~', + 'UI:GroupBy:Count' => 'Počet', 'UI:GroupBy:Count+' => '', 'UI:CountOfObjects' => '%1$d objekt/y/ov sa nezhoduje s kritériami.', diff --git a/dictionaries/tr.dictionary.itop.ui.php b/dictionaries/tr.dictionary.itop.ui.php index a0cf9a51ab..896f7823c6 100644 --- a/dictionaries/tr.dictionary.itop.ui.php +++ b/dictionaries/tr.dictionary.itop.ui.php @@ -472,6 +472,8 @@ We hope you’ll enjoy this version as much as we enjoyed imagining and creating 'UI:Error:MaintenanceTitle' => 'Maintenance~~', 'UI:Error:InvalidToken' => 'Error: the requested operation has already been performed (CSRF token not found)~~', + 'UI:Error:SMTP:UnknownVendor' => 'OAuth SMTP provider %1$s does not exist (email_transport_smtp.oauth.provider)~~', + 'UI:GroupBy:Count' => 'Say', 'UI:GroupBy:Count+' => 'Eleman sayısı', 'UI:CountOfObjects' => 'Kritere uyan %1$d nesne bulundu.', diff --git a/dictionaries/zh_cn.dictionary.itop.ui.php b/dictionaries/zh_cn.dictionary.itop.ui.php index a1f3fd83c1..a7b41a9a0d 100644 --- a/dictionaries/zh_cn.dictionary.itop.ui.php +++ b/dictionaries/zh_cn.dictionary.itop.ui.php @@ -477,6 +477,8 @@ We hope you’ll enjoy this version as much as we enjoyed imagining and creating 'UI:Error:MaintenanceTitle' => '维护', 'UI:Error:InvalidToken' => 'Error: 所请求的操作已执行 (未发现 CSRF token )', + 'UI:Error:SMTP:UnknownVendor' => 'OAuth SMTP provider %1$s does not exist (email_transport_smtp.oauth.provider)~~', + 'UI:GroupBy:Count' => '个数', 'UI:GroupBy:Count+' => '项目数', 'UI:CountOfObjects' => '%1$d 个对象符合指定的条件.', diff --git a/js/wizardhelper.js b/js/wizardhelper.js index c31f8ea87c..1523615144 100644 --- a/js/wizardhelper.js +++ b/js/wizardhelper.js @@ -176,6 +176,9 @@ function WizardHelper(sClass, sFormPrefix, sState, sInitialState, sStimulus) { var sString = "$('#"+aRefreshed[i]+"').trigger('change').trigger('update');"; window.setTimeout(sString, 1); // Synchronous 'trigger' does nothing, call it asynchronously } + if($('.blockUI').length == 0) { + $('.disabledDuringFieldLoading').prop("disabled", false).removeClass('disabledDuringFieldLoading'); + } }; this.UpdateWizard = function () { @@ -201,6 +204,10 @@ function WizardHelper(sClass, sFormPrefix, sState, sInitialState, sStimulus) { function (html) { $('#ajax_content').html(html); $('.blockUI').parent().unblock(); + + if($('.blockUI').length == 0) { + $('.disabledDuringFieldLoading').prop("disabled", false).removeClass('disabledDuringFieldLoading'); + } } ); }; @@ -235,6 +242,7 @@ function WizardHelper(sClass, sFormPrefix, sState, sInitialState, sStimulus) { this.ResetQuery(); this.UpdateWizard(); + var fieldForm=null; while (index < aFieldNames.length) { sAttCode = aFieldNames[index]; @@ -247,11 +255,16 @@ function WizardHelper(sClass, sFormPrefix, sState, sInitialState, sStimulus) { message: '', overlayCSS: {backgroundColor: '#f1f1f1', opacity: 0.3} }); + fieldForm=$('#field_' + sFieldId).closest('form'); this.RequestAllowedValues(sAttCode); } index++; } + if(fieldForm!=null){ + fieldForm.find('button[type=submit]:not(:disabled)').prop("disabled", true).addClass('disabledDuringFieldLoading'); + } + if (nbOfFieldsToUpdate > 0) { this.AjaxQueryServer(); diff --git a/lib/autoload.php b/lib/autoload.php index 460e675355..f1eeef5ab1 100644 --- a/lib/autoload.php +++ b/lib/autoload.php @@ -2,6 +2,11 @@ // autoload.php @generated by Composer +if (PHP_VERSION_ID < 50600) { + echo 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL; + exit(1); +} + require_once __DIR__ . '/composer/autoload_real.php'; return ComposerAutoloaderInit7f81b4a2a468a061c306af5e447a9a9f::getLoader(); diff --git a/lib/composer/ClassLoader.php b/lib/composer/ClassLoader.php index 0cd6055d1b..afef3fa2ad 100644 --- a/lib/composer/ClassLoader.php +++ b/lib/composer/ClassLoader.php @@ -149,7 +149,7 @@ class ClassLoader /** * @return string[] Array of classname => path - * @psalm-var array + * @psalm-return array */ public function getClassMap() { diff --git a/lib/composer/InstalledVersions.php b/lib/composer/InstalledVersions.php index 7c5502ca43..e7552a4a91 100644 --- a/lib/composer/InstalledVersions.php +++ b/lib/composer/InstalledVersions.php @@ -21,6 +21,8 @@ use Composer\Semver\VersionParser; * See also https://getcomposer.org/doc/07-runtime.md#installed-versions * * To require its presence, you can require `composer-runtime-api ^2.0` + * + * @final */ class InstalledVersions { diff --git a/lib/composer/autoload_classmap.php b/lib/composer/autoload_classmap.php index cff2ef251a..e377da9f3b 100644 --- a/lib/composer/autoload_classmap.php +++ b/lib/composer/autoload_classmap.php @@ -2,7 +2,7 @@ // autoload_classmap.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/lib/composer/autoload_namespaces.php b/lib/composer/autoload_namespaces.php index 1db5bf646e..6629b7e09b 100644 --- a/lib/composer/autoload_namespaces.php +++ b/lib/composer/autoload_namespaces.php @@ -2,7 +2,7 @@ // autoload_namespaces.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/lib/composer/autoload_psr4.php b/lib/composer/autoload_psr4.php index 5a52e9e005..0a7d4ce20d 100644 --- a/lib/composer/autoload_psr4.php +++ b/lib/composer/autoload_psr4.php @@ -2,7 +2,7 @@ // autoload_psr4.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/lib/composer/include_paths.php b/lib/composer/include_paths.php index d4fb967181..af33c14914 100644 --- a/lib/composer/include_paths.php +++ b/lib/composer/include_paths.php @@ -2,7 +2,7 @@ // include_paths.php @generated by Composer -$vendorDir = dirname(dirname(__FILE__)); +$vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( diff --git a/setup/wizardsteps.class.inc.php b/setup/wizardsteps.class.inc.php index 448439b8cf..89cc970989 100644 --- a/setup/wizardsteps.class.inc.php +++ b/setup/wizardsteps.class.inc.php @@ -695,41 +695,73 @@ class WizStepLicense extends WizardStep return array('class' => 'WizStepDBParams', 'state' => ''); } + private function NeedsRgpdConsent() + { + $sMode = $this->oWizard->GetParameter('install_mode'); + $aModules = SetupUtils::AnalyzeInstallation($this->oWizard); + return $sMode == 'install' && !SetupUtils::IsProductVersion($aModules); + } + /** * @param WebPage $oPage */ public function Display(WebPage $oPage) { - $aLicenses = SetupUtils::GetLicenses(); - $oPage->add_style( -<<add_style( + <<add('

Licenses agreements for the components of '.ITOP_APPLICATION.'

'); - $oPage->add_style('div a.no-arrow { background:transparent; padding-left:0;}'); - $oPage->add_style('.toggle { cursor:pointer; text-decoration:underline; color:#1C94C4; }'); - $oPage->add('
'); - $oPage->add('Components of '.ITOP_APPLICATION.''); - $oPage->add('
    '); - $index = 0; - foreach ($aLicenses as $oLicense) - { - $oPage->add('
  • '.$oLicense->product.', © '.$oLicense->author.' is licensed under the '.$oLicense->license_type.' license. (Details)'); - $oPage->add(''); - $oPage->add_ready_script('$(".license_text a").attr("target", "_blank").addClass("no-arrow");'); - $oPage->add_ready_script('$("#toggle_'.$index.'").on("click", function() { $("#license_'.$index.'").toggle(); } );'); - $index++; - } - $oPage->add('
'); - $oPage->add('
'); - $sChecked = ($this->oWizard->GetParameter('accept_license', 'no') == 'yes') ? ' checked ' : ''; - $oPage->add('
'); - $oPage->add_ready_script('$("#accept").bind("click change", function() { WizardUpdateButtons(); });'); + $oPage->add('

Licenses agreements for the components of '.ITOP_APPLICATION.'

'); + $oPage->add_style('div a.no-arrow { background:transparent; padding-left:0;}'); + $oPage->add_style('.toggle { cursor:pointer; text-decoration:underline; color:#1C94C4; }'); + $oPage->add('
'); + $oPage->add('Components of '.ITOP_APPLICATION.''); + $oPage->add('
    '); + $index = 0; + foreach ($aLicenses as $oLicense) { + $oPage->add('
  • '.$oLicense->product.', © '.$oLicense->author.' is licensed under the '.$oLicense->license_type.' license. (Details)'); + $oPage->add(''); + $oPage->add_ready_script('$(".license_text a").attr("target", "_blank").addClass("no-arrow");'); + $oPage->add_ready_script('$("#toggle_'.$index.'").on("click", function() { $("#license_'.$index.'").toggle(); } );'); + $index++; + } + $oPage->add('
'); + $oPage->add('
'); + $sChecked = ($this->oWizard->GetParameter('accept_license', 'no') == 'yes') ? ' checked ' : ''; + $oPage->add('
'); + if ($this->NeedsRgpdConsent()) { + $oPage->add('
'); + $oPage->add('
'); + $oPage->add('European General Data Protection Regulation'); + $oPage->add('
iTop software is compliant with the processing of personal data according to the European General Data Protection Regulation (GDPR).

+By installing iTop you agree that some information will be collected by Combodo to help you manage your instances and for statistical purposes. +This data remains anonymous until it is associated to a user account on iTop Hub.

+

List of collected data available in our Data privacy section.


'); + $oPage->add(''); + $oPage->add(''); + $oPage->add('
'); + } + $oPage->add_ready_script('$(".check_select").bind("click change", function() { WizardUpdateButtons(); });'); + + $oPage->add_script( + <<Get('email_transport_smtp.oauth.provider'); // email_transport_smtp.oauth.provider - $sProviderClass = "\Combodo\iTop\Core\Authentication\Client\OAuth\OAuthClientProvider".$sProviderVendor; + $sProviderClass = self::getProviderClass($sProviderVendor); $aProviderVendorParams = [ 'clientId' => MetaModel::GetConfig()->Get('email_transport_smtp.oauth.client_id'), // email_transport_smtp.oauth.client_id 'clientSecret' => MetaModel::GetConfig()->Get('email_transport_smtp.oauth.client_secret'),// email_transport_smtp.oauth.client_secret 'redirectUri' => $sProviderClass::GetRedirectUri(), - 'scope' => $sProviderClass::GetRequiredSMTPScope() + 'scope' => $sProviderClass::GetRequiredSMTPScope(), ]; $aAccessTokenParams = [ "access_token" => MetaModel::GetConfig()->Get('email_transport_smtp.oauth.access_token'), // email_transport_smtp.oauth.access_token "refresh_token" => MetaModel::GetConfig()->Get('email_transport_smtp.oauth.refresh_token'), // email_transport_smtp.oauth.refresh_token - 'scope' => $sProviderClass::GetRequiredSMTPScope() + 'scope' => $sProviderClass::GetRequiredSMTPScope(), ]; $aCollaborators = [ 'httpClient' => new Client(['verify' => false]), ]; - + return new $sProviderClass($aProviderVendorParams, $aCollaborators, $aAccessTokenParams); } - public static function getVendorProvider($sProviderVendor, $sClientId, $sClientSecret, $sScope, $aAdditional){ + + /** + * @param $sProviderVendor + * @param $sClientId + * @param $sClientSecret + * @param $sScope + * @param $aAdditional + * + * @return mixed + * @throws \CoreException + */ + public static function getVendorProvider($sProviderVendor, $sClientId, $sClientSecret, $sScope, $aAdditional) + { $sRedirectUrl = OAuthClientProviderAbstract::GetRedirectUri(); - $sProviderClass = "\Combodo\iTop\Core\Authentication\Client\OAuth\OAuthClientProvider".$sProviderVendor; + $sProviderClass = self::getProviderClass($sProviderVendor); $aCollaborators = [ 'httpClient' => new Client(['verify' => false]), ]; return new $sProviderClass(array_merge(['clientId' => $sClientId, 'clientSecret' => $sClientSecret, 'redirectUri' => $sRedirectUrl, 'scope' => $sScope], $aAdditional), $aCollaborators); } - - public static function getVendorProviderForAccessUrl($sProviderVendor, $sClientId, $sClientSecret, $sScope, $aAdditional){ + + public static function getVendorProviderForAccessUrl($sProviderVendor, $sClientId, $sClientSecret, $sScope, $aAdditional) + { $oProvider = static::getVendorProvider($sProviderVendor, $sClientId, $sClientSecret, $sScope, $aAdditional); + return $oProvider->GetVendorProvider()->getAuthorizationUrl([ 'scope' => [ - $sScope + $sScope, ], ]); } @@ -58,16 +79,33 @@ class OAuthClientProviderFactory { { return $oProvider->GetVendorProvider()->getAccessToken('authorization_code', ['code' => $sCode, 'scope' => $oProvider->GetScope()]); } - + public static function getConfFromRedirectUrl($sProviderVendor, $sClientId, $sClientSecret, $sRedirectUrlQuery) { $sRedirectUrl = OAuthClientProviderAbstract::GetRedirectUri(); - $sProviderClass = "\Combodo\iTop\Core\Authentication\Client\OAuth\OAuthClientProvider".$sProviderVendor; + $sProviderClass = self::getProviderClass($sProviderVendor); $aQuery = []; parse_str($sRedirectUrlQuery, $aQuery); $sCode = $aQuery['code']; $oProvider = new $sProviderClass(['clientId' => $sClientId, 'clientSecret' => $sClientSecret, 'redirectUri' => $sRedirectUrl]); + return $sProviderClass::getConfFromAccessToken($oProvider->GetVendorProvider()->getAccessToken('authorization_code', ['code' => $sCode]), $sClientId, $sClientSecret); } + /** + * @param $sProviderVendor + * + * @return string + * @throws \CoreException + */ + public static function getProviderClass($sProviderVendor): string + { + $sProviderClass = "\Combodo\iTop\Core\Authentication\Client\OAuth\OAuthClientProvider".$sProviderVendor; + if (!class_exists($sProviderClass)) { + throw new CoreException(dict::Format('UI:Error:SMTP:UnknownVendor', $sProviderVendor)); + } + + return $sProviderClass; + } + } \ No newline at end of file diff --git a/sources/Core/Authentication/Client/Smtp/SmtpOAuthLogin.php b/sources/Core/Authentication/Client/Smtp/SmtpOAuthLogin.php index 1b0f7b721b..1c261a5e73 100644 --- a/sources/Core/Authentication/Client/Smtp/SmtpOAuthLogin.php +++ b/sources/Core/Authentication/Client/Smtp/SmtpOAuthLogin.php @@ -92,7 +92,7 @@ class Oauth extends Login while (true) { $sResponse = $this->_receive(30); - IssueLog::Debug("SMTP Oauth receiving $sResponse", static::LOG_CHANNEL); + IssueLog::Debug("SMTP Oauth receiving ".trim($sResponse), static::LOG_CHANNEL); if ($sResponse === '+') { // Send empty client response.