diff --git a/htdocs/langs/en_US/modulebuilder.lang b/htdocs/langs/en_US/modulebuilder.lang index 32b642cb92e..536f8656165 100644 --- a/htdocs/langs/en_US/modulebuilder.lang +++ b/htdocs/langs/en_US/modulebuilder.lang @@ -179,4 +179,5 @@ CRUDRead=Read CRUDCreateWrite=Create or Update FailedToAddCodeIntoDescriptor=Failed to add code into descriptor. Check that the string comment "%s" is still present into the file. DictionariesCreated=Dictionary %s created successfully -DictionaryDeleted=Dictionary %s removed successfully \ No newline at end of file +DictionaryDeleted=Dictionary %s removed successfully +PropertyModuleUpdated=Property %s has been update successfully \ No newline at end of file diff --git a/htdocs/langs/fr_FR/modulebuilder.lang b/htdocs/langs/fr_FR/modulebuilder.lang index 4ca5ddc464c..7ed3dda2382 100644 --- a/htdocs/langs/fr_FR/modulebuilder.lang +++ b/htdocs/langs/fr_FR/modulebuilder.lang @@ -179,4 +179,5 @@ CRUDRead=Lire CRUDCreateWrite=Créer ou mettre à jour FailedToAddCodeIntoDescriptor=Échec de l'ajout de code dans le descripteur. Vérifiez que le commentaire de chaîne "%s" est toujours présent dans le fichier. DictionariesCreated = Le dictionnaire %s a été créé avec succès -DictionaryDeleted=Le dictionnaire %s a été supprimé avec succès \ No newline at end of file +DictionaryDeleted=Le dictionnaire %s a été supprimé avec succès +PropertyModuleUpdated=Propriété %s a été modifiée avec succès \ No newline at end of file diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 43fc0ff9a80..7760e878a23 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -2787,6 +2787,83 @@ if ($dirins && $action == "modify_menu" && GETPOST('menukey', 'int') && GETPOST( } } +// update properties description of module +if ($dirins && $action == "update_props_module" && !empty(GETPOST('keydescription', 'alpha')) && empty($cancel)) { + if (isModEnabled(strtolower($module))) { + $result = unActivateModule(strtolower($module)); + 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: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=menus&module='.$module); + setEventMessages($langs->trans('WarningModuleNeedRefrech', $langs->transnoentities($module)), null, 'warnings'); + } + $pathtofile = $listofmodules[strtolower($module)]['moduledescriptorrelpath']; + $moduledescriptorfile = $dirins.'/'.strtolower($module).'/core/modules/mod'.$module.'.class.php'; + $modulelogfile = $dirins.'/'.strtolower($module).'/ChangeLog.md'; + + 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()); + } + } + + $keydescription = GETPOST('keydescription', 'alpha'); + switch ($keydescription) { + case 'desc': + $propertyToUpdate = 'description'; + break; + case 'version': + $propertyToUpdate = 'version'; + break; + case 'family': + $propertyToUpdate = 'family'; + break; + case 'editor_name': + $propertyToUpdate = 'editor_name'; + break; + case 'editor_url': + $propertyToUpdate = 'editor_url'; + break; + default: + $error = GETPOST('keydescription'); + break; + } + + if (isset($propertyToUpdate) && !empty(GETPOST('propsmodule'))) { + $newValue = GETPOST('propsmodule'); + $lineToReplace = "\t\t\$this->$propertyToUpdate = "; + $newLine = "\t\t\$this->$propertyToUpdate = '$newValue';\n"; + + //for change version in log file + if ($propertyToUpdate === 'version') { + dolReplaceInFile($modulelogfile, array("## ".$moduleobj->$propertyToUpdate => $newValue)); + } + + $fileLines = file($moduledescriptorfile); + foreach ($fileLines as &$line) { + if (strpos($line, $lineToReplace) === 0) { + dolReplaceInFile($moduledescriptorfile, array($line => $newLine)); + break; + } + } + + clearstatcache(true); + if (function_exists('opcache_invalidate')) { + opcache_reset(); + } + setEventMessages($langs->trans('PropertyModuleUpdated', $propertyToUpdate), null); + header("Location: ".DOL_URL_ROOT.'/modulebuilder/index.php?tab=description&module='.$module); + exit; + } +} + /* * View */ @@ -3253,7 +3330,12 @@ if ($module == 'initmodule') { if (!empty($moduleobj)) { print '
'; print '
'; - + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; print ''; print ''; print ''; print ''; print ''; print ''; print '
'; print $langs->trans("Parameter"); @@ -3281,20 +3363,62 @@ if ($module == 'initmodule') { print '
'; print $langs->trans("Description"); print ''; - print $moduleobj->getDesc(); + if ($action == 'edit_moduledescription' && GETPOST('keydescription', 'alpha') === 'desc') { + print ''; + print ''; + print ''; + } else { + print $moduleobj->getDesc(); + print ''.img_edit().''; + } print '
'; print $langs->trans("Version"); print ''; - print $moduleobj->getVersion(); + if ($action == 'edit_moduledescription' && GETPOST('keydescription', 'alpha') === 'version') { + print ''; + print ''; + print ''; + } else { + print $moduleobj->getVersion(); + print ''.img_edit().''; + } print '
'; print $langs->trans("Family"); //print "
'crm','financial','hr','projects','products','ecm','technic','interface','other'"; print '
'; - print $moduleobj->family; + if ($action == 'edit_moduledescription' && GETPOST('keydescription', 'alpha') === 'family') { + print ''; + print ''; + print ''; + } else { + print $moduleobj->family; + print ''.img_edit().''; + } print '
'; @@ -3307,18 +3431,33 @@ if ($module == 'initmodule') { print '
'; print $langs->trans("EditorName"); print ''; - print $moduleobj->editor_name; + if ($action == 'edit_moduledescription' && GETPOST('keydescription', 'alpha') === 'editor_name') { + print ''; + print ''; + print ''; + } else { + print $moduleobj->editor_name; + print ''.img_edit().''; + } print '
'; print $langs->trans("EditorUrl"); print ''; - if (!empty($moduleobj->editor_url)) { - print ''.$moduleobj->editor_url.' '.img_picto('', 'globe').''; + if ($action == 'edit_moduledescription' && GETPOST('keydescription', 'alpha') === 'editor_url') { + print ''; + print ''; + print ''; + } else { + if (!empty($moduleobj->editor_url)) { + print ''.$moduleobj->editor_url.' '.img_picto('', 'globe').''; + } + print ''.img_edit().''; } print '
'; + print '
'; } else { print $langs->trans("ErrorFailedToLoadModuleDescriptorForXXX", $module).'
'; }