Fix: sql error with postgres when creating extrafield with an upper cas

character. code for new fields must be always lowercase.
This commit is contained in:
Laurent Destailleur 2014-02-25 15:48:13 +01:00
parent b1eef7cd42
commit 63a2aa3365
6 changed files with 8 additions and 4 deletions

View File

@ -117,8 +117,8 @@ if ($action == 'add')
if (! $error)
{
// Type et taille non encore pris en compte => varchar(255)
if (isset($_POST["attrname"]) && preg_match("/^\w[a-zA-Z0-9-_]*$/",$_POST['attrname']))
// attrname must be alphabetical and lower case only
if (isset($_POST["attrname"]) && preg_match("/^[a-z0-9-_]+$/",$_POST['attrname']))
{
// Construct array for parameter (value of select list)
$default_value = GETPOST('default_value');
@ -159,7 +159,7 @@ if ($action == 'add')
{
$error++;
$langs->load("errors");
$mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
$mesg=$langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters",$langs->transnoentities("AttributeCode"));
setEventMessage($mesg,'errors');
$action = 'create';
}

View File

@ -70,7 +70,7 @@
<!-- Label -->
<tr><td class="fieldrequired"><?php echo $langs->trans("Label"); ?></td><td class="valeur"><input type="text" name="label" size="40" value="<?php echo GETPOST('label'); ?>"></td></tr>
<!-- Code -->
<tr><td class="fieldrequired"><?php echo $langs->trans("AttributeCode"); ?> (<?php echo $langs->trans("AlphaNumOnlyCharsAndNoSpace"); ?>)</td><td class="valeur"><input type="text" name="attrname" id="attrname" size="10" value="<?php echo GETPOST('attrname'); ?>"></td></tr>
<tr><td class="fieldrequired"><?php echo $langs->trans("AttributeCode"); ?></td><td class="valeur"><input type="text" name="attrname" id="attrname" size="10" value="<?php echo GETPOST('attrname'); ?>"> (<?php echo $langs->trans("AlphaNumOnlyLowerCharsAndNoSpace"); ?>)</td></tr>
<!-- Type -->
<tr><td class="fieldrequired"><?php echo $langs->trans("Type"); ?></td><td class="valeur">
<?php print $form->selectarray('type',$type2label,GETPOST('type')); ?>

View File

@ -983,6 +983,7 @@ ExtraFieldsProject=Complementary attributes (projects)
ExtraFieldsProjectTask=Complementary attributes (tasks)
ExtraFieldHasWrongValue=Attribut %s has a wrong value.
AlphaNumOnlyCharsAndNoSpace=only alphanumericals characters without space
AlphaNumOnlyLowerCharsAndNoSpace=only alphanumericals and lower case characters without space
SendingMailSetup=Setup of sendings by email
SendmailOptionNotComplete=Warning, on some Linux systems, to send email from your email, sendmail execution setup must contains option -ba (parameter mail.force_extra_parameters into your php.ini file). If some recipients never receive emails, try to edit this PHP parameter with mail.force_extra_parameters = -ba).
PathToDocuments=Path to documents

View File

@ -62,6 +62,7 @@ ErrorNoValueForCheckBoxType=Please fill value for checkbox list
ErrorNoValueForRadioType=Please fill value for radio list
ErrorBadFormatValueList=The list value cannot have more than one come : <u>%s</u>, but need at least one: llave,valores
ErrorFieldCanNotContainSpecialCharacters=Field <b>%s</b> must not contains special characters.
ErrorFieldCanNotContainSpecialNorUpperCharacters=Field <b>%s</b> must not contains special characters, nor upper case characters.
ErrorNoAccountancyModuleLoaded=No accountancy module activated
ErrorExportDuplicateProfil=This profil name already exists for this export set.
ErrorLDAPSetupNotComplete=Dolibarr-LDAP matching is not complete.

View File

@ -983,6 +983,7 @@ ExtraFieldsProject=Attributs supplémentaires (projets)
ExtraFieldsProjectTask=Attributs supplémentaires (tâches)
ExtraFieldHasWrongValue=L'attribut %s a une valeur incorrecte.
AlphaNumOnlyCharsAndNoSpace=uniquement caractères alphanumériques sans espace
AlphaNumOnlyLowerCharsAndNoSpace=uniquement caractères minuscules alphanumériques sans espace
SendingMailSetup=Configuration de l'envoi par email
SendmailOptionNotComplete=Attention, sur certains systèmes Linux, avec cette méthode d'envoi, pour pouvoir envoyer des emails en votre nom, la configuration d'exécution de sendmail doit contenir l'option <b>-ba</b> (paramètre <b>mail.force_extra_parameters</b> dans le fichier <b>php.ini</b>). Si certains de vos destinataires ne reçoivent pas de message, essayer de modifier ce paramètre PHP avec <b>mail.force_extra_parameters = -ba</b>.
PathToDocuments=Chemin d'accès aux documents

View File

@ -62,6 +62,7 @@ ErrorNoValueForCheckBoxType=Les valeurs de la liste de case a cochées doivent
ErrorNoValueForRadioType=Les valeurs de la liste d'options doivent être renseignées
ErrorBadFormatValueList=Les valeurs de la liste ne peuvent pas contenir plus d'une virgule : <b>%s</b>, mais doivent en avoir au moins une: clef,valeur
ErrorFieldCanNotContainSpecialCharacters=Le champ <b>%s</b> ne peut contenir de caractères spéciaux.
ErrorFieldCanNotContainSpecialNorUpperCharacters=Le champ <b>%s</b> ne peut contenir de caractères spéciaux, ni de caractères en majuscules.
ErrorNoAccountancyModuleLoaded=Aucun module de comptabilité activé
ErrorExportDuplicateProfil=Ce nom de profil existe déjà pour ce lot d'export.
ErrorLDAPSetupNotComplete=Le matching Dolibarr-LDAP est incomplet.