Fix modulebuilder clone message

This commit is contained in:
Laurent Destailleur 2020-04-03 15:14:59 +02:00
parent a13287e285
commit d7e4e5f18c
3 changed files with 11 additions and 3 deletions

View File

@ -174,6 +174,7 @@ SaveAndStay=Save and stay
SaveAndNew=Save and new SaveAndNew=Save and new
TestConnection=Test connection TestConnection=Test connection
ToClone=Clone ToClone=Clone
ConfirmCloneAsk=Are you sure you want to clone the object <b>%s</b>?
ConfirmClone=Choose data you want to clone: ConfirmClone=Choose data you want to clone:
NoCloneOptionsSpecified=No data to clone defined. NoCloneOptionsSpecified=No data to clone defined.
Of=of Of=of

View File

@ -791,6 +791,12 @@ if ($dirins && $action == 'initobject' && $module && $objectname)
setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors');
$tabobj = 'newobject'; $tabobj = 'newobject';
} }
if (class_exists($objectname)) {
// TODO Add a more efficient detection. Scan disk ?
$error++;
setEventMessages($langs->trans("AnObjectWithThisClassNameAlreadyExists"), null, 'errors');
$tabobj = 'newobject';
}
$srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template'; $srcdir = DOL_DOCUMENT_ROOT.'/modulebuilder/template';
$destdir = $dirins.'/'.strtolower($module); $destdir = $dirins.'/'.strtolower($module);
@ -891,7 +897,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname)
// Edit the setup file and the card page // Edit the setup file and the card page
if (GETPOST('includedocgeneration', 'aZ09')) { if (GETPOST('includedocgeneration', 'aZ09')) {
// Replace '$includedocgeneration = 0;' into '$includedocgeneration = 1;' into files // Replace '$includedocgeneration = 0;' into '$includedocgeneration = 1;' into files
$arrayreplacement = array('$includedocgeneration = 0;', '$includedocgeneration = 1;'); $arrayreplacement = array('/\$includedocgeneration = 0;/' => '$includedocgeneration = 1;');
dolReplaceInFile($destdir.'/class/'.strtolower($objectname).'.class.php', $arrayreplacement, '', 0, 0, 1); dolReplaceInFile($destdir.'/class/'.strtolower($objectname).'.class.php', $arrayreplacement, '', 0, 0, 1);
} }
@ -2609,6 +2615,7 @@ elseif (! empty($module))
print '<input class="button" type="submit" name="add" value="'.$langs->trans("Add").'">'; print '<input class="button" type="submit" name="add" value="'.$langs->trans("Add").'">';
print '</td></tr>'; print '</td></tr>';
// List of existing properties
foreach ($properties as $propkey => $propval) foreach ($properties as $propkey => $propval)
{ {
/* If from Reflection /* If from Reflection
@ -2680,7 +2687,7 @@ elseif (! empty($module))
print $propenabled?$propenabled:''; print $propenabled?$propenabled:'';
print '</td>'; print '</td>';
print '<td class="center">'; print '<td class="center">';
print $propvisible?$propvisible:''; print $propvisible?$propvisible:'0';
print '</td>'; print '</td>';
print '<td class="center">'; print '<td class="center">';
print $propnoteditable?$propnoteditable:''; print $propnoteditable?$propnoteditable:'';

View File

@ -290,7 +290,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
if ($action == 'clone') { if ($action == 'clone') {
// Create an array for form // Create an array for form
$formquestion = array(); $formquestion = array();
$formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneMyObject', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneAsk', $object->ref), 'confirm_clone', $formquestion, 'yes', 1);
} }
// Confirmation of action xxxx // Confirmation of action xxxx