Revert bad practice: setEvent use SESSION. Such usage is limited to HTML

page context and can be used inside any pages.
However usage of _SESSION must never be used inside a library (except
for function dedicated to HTML page context), and never inside
object classes (we must use $this->errors, $this->mesgs or
$this->warnings instead).
This commit is contained in:
Laurent Destailleur 2012-07-29 14:15:29 +02:00
parent 0ee08418cc
commit d6a5b224fb
8 changed files with 17 additions and 8 deletions

View File

@ -1845,7 +1845,9 @@ class Propal extends CommonObject
if (! dol_delete_file($file,0,0,0,$this)) // For triggers
{
$this->db->rollback();
$this->error='ErrorFailToDeleteFile';
$this->errors=array('ErrorFailToDeleteFile');
$this->db->rollback();
return 0;
}
}
@ -1855,6 +1857,7 @@ class Propal extends CommonObject
if (! $res)
{
$this->error='ErrorFailToDeleteDir';
$this->errors=array('ErrorFailToDeleteDir');
$this->db->rollback();
return 0;
}

View File

@ -2262,7 +2262,8 @@ class Commande extends CommonOrder
}
else
{
$this->error=$this->db->error();
$this->error=$this->db->lasterror();
$this->errors=array($this->db->lasterror());
$this->db->rollback();
dol_syslog(get_class($this)."::updateline Error=".$this->error, LOG_ERR);
return -1;
@ -2271,6 +2272,7 @@ class Commande extends CommonOrder
else
{
$this->error=get_class($this)."::updateline Order status makes operation forbidden";
$this->errors=array('OrderStatusMakeOperationForbidden');
return -2;
}
}

View File

@ -1263,6 +1263,7 @@ class Facture extends CommonInvoice
if (! dol_delete_file($file,0,0,0,$this)) // For triggers
{
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
$this->db->rollback();
return 0;
}

View File

@ -688,7 +688,6 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$notrigger=0,$objec
if ($ok)
{
dol_syslog("Removed file ".$filename, LOG_DEBUG);
setEventMessage($langs->trans("FileWasRemoved", basename($filename)));
if (! $notrigger)
{
if (! is_object($object)) $object=(object) 'dummy';
@ -705,7 +704,6 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$notrigger=0,$objec
}
else {
dol_syslog("Failed to remove file ".$filename, LOG_WARNING);
setEventMessage($langs->trans("ErrorFailToDeleteFile", basename($filename)), 'errors');
}
}
}
@ -715,11 +713,9 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$notrigger=0,$objec
else $ok=unlink($file_osencoded); // The unlink encapsulated by dolibarr
if ($ok) {
dol_syslog("Removed file ".$file_osencoded, LOG_DEBUG);
setEventMessage($langs->trans("FileWasRemoved", basename($file_osencoded)));
}
else {
dol_syslog("Failed to remove file ".$file_osencoded, LOG_WARNING);
setEventMessage($langs->trans("ErrorFailToDeleteFile", basename($file_osencoded)), 'errors');
}
}
return $ok;
@ -878,7 +874,7 @@ function dol_meta_create($object)
{
//Pour les articles
$meta .= "ITEM_" . $i . "_QUANTITY=\"" . $object->lines[$i]->qty . "\"
ITEM_" . $i . "_UNIT_PRICE=\"" . $object->lines[$i]->total_ht . "\"
ITEM_" . $i . "_TOTAL_HT=\"" . $object->lines[$i]->total_ht . "\"
ITEM_" . $i . "_TVA=\"" .$object->lines[$i]->tva_tx . "\"
ITEM_" . $i . "_DESCRIPTION=\"" . str_replace("\r\n","",nl2br($object->lines[$i]->desc)) . "\"
";
@ -926,6 +922,7 @@ function dol_init_file_process($pathtoscan='')
/**
* Get and save an upload file (for example after submitting a new file a mail form).
* All information used are in db, conf, langs, user and _FILES.
* Note: This function can be used only into a HTML page context.
*
* @param string $upload_dir Directory to store upload files
* @param int $allowoverwrite 1=Allow overwrite existing file

View File

@ -547,7 +547,10 @@ class Expedition extends CommonObject
$file = $dir . "/" . $expeditionref . ".pdf";
if (file_exists($file))
{
dol_delete_file($file);
if (!dol_delete_file($file))
{
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
}
}
if (file_exists($dir))
{

View File

@ -651,6 +651,7 @@ class Fichinter extends CommonObject
if (! dol_delete_file($file,0,0,0,$this)) // For triggers
{
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
return 0;
}
}

View File

@ -1322,6 +1322,7 @@ class CommandeFournisseur extends CommonOrder
{
if (! dol_delete_file($file,0,0,0,$this)) // For triggers
{
$this->error='ErrorFailToDeleteFile';
$error++;
}
}

View File

@ -399,6 +399,7 @@ class Livraison extends CommonObject
{
if (! dol_delete_file($file))
{
$this->error=$langs->trans("ErrorCanNotDeleteFile",$file);
return 0;
}
}