2
0
forked from Wavyzz/dolibarr

Uniformize code:

New: Call to hook after generation is also done into odt.
Fix: Missing hook before save.
This commit is contained in:
Laurent Destailleur
2014-08-21 15:02:18 +02:00
parent bc0c5fb55e
commit c799f0f10f
7 changed files with 36 additions and 2 deletions

View File

@@ -1019,6 +1019,8 @@ class doc_generic_project_odt extends ModelePDFProjects
}
}
$reshook=$hookmanager->executeHooks('afterODTCreation',$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

@@ -816,9 +816,31 @@ class doc_generic_task_odt extends ModelePDFTask
}
// Call the beforeODTSave hook
$parameters=array('odfHandler'=>&$odfHandler,'file'=>$file,'object'=>$object,'outputlangs'=>$outputlangs);
$reshook=$hookmanager->executeHooks('beforeODTSave',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
// Write new file
$odfHandler->saveToDisk($file);
if (!empty($conf->global->MAIN_ODT_AS_PDF)) {
try {
$odfHandler->exportAsAttachedPDF($file);
}catch (Exception $e){
$this->error=$e->getMessage();
return -1;
}
}
else {
try {
$odfHandler->saveToDisk($file);
}catch (Exception $e){
$this->error=$e->getMessage();
return -1;
}
}
$reshook=$hookmanager->executeHooks('afterODTCreation',$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));