[Qual] Uniformize code

This commit is contained in:
philippe grand 2015-11-19 13:59:58 +01:00
parent 3094f9ed32
commit 4f280f63d0
11 changed files with 61 additions and 61 deletions

View File

@ -116,7 +116,7 @@ if (empty($reshook))
exit; exit;
} }
else { else {
setEventMessage($object->error,'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
@ -137,7 +137,7 @@ if (empty($reshook))
} }
else else
{ {
setEventMessage($object->error,'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} }
@ -267,7 +267,7 @@ if (empty($reshook))
$id = $object->create($user); $id = $object->create($user);
if ($id < 0) { if ($id < 0) {
setEventMessage($object->error,'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
if ($id > 0) if ($id > 0)
@ -364,13 +364,13 @@ if (empty($reshook))
} }
else else
{ {
setEventMessage($srcobject->error,'errors'); setEventMessages($srcobject->error, $srcobject->errors, 'errors');
$error++; $error++;
} }
} }
else else
{ {
setEventMessage($object->error,'errors'); setEventMessages($object->error, $object->errors, 'errors');
$error++; $error++;
} }
} }
@ -383,7 +383,7 @@ if (empty($reshook))
exit; exit;
} }
else { else {
setEventMessage($object->error,'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
$action='create'; $action='create';
} }
@ -612,7 +612,7 @@ if (empty($reshook))
} }
else else
{ {
setEventMessage($object->error,'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} }
@ -676,13 +676,13 @@ if (empty($reshook))
} }
else else
{ {
setEventMessage($objectline->error,'errors'); setEventMessages($objectline->error, $objectline->errors, 'errors');
$db->rollback(); $db->rollback();
} }
} }
else else
{ {
setEventMessage($objectline->error,'errors'); setEventMessages($objectline->error, $objectline->errors, 'errors');
} }
} }
@ -697,7 +697,7 @@ if (empty($reshook))
} }
else else
{ {
setEventMessage($object->error,'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
@ -722,7 +722,7 @@ if (empty($reshook))
} }
else else
{ {
setEventMessage($object->error,'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
@ -741,7 +741,7 @@ if (empty($reshook))
} }
else else
{ {
setEventMessage($object->error,'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
else else
@ -768,7 +768,7 @@ if (empty($reshook))
if ($error) { if ($error) {
$action = 'edit_extras'; $action = 'edit_extras';
setEventMessage($object->error,'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
elseif ($action=='setref_supplier') elseif ($action=='setref_supplier')
@ -778,12 +778,12 @@ if (empty($reshook))
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result < 0) { if ($result < 0) {
setEventMessage($object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
$result = $object->setValueFrom('ref_supplier',GETPOST('ref_supplier','alpha')); $result = $object->setValueFrom('ref_supplier',GETPOST('ref_supplier','alpha'));
if ($result < 0) { if ($result < 0) {
setEventMessage($object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$action = 'editref_supplier'; $action = 'editref_supplier';
} else { } else {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
@ -803,12 +803,12 @@ if (empty($reshook))
{ {
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result < 0) { if ($result < 0) {
setEventMessage($object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
$result = $object->setValueFrom('ref_customer',GETPOST('ref_customer','alpha')); $result = $object->setValueFrom('ref_customer',GETPOST('ref_customer','alpha'));
if ($result < 0) { if ($result < 0) {
setEventMessage($object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$action = 'editref_customer'; $action = 'editref_customer';
} else { } else {
header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
@ -827,12 +827,12 @@ if (empty($reshook))
if (!$cancelbutton) { if (!$cancelbutton) {
$result = $object->fetch($id); $result = $object->fetch($id);
if ($result < 0) { if ($result < 0) {
setEventMessage($object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
$result = $object->setValueFrom('ref',GETPOST('ref','alpha'));; $result = $object->setValueFrom('ref',GETPOST('ref','alpha'));;
if ($result < 0) { if ($result < 0) {
setEventMessage($object->errors, 'errors'); setEventMessages($object->error, $object->errors, 'errors');
$action = 'editref'; $action = 'editref';
} else { } else {
header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id); header("Location: " . $_SERVER['PHP_SELF'] . "?id=" . $object->id);
@ -876,8 +876,8 @@ if (empty($reshook))
$upload_dir = $conf->contrat->dir_output; $upload_dir = $conf->contrat->dir_output;
$file = $upload_dir . '/' . GETPOST('file'); $file = $upload_dir . '/' . GETPOST('file');
$ret = dol_delete_file($file, 0, 0, 0, $object); $ret = dol_delete_file($file, 0, 0, 0, $object);
if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('file'))); if ($ret) setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
} }
} }
@ -898,11 +898,11 @@ if (empty($reshook))
if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{ {
$langs->load("errors"); $langs->load("errors");
setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"),'errors'); setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
} }
else else
{ {
setEventMessage($object->error,'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} }
@ -924,7 +924,7 @@ if (empty($reshook))
exit; exit;
} }
else { else {
setEventMessage($object->error,'errors'); setEventMessages($object->error, $object->errors, 'errors');
} }
} }
} }

View File

@ -74,7 +74,7 @@ if ($action == 'addcontact' && $user->rights->contrat->creer)
$mesg = $object->error; $mesg = $object->error;
} }
setEventMessage($mesg, 'errors'); setEventMessages($mesg, null, 'errors');
} }
} }

View File

@ -102,7 +102,7 @@ if ($action == 'remove_file' && $permissioncreate)
$filetodelete=GETPOST('file','alpha'); $filetodelete=GETPOST('file','alpha');
$file = $upload_dir . '/' . $filetodelete; $file = $upload_dir . '/' . $filetodelete;
$ret=dol_delete_file($file,0,0,0,$object); $ret=dol_delete_file($file,0,0,0,$object);
if ($ret) setEventMessage($langs->trans("FileWasRemoved", $filetodelete)); if ($ret) setEventMessages($langs->trans("FileWasRemoved", $filetodelete), null, 'mesgs');
else setEventMessage($langs->trans("ErrorFailToDeleteFile", $filetodelete), 'errors'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", $filetodelete), null, 'errors');
} }

View File

@ -165,7 +165,7 @@ if ($action == 'add')
); );
if ($result > 0) if ($result > 0)
{ {
setEventMessage($langs->trans('SetupSaved')); setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} }
@ -173,7 +173,7 @@ if ($action == 'add')
{ {
$error++; $error++;
$mesg=$extrafields->error; $mesg=$extrafields->error;
setEventMessage($mesg,'errors'); setEventMessages($mesg, null, 'errors');
} }
} }
else else
@ -181,13 +181,13 @@ if ($action == 'add')
$error++; $error++;
$langs->load("errors"); $langs->load("errors");
$mesg=$langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters",$langs->transnoentities("AttributeCode")); $mesg=$langs->trans("ErrorFieldCanNotContainSpecialNorUpperCharacters",$langs->transnoentities("AttributeCode"));
setEventMessage($mesg,'errors'); setEventMessages($mesg, null, 'errors');
$action = 'create'; $action = 'create';
} }
} }
else else
{ {
setEventMessage($mesg,'errors'); setEventMessages($mesg, null, 'errors');
} }
} }
} }
@ -315,7 +315,7 @@ if ($action == 'update')
); );
if ($result > 0) if ($result > 0)
{ {
setEventMessage($langs->trans('SetupSaved')); setEventMessages($langs->trans('SetupSaved'), null, 'mesgs');
header("Location: ".$_SERVER["PHP_SELF"]); header("Location: ".$_SERVER["PHP_SELF"]);
exit; exit;
} }
@ -323,7 +323,7 @@ if ($action == 'update')
{ {
$error++; $error++;
$mesg=$extrafields->error; $mesg=$extrafields->error;
setEventMessage($mesg,'errors'); setEventMessages($mesg, null, 'errors');
} }
} }
else else
@ -331,12 +331,12 @@ if ($action == 'update')
$error++; $error++;
$langs->load("errors"); $langs->load("errors");
$mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode")); $mesg=$langs->trans("ErrorFieldCanNotContainSpecialCharacters",$langs->transnoentities("AttributeCode"));
setEventMessage($mesg,'errors'); setEventMessages($mesg, null, 'errors');
} }
} }
else else
{ {
setEventMessage($mesg,'errors'); setEventMessages($mesg, null, 'errors');
} }
} }
} }

