Add error management to avoid blank page when there is no permission to

read file.
This commit is contained in:
Laurent Destailleur 2013-10-23 19:19:54 +02:00
parent fe4df6770a
commit 16bcd6b5e5
7 changed files with 132 additions and 84 deletions

View File

@ -392,15 +392,22 @@ class doc_generic_order_odt extends ModelePDFCommandes
// Open and load template
require_once ODTPHP_PATH.'odf.php';
$odfHandler = new odf(
$srctemplatepath,
array(
'PATH_TO_TMP' => $conf->commande->dir_temp,
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'DELIMITER_LEFT' => '{',
'DELIMITER_RIGHT' => '}'
)
);
try {
$odfHandler = new odf(
$srctemplatepath,
array(
'PATH_TO_TMP' => $conf->commande->dir_temp,
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'DELIMITER_LEFT' => '{',
'DELIMITER_RIGHT' => '}'
)
);
}
catch(Exception $e)
{
$this->error=$e->getMessage();
return -1;
}
// After construction $odfHandler->contentXml contains content and
// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
// [!-- BEGIN lines --]*[!-- END lines --]
@ -534,7 +541,7 @@ class doc_generic_order_odt extends ModelePDFCommandes
dol_syslog($this->error, LOG_WARNING);
return -1;
}
// Replace labels translated
$tmparray=$outputlangs->get_translations_for_substitutions();
foreach($tmparray as $key=>$value)

View File

@ -127,7 +127,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition
'object_total_localtax2'=>price2num($object->total_localtax2),
'object_total_ttc'=>price2num($object->total_ttc),
'object_total_discount_ht' => price2num($object->getTotalDiscount()),
'object_vatrate'=>vatrate($object->tva),
'object_note_private'=>$object->note,
'object_note'=>$object->note_public,
@ -392,15 +392,22 @@ class doc_generic_shipment_odt extends ModelePdfExpedition
// Open and load template
require_once ODTPHP_PATH.'odf.php';
$odfHandler = new odf(
$srctemplatepath,
array(
'PATH_TO_TMP' => $conf->expedition->dir_temp,
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'DELIMITER_LEFT' => '{',
'DELIMITER_RIGHT' => '}'
)
);
try {
$odfHandler = new odf(
$srctemplatepath,
array(
'PATH_TO_TMP' => $conf->expedition->dir_temp,
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'DELIMITER_LEFT' => '{',
'DELIMITER_RIGHT' => '}'
)
);
}
catch(Exception $e)
{
$this->error=$e->getMessage();
return -1;
}
// After construction $odfHandler->contentXml contains content and
// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
// [!-- BEGIN lines --]*[!-- END lines --]
@ -534,7 +541,7 @@ class doc_generic_shipment_odt extends ModelePdfExpedition
dol_syslog($this->error, LOG_WARNING);
return -1;
}
// Replace labels translated
$tmparray=$outputlangs->get_translations_for_substitutions();
foreach($tmparray as $key=>$value)

View File

@ -423,15 +423,22 @@ class doc_generic_invoice_odt extends ModelePDFFactures
// Open and load template
require_once ODTPHP_PATH.'odf.php';
$odfHandler = new odf(
$srctemplatepath,
array(
'PATH_TO_TMP' => $conf->facture->dir_temp,
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'DELIMITER_LEFT' => '{',
'DELIMITER_RIGHT' => '}'
)
);
try {
$odfHandler = new odf(
$srctemplatepath,
array(
'PATH_TO_TMP' => $conf->facture->dir_temp,
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'DELIMITER_LEFT' => '{',
'DELIMITER_RIGHT' => '}'
)
);
}
catch(Exception $e)
{
$this->error=$e->getMessage();
return -1;
}
// After construction $odfHandler->contentXml contains content and
// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
// [!-- BEGIN lines --]*[!-- END lines --]
@ -514,7 +521,7 @@ class doc_generic_invoice_odt extends ModelePDFFactures
dol_syslog($this->error, LOG_WARNING);
return -1;
}
// Replace labels translated
$tmparray=$outputlangs->get_translations_for_substitutions();
foreach($tmparray as $key=>$value)

