Skip to content

Commit

Permalink
Uniformize code:
Browse files Browse the repository at this point in the history
New: Call to hook after generation is also done into odt.
Fix: Missing hook before save.
  • Loading branch information
eldy committed Aug 21, 2014
1 parent bc0c5fb commit c799f0f
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 2 deletions.
Expand Up @@ -482,6 +482,8 @@ function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidede
}
}

$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));

Expand Down
Expand Up @@ -482,6 +482,8 @@ function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidede
}
}

$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));

Expand Down
Expand Up @@ -439,6 +439,8 @@ function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidede
}
}

$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));

Expand Down
Expand Up @@ -1019,6 +1019,8 @@ function write_file($object,$outputlangs,$srctemplatepath)
}
}

$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));

Expand Down
Expand Up @@ -816,9 +816,31 @@ function write_file($object,$outputlangs,$srctemplatepath)
}


// 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));

Expand Down
Expand Up @@ -517,6 +517,8 @@ function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidede
}
}

$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));

Expand Down
2 changes: 2 additions & 0 deletions htdocs/core/modules/societe/doc/doc_generic_odt.modules.php
Expand Up @@ -416,6 +416,8 @@ function write_file($object,$outputlangs,$srctemplatepath,$hidedetails=0,$hidede
}
}

$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));

Expand Down

0 comments on commit c799f0f

Please sign in to comment.