noalyss-commit
[Top][All Lists]
Advanced

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

[Noalyss-commit] [noalyss] 02/03: ajax : 0001438: Remplacement de HtmlIn


From: Dany De Bontridder
Subject: [Noalyss-commit] [noalyss] 02/03: ajax : 0001438: Remplacement de HtmlInput par HttpInput
Date: Sun, 11 Jun 2017 07:37:20 -0400 (EDT)

sparkyx pushed a commit to branch master
in repository noalyss.

commit 83f6046e8806f05894d8e3f9f454467ddf177cc2
Author: Dany De Bontridder <address@hidden>
Date:   Tue Jun 6 22:06:11 2017 +0200

    ajax : 0001438: Remplacement de HtmlInput par HttpInput
---
 include/ajax/ajax_ledger.php        |  2 +-
 include/ajax/ajax_save_predf_op.php | 64 +++++++++++++++++++++----------------
 include/ajax/ajax_todo_list.php     | 24 +++++++-------
 3 files changed, 51 insertions(+), 39 deletions(-)

diff --git a/include/ajax/ajax_ledger.php b/include/ajax/ajax_ledger.php
index ed8a183..641f829 100644
--- a/include/ajax/ajax_ledger.php
+++ b/include/ajax/ajax_ledger.php
@@ -504,7 +504,7 @@ case 'save':
             ///////////////////////////////////////////////////////////////////
             // Save related
             //////////////////////////////////////////////////////////////////
-            $related=HtmlInput::default_value_post("related", "0");
+            $related=$http->post("related","string");
             if ($related == "0" )                
                 throw new Exception('Parameter not send -> 
related'.__FILE__.__LINE__,10);
             $op->insert_related_action($related);
diff --git a/include/ajax/ajax_save_predf_op.php 
b/include/ajax/ajax_save_predf_op.php
index 83a7479..7e49d11 100644
--- a/include/ajax/ajax_save_predf_op.php
+++ b/include/ajax/ajax_save_predf_op.php
@@ -23,36 +23,46 @@
  * \brief save the new predefined operation 
  * included from ajax_misc
  */
+require_once NOALYSS_INCLUDE.'/lib/class_http_input.php';
+$http=new HttpInput();
+
 if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
 if ($g_user->check_module('PREDOP') == 0) exit();
-$name=HtmlInput::default_value_post("opd_name", "");
+$name=$http->post("opd_name","string", "");
 if ( trim($name) != '')
   {
-    $od_id=HtmlInput::default_value_post("od_id", -1);
-    
-    if ( $od_id == -1 ||isNumber($od_id) == 0) return;
-    
-    $cn->exec_sql('delete from op_predef where od_id=$1',
-                 array($od_id));
-    
-    $cn->exec_sql("delete from op_predef_detail where od_id=$1",array($od_id));
-    
-    $jrn_type=HtmlInput::default_value_post("jrn_type", null);
-    switch ($jrn_type) {
-        case 'ACH':
-        $operation=new Pre_op_ach($cn);
-        break;
-        case 'VEN':
-        $operation=new Pre_op_ven($cn);
-        break;
-        case 'ODS':
-        $operation=new Pre_Op_Advanced($cn);
-        break;
-    default :
-        throw new Exception(_('Type de journal invalide'));
-    }
-    $operation->get_post();
-    $operation->save();
-    $cn->commit();
+      try
+      {
+        $od_id=$http->post("od_id", "number");
+        $cn->exec_sql('delete from op_predef where od_id=$1',
+                      array($od_id));
+
+        $cn->exec_sql("delete from op_predef_detail where 
od_id=$1",array($od_id));
+
+        $jrn_type=$http->post("jrn_type");
+        switch ($jrn_type) {
+            case 'ACH':
+            $operation=new Pre_op_ach($cn);
+            break;
+            case 'VEN':
+            $operation=new Pre_op_ven($cn);
+            break;
+            case 'ODS':
+            $operation=new Pre_Op_Advanced($cn);
+            break;
+        default :
+            throw new Exception(_('Type de journal invalide'));
+        }
+        $operation->get_post();
+        $operation->save();
+        $cn->commit();
+          
+      }
+      catch (Exception $exc)
+      {
+          error_log($exc->getTraceAsString());
+          throw $exc;
+      }
+
   }
 ?>
\ No newline at end of file
diff --git a/include/ajax/ajax_todo_list.php b/include/ajax/ajax_todo_list.php
index 74b2863..3aca70d 100644
--- a/include/ajax/ajax_todo_list.php
+++ b/include/ajax/ajax_todo_list.php
@@ -39,6 +39,8 @@ require_once  NOALYSS_INCLUDE.'/class/class_todo_list.php';
 require_once  NOALYSS_INCLUDE.'/lib/class_database.php';
 require_once  NOALYSS_INCLUDE.'/class/class_user.php';
 mb_internal_encoding("UTF-8");
+require_once NOALYSS_INCLUDE.'/lib/class_http_input.php';
+$http=new HttpInput();
 
 $cn= Dossier::connect();
 global $g_user;
@@ -83,7 +85,7 @@ if (isset($_REQUEST['del']))
     $todo->delete();
     exit();
 }
-$ac=HtmlInput::default_value_get('act', 'save');
+$ac=$http->get('act', "string",'save');
 
 
////////////////////////////////////////////////////////////////////////////////
 // Save the modification of a note
@@ -93,7 +95,7 @@ if ($ac == 'save')
     
     $cn=Dossier::connect();
     $todo=new Todo_List($cn);
-     $id=HtmlInput::default_value_get("id", 0);
+     $id=$http->get("id","string", 0);
     $todo->set_parameter("id",$id);
     if ($id <> 0 ) { $todo->load(); }
     else
@@ -101,10 +103,10 @@ if ($ac == 'save')
         $todo->set_parameter("owner", $_SESSION['g_user']);
     }
     
