diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 89a24ff2f7b..aa9505b635f 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1001,10 +1001,11 @@ class Categorie * @param int $id Id * @param string $nom Name * @param string $type Type - * @param boolean $exact Ture or false + * @param boolean $exact Exact string search (true/false) + * @param boolean $case Case sensitive (true/false) * @return array Array of category id */ - function rechercher($id, $nom, $type, $exact = false) + function rechercher($id, $nom, $type, $exact = false, $case = false) { $cats = array (); @@ -1015,10 +1016,13 @@ class Categorie if ($nom) { if (! $exact) - { $nom = '%'.str_replace('*', '%', $nom).'%'; - } - $sql.= "AND label LIKE '".$nom."'"; + if (! $case) + $sql.= "AND label LIKE '".$this->db->escape($nom)."'"; + else + // FIXME Mysql "LIKE" is case insensitive by default and use LIKE BINARY for case sensitive + // Pgsql "LIKE" is case sensitive by default, and use ILIKE for case insensitive + $sql.= "AND label LIKE BINARY '".$this->db->escape($nom)."'"; } if ($id) { diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index 0f0915d7dd2..df9d0fc0eab 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -257,7 +257,7 @@ foreach($fulltree as $key => $val) $categstatic->id=$val['id']; $categstatic->ref=$val['label']; $categstatic->type=$type; - print '  '.$categstatic->getNomUrl(0,'',28); + print '  '.$categstatic->getNomUrl(0,'',60); //print '  '.dol_trunc($val['label'],28); //if ($section == $val['id']) print '';