Fix: Object should never be a global variable as there is several object in a context. Also object type must be fixed for each "trigger code". So we add trigger code and object on parameter because only caller of a function know which object type we use and what trigger code we want to trigger.
This commit is contained in:
parent
8113a64483
commit
1d8b4a24d5
@ -20,7 +20,7 @@
|
|||||||
/**
|
/**
|
||||||
* \file htdocs/lib/files.lib.php
|
* \file htdocs/lib/files.lib.php
|
||||||
* \brief Library for file managing functions
|
* \brief Library for file managing functions
|
||||||
* \version $Id: files.lib.php,v 1.68 2011/07/11 06:23:22 hregis Exp $
|
* \version $Id: files.lib.php,v 1.69 2011/07/13 21:33:38 eldy Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -590,12 +590,13 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable
|
|||||||
* @param disableglob Disable usage of glob like *
|
* @param disableglob Disable usage of glob like *
|
||||||
* @param nophperrors Disable all PHP output errors
|
* @param nophperrors Disable all PHP output errors
|
||||||
* @param notrigger Disable all triggers
|
* @param notrigger Disable all triggers
|
||||||
|
* @param triggercode Code of trigger
|
||||||
|
* @param object Object for trigger
|
||||||
* @return boolean True if file is deleted, False if error
|
* @return boolean True if file is deleted, False if error
|
||||||
*/
|
*/
|
||||||
function dol_delete_file($file,$disableglob=0,$nophperrors=0,$notrigger=0)
|
function dol_delete_file($file,$disableglob=0,$nophperrors=0,$notrigger=0,$triggercode='FILE_DELETE',$object=null)
|
||||||
{
|
{
|
||||||
global $conf, $user, $langs;
|
global $db, $conf, $user, $langs;
|
||||||
global $object;
|
|
||||||
|
|
||||||
//print "x".$file." ".$disableglob;
|
//print "x".$file." ".$disableglob;
|
||||||
$ok=true;
|
$ok=true;
|
||||||
@ -611,12 +612,13 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$notrigger=0)
|
|||||||
dol_syslog("Removed file ".$filename,LOG_DEBUG);
|
dol_syslog("Removed file ".$filename,LOG_DEBUG);
|
||||||
if (! $notrigger)
|
if (! $notrigger)
|
||||||
{
|
{
|
||||||
|
if (! is_object($object)) $object=(object) 'dummy';
|
||||||
$object->src_file=$file;
|
$object->src_file=$file;
|
||||||
|
|
||||||
// Appel des triggers
|
// Appel des triggers
|
||||||
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
||||||
$interface=new Interfaces($db);
|
$interface=new Interfaces($db);
|
||||||
$result=$interface->run_triggers('FILE_DELETE',$object,$user,$langs,$conf);
|
$result=$interface->run_triggers($triggercode,$object,$user,$langs,$conf);
|
||||||
if ($result < 0) { $error++; $errors=$interface->errors; }
|
if ($result < 0) { $error++; $errors=$interface->errors; }
|
||||||
// Fin appel triggers
|
// Fin appel triggers
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user