';
@@ -377,6 +332,53 @@ print '
';
+
+print ' ';
+
+if (!getDolGlobalString('MULTICURRENCY_DISABLE_SYNC_CURRENCYLAYER')) {
+ print '';
+}
+
+
// End of page
llxFooter();
$db->close();
diff --git a/htdocs/core/modules/modMultiCurrency.class.php b/htdocs/core/modules/modMultiCurrency.class.php
index c1e1a3a795a..2abcf240310 100644
--- a/htdocs/core/modules/modMultiCurrency.class.php
+++ b/htdocs/core/modules/modMultiCurrency.class.php
@@ -150,7 +150,7 @@ class modMultiCurrency extends DolibarrModules
$datestart=dol_mktime(21, 15, 0, $arraydate['mon'], $arraydate['mday'], $arraydate['year']);
$this->cronjobs = array(
- 0 =>array('priority'=>61, 'label'=>'MutltiCurrencyAutoUpdateCurrencies', 'jobtype'=>'method', 'class'=>'multicurrency/class/multicurrency.class.php', 'objectname'=>'MultiCurrency', 'method'=>'syncRates', 'parameters'=>'0,0,cron', 'comment'=>'Update all the currencies using the currencylayer API. An APi key needs to be given in the multi-currency module config on constant MULTICURRENCY_APP_ID', 'frequency'=>1, 'unitfrequency'=>2678400, 'status'=>$statusatinstall, 'test'=>'isModEnabled("cron")', 'datestart'=>$datestart),
+ 0 =>array('priority'=>61, 'label'=>'MutltiCurrencyAutoUpdateCurrencies', 'jobtype'=>'method', 'class'=>'multicurrency/class/multicurrency.class.php', 'objectname'=>'MultiCurrency', 'method'=>'syncRates', 'parameters'=>'0,0,cron', 'comment'=>'Update all the currencies using the currencylayer API. An APi key needs to be given in the multi-currency module config page', 'frequency'=>1, 'unitfrequency'=>2678400, 'status'=>$statusatinstall, 'test'=>'isModEnabled("cron")', 'datestart'=>$datestart),
);
// Permissions
diff --git a/htdocs/multicurrency/class/multicurrency.class.php b/htdocs/multicurrency/class/multicurrency.class.php
index bee9aa4eced..a895c830d7e 100644
--- a/htdocs/multicurrency/class/multicurrency.class.php
+++ b/htdocs/multicurrency/class/multicurrency.class.php
@@ -638,15 +638,24 @@ class MultiCurrency extends CommonObject
/**
* Sync rates from API
*
- * @param string $key Key to use. Come from $conf->global->MULTICURRENCY_APP_ID.
+ * @param string $key Key to use. Come from getDolGlobalString("MULTICURRENCY_APP_ID")
* @param int $addifnotfound Add if not found
* @param string $mode "" for standard use, "cron" to use it in a cronjob
- * @return int <0 if KO, >0 if OK, if mode = "cron" OK is
+ * @return int <0 if KO, >0 if OK, if mode = "cron" OK is 0
*/
public function syncRates($key, $addifnotfound = 0, $mode = "")
{
global $conf, $db, $langs;
+ if (!getDolGlobalString('MULTICURRENCY_DISABLE_SYNC_CURRENCYLAYER')) {
+ if ($mode == "cron") {
+ $this->output = $langs->trans('Use of API for currency update is disabled by option MULTICURRENCY_DISABLE_SYNC_CURRENCYLAYER');
+ } else {
+ setEventMessages($langs->trans('Use of API for currency update is disabled by option MULTICURRENCY_DISABLE_SYNC_CURRENCYLAYER'), null, 'errors');
+ }
+ return -1;
+ }
+
if (empty($key)) {
$key = getDolGlobalString("MULTICURRENCY_APP_ID");
}
@@ -688,9 +697,9 @@ class MultiCurrency extends CommonObject
dol_syslog("Failed to call endpoint ".$response->error->info, LOG_WARNING);
if ($mode == "cron") {
$this->output = $langs->trans('multicurrency_syncronize_error', $response->error->info);
+ } else {
+ setEventMessages($langs->trans('multicurrency_syncronize_error', $response->error->info), null, 'errors');
}
- setEventMessages($langs->trans('multicurrency_syncronize_error', $response->error->info), null, 'errors');
-
return -1;
}
} else {