-    $todo->set_parameter("date", HtmlInput::default_value_get("p_date_todo", 
""));
-    $todo->set_parameter("title", HtmlInput::default_value_get("p_title", ""));
-    $todo->set_parameter("desc", HtmlInput::default_value_get("p_desc", ""));
-    $todo->set_is_public(HtmlInput::default_value_get("p_public", "N"));
+    $todo->set_parameter("date",$http->get("p_date_todo","string", ""));
+    $todo->set_parameter("title", $http->get("p_title","string", ""));
+    $todo->set_parameter("desc", $http->get("p_desc","string", ""));
+    $todo->set_is_public($http->get("p_public", "string","N"));
     
     ob_start();
     if ( $todo->get_parameter('owner') == $_SESSION['g_user'] ) $todo->save();
@@ -148,7 +150,7 @@ if ($ac == 'save')
 
////////////////////////////////////////////////////////////////////////////////
 if ($ac=='shared_note')
 {
-    $id=HtmlInput::default_value_get("todo_id", -1);
+    $id=$http->get("todo_id", "string",-1);
     // If note_id is not correct then give an error
     if ($id==-1||isNumber($id)==0)
     {
@@ -221,8 +223,8 @@ if ($ac=='shared_note')
 
////////////////////////////////////////////////////////////////////////////////
 if ( $ac=="set_share") 
 {
-    $id=HtmlInput::default_value_get("todo_id", 0);
-    $p_login=HtmlInput::default_value_get("login","");
+    $id=$http->get("todo_id", "string",0);
+    $p_login=$http->get("login","string","");
     // If note_id is not correct then give an error
     if ($id==0||isNumber($id)==0  || trim ($p_login)=="")
     {
@@ -279,8 +281,8 @@ if ( $ac=="set_share")
 
////////////////////////////////////////////////////////////////////////////////
 if ( $ac=="remove_share") 
 {
-    $id=HtmlInput::default_value_get("todo_id", 0);
-    $p_login=HtmlInput::default_value_get("login","");
+    $id=$http->get("todo_id","string", 0);
+    $p_login=$http->get("login","string","");
     // If note_id is not correct then give an error
     if ($id==0||isNumber($id)==0  || trim ($p_login)=="")
     {



reply via email to

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