diff --git a/htdocs/admin/oauth.php b/htdocs/admin/oauth.php
index 4b3525fa803..341cc3d75cd 100644
--- a/htdocs/admin/oauth.php
+++ b/htdocs/admin/oauth.php
@@ -294,7 +294,14 @@ print ' ';
/*
* Parameters
*/
-dol_fiche_head($head, $mode, $langs->trans("ModuleSetup"), 0, 'technic');
+dol_fiche_head(array(), '', '', 0, 'technic');
+
+
+// Define $urlwithroot
+$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
+$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
+//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
+
print '
';
@@ -307,6 +314,24 @@ foreach ($list as $key)
$label = $langs->trans($key[0]);
print ''.$label.' ';
+ if (in_array($key[0], array('OAUTH_GOOGLE_NAME')))
+ {
+ $redirect_uri=$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php';
+ $var = !$var;
+ print '';
+ print ''.$langs->trans("UseTheFollowingUrlAsRedirectURI").' ';
+ print '';
+ print ' ';
+ }
+ else
+ {
+ $var = !$var;
+ print '';
+ print ''.$langs->trans("UseTheFollowingUrlAsRedirectURI").' ';
+ print ''.$langs->trans("FeatureNotYetSupported").' ';
+ print ' ';
+ }
+
// Api Id
$var = !$var;
print '';
diff --git a/htdocs/core/modules/printing/printgcp.modules.php b/htdocs/core/modules/printing/printgcp.modules.php
index ab838270372..069762dde23 100644
--- a/htdocs/core/modules/printing/printgcp.modules.php
+++ b/htdocs/core/modules/printing/printgcp.modules.php
@@ -58,8 +58,13 @@ class printing_printgcp extends PrintingDriver
*/
function __construct($db)
{
- global $conf;
+ global $conf, $dolibarr_main_url_root;
+ // Define $urlwithroot
+ $urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
+ $urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
+ //$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
+
$this->db = $db;
$this->google_id = $conf->global->OAUTH_GOOGLE_ID;
$this->google_secret = $conf->global->OAUTH_GOOGLE_SECRET;
@@ -70,7 +75,7 @@ class printing_printgcp extends PrintingDriver
$credentials = new Credentials(
$this->google_id,
$this->google_secret,
- DOL_MAIN_URL_ROOT.'/core/modules/oauth/getgoogleoauthcallback.php'
+ $urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php'
);
$access = ($storage->hasAccessToken('Google')?'HasAccessToken':'NoAccessToken');
$serviceFactory = new \OAuth\ServiceFactory();
@@ -103,6 +108,7 @@ class printing_printgcp extends PrintingDriver
if (!$conf->oauth->enabled) {
$this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'ModuleAuthNotActive', 'type'=>'info');
} else {
+
if ($this->google_id != '' && $this->google_secret != '') {
$this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthConfigured', 'type'=>'info');
$this->conf[] = array('varname'=>'PRINTGCP_TOKEN_ACCESS', 'info'=>$access, 'type'=>'info');
@@ -112,7 +118,7 @@ class printing_printgcp extends PrintingDriver
$this->conf[] = array('varname'=>'PRINTGCP_TOKEN_EXPIRED', 'info'=>($expire?'Yes':'No'), 'type'=>'info');
$this->conf[] = array('varname'=>'PRINTGCP_TOKEN_EXPIRE_AT', 'info'=>(date("Y-m-d H:i:s", $token->getEndOfLife())), 'type'=>'info');
}
- $this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>DOL_MAIN_URL_ROOT.'/core/modules/oauth/getgoogleoauthcallback.php', 'type'=>'authlink');
+ $this->conf[] = array('varname'=>'PRINTGCP_AUTHLINK', 'link'=>$urlwithroot.'/core/modules/oauth/getgoogleoauthcallback.php', 'type'=>'authlink');
} else {
$this->conf[] = array('varname'=>'PRINTGCP_INFO', 'info'=>'GoogleAuthNotConfigured', 'type'=>'info');
}
diff --git a/htdocs/langs/en_US/oauth.lang b/htdocs/langs/en_US/oauth.lang
index a45f9920dea..ef58d605c49 100644
--- a/htdocs/langs/en_US/oauth.lang
+++ b/htdocs/langs/en_US/oauth.lang
@@ -1,5 +1,7 @@
# Dolibarr language file - Source file is en_US - oauth
ConfigOAuth=Oauth Configuration
+NoAccessToken=No token access saved.
+UseTheFollowingUrlAsRedirectURI=Use the following URL as the Redirect URI when creating your credential on your OAuth provider:
OAUTH_AMAZON_NAME=Api Amazon
OAUTH_AMAZON_ID=Api Amazon Id
OAUTH_AMAZON_SECRET=Api Amazon Secret
diff --git a/htdocs/langs/en_US/printing.lang b/htdocs/langs/en_US/printing.lang
index 81ee8071b2e..2e05349cfc8 100644
--- a/htdocs/langs/en_US/printing.lang
+++ b/htdocs/langs/en_US/printing.lang
@@ -81,3 +81,5 @@ STATE_IPP_none=None
MEDIA_IPP_stationery=Stationery
MEDIA_IPP_thermal=Thermal
IPP_COLOR_print-black=BW Printer
+GoogleAuthNotConfigured=Google OAuth setup not done. Enable module OAuth and set a Google ID/Secret.
+GoogleAuthConfigured=Google OAuth credentials found.
\ No newline at end of file
diff --git a/htdocs/printing/admin/printing.php b/htdocs/printing/admin/printing.php
index 6a28f352578..2f7e2f2da7f 100644
--- a/htdocs/printing/admin/printing.php
+++ b/htdocs/printing/admin/printing.php
@@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/printing/lib/printing.lib.php';
$langs->load("admin");
$langs->load("printing");
+$langs->load("oauth");
if (! $user->admin) accessforbidden();
@@ -178,15 +179,17 @@ if ($mode == 'setup' && $user->admin)
}
print '
';
+
+ dol_fiche_end();
+
if (! empty($driver))
{
if ($submit_enabled) {
print '
';
}
}
- print '';
- dol_fiche_end();
+ print '';
}
if ($mode == 'config' && $user->admin)
{