From d7e4e5f18cb20b0966e70c246f33dace82a914e8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 3 Apr 2020 15:14:59 +0200 Subject: [PATCH] Fix modulebuilder clone message --- htdocs/langs/en_US/main.lang | 1 + htdocs/modulebuilder/index.php | 11 +++++++++-- htdocs/modulebuilder/template/myobject_card.php | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 8f8480a03cb..31e0d5a1c8d 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -174,6 +174,7 @@ SaveAndStay=Save and stay SaveAndNew=Save and new TestConnection=Test connection ToClone=Clone +ConfirmCloneAsk=Are you sure you want to clone the object %s? ConfirmClone=Choose data you want to clone: NoCloneOptionsSpecified=No data to clone defined. Of=of diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 16684fc36e4..65f6f4b3643 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -791,6 +791,12 @@ if ($dirins && $action == 'initobject' && $module && $objectname) setEventMessages($langs->trans("SpaceOrSpecialCharAreNotAllowed"), null, 'errors'); $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'; $destdir = $dirins.'/'.strtolower($module); @@ -891,7 +897,7 @@ if ($dirins && $action == 'initobject' && $module && $objectname) // Edit the setup file and the card page if (GETPOST('includedocgeneration', 'aZ09')) { // 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); } @@ -2609,6 +2615,7 @@ elseif (! empty($module)) print ''; print ''; + // List of existing properties foreach ($properties as $propkey => $propval) { /* If from Reflection @@ -2680,7 +2687,7 @@ elseif (! empty($module)) print $propenabled?$propenabled:''; print ''; print ''; - print $propvisible?$propvisible:''; + print $propvisible?$propvisible:'0'; print ''; print ''; print $propnoteditable?$propnoteditable:''; diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index ca2516eddb6..97adff0558f 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -290,7 +290,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($action == 'clone') { // Create an array for form $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