From 8839ae38d31c448a8c9bd51b0fb83df1ab5c3396 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 17 Feb 2014 15:21:19 +0100 Subject: [PATCH] Fix: [ bug #1241 ] error in request in select_paper file /core/class/html.formadmin.class.php --- htdocs/core/class/html.formadmin.class.php | 20 ++- test/phpunit/FormAdminTest.php | 139 +++++++++++++++++++++ 2 files changed, 153 insertions(+), 6 deletions(-) create mode 100644 test/phpunit/FormAdminTest.php diff --git a/htdocs/core/class/html.formadmin.class.php b/htdocs/core/class/html.formadmin.class.php index ccd3e038f74..6d570b70880 100644 --- a/htdocs/core/class/html.formadmin.class.php +++ b/htdocs/core/class/html.formadmin.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2005-2011 Regis Houssin * Copyright (C) 2007 Patrick Raguin * @@ -146,7 +146,7 @@ class FormAdmin if (preg_match('/eldy_(backoffice|frontoffice)\.php$/i',$file)) continue; // We exclude all menu manager files if (preg_match('/auguria_(backoffice|frontoffice)\.php$/i',$file)) continue; // We exclude all menu manager files if (preg_match('/smartphone_(backoffice|frontoffice)\.php$/i',$file)) continue; // We exclude all menu manager files - + $filelib=preg_replace('/\.php$/i','',$file); $prefix=''; // 0=Recommanded, 1=Experimental, 2=Developpement, 3=Other @@ -324,7 +324,7 @@ class FormAdmin * * @param string $selected Paper format pre-selected * @param string $htmlname Name of HTML select field - * @param string $filter Key to filter + * @param string $filter Value to filter on code * @param int $showempty Add empty value * @return string Return HTML output */ @@ -332,8 +332,12 @@ class FormAdmin { global $langs; - $sql="SELECT code, label, width, height, unit FROM ".MAIN_DB_PREFIX."c_paper_format where active=1"; - if ($filter) $sql.=" WHERE code LIKE '%".$filter."%'"; + $langs->load("dict"); + + $sql = "SELECT code, label, width, height, unit"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_paper_format"; + $sql.= " WHERE active=1"; + if ($filter) $sql.=" AND code LIKE '%".$this->db->escape($filter)."%'"; $resql=$this->db->query($sql); if ($resql) @@ -350,7 +354,11 @@ class FormAdmin $i++; } } - else dol_print_error($this->db); + else + { + dol_print_error($this->db); + return ''; + } $out=''; $out.= ''); + print __METHOD__." result=".$result."\n"; + return $result; + } + +} +?> \ No newline at end of file