From 0675975f36e3b35c52f267d4dd0f71ede65a24f7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 31 Oct 2006 21:35:48 +0000 Subject: [PATCH] Fix: Creation nouveau type d'adherent --- htdocs/adherents/adherent_type.class.php | 43 ++++++++++++------------ htdocs/adherents/type.php | 17 +++++++--- 2 files changed, 34 insertions(+), 26 deletions(-) diff --git a/htdocs/adherents/adherent_type.class.php b/htdocs/adherents/adherent_type.class.php index 7a2f0ba4288..7ad42337910 100644 --- a/htdocs/adherents/adherent_type.class.php +++ b/htdocs/adherents/adherent_type.class.php @@ -73,31 +73,30 @@ class AdherentType } -/** - \brief Fonction qui permet de créer le status de l'adhérent - \param userid userid de l'adhérent - \return > 0 si ok, < 0 si ko -*/ - + /** + \brief Fonction qui permet de créer le status de l'adhérent + \param userid userid de l'adhérent + \return > 0 si ok, < 0 si ko + */ function create($userid) - { - $this->statut=trim($this->statut); - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type (statut)"; - $sql .= " VALUES ($this->statut)"; - - $result = $this->db->query($sql); - - if ($result) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent_type"); - return $this->update(); + $this->statut=trim($this->statut); + + $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent_type (statut)"; + $sql.= " VALUES ($this->statut)"; + + dolibarr_syslog("Adherent_type::create sql=".$sql); + $result = $this->db->query($sql); + if ($result) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."adherent_type"); + return $this->update(); + } + else + { + return -1; + } } - else - { - return -1; - } - } /** diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index 52f668b7c43..a2479b9bc5d 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2004-2006 Laurent Destailleur * * 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 @@ -33,13 +33,16 @@ require(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php"); require(DOL_DOCUMENT_ROOT."/adherents/adherent_type.class.php"); $langs->load("members"); +$user->getrights('adherent'); $rowid=isset($_GET["rowid"])?$_GET["rowid"]:$_POST["rowid"]; -if ($_POST["action"] == 'add' && $user->rights->adherent->configurer) +if ($_POST["action"] == 'add') { + if (! $user->rights->adherent->configurer) accessforbidden(); + if ($_POST["button"] != $langs->trans("Cancel")) { $adht = new AdherentType($db); @@ -56,14 +59,20 @@ if ($_POST["action"] == 'add' && $user->rights->adherent->configurer) if ($id > 0) { Header("Location: type.php"); - exit + exit; } } + else + { + $mesg=$this->langs("ErrorFieldRequired",$langs->trans("Label")); + } } } -if ($_POST["action"] == 'update' && $user->rights->adherent->creer) +if ($_POST["action"] == 'update') { + if (! $user->rights->adherent->creer) accessforbidden(); + if ($_POST["button"] != $langs->trans("Cancel")) { $adht = new AdherentType($db);