From 031bc911ea5b2e25efc06c7f8f418379baf5a239 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 13 Feb 2013 16:46:28 +0100 Subject: [PATCH] Fix: Mass save or update of const fails. --- htdocs/admin/const.php | 46 +++++++++++++++++++++++++++++------- htdocs/langs/en_US/main.lang | 1 + htdocs/langs/fr_FR/main.lang | 1 + 3 files changed, 39 insertions(+), 9 deletions(-) diff --git a/htdocs/admin/const.php b/htdocs/admin/const.php index 0d263991714..77534fd0d76 100644 --- a/htdocs/admin/const.php +++ b/htdocs/admin/const.php @@ -35,7 +35,7 @@ $rowid=GETPOST('rowid','int'); $entity=GETPOST('entity','int'); $action=GETPOST('action','alpha'); $update=GETPOST('update','alpha'); -$delete=GETPOST('delete','alpha'); +$delete=GETPOST('delete'); // Do not use alpha here $debug=GETPOST('debug','int'); $consts=GETPOST('const'); $constname=GETPOST('constname','alpha'); @@ -47,6 +47,7 @@ $typeconst=array('yesno' => 'yesno', 'texte' => 'texte', 'chaine' => 'chaine'); $mesg=''; + /* * Actions */ @@ -68,46 +69,70 @@ if ($action == 'add') if (! $error) { - if (dolibarr_set_const($db, $constname, $constvalue, $typeconst[$consttype], 1, $constnote, $entity) < 0) + if (dolibarr_set_const($db, $constname, $constvalue, $typeconst[$consttype], 1, $constnote, $entity) >= 0) + { + setEventMessage($langs->trans("RecordSaved")); + } + else { dol_print_error($db); } } } -if (! empty($consts) && $update == $langs->trans("Modify")) +// Mass update +if (! empty($consts) && $action == 'update') { + $nbmodified=0; foreach($consts as $const) { if (! empty($const["check"])) { - if (dolibarr_set_const($db, $const["name"], $const["value"], $const["type"], 1, $const["note"], $const["entity"]) < 0) + if (dolibarr_set_const($db, $const["name"], $const["value"], $const["type"], 1, $const["note"], $const["entity"]) >= 0) + { + $nbmodified++; + } + else { dol_print_error($db); } } } + if ($nbmodified > 0) setEventMessage($langs->trans("RecordSaved")); + $action=''; } -// Delete several lines at once -if (! empty($consts) && $delete == $langs->trans("Delete")) +// Mass delete +if (! empty($consts) && $action == 'delete') { + + $nbdeleted=0; foreach($consts as $const) { if (! empty($const["check"])) // Is checkbox checked { - if (dolibarr_del_const($db, $const["rowid"], -1) < 0) + if (dolibarr_del_const($db, $const["rowid"], -1) >= 0) + { + $nbdeleted++; + } + else { dol_print_error($db); } } } + if ($nbdeleted > 0) setEventMessage($langs->trans("RecordDeleted")); + $action=''; } // Delete line from delete picto if ($action == 'delete') { - if (dolibarr_del_const($db, $rowid, $entity) < 0) + if (dolibarr_del_const($db, $rowid, $entity) >= 0) + { + setEventMessage($langs->trans("RecordDeleted")); + } + else { dol_print_error($db); } @@ -130,11 +155,13 @@ jQuery(document).ready(function() { jQuery("#delconst").hide(); jQuery(".checkboxfordelete").click(function() { jQuery("#delconst").show(); + jQuery("#action").val('delete'); }); jQuery(".inputforupdate").keypress(function() { var field_id = jQuery(this).attr("id"); var row_num = field_id.split("_"); jQuery("#updateconst").show(); + jQuery("#action").val('update'); jQuery("#check_" + row_num[1]).attr("checked",true); }); }); @@ -195,7 +222,8 @@ print ''; print "\n"; print '
entity) && $debug)?'?debug=1':'').'" method="POST">'; -print ''; +print ''; +print ''; // Show constants $sql = "SELECT"; diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index dc2ee6b225e..98c28b231b2 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -58,6 +58,7 @@ NbOfEntries=Nb of entries GoToWikiHelpPage=Read online help (need Internet access) GoToHelpPage=Read help RecordSaved=Record saved +RecordDeleted=Record deleted LevelOfFeature=Level of features NotDefined=Not defined DefinedAndHasThisValue=Defined and value to diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index e402a8cd1fe..301b97c1e3a 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -58,6 +58,7 @@ NbOfEntries=Nb d'entrées GoToWikiHelpPage=Consulter l'aide (nécessite un accès internet) GoToHelpPage=Consulter l'aide RecordSaved=Enregistrement sauvegardé +RecordDeleted=Enregistrement supprimé LevelOfFeature=Niveau de fonctionnalités NotDefined=Non défini DolibarrInHttpAuthenticationSoPasswordUseless=Dolibarr est configuré en mode authentification %s dans son fichier de configuration conf.php.
Cela signifie que la base des mots de passe est externe à Dolibarr, aussi toute modification de ce champ peut s'avérer sans effet.