diff --git a/htdocs/admin/modules.php b/htdocs/admin/modules.php
index e93b5a58e96..db019bd262a 100644
--- a/htdocs/admin/modules.php
+++ b/htdocs/admin/modules.php
@@ -282,10 +282,39 @@ if ($action == 'set' && $user->admin) {
}
header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y ? '&page_y='.$page_y : ''));
exit;
+} elseif (getDolGlobalInt("MAIN_FEATURES_LEVEL") > 1 && $action == 'reload' && $user->admin && GETPOST('confirm') == 'yes') {
+ $result = unActivateModule($value, 0);
+ dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity);
+ if ($result) {
+ setEventMessages($result, null, 'errors');
+ header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y ? '&page_y='.$page_y : ''));
+ }
+ $resarray = activateModule($value, 0, 1);
+ dolibarr_set_const($db, "MAIN_IHM_PARAMS_REV", (int) $conf->global->MAIN_IHM_PARAMS_REV + 1, 'chaine', 0, '', $conf->entity);
+ if (!empty($resarray['errors'])) {
+ setEventMessages('', $resarray['errors'], 'errors');
+ } else {
+ if ($resarray['nbperms'] > 0) {
+ $tmpsql = "SELECT COUNT(rowid) as nb FROM ".MAIN_DB_PREFIX."user WHERE admin <> 1";
+ $resqltmp = $db->query($tmpsql);
+ if ($resqltmp) {
+ $obj = $db->fetch_object($resqltmp);
+ if ($obj && $obj->nb > 1) {
+ $msg = $langs->trans('ModuleEnabledAdminMustCheckRights');
+ setEventMessages($msg, null, 'warnings');
+ }
+ } else {
+ dol_print_error($db);
+ }
+ }
+ }
+ header("Location: ".$_SERVER["PHP_SELF"]."?mode=".$mode.$param.($page_y ? '&page_y='.$page_y : ''));
+ exit;
}
+
/*
* View
*/
@@ -464,6 +493,19 @@ if ($action == 'reset_confirm' && $user->admin) {
}
}
+if ($action == 'reload_confirm' && $user->admin) {
+ if (!empty($modules[$value])) {
+ $objMod = $modules[$value];
+
+ if (!empty($objMod->langfiles)) {
+ $langs->loadLangs($objMod->langfiles);
+ }
+
+ $form = new Form($db);
+ $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?value='.$value.'&mode='.$mode.$param, $langs->trans('ConfirmReload'), $langs->trans(GETPOST('confirm_message_code')), 'reload', '', 'no', 1);
+ }
+}
+
print $formconfirm;
asort($orders);
@@ -802,10 +844,22 @@ if ($mode == 'common' || $mode == 'commonkanban') {
$codeenabledisable .= 'numero.'&token='.newToken().'&module_position='.$module_position.'&action=reset_confirm&confirm_message_code='.urlencode($objMod->warnings_unactivation[$mysoc->country_code]).'&value='.$modName.'&mode='.$mode.$param.'">';
$codeenabledisable .= img_picto($langs->trans("Activated"), 'switch_on');
$codeenabledisable .= '';
+ if (getDolGlobalInt("MAIN_FEATURES_LEVEL") > 1) {
+ $codeenabledisable .= ' ';
+ $codeenabledisable .= 'numero.'&token='.newToken().'&module_position='.$module_position.'&action=reload_confirm&value='.$modName.'&mode='.$mode.'&confirm=yes'.$param.'">';
+ $codeenabledisable .= img_picto($langs->trans("Reload"), 'refresh', 'class="fa-15"');
+ $codeenabledisable .= '';
+ }
} else {
$codeenabledisable .= 'numero.'&token='.newToken().'&module_position='.$module_position.'&action=reset&value='.$modName.'&mode='.$mode.'&confirm=yes'.$param.'">';
$codeenabledisable .= img_picto($langs->trans("Activated"), 'switch_on');
$codeenabledisable .= '';
+ if (getDolGlobalInt("MAIN_FEATURES_LEVEL") > 1) {
+ $codeenabledisable .= ' ';
+ $codeenabledisable .= 'numero.'&token='.newToken().'&module_position='.$module_position.'&action=reload&value='.$modName.'&mode='.$mode.'&confirm=yes'.$param.'">';
+ $codeenabledisable .= img_picto($langs->trans("Reload"), 'refresh', 'class="fa-15"');
+ $codeenabledisable .= '';
+ }
}
}
diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php
index 71bcc082961..92895793082 100644
--- a/htdocs/core/lib/admin.lib.php
+++ b/htdocs/core/lib/admin.lib.php
@@ -1084,11 +1084,12 @@ function purgeSessions($mysessionid)
/**
* Enable a module
*
- * @param string $value Name of module to activate
- * @param int $withdeps Activate/Disable also all dependencies
- * @return array array('nbmodules'=>nb modules activated with success, 'errors=>array of error messages, 'nbperms'=>Nb permission added);
+ * @param string $value Name of module to activate
+ * @param int $withdeps Activate/Disable also all dependencies
+ * @param int $noconfverification Remove verification of $conf variable for module
+ * @return array array('nbmodules'=>nb modules activated with success, 'errors=>array of error messages, 'nbperms'=>Nb permission added);
*/
-function activateModule($value, $withdeps = 1)
+function activateModule($value, $withdeps = 1, $noconfverification = 0)
{
global $db, $langs, $conf, $mysoc;
@@ -1144,8 +1145,10 @@ function activateModule($value, $withdeps = 1)
}
$const_name = $objMod->const_name;
- if (!empty($conf->global->$const_name)) {
- return $ret;
+ if ($noconfverification == 0) {
+ if (!empty($conf->global->$const_name)) {
+ return $ret;
+ }
}
$result = $objMod->init(); // Enable module
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index db11289d299..715d500db78 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -2361,3 +2361,5 @@ AllowExternalDownload=Allow external download (without login, using a shared lin
DeadlineDayVATSubmission=Deadline day for vat submission on the next month
MaxNumberOfAttachementOnForms=Max number of joinded files in a form
IfDefinedUseAValueBeetween=If defined, use a value between %s and %s
+Reload=Reload
+ConfirmReload=Confirm module reload