[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 24/26: Code cleaning Improve doc and test
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 24/26: Code cleaning Improve doc and test |
Date: |
Wed, 11 Aug 2021 11:08:17 -0400 (EDT) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit b577422914395b314b97439e87368e05223bd68c
Author: sparkyx <danydb@noalyss.eu>
AuthorDate: Wed Aug 11 13:04:44 2021 +0200
Code cleaning Improve doc and test
---
include/class/document.class.php | 33 ++++++++++++++++++++++-----------
include/customer.inc.php | 3 ++-
include/database/attr_def_sql.class.php | 6 +++---
include/lib/database_core.class.php | 21 ++++++++++++++++-----
4 files changed, 43 insertions(+), 20 deletions(-)
diff --git a/include/class/document.class.php b/include/class/document.class.php
index ff3bdba..136ae70 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 dd2792c..afc61c3 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 a31a49f..758f537 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 8b68149..d4c9b58 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
*
- [Noalyss-commit] [noalyss] 03/26: New function header_csv($filename), (continued)
- [Noalyss-commit] [noalyss] 03/26: New function header_csv($filename), Dany De Bontridder, 2021/08/11
- [Noalyss-commit] [noalyss] 05/26: Merge branch 'master' into b-orion, Dany De Bontridder, 2021/08/11
- [Noalyss-commit] [noalyss] 04/26: Code documentation, Dany De Bontridder, 2021/08/11
- [Noalyss-commit] [noalyss] 08/26: Task #0002050: Mobile : menu différent, Dany De Bontridder, 2021/08/11
- [Noalyss-commit] [noalyss] 06/26: Merge branch 'master' into b-orion, Dany De Bontridder, 2021/08/11
- [Noalyss-commit] [noalyss] 07/26: Documentation for Doxygen, Dany De Bontridder, 2021/08/11
- [Noalyss-commit] [noalyss] 12/26: Code cleaning : extra information are now a fonction, Dany De Bontridder, 2021/08/11
- [Noalyss-commit] [noalyss] 10/26: Documentation doxygen, Dany De Bontridder, 2021/08/11
- [Noalyss-commit] [noalyss] 19/26: cosmetic : fix icon in followup for the trash can, Dany De Bontridder, 2021/08/11
- [Noalyss-commit] [noalyss] 16/26: cosmetic : flashing color for h2.error, Dany De Bontridder, 2021/08/11
- [Noalyss-commit] [noalyss] 24/26: Code cleaning Improve doc and test,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 15/26: Bug in print_ledger_purchase for company w/o vat, Dany De Bontridder, 2021/08/11
- [Noalyss-commit] [noalyss] 14/26: Code cleaning : extra information are now a fonction, Dany De Bontridder, 2021/08/11
- [Noalyss-commit] [noalyss] 25/26: Improve code : Card_Property is separated from Card (Fiche) , add more phpunit tests, Dany De Bontridder, 2021/08/11
- [Noalyss-commit] [noalyss] 18/26: Task #0002046: Improve COMPTA/MENUACH/ACH, Dany De Bontridder, 2021/08/11
- [Noalyss-commit] [noalyss] 20/26: Code cleaning : remove useless class gestion_sold gestion_purchase and gestion_table, Dany De Bontridder, 2021/08/11
- [Noalyss-commit] [noalyss] 21/26: Merge branch 'master' of gitlab.noalyss.eu:noalyss/noalyss, Dany De Bontridder, 2021/08/11
- [Noalyss-commit] [noalyss] 23/26: translate, Dany De Bontridder, 2021/08/11
- [Noalyss-commit] [noalyss] 26/26: Code cleaning : remove Fic_Attr , replace by Attr_Def_SQL, Dany De Bontridder, 2021/08/11
- [Noalyss-commit] [noalyss] 17/26: Bug #0002048: PRINTJRN : export CSV et PDF cosmetic : remove currency data if the currency is EUR, Dany De Bontridder, 2021/08/11
- [Noalyss-commit] [noalyss] 13/26: Translation, Dany De Bontridder, 2021/08/11