Work on modulebuilder

This commit is contained in:
Laurent Destailleur
2017-09-22 23:38:25 +02:00
parent 63ec14e47d
commit 96aed9c29d
4 changed files with 47 additions and 25 deletions

View File

@@ -46,10 +46,20 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
// Check parameters
if (count($addfieldentry) > 0)
{
if (empty($addfieldentry['name']))
{
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Name")), null, 'errors');
return -2;
}
if (empty($addfieldentry['label']))
{
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Label")), null, 'errors');
return -2;
}
if (! preg_match('/^(integer|date|timestamp|varchar|double)/', $addfieldentry['type']))
{
setEventMessages($langs->trans('FilesForObjectUpdated', $objectname), null, 'errors');
return -1;
setEventMessages($langs->trans('BadFormatForType', $objectname), null, 'errors');
return -2;
}
}
@@ -59,7 +69,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
{
$langs->load("errors");
setEventMessages($langs->trans("ErrorFileNotFound", $pathoffiletoeditsrc), null, 'errors');
return -1;
return -3;
}
//$pathoffiletoedittmp=$destdir.'/class/'.strtolower($objectname).'.class.php.tmp';
@@ -69,7 +79,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
{
include_once $pathoffiletoeditsrc;
if (class_exists($objectname)) $object=new $objectname($db);
else return -1;
else return -4;
// Backup old file
dol_copy($pathoffiletoedittarget, $pathoffiletoedittarget.'.back', $newmask, 1);
@@ -157,7 +167,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir='
catch(Exception $e)
{
print $e->getMessage();
return -1;
return -5;
}
}