mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-07 10:08:27 +01:00
Fix better comaptibilty for extrafield email/mail
This commit is contained in:
@@ -55,7 +55,7 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
|
||||
|
||||
$error = 0;
|
||||
|
||||
// Check parameters
|
||||
// Check parameters into $addfieldentry (this provided array is filled by modulebuilder/index.php)
|
||||
if (is_array($addfieldentry) && count($addfieldentry) > 0) {
|
||||
if (empty($addfieldentry['name'])) {
|
||||
setEventMessages($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Name")), null, 'errors');
|
||||
@@ -66,11 +66,12 @@ function rebuildObjectClass($destdir, $module, $objectname, $newmask, $readdir =
|
||||
return -2;
|
||||
}
|
||||
if (!preg_match('/^(integer|price|sellist|varchar|double|text|html|duration|stars)/', $addfieldentry['type'])
|
||||
&& !preg_match('/^(boolean|smallint|real|date|datetime|timestamp|phone|mail|url|ip|password)$/', $addfieldentry['type'])) {
|
||||
&& !preg_match('/^(boolean|smallint|real|date|datetime|timestamp|phone|email|url|ip|password)$/', $addfieldentry['type'])) { // Use email for email, mail is kept for compatibility
|
||||
setEventMessages($langs->trans('BadValueForType', $addfieldentry['type']), null, 'errors');
|
||||
return -2;
|
||||
}
|
||||
// Check for type stars(NumberOfStars), NumberOfStars must be an integer between 1 and 10
|
||||
$matches = array();
|
||||
if (preg_match('/^stars\((.+)\)$/', $addfieldentry['type'], $matches)) {
|
||||
if (!ctype_digit($matches[1]) || $matches[1] < 1 || $matches[1] > 10) {
|
||||
setEventMessages($langs->trans('BadValueForType', $addfieldentry['type']), null, 'errors');
|
||||
@@ -350,7 +351,7 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = '
|
||||
$type = 'integer';
|
||||
} elseif ($type == 'chkbxlst') {
|
||||
$type = 'varchar(128)';
|
||||
} elseif ($type == 'mail') {
|
||||
} elseif ($type == 'mail' || $type == 'email') { // Prefer to use 'email'
|
||||
$type = 'varchar(128)';
|
||||
} elseif (strpos($type, 'stars(') === 0) {
|
||||
$type = 'integer';
|
||||
@@ -358,6 +359,8 @@ function rebuildObjectSql($destdir, $module, $objectname, $newmask, $readdir = '
|
||||
$type = 'varchar(20)';
|
||||
} elseif ($type == 'ip') {
|
||||
$type = 'varchar(32)';
|
||||
} elseif ($type == 'url') {
|
||||
$type = 'varchar(255)';
|
||||
}
|
||||
|
||||
$texttoinsert .= "\t".$key." ".$type;
|
||||
|
||||
Reference in New Issue
Block a user