Fix no loose of configuration of action auto after upgrade Close #7527

This commit is contained in:
Laurent Destailleur 2017-10-03 17:21:18 +02:00
parent b40012d08f
commit 1f11dcb4bd
3 changed files with 9 additions and 29 deletions

View File

@ -80,8 +80,7 @@ if ($action == "save" && empty($cancel))
{
$param='MAIN_AGENDA_ACTIONAUTO_'.$trigger['code'];
//print "param=".$param." - ".$_POST[$param];
if (GETPOST($param,'alpha')) $res = dolibarr_set_const($db,$param,GETPOST($param,'alpha'),'chaine',0,'',$conf->entity);
else $res = dolibarr_del_const($db,$param,$conf->entity);
$res = dolibarr_set_const($db,$param,(GETPOST($param,'alpha')?GETPOST($param,'alpha'):''),'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
}

View File

@ -406,7 +406,7 @@ class DolibarrModules // Can not be abstract, because we need to insta
if (! $err) $err+=$this->insert_module_parts();
// Insert constant defined by modules (into llx_const)
if (! $err) $err+=$this->insert_const();
if (! $err && ! preg_match('/newboxdefonly/',$options)) $err+=$this->insert_const(); // Test on newboxdefonly to avoid to erase value during upgrade
// Insert boxes def into llx_boxes_def and boxes setup (into llx_boxes)
if (! $err && ! preg_match('/noboxes/',$options)) $err+=$this->insert_boxes($options);

View File

@ -410,15 +410,16 @@ if (! GETPOST('action','aZ09') || preg_match('/upgrade/i',GETPOST('action','aZ09
migrate_reload_menu($db,$langs,$conf,$versionto);
}
// Can force activation of some module during migration with paramater 'enablemodules=MAIN_MODULE_XXX,MAIN_MODULE_YYY,...'
// Can force activation of some module during migration with parameter 'enablemodules=MAIN_MODULE_XXX,MAIN_MODULE_YYY,...'
// In most cases (online install or upgrade) $enablemodules is empty. Can be forced when ran from command line.
if (! $error && $enablemodules)
{
// Reload modules (this must be always and only into last targeted version)
// Reload modules (this must be always done and only into last targeted version)
$listofmodules=array();
$tmplistofmodules=explode(',', $enablemodules);
foreach($tmplistofmodules as $value)
{
$listofmodules[$value]='newboxdefonly';
$listofmodules[$value]='forceactivate';
}
migrate_reload_modules($db,$langs,$conf,$listofmodules,1);
}
@ -4118,31 +4119,11 @@ function migrate_delete_old_dir($db,$langs,$conf)
*/
function migrate_reload_modules($db,$langs,$conf,$listofmodule=array(),$force=0)
{
if (count($listofmodule) == 0) return;
dolibarr_install_syslog("upgrade2::migrate_reload_modules force=".$force);
// If no info is provided, we reload all modules with mode newboxdefonly.
if (count($listofmodule) == 0)
{
$listofmodule=array(
'MAIN_MODULE_AGENDA'=>'newboxdefonly',
'MAIN_MODULE_SOCIETE'=>'newboxdefonly',
'MAIN_MODULE_PRODUIT'=>'newboxdefonly',
'MAIN_MODULE_SERVICE'=>'newboxdefonly',
'MAIN_MODULE_COMMANDE'=>'newboxdefonly',
'MAIN_MODULE_FACTURE'=>'newboxdefonly',
'MAIN_MODULE_FOURNISSEUR'=>'newboxdefonly',
'MAIN_MODULE_HOLIDAY'=>'newboxdefonly',
'MAIN_MODULE_USER'=>'newboxdefonly',
'MAIN_MODULE_DEPLACEMENT'=>'newboxdefonly',
'MAIN_MODULE_DON'=>'newboxdefonly',
'MAIN_MODULE_ECM'=>'newboxdefonly',
'MAIN_MODULE_PAYBOX'=>'newboxdefonly',
'MAIN_MODULE_OPENSURVEY'=>'newboxdefonly',
'MAIN_MODULE_SALARIES'=>'newboxdefonly'
);
}
foreach($listofmodule as $moduletoreload => $reloadmode)
foreach($listofmodule as $moduletoreload => $reloadmode) // reloadmodule can be 'noboxes', 'newboxdefonly', 'forceactivate'
{
if (empty($moduletoreload) || (empty($conf->global->$moduletoreload) && ! $force)) continue; // Discard reload if module not enabled