From 4f280f63d0988d39307212e20f50f26d15a45847 Mon Sep 17 00:00:00 2001 From: philippe grand Date: Thu, 19 Nov 2015 13:59:58 +0100 Subject: [PATCH] [Qual] Uniformize code --- htdocs/contrat/card.php | 48 +++++++++---------- htdocs/contrat/contact.php | 2 +- htdocs/core/actions_builddoc.inc.php | 4 +- htdocs/core/actions_extrafields.inc.php | 16 +++---- htdocs/core/actions_sendmails.inc.php | 16 +++---- htdocs/core/actions_setnotes.inc.php | 4 +- htdocs/core/class/extrafields.class.php | 2 +- htdocs/core/class/html.formmail.class.php | 2 +- htdocs/core/lib/files.lib.php | 14 +++--- htdocs/core/photos_resize.php | 4 +- .../tpl/document_actions_pre_headers.tpl.php | 10 ++-- 11 files changed, 61 insertions(+), 61 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 0bce12b2918..3514ab6acfc 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -116,7 +116,7 @@ if (empty($reshook)) exit; } else { - setEventMessage($object->error,'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -137,7 +137,7 @@ if (empty($reshook)) } else { - setEventMessage($object->error,'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } } @@ -267,7 +267,7 @@ if (empty($reshook)) $id = $object->create($user); if ($id < 0) { - setEventMessage($object->error,'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } if ($id > 0) @@ -364,13 +364,13 @@ if (empty($reshook)) } else { - setEventMessage($srcobject->error,'errors'); + setEventMessages($srcobject->error, $srcobject->errors, 'errors'); $error++; } } else { - setEventMessage($object->error,'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $error++; } } @@ -383,7 +383,7 @@ if (empty($reshook)) exit; } else { - setEventMessage($object->error,'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } $action='create'; } @@ -612,7 +612,7 @@ if (empty($reshook)) } else { - setEventMessage($object->error,'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } } @@ -676,13 +676,13 @@ if (empty($reshook)) } else { - setEventMessage($objectline->error,'errors'); + setEventMessages($objectline->error, $objectline->errors, 'errors'); $db->rollback(); } } else { - setEventMessage($objectline->error,'errors'); + setEventMessages($objectline->error, $objectline->errors, 'errors'); } } @@ -697,7 +697,7 @@ if (empty($reshook)) } else { - setEventMessage($object->error,'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -722,7 +722,7 @@ if (empty($reshook)) } else { - setEventMessage($object->error,'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } @@ -741,7 +741,7 @@ if (empty($reshook)) } else { - setEventMessage($object->error,'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } else @@ -768,7 +768,7 @@ if (empty($reshook)) if ($error) { $action = 'edit_extras'; - setEventMessage($object->error,'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } elseif ($action=='setref_supplier') @@ -778,12 +778,12 @@ if (empty($reshook)) $result = $object->fetch($id); if ($result < 0) { - setEventMessage($object->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } $result = $object->setValueFrom('ref_supplier',GETPOST('ref_supplier','alpha')); if ($result < 0) { - setEventMessage($object->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $action = 'editref_supplier'; } else { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); @@ -803,12 +803,12 @@ if (empty($reshook)) { $result = $object->fetch($id); if ($result < 0) { - setEventMessage($object->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } $result = $object->setValueFrom('ref_customer',GETPOST('ref_customer','alpha')); if ($result < 0) { - setEventMessage($object->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $action = 'editref_customer'; } else { header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); @@ -827,12 +827,12 @@ if (empty($reshook)) if (!$cancelbutton) { $result = $object->fetch($id); if ($result < 0) { - setEventMessage($object->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } $result = $object->setValueFrom('ref',GETPOST('ref','alpha'));; if ($result < 0) { - setEventMessage($object->errors, 'errors'); + setEventMessages($object->error, $object->errors, 'errors'); $action = 'editref'; } else { header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); @@ -876,8 +876,8 @@ if (empty($reshook)) $upload_dir = $conf->contrat->dir_output; $file = $upload_dir . '/' . GETPOST('file'); $ret = dol_delete_file($file, 0, 0, 0, $object); - if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('file'))); - else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors'); + if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs'); + else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors'); } } @@ -898,11 +898,11 @@ if (empty($reshook)) if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') { $langs->load("errors"); - setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"),'errors'); + setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors'); } else { - setEventMessage($object->error,'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } } @@ -924,7 +924,7 @@ if (empty($reshook)) exit; } else { - setEventMessage($object->error,'errors'); + setEventMessages($object->error, $object->errors, 'errors'); } } } diff --git a/htdocs/contrat/contact.php b/htdocs/contrat/contact.php index 1528e472cbe..cd070f6078d 100644 --- a/htdocs/contrat/contact.php +++ b/htdocs/contrat/contact.php @@ -74,7 +74,7 @@ if ($action == 'addcontact' && $user->rights->contrat->creer) $mesg = $object->error; } - setEventMessage($mesg, 'errors'); + setEventMessages($mesg, null, 'errors'); } } diff --git a/htdocs/core/actions_builddoc.inc.php b/htdocs/core/actions_builddoc.inc.php index 27e5d8f602b..29ae4eb3365 100644 --- a/htdocs/core/actions_builddoc.inc.php +++ b/htdocs/core/actions_builddoc.inc.php @@ -102,7 +102,7 @@ if ($action == 'remove_file' && $permissioncreate) $filetodelete=GETPOST('file','alpha'); $file = $upload_dir . '/' . $filetodelete; $ret=dol_delete_file($file,0,0,0,$object); - if ($ret) setEventMessage($langs->trans("FileWasRemoved", $filetodelete)); - else setEventMessage($langs->trans("ErrorFailToDeleteFile", $filetodelete), 'errors'); + if ($ret) setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs'); + else setEventMessages($langs->trans("ErrorFailToDeleteFile", $filetodelete), null, 'errors'); } diff --git a/htdocs/core/actions_extrafields.inc.php b/htdocs/core/actions_extrafields.inc.php index 8ac95358bb8..b866c322158 100644 --- a/htdocs/core/actions_extrafields.inc.php +++ b/htdocs/core/actions_extrafields.inc.php @@ -165,7 +165,7 @@ if ($action == 'add') ); if ($result > 0) { - setEventMessage($langs->trans('SetupSaved')); + setEventMessages($langs->trans('SetupSaved'), null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]); exit; } @@ -173,7 +173,7 @@ if ($action == 'add') { $error++; $mesg=$extrafields->error; - setEventMessage($mesg,'errors'); + setEventMessages($mesg, null, 'errors'); } } else @@ -181,13 +181,13 @@ if ($action == 'add') $error++; $langs->load("errors"); $mesg=$langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters",$langs->transnoentities("AttributeCode")); - setEventMessage($mesg,'errors'); + setEventMessages($mesg, null, 'errors'); $action = 'create'; } } else { - setEventMessage($mesg,'errors'); + setEventMessages($mesg, null, 'errors'); } } } @@ -315,7 +315,7 @@ if ($action == 'update') ); if ($result > 0) { - setEventMessage($langs->trans('SetupSaved')); + setEventMessages($langs->trans('SetupSaved'), null, 'mesgs'); header("Location: ".$_SERVER["PHP_SELF"]); exit; } @@ -323,7 +323,7 @@ if ($action == 'update') { $error++; $mesg=$extrafields->error; - setEventMessage($mesg,'errors'); + setEventMessages($mesg, null, 'errors'); } } else @@ -331,12 +331,12 @@ if ($action == 'update') $error++; $langs->load("errors"); $mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode")); - setEventMessage($mesg,'errors'); + setEventMessages($mesg, null, 'errors'); } } else { - setEventMessage($mesg,'errors'); + setEventMessages($mesg, null, 'errors'); } } } diff --git a/htdocs/core/actions_sendmails.inc.php b/htdocs/core/actions_sendmails.inc.php index 1f96d085bb8..9b7ba19ff61 100644 --- a/htdocs/core/actions_sendmails.inc.php +++ b/htdocs/core/actions_sendmails.inc.php @@ -83,7 +83,7 @@ if(! empty($_POST['removAll'])) $result = dol_delete_file($pathtodelete,1); // Delete uploded Files $langs->load("other"); - setEventMessage($langs->trans("FileWasRemoved",$filetodelete)); + setEventMessages($langs->trans("FileWasRemoved",$filetodelete), null, 'mesgs'); $formmail->remove_attached_files($key); // Update Session } @@ -119,14 +119,14 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO $possibleuser=$dolimail->get_from_user_by_mail($_POST['sendto'],"1"); // suche in llx_societe and socpeople if (!$possibleaccounts && !$possibleuser) { - setEventMessage($langs->trans('ErrorFailedToFindSocieteRecord',$_POST['sendto']),'errors'); + setEventMessages($langs->trans('ErrorFailedToFindSocieteRecord',$_POST['sendto']), null, 'errors'); } elseif (count($possibleaccounts)>1) { $sendtosocid=$possibleaccounts[1]['id']; $result=$object->fetch($sendtosocid); - setEventMessage($langs->trans('ErrorFoundMoreThanOneRecordWithEmail',$_POST['sendto'],$object->name)); + setEventMessages($langs->trans('ErrorFoundMoreThanOneRecordWithEmail',$_POST['sendto'],$object->name), null, 'mesgs'); } else { @@ -251,7 +251,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO { $info = FALSE; $err = $langs->trans('Error3_Imap_Connection_Error'); - setEventMessage($err,$mailboxconfig->element,'errors'); + setEventMessages($err,$mailboxconfig->element, null, 'errors'); } else { @@ -323,7 +323,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO // Redirect here // This avoid sending mail twice if going out and then back to page $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); - setEventMessage($mesg); + setEventMessages($mesg, null, 'mesgs'); if($conf->dolimail->enabled) header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.$object->id.'&'.($paramname2?$paramname2:'mid').'='.$parm2val); else header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.$object->id); exit; @@ -344,7 +344,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO } $mesg.=''; - setEventMessage($mesg,'warnings'); + setEventMessages($mesg, null, 'warnings'); $action = 'presend'; } } @@ -359,7 +359,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO else { $langs->load("errors"); - setEventMessage($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("MailTo")),'warnings'); + setEventMessages($langs->trans('ErrorFieldRequired',$langs->transnoentitiesnoconv("MailTo")), null, 'warnings'); dol_syslog('Try to send email with no recipiend defined', LOG_WARNING); $action = 'presend'; } @@ -367,7 +367,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO else { $langs->load("other"); - setEventMessage($langs->trans('ErrorFailedToReadEntity',$object->element),'errors'); + setEventMessages($langs->trans('ErrorFailedToReadEntity',$object->element), null, 'errors'); dol_syslog('Failed to read data of object id='.$object->id.' element='.$object->element); $action = 'presend'; } diff --git a/htdocs/core/actions_setnotes.inc.php b/htdocs/core/actions_setnotes.inc.php index dccce99cf9f..3fa76891124 100644 --- a/htdocs/core/actions_setnotes.inc.php +++ b/htdocs/core/actions_setnotes.inc.php @@ -33,7 +33,7 @@ if ($action == 'setnote_public' && ! empty($permissionnote) && ! GETPOST('cancel if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); if (empty($object->id)) $object->fetch($id); // Fetch may not be already done $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); - if ($result < 0) setEventMessage($object->error,'errors'); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } // Set public note else if ($action == 'setnote_private' && ! empty($permissionnote) && ! GETPOST('cancel')) @@ -41,5 +41,5 @@ else if ($action == 'setnote_private' && ! empty($permissionnote) && ! GETPOST(' if (empty($action) || ! is_object($object) || empty($id)) dol_print_error('','Include of actions_setnotes.inc.php was done but required variable was not set before'); if (empty($object->id)) $object->fetch($id); // Fetch may not be already done $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); - if ($result < 0) setEventMessage($object->error,'errors'); + if ($result < 0) setEventMessages($object->error, $object->errors, 'errors'); } diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 645b50cb8bc..4380f336755 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -1480,7 +1480,7 @@ class ExtraFields if($nofillrequired) { $langs->load('errors'); - setEventMessage($langs->trans('ErrorFieldsRequired').' : '.implode(', ',$error_field_required),'errors'); + setEventMessages($langs->trans('ErrorFieldsRequired').' : '.implode(', ',$error_field_required), null, 'errors'); return -1; } else { diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 34668e23c90..2cfe305efcf 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -301,7 +301,7 @@ class FormMail extends Form $result = $this->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs); if ($result<0) { - setEventMessage($this->error,'errors'); + setEventMessages($this->error, $this->errors, 'errors'); } $modelmail_array=array(); foreach($this->lines_model as $line) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 3e35e66336f..db6582ba332 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -1470,22 +1470,22 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio $imgThumbMini = vignette($destpath, 160, 120, '_mini', 50, "thumbs"); } - setEventMessage($langs->trans("FileTransferComplete")); + setEventMessages($langs->trans("FileTransferComplete"), null, 'mesgs'); } else { $langs->load("errors"); if ($resupload < 0) // Unknown error { - setEventMessage($langs->trans("ErrorFileNotUploaded"), 'errors'); + setEventMessages($langs->trans("ErrorFileNotUploaded"), null, 'errors'); } else if (preg_match('/ErrorFileIsInfectedWithAVirus/',$resupload)) // Files infected by a virus { - setEventMessage($langs->trans("ErrorFileIsInfectedWithAVirus"), 'errors'); + setEventMessages($langs->trans("ErrorFileIsInfectedWithAVirus"), null, 'errors'); } else // Known error { - setEventMessage($langs->trans($resupload), 'errors'); + setEventMessages($langs->trans($resupload), null, 'errors'); } } } @@ -1501,9 +1501,9 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio $res = $linkObject->create($user); $langs->load('link'); if ($res > 0) { - setEventMessage($langs->trans("LinkComplete")); + setEventMessages($langs->trans("LinkComplete"), null, 'mesgs'); } else { - setEventMessage($langs->trans("ErrorFileNotLinked"), 'errors'); + setEventMessages($langs->trans("ErrorFileNotLinked"), null, 'errors'); } } } @@ -1549,7 +1549,7 @@ function dol_remove_file_process($filenb,$donotupdatesession=0,$donotdeletefile= if (empty($donotdeletefile)) { $langs->load("other"); - setEventMessage($langs->trans("FileWasRemoved",$filetodelete)); + setEventMessages($langs->trans("FileWasRemoved",$filetodelete), null, 'mesgs'); } if (empty($donotupdatesession)) { diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php index cb929daad3b..20c35bef497 100644 --- a/htdocs/core/photos_resize.php +++ b/htdocs/core/photos_resize.php @@ -139,7 +139,7 @@ if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POS } else { - setEventMessage($result, 'errors'); + setEventMessages($result, null, 'errors'); $_GET['file']=$_POST["file"]; $action=''; } @@ -168,7 +168,7 @@ if ($action == 'confirm_crop') } else { - setEventMessage($result, 'errors'); + setEventMessages($result, null, 'errors'); $_GET['file']=$_POST["file"]; $action=''; } diff --git a/htdocs/core/tpl/document_actions_pre_headers.tpl.php b/htdocs/core/tpl/document_actions_pre_headers.tpl.php index b33377eec6a..79b33a665a2 100644 --- a/htdocs/core/tpl/document_actions_pre_headers.tpl.php +++ b/htdocs/core/tpl/document_actions_pre_headers.tpl.php @@ -88,8 +88,8 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') } } - if ($ret) setEventMessage($langs->trans("FileWasRemoved", $urlfile)); - else setEventMessage($langs->trans("ErrorFailToDeleteFile", $urlfile), 'errors'); + if ($ret) setEventMessages($langs->trans("FileWasRemoved", $urlfile), null, 'mesgs'); + else setEventMessages($langs->trans("ErrorFailToDeleteFile", $urlfile), null, 'errors'); } elseif ($linkid) { @@ -101,12 +101,12 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes') $langs->load('link'); if ($res > 0) { - setEventMessage($langs->trans("LinkRemoved", $link->label)); + setEventMessages($langs->trans("LinkRemoved", $link->label), null, 'mesgs'); } else { if (count($link->errors)) { setEventMessages('', $link->errors, 'errors'); } else { - setEventMessage($langs->trans("ErrorFailedToDeleteLink", $link->label), 'errors'); + setEventMessages($langs->trans("ErrorFailedToDeleteLink", $link->label), null, 'errors'); } } } @@ -132,7 +132,7 @@ elseif ($action == 'confirm_updateline' && GETPOST('save') && GETPOST('link', 'a $res = $link->update($user); if (!$res) { - setEventMessage($langs->trans("ErrorFailedToUpdateLink", $link->label)); + setEventMessages($langs->trans("ErrorFailedToUpdateLink", $link->label), null, 'mesgs'); } } else