New: Add hooks to execute code after pdf generation

This commit is contained in:
Laurent Destailleur 2011-10-19 22:05:54 +02:00
parent ae4b871f04
commit a0855a3867
5 changed files with 41 additions and 20 deletions

View File

@ -41,18 +41,17 @@ class FormFile
*
* @param DoliDB $DB Database handler
*/
function FormFile($DB)
function FormFile($db)
{
$this->db = $DB;
$this->db = $db;
$this->numoffiles=0;
return 1;
}
/**
* Show form to upload a new file
*
* @param url Url
* @param title Title zone (Title or '' or 'none')
* @param addcancel 1=Add 'Cancel' button

View File

@ -405,6 +405,15 @@ class pdf_crabe extends ModelePDFFactures
$pdf->Close();
$pdf->Output($file,'F');
// Actions on extra fields (by external module or standard code)
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
$hookmanager=new HookManager($this->db);
$hookmanager->callHooks(array('pdfgeneration'));
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
global $action;
$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));

View File

@ -108,7 +108,7 @@ class pdf_oursin extends ModelePDFFactures
/**
* Function to build pdf onto disk
*
*
* @param int $object Id of object to generate
* @param object $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file
@ -290,6 +290,15 @@ class pdf_oursin extends ModelePDFFactures
$pdf->Close();
$pdf->Output($file,'F');
// Actions on extra fields (by external module or standard code)
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
$hookmanager=new HookManager($this->db);
$hookmanager->callHooks(array('pdfgeneration'));
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
global $action;
$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));

View File

@ -383,16 +383,18 @@ class pdf_propale_azur extends ModelePDFPropales
$pdf->Close();
$pdf->Output($file,'F');
// Actions on extra fields (by external module or standard code)
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
$hookmanager=new HookManager($this->db);
$hookmanager->callHooks(array('pdfgeneration'));
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
global $action;
$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
// Add external file
//$pdfConcat = new concat_pdf();
//$pdfConcat->setFiles(array($file, DOL_DOCUMENT_ROOT."/includes/modules/propale/morefile.pdf"));
//$pdfConcat->concat();
//$pdf->AliasNbPages();
//$pdfConcat->Output($file,'F');
$outputlangs->charset_output=$sav_charset_output;
return 1; // Pas d'erreur
}

View File

@ -102,7 +102,7 @@ class pdf_propale_jaune extends ModelePDFPropales
/**
* Function to build pdf onto disk
*
*
* @param int $object Id of object to generate
* @param object $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file
@ -383,16 +383,18 @@ class pdf_propale_jaune extends ModelePDFPropales
$pdf->Close();
$pdf->Output($file,'F');
// Actions on extra fields (by external module or standard code)
include_once(DOL_DOCUMENT_ROOT.'/core/class/hookmanager.class.php');
$hookmanager=new HookManager($this->db);
$hookmanager->callHooks(array('pdfgeneration'));
$parameters=array('file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
global $action;
$reshook=$hookmanager->executeHooks('afterPDFCreation',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));
// Add external file
//$pdfConcat = new concat_pdf();
//$pdfConcat->setFiles(array($file, DOL_DOCUMENT_ROOT."/includes/modules/propale/morefile.pdf"));
//$pdfConcat->concat();
//$pdf->AliasNbPages();
//$pdfConcat->Output($file,'F');
$outputlangs->charset_output=$sav_charset_output;
return 1; // Pas d'erreur
}