View File

@ -392,7 +392,7 @@ class doc_generic_project_odt extends ModelePDFProjects
}
$hookmanager->initHooks(array('odtgeneration'));
global $action;
if (! is_object($outputlangs)) $outputlangs=$langs;
$sav_charset_output=$outputlangs->charset_output;
$outputlangs->charset_output='UTF-8';
@ -469,15 +469,22 @@ class doc_generic_project_odt extends ModelePDFProjects
// Open and load template
require_once ODTPHP_PATH.'odf.php';
$odfHandler = new odf(
$srctemplatepath,
array(
'PATH_TO_TMP' => $conf->projet->dir_temp,
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'DELIMITER_LEFT' => '{',
'DELIMITER_RIGHT' => '}'
)
);
try {
$odfHandler = new odf(
$srctemplatepath,
array(
'PATH_TO_TMP' => $conf->projet->dir_temp,
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'DELIMITER_LEFT' => '{',
'DELIMITER_RIGHT' => '}'
)
);
}
catch(Exception $e)
{
$this->error=$e->getMessage();
return -1;
}
// After construction $odfHandler->contentXml contains content and
// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
// [!-- BEGIN lines --]*[!-- END lines --]
@ -586,7 +593,7 @@ class doc_generic_project_odt extends ModelePDFProjects
if (!empty($object->fk_soc)) $socid = $object->fk_soc;
$tasksarray=$taskstatic->getTasksArray(0, 0, $object->id, $socid, 0);
foreach ($tasksarray as $task)
{
@ -910,14 +917,14 @@ class doc_generic_project_odt extends ModelePDFProjects
{
$ref_array=array();
$ref_array['type']=$langs->trans($classname);
$element = new $classname($this->db);
$element->fetch($elementarray[$i]);
$element->fetch_thirdparty();
//Ref object
$ref_array['ref']=$element->ref;
//Date object
$dateref=$element->date;
if (empty($dateref)) $dateref=$element->datep;
@ -976,7 +983,7 @@ class doc_generic_project_odt extends ModelePDFProjects
dol_syslog($this->error, LOG_WARNING);
return -1;
}
// Replace labels translated
$tmparray=$outputlangs->get_translations_for_substitutions();
foreach($tmparray as $key=>$value)
@ -1010,7 +1017,7 @@ class doc_generic_project_odt extends ModelePDFProjects
$this->error=$e->getMessage();
return -1;
}
}
}
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));

View File

