From c7bfb82999a8f21d8e0384285ae2f9352619adc8 Mon Sep 17 00:00:00 2001 From: simnandez Date: Tue, 27 Mar 2012 08:56:37 +0100 Subject: [PATCH] Fix: Uniformize code --- htdocs/compta/deplacement/fiche.php | 61 +++++++++++++++-------------- htdocs/compta/deplacement/list.php | 3 +- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/htdocs/compta/deplacement/fiche.php b/htdocs/compta/deplacement/fiche.php index 95ed1c35a4e..cf97fd8ee83 100644 --- a/htdocs/compta/deplacement/fiche.php +++ b/htdocs/compta/deplacement/fiche.php @@ -2,6 +2,7 @@ /* Copyright (C) 2003 Rodolphe Quiedeville * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2012 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -40,8 +41,8 @@ $id = GETPOST('id','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'deplacement', $id,''); -$action = GETPOST('action'); -$confirm = GETPOST('confirm'); +$action = GETPOST('action','alpha'); +$confirm = GETPOST('confirm','alpha'); $mesg = ''; @@ -115,17 +116,17 @@ else if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->depl else if ($action == 'add' && $user->rights->deplacement->creer) { - if (! $_POST["cancel"]) + if (! GETPOST('cancel','alpha')) { $error=0; - $object->date = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - $object->km = $_POST["km"]; - $object->type = $_POST["type"]; - $object->socid = $_POST["socid"]; - $object->fk_user = $_POST["fk_user"]; - $object->note_private = $_POST["note_private"]; - $object->note_public = $_POST["note_public"]; + $object->date = dol_mktime(12, 0, 0, GETPOST('remonth','int'), GETPOST('reday','int'), GETPOST('reyear','int')); + $object->km = GETPOST('km','int'); + $object->type = GETPOST('type','alpha'); + $object->socid = GETPOST('socid','int'); + $object->fk_user = GETPOST('fk_user','int'); + $object->note_private = GETPOST('note_private','alpha'); + $object->note_public = GETPOST('note_public','alpha'); $object->statut = 0; if (! $object->date) @@ -174,17 +175,17 @@ else if ($action == 'add' && $user->rights->deplacement->creer) // Update record else if ($action == 'update' && $user->rights->deplacement->creer) { - if (empty($_POST["cancel"])) + if (! GETPOST('cancel','alpha')) { $result = $object->fetch($id); - $object->date = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); - $object->km = $_POST["km"]; - $object->type = $_POST["type"]; - $object->fk_user = $_POST["fk_user"]; - $object->socid = $_POST["socid"]; - $object->note_private = $_POST["note_private"]; - $object->note_public = $_POST["note_public"]; + $object->date = dol_mktime(12, 0, 0, GETPOST('remonth','int'), GETPOST('reday','int'), GETPOST('reyear','int')); + $object->km = GETPOST('km','int'); + $object->type = GETPOST('type','alpha'); + $object->socid = GETPOST('socid','int'); + $object->fk_user = GETPOST('fk_user','int'); + $object->note_private = GETPOST('note_private','alpha'); + $object->note_public = GETPOST('note_public','alpha'); $result = $object->update($user); @@ -209,14 +210,14 @@ else if ($action == 'update' && $user->rights->deplacement->creer) else if ($action == 'classin' && $user->rights->deplacement->creer) { $object->fetch($id); - $result=$object->setProject($_POST['projectid']); + $result=$object->setProject(GETPOST('projectid','int')); if ($result < 0) dol_print_error($db, $object->error); } // Set fields else if ($action == 'setdated' && $user->rights->deplacement->creer) { - $dated=dol_mktime($_POST['datedhour'], $_POST['datedmin'], $_POST['datedsec'], $_POST['datedmonth'], $_POST['datedday'], $_POST['datedyear']); + $dated=dol_mktime(GETPOST('datedhour','int'), GETPOST('datedmin','int'), GETPOST('datedsec','int'), GETPOST('datedmonth','int'), GETPOST('datedday','int'), GETPOST('datedyear','int')); $object->fetch($id); $result=$object->setValueFrom('dated',$dated,'','','date'); if ($result < 0) dol_print_error($db, $object->error); @@ -224,19 +225,19 @@ else if ($action == 'setdated' && $user->rights->deplacement->creer) else if ($action == 'setkm' && $user->rights->deplacement->creer) { $object->fetch($id); - $result=$object->setValueFrom('km',GETPOST('km')); + $result=$object->setValueFrom('km',GETPOST('km','int')); if ($result < 0) dol_print_error($db, $object->error); } else if ($action == 'setnote_public' && $user->rights->deplacement->creer) { $object->fetch($id); - $result=$object->setValueFrom('note_public',GETPOST('note_public')); + $result=$object->setValueFrom('note_public',GETPOST('note_public','alpha')); if ($result < 0) dol_print_error($db, $object->error); } else if ($action == 'setnote' && $user->rights->deplacement->creer) { $object->fetch($id); - $result=$object->setValueFrom('note',GETPOST('note')); + $result=$object->setValueFrom('note',GETPOST('note','alpha')); if ($result < 0) dol_print_error($db, $object->error); } @@ -258,7 +259,7 @@ if ($action == 'create') dol_htmloutput_errors($mesg); - $datec = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + $datec = dol_mktime(12, 0, 0, GETPOST('remonth','int'), GETPOST('reday','int'), GETPOST('reyear','int')); print '
' . "\n"; print ''; @@ -268,12 +269,12 @@ if ($action == 'create') print ""; print ''.$langs->trans("Type").''; - print $form->select_type_fees(GETPOST("type"),'type',1); + print $form->select_type_fees(GETPOST('type','int'),'type',1); print ''; print ""; print ''.$langs->trans("Person").''; - print $form->select_users(GETPOST("fk_user"),'fk_user',1); + print $form->select_users(GETPOST('fk_user','int'),'fk_user',1); print ''; print ""; @@ -295,7 +296,7 @@ if ($action == 'create') print ''.$langs->trans('NotePublic').''; print ''; require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); - $doleditor=new DolEditor('note_public',GETPOST('note_public'),600,200,'dolibarr_notes','In',false,true,true,ROWS_8,100); + $doleditor=new DolEditor('note_public',GETPOST('note_public','alpha'),600,200,'dolibarr_notes','In',false,true,true,ROWS_8,100); print $doleditor->Create(1); print ''; @@ -306,7 +307,7 @@ if ($action == 'create') print ''.$langs->trans('NotePrivate').''; print ''; require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); - $doleditor=new DolEditor('note_private',GETPOST('note_private'),600,200,'dolibarr_notes','In',false,true,true,ROWS_8,100); + $doleditor=new DolEditor('note_private',GETPOST('note_private','alpha'),600,200,'dolibarr_notes','In',false,true,true,ROWS_8,100); print $doleditor->Create(1); print ''; } @@ -353,13 +354,13 @@ else if ($id) // Type print ""; print ''.$langs->trans("Type").''; - print $form->select_type_fees($_POST["type"]?$_POST["type"]:$object->type,'type',0); + print $form->select_type_fees(GETPOST('type','int')?GETPOST('type','int'):$object->type,'type',0); print ''; // Who print ""; print ''.$langs->trans("Person").''; - print $form->select_users($_POST["fk_user"]?$_POST["fk_user"]:$object->fk_user,'fk_user',0); + print $form->select_users(GETPOST('fk_user','int')?GETPOST('fk_user','int'):$object->fk_user,'fk_user',0); print ''; // Date diff --git a/htdocs/compta/deplacement/list.php b/htdocs/compta/deplacement/list.php index 881fb54cbc0..ae672f499c3 100755 --- a/htdocs/compta/deplacement/list.php +++ b/htdocs/compta/deplacement/list.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2012 Juanjo Menent * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -47,7 +48,7 @@ if (! $sortorder) $sortorder="DESC"; if (! $sortfield) $sortfield="d.dated"; $limit = $conf->liste_limit; -$search_ref=GETPOST('search_ref'); +$search_ref=GETPOST('search_ref','alpha'); /*