diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php
index 95e83c3ed39..01c05dadac8 100644
--- a/htdocs/modulebuilder/index.php
+++ b/htdocs/modulebuilder/index.php
@@ -466,7 +466,12 @@ if ($dirins && $action == 'initsqlextrafields' && !empty($module)) {
dolReplaceInFile($destfile2, $arrayreplacement);
} else {
$langs->load("errors");
- setEventMessages($langs->trans('ErrorFailToCreateFile', ''), null, 'errors');
+ if ($result1 <= 0) {
+ setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile1), null, 'errors');
+ }
+ if ($result2 <= 0) {
+ setEventMessages($langs->trans('ErrorFailToCreateFile', $destfile2), null, 'errors');
+ }
}
// TODO Enable in class the property $isextrafieldmanaged = 1
}
@@ -780,6 +785,19 @@ if ($dirins && $action == 'confirm_removefile' && !empty($module)) {
if (!$result) {
setEventMessages($langs->trans("ErrorFailToDeleteFile", basename($filetodelete)), null, 'errors');
} else {
+ // If we delete a sql file
+ if (preg_match('/\.sql$/', $relativefilename)) {
+ if (preg_match('/\.key\.sql$/', $relativefilename)) {
+ $relativefilename = preg_replace('/\.key\.sql$/', '.sql', $relativefilename);
+ $filetodelete = $dirins.'/'.$relativefilename;
+ $result = dol_delete_file($filetodelete);
+ } elseif (preg_match('/\.sql$/', $relativefilename)) {
+ $relativefilename = preg_replace('/\.sql$/', '.key.sql', $relativefilename);
+ $filetodelete = $dirins.'/'.$relativefilename;
+ $result = dol_delete_file($filetodelete);
+ }
+ }
+
if (dol_is_dir_empty($dirtodelete)) {
dol_delete_dir($dirtodelete);
}
@@ -1641,7 +1659,6 @@ if ($action == 'savefile' && empty($cancel)) {
$content = GETPOST('editfilecontent', $check);
-
// Save file on disk
if ($content) {
dol_delete_file($pathoffile);
@@ -2573,8 +2590,9 @@ if ($module == 'initmodule') {
print '
';
print '
'.$langs->trans("ClassFile").' :
'.($realpathtoclass ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtoclass).($realpathtoclass ? '' : '').'';
print '
'.img_picto($langs->trans("Edit"), 'edit').'';
+ // API file
print '
';
- print '
'.$langs->trans("ApiClassFile").' :
'.($realpathtoapi ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtoapi).($realpathtoapi ? '' : '').'';
+ print '
'.$langs->trans("ApiClassFile").' :
'.($realpathtoapi ? '' : '').(dol_is_file($realpathtoapi)?'':'').preg_replace('/^'.strtolower($module).'\//', '', $pathtoapi).(dol_is_file($realpathtoapi)?'':'').($realpathtoapi ? '' : '').'';
if (dol_is_file($realpathtoapi)) {
print '
'.img_picto($langs->trans("Edit"), 'edit').'';
print ' ';
@@ -2591,7 +2609,7 @@ if ($module == 'initmodule') {
}
// PHPUnit
print '
';
- print '
'.$langs->trans("TestClassFile").' :
'.($realpathtophpunit ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtophpunit).($realpathtophpunit ? '' : '').'';
+ print '
'.$langs->trans("TestClassFile").' :
'.($realpathtophpunit ? '' : '').(dol_is_file($realpathtophpunit)?'':'').preg_replace('/^'.strtolower($module).'\//', '', $pathtophpunit).(dol_is_file($realpathtophpunit)?'':'').($realpathtophpunit ? '' : '').'';
if (dol_is_file($realpathtophpunit)) {
print '
'.img_picto($langs->trans("Edit"), 'edit').'';
print ' ';
@@ -2624,7 +2642,7 @@ if ($module == 'initmodule') {
print '
'.img_picto($langs->trans("Edit"), 'edit').'';
//print '
'.$langs->trans("RunSql").'';
print '
';
- print '
'.$langs->trans("SqlFileExtraFields").' :
'.($realpathtosqlextra ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosqlextra).($realpathtosqlextra ? '' : '').'';
+ print '
'.$langs->trans("SqlFileExtraFields").' :
'.($realpathtosqlextra ? '' : '').(dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosqlextra).(dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey) ? '' : '').($realpathtosqlextra ? '' : '').'';
if (dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey)) {
print '
'.img_picto($langs->trans("Edit"), 'edit').'';
print ' ';
@@ -2636,7 +2654,7 @@ if ($module == 'initmodule') {
}
//print '
'.$langs->trans("RunSql").'';
print '
';
- print '
'.$langs->trans("SqlFileKeyExtraFields").' :
'.($realpathtosqlextrakey ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosqlextrakey).($realpathtosqlextrakey ? '' : '').'';
+ print '
'.$langs->trans("SqlFileKeyExtraFields").' :
'.($realpathtosqlextrakey ? '' : '').(dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey) ? '' : '').preg_replace('/^'.strtolower($module).'\//', '', $pathtosqlextrakey).(dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey) ? '' : '').($realpathtosqlextrakey ? '' : '').'';
if (dol_is_file($realpathtosqlextra) && dol_is_file($realpathtosqlextrakey)) {
print '
'.img_picto($langs->trans("Edit"), 'edit').'';
print ' ';