diff --git a/include/class/document.class.php b/include/class/document.class.php index ff3bdbac7..136ae7090 100644 --- a/include/class/document.class.php +++ b/include/class/document.class.php @@ -113,10 +113,14 @@ class Document try { // create a temp directory in /tmp to unpack file and to parse it $dirname=tempnam($_ENV['TMP'], 'doc_'); - + if ($dirname == false) { + throw new Exception ('DC117 cannot create tmp file',5000); + } unlink($dirname); - mkdir($dirname); + if ( mkdir($dirname) == false ) { + throw new Exception ("DC121 cannot create $dirname directory",5000); + } // Retrieve the lob and save it into $dirname $this->db->start(); $dm_info="select md_name,md_type,md_lob,md_filename,md_mimetype @@ -183,7 +187,7 @@ class Document if ($res!==TRUE) { record_log(sprintf('DOCUMENT.GENERATE.D3 zip failed %s', $filename)); - throw new Exception(_('Echec compression')); + throw new Exception(_('Echec compression'),5000); } $zip->add_recurse_folder($dirname.DIRECTORY_SEPARATOR); $zip->close(); @@ -241,7 +245,7 @@ class Document if (mkdir($temp_dir)==false) { $msg=sprintf(_("Ne peut pas créer le répertoire %s", $temp_dir)); - report_log("D221".$msg); + record_log("D221".$msg); throw new Exception($msg); } } @@ -252,7 +256,7 @@ class Document if ($h===false) { $msg=sprintf(_("Ne peut pas ouvrir [%s] [%s]"), $p_dir, $p_file); - report_log("D232".$msg); + record_log("D232".$msg); throw new Exception($msg); } if ($output_file==false) @@ -1850,23 +1854,30 @@ class Document function transform2pdf() { if (GENERATE_PDF == 'NO' ) { - \record_log(__FILE__."DOC37 : PDF not available"); - throw new \Exception("Cannot not transform to PDF"); + \record_log(__FILE__."D1857 PDF not available"); + throw new \Exception("Cannot not transform to PDF",5000); } // Extract from public.document $dirname=tempnam($_ENV['TMP'],"document"); + + if ( $dirname == false ) { + throw new Exception("D1862.cannot create tmp file",5000); + } unlink($dirname); umask(0); - mkdir($dirname); + if ( mkdir($dirname) == false ) { + throw new Exception("D1868.cannot create tmp directory",5000); + } + $destination_file=$dirname."/".$this->d_filename; $this->export_file($destination_file); ob_start(); passthru(OFFICE . escapeshellarg($destination_file), $status); $result =ob_get_contents(); - ob_clean(); + ob_end_clean(); if ($status != 0) { - \record_log(__FILE__."DOC45 : Error cannot transform into PDF"." output [$result]"); - throw new \Exception("DOC45 Cannot not transform to PDF"); + \record_log(__FILE__."D1879 Error cannot transform into PDF"." output [$result]"); + throw new \Exception("D1879 Cannot not transform to PDF"); } // remove extension $ext = strrpos($this->d_filename, "."); diff --git a/include/customer.inc.php b/include/customer.inc.php index dd2792cc2..afc61c3c6 100644 --- a/include/customer.inc.php +++ b/include/customer.inc.php @@ -18,7 +18,8 @@ */ // Copyright Author Dany De Bontridder danydb@aevalys.eu /** - * \brief include from client.inc.php and concerned only the customer card and + * \file + * \brief include from and concerned only the customer card and * the customer category */ if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis'); diff --git a/include/database/attr_def_sql.class.php b/include/database/attr_def_sql.class.php index a31a49f26..758f53763 100644 --- a/include/database/attr_def_sql.class.php +++ b/include/database/attr_def_sql.class.php @@ -26,10 +26,10 @@ * @brief abstract of the table public.attr_def */ /** - * @class Attr_def_SQL - * @brief abstract of the table public.attr_def + * @class Attr_Def_SQL + * @brief ORM of the table public.attr_def */ -class Attr_def_SQL extends Table_Data_SQL +class Attr_Def_SQL extends Table_Data_SQL { function __construct(DatabaseCore $p_cn, $p_id=-1) diff --git a/include/lib/database_core.class.php b/include/lib/database_core.class.php index 8b68149b0..d4c9b5896 100644 --- a/include/lib/database_core.class.php +++ b/include/lib/database_core.class.php @@ -874,7 +874,18 @@ class DatabaseCore { } - + /** + * @brief get the transaction status : + * The status can be + * - PGSQL_TRANSACTION_IDLE (currently idle), + * - PGSQL_TRANSACTION_ACTIVE (a command is in progress), + * - PGSQL_TRANSACTION_INTRANS (idle, in a valid transaction block), + * - PGSQL_TRANSACTION_INERROR (idle, in a failed transaction block). + * - PGSQL_TRANSACTION_UNKNOWN is reported if the connection is bad. + * - PGSQL_TRANSACTION_ACTIVE is reported only when a query has been sent to the server + * and not yet completed. + * * @return PGSQL_TRANSACTION_IDLE | PGSQL_TRANSACTION_ACTIVE | PGSQL_TRANSACTION_INTRANS | PGSQL_TRANSACTION_INERROR | PGSQL_TRANSACTION_UNKNOWN | PGSQL_TRANSACTION_ACTIVE + */ function status() { return pg_transaction_status($this->db); @@ -924,7 +935,7 @@ class DatabaseCore } /** - * Check if a prepared statement already exists or not + * @brief Check if a prepared statement already exists or not * @param string $query_name name of the prepared query * @return boolean false is not yet prepared */ @@ -936,7 +947,7 @@ class DatabaseCore } /** - * with the handle of a successull query, echo each row into CSV and + * @brief with the handle of a successull query, echo each row into CSV and * send it directly * @param type $ret handle to a query * @param type $aheader double array, each item of the array contains @@ -968,14 +979,14 @@ class DatabaseCore } } /** - * Returns the number of columns in a ret + * @brief Returns the number of columns in a ret * @param handler $p_ret handler to a query */ static function nb_column($p_ret) { return pg_num_fields($p_ret); } /** - * FInd if a SQL Select has a SQL stmt to inject or damage Data + * @brief FInd if a SQL Select has a SQL stmt to inject or damage Data * When a SELECT SQL string is build, this string could contain a SQL attempt to damage data, *so the statement DELETE TRUNCATE ... are forbidden. Throw an exception EXC_INVALID *