Fix: column name should not be an numeric
This commit is contained in:
parent
6a570222cc
commit
c69565fd69
@ -28,7 +28,7 @@ $extrasize=GETPOST('size');
|
|||||||
if (GETPOST('type')=='double' && strpos($extrasize,',')===false) $extrasize='24,8';
|
if (GETPOST('type')=='double' && strpos($extrasize,',')===false) $extrasize='24,8';
|
||||||
if (GETPOST('type')=='date') $extrasize='';
|
if (GETPOST('type')=='date') $extrasize='';
|
||||||
if (GETPOST('type')=='datetime') $extrasize='';
|
if (GETPOST('type')=='datetime') $extrasize='';
|
||||||
if (GETPOST('type')=='select') $extrasize='';
|
if (GETPOST('type')=='select') $extrasize='';
|
||||||
|
|
||||||
|
|
||||||
// Add attribute
|
// Add attribute
|
||||||
@ -87,7 +87,7 @@ if ($action == 'add')
|
|||||||
$mesg[]=$langs->trans("ErrorNoValueForRadioType");
|
$mesg[]=$langs->trans("ErrorNoValueForRadioType");
|
||||||
$action = 'create';
|
$action = 'create';
|
||||||
}
|
}
|
||||||
if (((GETPOST('type')=='radio') || (GETPOST('type')=='checkbox')) && GETPOST('param'))
|
if (((GETPOST('type')=='radio') || (GETPOST('type')=='checkbox')) && GETPOST('param'))
|
||||||
{
|
{
|
||||||
// Construct array for parameter (value of select list)
|
// Construct array for parameter (value of select list)
|
||||||
$parameters = GETPOST('param');
|
$parameters = GETPOST('param');
|
||||||
@ -95,7 +95,7 @@ if ($action == 'add')
|
|||||||
foreach($parameters_array as $param_ligne)
|
foreach($parameters_array as $param_ligne)
|
||||||
{
|
{
|
||||||
if (!empty($param_ligne)) {
|
if (!empty($param_ligne)) {
|
||||||
if (preg_match_all('/,/',$param_ligne,$matches))
|
if (preg_match_all('/,/',$param_ligne,$matches))
|
||||||
{
|
{
|
||||||
if (count($matches[0])>1) {
|
if (count($matches[0])>1) {
|
||||||
$error++;
|
$error++;
|
||||||
@ -104,7 +104,7 @@ if ($action == 'add')
|
|||||||
$action = 'create';
|
$action = 'create';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
$langs->load("errors");
|
$langs->load("errors");
|
||||||
@ -112,12 +112,12 @@ if ($action == 'add')
|
|||||||
$action = 'create';
|
$action = 'create';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
// attrname must be alphabetical and lower case only
|
// attrname must be alphabetical and lower case only
|
||||||
if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/",$_POST['attrname']))
|
if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/",$_POST['attrname']))
|
||||||
{
|
{
|
||||||
// Construct array for parameter (value of select list)
|
// Construct array for parameter (value of select list)
|
||||||
@ -139,8 +139,8 @@ if ($action == 'add')
|
|||||||
list($key,$value) = explode(',',$param_ligne);
|
list($key,$value) = explode(',',$param_ligne);
|
||||||
$params['options'][$key] = $value;
|
$params['options'][$key] = $value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$result=$extrafields->addExtraField($_POST['attrname'],$_POST['label'],$_POST['type'],$_POST['pos'],$extrasize,$elementtype,(GETPOST('unique')?1:0),(GETPOST('required')?1:0),$default_value,$params);
|
$result=$extrafields->addExtraField($_POST['attrname'],$_POST['label'],$_POST['type'],$_POST['pos'],$extrasize,$elementtype,(GETPOST('unique')?1:0),(GETPOST('required')?1:0),$default_value,$params);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
@ -164,7 +164,7 @@ if ($action == 'add')
|
|||||||
$action = 'create';
|
$action = 'create';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setEventMessage($mesg,'errors');
|
setEventMessage($mesg,'errors');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2120,11 +2120,11 @@ abstract class CommonObject
|
|||||||
|
|
||||||
foreach ($tab as $key => $value)
|
foreach ($tab as $key => $value)
|
||||||
{
|
{
|
||||||
// Test fetch_array ! is_int($key) because fetch_array seult is a mix table with Key as alpha and Key as int (depend db engine)
|
// Test fetch_array ! is_int($key) because fetch_array result is a mix table with some key as alpha and some key as int (depend db engine)
|
||||||
if ($key != 'rowid' && $key != 'tms' && $key != 'fk_member' && ! is_int($key))
|
if ($key != 'rowid' && $key != 'tms' && ! is_int($key))
|
||||||
{
|
{
|
||||||
// we can add this attribute to adherent object
|
// we can add this attribute to object properties
|
||||||
$this->array_options["options_$key"]=$value;
|
$this->array_options["options_".$key]=$value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -154,7 +154,7 @@ class ExtraFields
|
|||||||
{
|
{
|
||||||
$table=$elementtype.'_extrafields';
|
$table=$elementtype.'_extrafields';
|
||||||
|
|
||||||
if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname))
|
if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname) && ! is_numeric($attrname))
|
||||||
{
|
{
|
||||||
if ($type=='boolean') {
|
if ($type=='boolean') {
|
||||||
$typedb='int';
|
$typedb='int';
|
||||||
@ -226,8 +226,7 @@ class ExtraFields
|
|||||||
// Clean parameters
|
// Clean parameters
|
||||||
if (empty($pos)) $pos=0;
|
if (empty($pos)) $pos=0;
|
||||||
|
|
||||||
|
if (! empty($attrname) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname) && ! is_numeric($attrname))
|
||||||
if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname))
|
|
||||||
{
|
{
|
||||||
if(is_array($param) and count($param) > 0)
|
if(is_array($param) and count($param) > 0)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user