[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]);
+ }
+ }
+}
?>
- [Noalyss-commit] [noalyss] branch master updated (2a9161f -> edccfbe), Dany De Bontridder, 2014/11/09
- [Noalyss-commit] [noalyss] 01/13: Task #145 - Amélioration stock Solde banque : agrandissement table, Dany De Bontridder, 2014/11/09
- [Noalyss-commit] [noalyss] 02/13: Task #1045 - Amélioration apparence : MENU : Menu verticaux différent, Dany De Bontridder, 2014/11/09
- [Noalyss-commit] [noalyss] 03/13: Task #1045 - Amélioration apparence : Ne montre pas échéance pour journaux financiers, Dany De Bontridder, 2014/11/09
- [Noalyss-commit] [noalyss] 04/13: Task #1045 - Amélioration apparence : Solde banque : agrandissement table, Dany De Bontridder, 2014/11/09
- [Noalyss-commit] [noalyss] 05/13: Ajout test paramètres passés,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 07/13: Task #1045 - Amélioration apparence : Icone enlever tag, Dany De Bontridder, 2014/11/09
- [Noalyss-commit] [noalyss] 06/13: devient une classe abstraite, Dany De Bontridder, 2014/11/09
- [Noalyss-commit] [noalyss] 08/13: Enleve global $cn, Dany De Bontridder, 2014/11/09
- [Noalyss-commit] [noalyss] 09/13: ajout à HTMLINPUT::anchor d'un style ou classe, Dany De Bontridder, 2014/11/09
- [Noalyss-commit] [noalyss] 12/13: Task #1045 - Amélioration apparence : Ajout symbole pour enlever tag, Dany De Bontridder, 2014/11/09
- [Noalyss-commit] [noalyss] 10/13: Ajout test paramètres passés, Dany De Bontridder, 2014/11/09
- [Noalyss-commit] [noalyss] 11/13: Task #1045 - Amélioration apparence : correction position fenêtre tag, Dany De Bontridder, 2014/11/09
- [Noalyss-commit] [noalyss] 13/13: Passage par reference de la connexion, Dany De Bontridder, 2014/11/09