diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index a7589be4860..4f1b808d0a2 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -521,6 +521,17 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it // Return code if (!$err) { $this->db->commit(); + + // set $conf properties + $conf->global->{$this->const_name} = 1; + $moduleNameInConf = strtolower(preg_replace('/^MAIN_MODULE_/', '', $this->const_name)); + // two exceptions to handle + if ($moduleNameInConf === 'propale') $moduleNameInConf = 'propal'; + elseif ($moduleNameInConf === 'supplierproposal') $moduleNameInConf = 'supplier_proposal'; + if (! isset($conf->{$moduleNameInConf})) { + $conf->{$moduleNameInConf} = (object) array('enabled' => 1); + } + return 1; } else { $this->db->rollback(); @@ -539,6 +550,7 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it */ protected function _remove($array_sql, $options = '') { + global $conf; // phpcs:enable $err = 0; @@ -605,6 +617,15 @@ class DolibarrModules // Can not be abstract, because we need to instantiate it // Return code if (!$err) { $this->db->commit(); + + // unset $conf properties + if (isset($conf->global->{$this->const_name})) unset($conf->global->{$this->const_name}); + $moduleNameInConf = strtolower(preg_replace('/^MAIN_MODULE_/', '', $this->const_name)); + // two exceptions to handle + if ($moduleNameInConf === 'propale') $moduleNameInConf = 'propal'; + elseif ($moduleNameInConf === 'supplierproposal') $moduleNameInConf = 'supplier_proposal'; + if (isset($conf->{$moduleNameInConf})) unset($conf->{$moduleNameInConf}); + return 1; } else { $this->db->rollback();