View File

@ -83,7 +83,7 @@ if(! empty($_POST['removAll']))
$result = dol_delete_file($pathtodelete,1); // Delete uploded Files $result = dol_delete_file($pathtodelete,1); // Delete uploded Files
$langs->load("other"); $langs->load("other");
setEventMessage($langs->trans("FileWasRemoved",$filetodelete)); setEventMessages($langs->trans("FileWasRemoved",$filetodelete), null, 'mesgs');
$formmail->remove_attached_files($key); // Update Session $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 $possibleuser=$dolimail->get_from_user_by_mail($_POST['sendto'],"1"); // suche in llx_societe and socpeople
if (!$possibleaccounts && !$possibleuser) if (!$possibleaccounts && !$possibleuser)
{ {
setEventMessage($langs->trans('ErrorFailedToFindSocieteRecord',$_POST['sendto']),'errors'); setEventMessages($langs->trans('ErrorFailedToFindSocieteRecord',$_POST['sendto']), null, 'errors');
} }
elseif (count($possibleaccounts)>1) elseif (count($possibleaccounts)>1)
{ {
$sendtosocid=$possibleaccounts[1]['id']; $sendtosocid=$possibleaccounts[1]['id'];
$result=$object->fetch($sendtosocid); $result=$object->fetch($sendtosocid);
setEventMessage($langs->trans('ErrorFoundMoreThanOneRecordWithEmail',$_POST['sendto'],$object->name)); setEventMessages($langs->trans('ErrorFoundMoreThanOneRecordWithEmail',$_POST['sendto'],$object->name), null, 'mesgs');
} }
else else
{ {
@ -251,7 +251,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
{ {
$info = FALSE; $info = FALSE;
$err = $langs->trans('Error3_Imap_Connection_Error'); $err = $langs->trans('Error3_Imap_Connection_Error');
setEventMessage($err,$mailboxconfig->element,'errors'); setEventMessages($err,$mailboxconfig->element, null, 'errors');
} }
else else
{ {
@ -323,7 +323,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
// Redirect here // Redirect here
// This avoid sending mail twice if going out and then back to page // 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)); $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); 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); else header('Location: '.$_SERVER["PHP_SELF"].'?'.($paramname?$paramname:'id').'='.$object->id);
exit; exit;
@ -344,7 +344,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
} }
$mesg.='</div>'; $mesg.='</div>';
setEventMessage($mesg,'warnings'); setEventMessages($mesg, null, 'warnings');
$action = 'presend'; $action = 'presend';
} }
} }
@ -359,7 +359,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
else else
{ {
$langs->load("errors"); $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); dol_syslog('Try to send email with no recipiend defined', LOG_WARNING);
$action = 'presend'; $action = 'presend';
} }
@ -367,7 +367,7 @@ if (($action == 'send' || $action == 'relance') && ! $_POST['addfile'] && ! $_PO
else else
{ {
$langs->load("other"); $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); dol_syslog('Failed to read data of object id='.$object->id.' element='.$object->element);
$action = 'presend'; $action = 'presend';
} }

