Fix : fix bug class and sql regeneration in modulebuilder

This commit is contained in:
lmarcouiller 2022-02-21 15:41:41 +01:00
parent f0f81cd2cd
commit 192e62fa5c
2 changed files with 20 additions and 18 deletions

View File

@ -125,46 +125,46 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
$texttoinsert .= " 'position'=>".($val['position'] !== '' ? $val['position'] : 50).",";
$texttoinsert .= " 'notnull'=>".(empty($val['notnull']) ? 0 : $val['notnull']).",";
$texttoinsert .= " 'visible'=>".($val['visible'] !== '' ? $val['visible'] : -1).",";
if ($val['noteditable']) {
if (!empty($val['noteditable'])) {
$texttoinsert .= " 'noteditable'=>'".$val['noteditable']."',";
}
if ($val['default'] || $val['default'] === '0') {
if (!empty($val['default']) || (!empty($val['default']) && $val['default'] === '0')) {
$texttoinsert .= " 'default'=>'".$val['default']."',";
}
if ($val['index']) {
if (!empty($val['index'])) {
$texttoinsert .= " 'index'=>".$val['index'].",";
}
if ($val['foreignkey']) {
if (!empty($val['foreignkey'])) {
$texttoinsert .= " 'foreignkey'=>'".$val['foreignkey']."',";
}
if ($val['searchall']) {
if (!empty($val['searchall'])) {
$texttoinsert .= " 'searchall'=>".$val['searchall'].",";
}
if ($val['isameasure']) {
if (!empty($val['isameasure'])) {
$texttoinsert .= " 'isameasure'=>'".$val['isameasure']."',";
}
if ($val['css']) {
if (!empty($val['css'])) {
$texttoinsert .= " 'css'=>'".$val['css']."',";
}
if ($val['cssview']) {
if (!empty($val['cssview'])) {
$texttoinsert .= " 'cssview'=>'".$val['cssview']."',";
}
if ($val['csslist']) {
if (!empty($val['csslist'])) {
$texttoinsert .= " 'csslist'=>'".$val['csslist']."',";
}
if ($val['help']) {
if (!empty($val['help'])) {
$texttoinsert .= " 'help'=>\"".preg_replace('/"/', '', $val['help'])."\",";
}
if ($val['showoncombobox']) {
if (!empty($val['showoncombobox'])) {
$texttoinsert .= " 'showoncombobox'=>'".$val['showoncombobox']."',";
}
if ($val['disabled']) {
if (!empty($val['disabled'])) {
$texttoinsert .= " 'disabled'=>'".$val['disabled']."',";
}
if ($val['autofocusoncreate']) {
if (!empty($val['autofocusoncreate'])) {
$texttoinsert .= " 'autofocusoncreate'=>'".$val['autofocusoncreate']."',";
}
if ($val['arrayofkeyval']) {
if (!empty($val['arrayofkeyval'])) {
$texttoinsert .= " 'arrayofkeyval'=>array(";
$i = 0;
foreach ($val['arrayofkeyval'] as $key2 => $val2) {
@ -176,10 +176,10 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
}
$texttoinsert .= "),";
}
if ($val['validate']) {
if (!empty($val['validate'])) {
$texttoinsert .= " 'validate'=>'".$val['validate']."',";
}
if ($val['comment']) {
if (!empty($val['comment'])) {
$texttoinsert .= " 'comment'=>\"".preg_replace('/"/', '', $val['comment'])."\"";
}
@ -311,7 +311,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = '
if ($key == 'entity') {
$texttoinsert .= ' DEFAULT 1';
} else {
if ($val['default'] != '') {
if (!empty($val['default']) && $val['default'] != '') {
if (preg_match('/^null$/i', $val['default'])) {
$texttoinsert .= " DEFAULT NULL";
} elseif (preg_match('/varchar/', $type)) {

View File

@ -1309,7 +1309,7 @@ if ($dirins && $action == 'addproperty' && empty($cancel) && !empty($module) &&
}
}
if (!$error) {
if (!$error && !GETPOST('regenerateclasssql')&& !GETPOST('regeneratemissing')) {
$addfieldentry = array(
'name'=>GETPOST('propname', 'aZ09'),
'label'=>GETPOST('proplabel', 'alpha'),
@ -1335,6 +1335,8 @@ if ($dirins && $action == 'addproperty' && empty($cancel) && !empty($module) &&
if (!empty($addfieldentry['arrayofkeyval']) && !is_array($addfieldentry['arrayofkeyval'])) {
$addfieldentry['arrayofkeyval'] = json_decode($addfieldentry['arrayofkeyval'], true);
}
} else {
$addfieldentry = array();
}
/*if (GETPOST('regeneratemissing'))