From 0a8e64d5074a85e04e6662787fb276890188cfae Mon Sep 17 00:00:00 2001 From: Rodolphe Quiedeville Date: Fri, 20 Apr 2007 07:37:18 +0000 Subject: [PATCH] Empeche la creation d'une grille sans nom --- .../telephonie.tarif.grille.class.php | 41 +++++++++++-------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/htdocs/telephonie/telephonie.tarif.grille.class.php b/htdocs/telephonie/telephonie.tarif.grille.class.php index ec5788fef2f..640060000c6 100644 --- a/htdocs/telephonie/telephonie.tarif.grille.class.php +++ b/htdocs/telephonie/telephonie.tarif.grille.class.php @@ -55,27 +55,36 @@ class TelephonieTarifGrille { \brief Creation d'une nouvelle grille */ function CreateGrille($user, $name, $type, $copy=0) - { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_tarif_grille"; - $sql .= "(libelle, type_tarif)"; - $sql .= " VALUES ('".addslashes($name)."','".$type."');"; - - if ( $this->db->query($sql) ) - { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'telephonie_tarif_grille'); + { + $result = 0; - $this->Perms($user, 2, $user->id); + if (strlen(trim($name)) > 0) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_tarif_grille"; + $sql .= "(libelle, type_tarif)"; + $sql .= " VALUES ('".addslashes($name)."','".$type."');"; + + if ( $this->db->query($sql) ) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX.'telephonie_tarif_grille'); + + $this->Perms($user, 2, $user->id); + } + else + { + dolibarr_syslog($this->db->error()); + $result = -1; + } + + if ($copy > 0 && $type == 'vente') + { + $this->CopieGrille($user,$copy); + } } else { - dolibarr_syslog($this->db->error()); + $result = -2; } - - if ($copy > 0 && $type == 'vente') - { - $this->CopieGrille($user,$copy); - } - return $result; }