@ -425,7 +425,7 @@ class doc_generic_task_odt extends ModelePDFTask
return -1;
}
}
if (file_exists($dir))
{
@ -455,15 +455,22 @@ class doc_generic_task_odt extends ModelePDFTask
// Open and load template
require_once ODTPHP_PATH.'odf.php';
$odfHandler = new odf(
$srctemplatepath,
array(
'PATH_TO_TMP' => $conf->projet->dir_temp,
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'DELIMITER_LEFT' => '{',
'DELIMITER_RIGHT' => '}'
)
);
try {
$odfHandler = new odf(
$srctemplatepath,
array(
'PATH_TO_TMP' => $conf->projet->dir_temp,
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'DELIMITER_LEFT' => '{',
'DELIMITER_RIGHT' => '}'
)
);
}
catch(Exception $e)
{
$this->error=$e->getMessage();
return -1;
}
// After construction $odfHandler->contentXml contains content and
// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
// [!-- BEGIN lines --]*[!-- END lines --]
@ -677,7 +684,7 @@ class doc_generic_task_odt extends ModelePDFTask
$i++;
}
$this->db->free($resql);
$odfHandler->mergeSegment($listlinestasktime);
}
@ -711,7 +718,7 @@ class doc_generic_task_odt extends ModelePDFTask
//$listlines->merge();
$odfHandler->mergeSegment($listtasksfiles);
}
catch(OdfException $e)
{
@ -793,7 +800,7 @@ class doc_generic_task_odt extends ModelePDFTask
$contact['fullname']=$objectdetail->getFullName($outputlangs,1);
$tmparray=$this->get_substitutionarray_project_contacts($contact,$outputlangs);
foreach($tmparray as $key => $val)
{
try

View File

@ -278,9 +278,9 @@ class doc_generic_proposal_odt extends ModelePDFPropales
$newfiletmp=preg_replace('/\.od(t|s)/i','',$newfile);
$newfiletmp=preg_replace('/template_/i','',$newfiletmp);
$newfiletmp=preg_replace('/modele_/i','',$newfiletmp);
$newfiletmp=$objectref.'_'.$newfiletmp;
// Get extension (ods or odt)
$newfileformat=substr($newfile, strrpos($newfile, '.')+1);
if ( ! empty($conf->global->MAIN_DOC_USE_TIMING))
@ -344,15 +344,22 @@ class doc_generic_proposal_odt extends ModelePDFPropales
// Open and load template
require_once ODTPHP_PATH.'odf.php';
$odfHandler = new odf(
$srctemplatepath,
array(
'PATH_TO_TMP' => $conf->propal->dir_temp,
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'DELIMITER_LEFT' => '{',
'DELIMITER_RIGHT' => '}'
)
);
try {
$odfHandler = new odf(
$srctemplatepath,
array(
'PATH_TO_TMP' => $conf->propal->dir_temp,
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'DELIMITER_LEFT' => '{',
'DELIMITER_RIGHT' => '}'
)
);
}
catch(Exception $e)
{
$this->error=$e->getMessage();
return -1;
}
// After construction $odfHandler->contentXml contains content and
// [!-- BEGIN row.lines --]*[!-- END row.lines --] has been replaced by
// [!-- BEGIN lines --]*[!-- END lines --]
@ -487,7 +494,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales
dol_syslog($this->error, LOG_WARNING);
return -1;
}
// Replace labels translated
$tmparray=$outputlangs->get_translations_for_substitutions();
foreach($tmparray as $key=>$value)
@ -520,7 +527,7 @@ class doc_generic_proposal_odt extends ModelePDFPropales
$this->error=$e->getMessage();
return -1;
}
}
}
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));

View File

@ -236,16 +236,22 @@ class doc_generic_odt extends ModeleThirdPartyDoc
// Open and load template
require_once ODTPHP_PATH.'odf.php';
$odfHandler = new odf(
$srctemplatepath,
array(
'PATH_TO_TMP' => $conf->societe->multidir_temp[$object->entity],
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'DELIMITER_LEFT' => '{',
'DELIMITER_RIGHT' => '}'
)
);
try {
$odfHandler = new odf(
$srctemplatepath,
array(
'PATH_TO_TMP' => $conf->societe->multidir_temp[$object->entity],
'ZIP_PROXY' => 'PclZipProxy', // PhpZipProxy or PclZipProxy. Got "bad compression method" error when using PhpZipProxy.
'DELIMITER_LEFT' => '{',
'DELIMITER_RIGHT' => '}'
)
);
}
catch(Exception $e)
{
$this->error=$e->getMessage();
return -1;
}
//print $odfHandler->__toString()."\n";
// Make substitutions into odt of user info
@ -318,7 +324,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc
// setVars failed, probably because key not found
}
}
// Replace labels translated
$tmparray=$outputlangs->get_translations_for_substitutions();
foreach($tmparray as $key=>$value)
@ -351,7 +357,7 @@ class doc_generic_odt extends ModeleThirdPartyDoc
$this->error=$e->getMessage();
return -1;
}
}
}
if (! empty($conf->global->MAIN_UMASK))
@chmod($file, octdec($conf->global->MAIN_UMASK));