diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 16f664a8cd6..fdfa386f5e9 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -2022,7 +2022,45 @@ if (($dirins && $action == 'confirm_deletedictionary' && $dicname) || ($dirins & exit; } } +if ($dirins && $action == 'updatedictionary' && GETPOST('dictionnarykey')) { + $keydict = GETPOST('dictionnarykey') - 1 ; + $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; + $destdir = $dirins.'/'.strtolower($module); + $moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; + dol_include_once($pathtofile); + $class = 'mod'.$module; + + if (class_exists($class)) { + try { + $moduleobj = new $class($db); + } catch (Exception $e) { + $error++; + dol_print_error($db, $e->getMessage()); + } + } else { + $error++; + $langs->load("errors"); + dol_print_error($db, $langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module)); + exit; + } + + $dicts = $moduleobj->dictionaries; + if (!empty(GETPOST('tablib')) && GETPOST('tablib') !== $dicts['tablib'][$keydict]) { + $dicts['tablib'][$keydict] = ucfirst(strtolower(GETPOST('tablib'))); + $updateDict = updateDictionaryInFile($module, $moduledescriptorfile, $dicts); + if ($updateDict > 0) { + setEventMessages($langs->trans("DictionaryNameUpdated", ucfirst(GETPOST('tablib'))), null); + } + if (function_exists('opcache_invalidate')) { + opcache_reset(); // remove the include cache hell ! + } + clearstatcache(true); + header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=dictionaries&module='.$module.($forceddirread ? '@'.$dirread : '')); + exit; + } + //var_dump(GETPOST('tablib'));exit; +} if ($dirins && $action == 'generatedoc') { $modulelowercase = strtolower($module); @@ -4279,7 +4317,8 @@ if ($module == 'initmodule') { } } - print load_fiche_titre($langs->trans("ListOfDictionariesEntries"), '', ''); + $newdict = dolGetButtonTitle($langs->trans('NewDictionary'), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/modulebuilder/index.php?tab=dictionaries&module='.urlencode($module).'&tabdic=newdictionary'); + print_barre_liste($langs->trans("ListOfDictionariesEntries"), '', $_SERVER["PHP_SELF"], '', '', '', '', '', '', '', 0, $newdict, '', '', 0, 0, 1); print '