noalyss-commit
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Noalyss-commit] [noalyss] 05/13: Ajout test paramètres passés


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 05/13: Ajout test paramètres passés
Date: Sun, 09 Nov 2014 17:25:11 +0000

sparkyx pushed a commit to branch master
in repository noalyss.

commit 75ba5461499eb24061608f36ffb088366c466294
Author: Dany De Bontridder <address@hidden>
Date:   Sun Nov 9 18:08:22 2014 +0100

    Ajout test paramètres passés
---
 include/class_acc_ledger_fin.php  |   18 ++++++++++++++----
 include/class_acc_ledger_sold.php |   15 ++++++++++++++-
 include/user_common.php           |   16 ++++++++++++++++
 3 files changed, 44 insertions(+), 5 deletions(-)

diff --git a/include/class_acc_ledger_fin.php b/include/class_acc_ledger_fin.php
index 66c155c..fdbc2a6 100644
--- a/include/class_acc_ledger_fin.php
+++ b/include/class_acc_ledger_fin.php
@@ -45,15 +45,25 @@ class Acc_Ledger_Fin extends Acc_Ledger
                $this->type = 'FIN';
        }
 
-       /**\brief verify that the data are correct before inserting or 
confirming
-        * \param an array (usually $_POST)
-        * \return String
-        * \throw Exception on error occurs
+       /**
+         * Verify that the data are correct before inserting or confirming
+         * @brief verify the data 
+        * @param an array (usually $_POST)
+        * @return String
+        * @throw Exception on error occurs
         */
 
        public function verify($p_array)
        {
                global $g_user;
+                if (is_array($p_array ) == false || empty($p_array))
+                    throw new Exception ("Array empty");
+               /*
+                * Check needed value
+                */
+                check_parameter($p_array,'p_jrn');
+
+                
                extract($p_array);
                /* check for a double reload */
                if (isset($mt) && $this->db->count_sql('select jr_mt from jrn 
where jr_mt=$1', array($mt)) != 0)
diff --git a/include/class_acc_ledger_sold.php 
b/include/class_acc_ledger_sold.php
index 923e4bd..bbd46d3 100644
--- a/include/class_acc_ledger_sold.php
+++ b/include/class_acc_ledger_sold.php
@@ -61,7 +61,17 @@ class Acc_Ledger_Sold extends Acc_Ledger {
 
     public function verify($p_array) {
         global $g_parameter, $g_user;
+        
+        if (is_array($p_array ) == false || empty($p_array))
+                    throw new Exception ("Array empty");
+        
         extract($p_array);
+        
+        /*
+         * Check needed value
+         */
+        check_parameter($p_array,'p_jrn,e_date,e_client');
+
         /* check for a double reload */
         if (isset($mt) && $this->db->count_sql('select jr_mt from jrn where 
jr_mt=$1', array($mt)) != 0)
             throw new Exception(_('Double Encodage'), 5);
@@ -918,7 +928,10 @@ class Acc_Ledger_Sold extends Acc_Ledger {
         return $r;
     }
 
-    /* !\brief update the payment
+    /**
+     * @brief update the payment
+     * @deprecated
+     * 
      */
 
     function show_unpaid() {
diff --git a/include/user_common.php b/include/user_common.php
index 6b0d56a..a1ed734 100644
--- a/include/user_common.php
+++ b/include/user_common.php
@@ -226,4 +226,20 @@ function toNumber($p_num)
     $p_num=str_replace(',','.',$p_num);
     return $p_num;
 }
+/**
+ * Check that all the index are in the array, used by function to check if
+ * the array contains the needed variables before an extract
+ * @param type $p_array array to check
+ * @param type $needed string containing variable separated by comma
+ * @throws Exception
+ */
+function check_parameter($p_array,$p_needed)
+{
+    $needed = split(',',$p_needed);
+    for ($e=0;$e<$needed;$e++) {
+            if ( ! isset($p_array[$needed[$e]])) {
+                throw new Exception (_('Paramètre manquant')." ".$needed[$e]);
+            }
+        }
+}
 ?>



reply via email to

[Prev in Thread] Current Thread [Next in Thread]