diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index 7e37437e42e..2d1040ac9cb 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -1709,6 +1709,25 @@ class BlockedLog } + /** + * Check if module can be enabled. + * + * @return string '' if ok, error message if not possible + */ + public function canBeEnabled() + { + global $dolibarr_main_force_https; + + include_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php'; + + if (isALNEQualifiedVersion(0, 1) && empty($dolibarr_main_force_https)) { + return 'Error: The HTTPS must be forced by setting the $dolibarr_main_force_https into Dolibarr conf/conf.php file to allow the use of this module in France.'; + } + + return ''; + } + + /** * Check if module can be disabled. * @@ -1718,6 +1737,8 @@ class BlockedLog { global $mysoc; + include_once DOL_DOCUMENT_ROOT.'/blockedlog/lib/blockedlog.lib.php'; + $canbedisabled = 1; if (isALNEQualifiedVersion() && $mysoc->country_code == 'FR') { $canbedisabled = 0; diff --git a/htdocs/core/modules/modBlockedLog.class.php b/htdocs/core/modules/modBlockedLog.class.php index 3a83ed5d018..1486a70039d 100644 --- a/htdocs/core/modules/modBlockedLog.class.php +++ b/htdocs/core/modules/modBlockedLog.class.php @@ -171,17 +171,20 @@ class modBlockedLog extends DolibarrModules $sql = array(); + + require_once DOL_DOCUMENT_ROOT . '/blockedlog/class/blockedlog.class.php'; + $b = new BlockedLog($this->db); + + $this->db->begin(); include_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/security2.lib.php'; // Check that the HTTPS is forced - global $dolibarr_main_force_https; - - if (isALNEQualifiedVersion(0, 1) && empty($dolibarr_main_force_https)) { - $this->error = 'Error: The HTTPS must be forced by setting the $dolibarr_main_force_https into Dolibarr conf/conf.php file to allow the use of this module in France.'; - + $s = $b->canBeEnabled(); + if ($s) { // Activation not allowed + $this->error = $s; return 0; } @@ -217,7 +220,6 @@ class modBlockedLog extends DolibarrModules // We add an entry to show we enable module - require_once DOL_DOCUMENT_ROOT . '/blockedlog/class/blockedlog.class.php'; $object = new stdClass(); $object->id = 0; @@ -226,8 +228,6 @@ class modBlockedLog extends DolibarrModules $object->entity = $conf->entity; $object->date = dol_now(); - $b = new BlockedLog($this->db); - // Add first entry in unalterable Log to track that module was activated $action = 'MODULE_SET'; $result = $b->setObjectData($object, $action, 0, $user, null);