View File

@ -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($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 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'); $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 // Set public note
else if ($action == 'setnote_private' && ! empty($permissionnote) && ! GETPOST('cancel')) 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($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 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'); $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');
} }

View File

@ -1480,7 +1480,7 @@ class ExtraFields
if($nofillrequired) { if($nofillrequired) {
$langs->load('errors'); $langs->load('errors');
setEventMessage($langs->trans('ErrorFieldsRequired').' : '.implode(', ',$error_field_required),'errors'); setEventMessages($langs->trans('ErrorFieldsRequired').' : '.implode(', ',$error_field_required), null, 'errors');
return -1; return -1;
} }
else { else {

View File

@ -301,7 +301,7 @@ class FormMail extends Form
$result = $this->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs); $result = $this->fetchAllEMailTemplate($this->param["models"], $user, $outputlangs);
if ($result<0) if ($result<0)
{ {
setEventMessage($this->error,'errors'); setEventMessages($this->error, $this->errors, 'errors');
} }
$modelmail_array=array(); $modelmail_array=array();
foreach($this->lines_model as $line) foreach($this->lines_model as $line)

View File

@ -1470,22 +1470,22 @@ function dol_add_file_process($upload_dir, $allowoverwrite=0, $donotupdatesessio
$imgThumbMini = vignette($destpath, 160, 120, '_mini', 50, "thumbs"); $imgThumbMini = vignette($destpath, 160, 120, '_mini', 50, "thumbs");
} }
setEventMessage($langs->trans("FileTransferComplete")); setEventMessages($langs->trans("FileTransferComplete"), null, 'mesgs');
} }
else else
{ {
$langs->load("errors"); $langs->load("errors");
if ($resupload < 0) // Unknown error 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 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 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); $res = $linkObject->create($user);
$langs->load('link'); $langs->load('link');
if ($res > 0) { if ($res > 0) {
setEventMessage($langs->trans("LinkComplete")); setEventMessages($langs->trans("LinkComplete"), null, 'mesgs');
} else { } 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)) if (empty($donotdeletefile))
{ {
$langs->load("other"); $langs->load("other");
setEventMessage($langs->trans("FileWasRemoved",$filetodelete)); setEventMessages($langs->trans("FileWasRemoved",$filetodelete), null, 'mesgs');
} }
if (empty($donotupdatesession)) if (empty($donotupdatesession))
{ {

View File

@ -139,7 +139,7 @@ if ($action == 'confirm_resize' && (isset($_POST["file"]) != "") && (isset($_POS
} }
else else
{ {
setEventMessage($result, 'errors'); setEventMessages($result, null, 'errors');
$_GET['file']=$_POST["file"]; $_GET['file']=$_POST["file"];
$action=''; $action='';
} }
@ -168,7 +168,7 @@ if ($action == 'confirm_crop')
} }
else else
{ {
setEventMessage($result, 'errors'); setEventMessages($result, null, 'errors');
$_GET['file']=$_POST["file"]; $_GET['file']=$_POST["file"];
$action=''; $action='';
} }

View File

@ -88,8 +88,8 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
} }
} }
if ($ret) setEventMessage($langs->trans("FileWasRemoved", $urlfile)); if ($ret) setEventMessages($langs->trans("FileWasRemoved", $urlfile), null, 'mesgs');
else setEventMessage($langs->trans("ErrorFailToDeleteFile", $urlfile), 'errors'); else setEventMessages($langs->trans("ErrorFailToDeleteFile", $urlfile), null, 'errors');
} }
elseif ($linkid) elseif ($linkid)
{ {
@ -101,12 +101,12 @@ if ($action == 'confirm_deletefile' && $confirm == 'yes')
$langs->load('link'); $langs->load('link');
if ($res > 0) { if ($res > 0) {
setEventMessage($langs->trans("LinkRemoved", $link->label)); setEventMessages($langs->trans("LinkRemoved", $link->label), null, 'mesgs');
} else { } else {
if (count($link->errors)) { if (count($link->errors)) {
setEventMessages('', $link->errors, 'errors'); setEventMessages('', $link->errors, 'errors');
} else { } 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); $res = $link->update($user);
if (!$res) if (!$res)
{ {
setEventMessage($langs->trans("ErrorFailedToUpdateLink", $link->label)); setEventMessages($langs->trans("ErrorFailedToUpdateLink", $link->label), null, 'mesgs');
} }
} }
else else