From eb8d23d680624f45471009dfc3a082f2e27ae216 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 9 Mar 2009 10:10:02 +0000 Subject: [PATCH] Qual: Add integrity on member type Fix: Incomplete module leopard --- htdocs/adherents/adherent.class.php | 9 ++++---- htdocs/admin/societe.php | 10 ++++----- .../societe/mod_codeclient_leopard.php | 21 +++++++++++++------ .../modules/societe/modules_societe.class.php | 10 ++++----- mysql/migration/2.5.0-2.6.0.sql | 4 ++++ mysql/tables/llx_adherent.key.sql | 3 +++ mysql/tables/llx_adherent.sql | 2 +- 7 files changed, 38 insertions(+), 21 deletions(-) diff --git a/htdocs/adherents/adherent.class.php b/htdocs/adherents/adherent.class.php index 2ce0df03496..0a4d04eb851 100644 --- a/htdocs/adherents/adherent.class.php +++ b/htdocs/adherents/adherent.class.php @@ -259,7 +259,7 @@ class Adherent extends CommonObject { global $conf,$langs; - // Verification parametres + // Check parameters if ($conf->global->ADHERENT_MAIL_REQUIRED && ! ValidEMail($this->email)) { $this->error = $langs->trans("ErrorBadEMail",$this->email); @@ -269,13 +269,14 @@ class Adherent extends CommonObject $this->db->begin(); - // Insertion membre + // Insert member $sql = "INSERT INTO ".MAIN_DB_PREFIX."adherent"; - $sql.= " (datec,login,fk_user_author,fk_user_mod,fk_user_valid,morphy)"; + $sql.= " (datec,login,fk_user_author,fk_user_mod,fk_user_valid,morphy,fk_adherent_type)"; $sql.= " VALUES ("; $sql.= " '".$this->db->idate($this->datec)."',"; $sql.= " '".addslashes($this->login)."',"; - $sql.= " '".$user->id."',null,null,'".$this->morphy."'"; + $sql.= " '".$user->id."',null,null,'".$this->morphy."',"; + $sql.= " '".$this->typeid."'"; $sql.= ")"; dol_syslog("Adherent::create sql=".$sql); diff --git a/htdocs/admin/societe.php b/htdocs/admin/societe.php index a47d229d1fe..341fc9401ae 100644 --- a/htdocs/admin/societe.php +++ b/htdocs/admin/societe.php @@ -1,7 +1,7 @@ * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2008 Laurent Destailleur + * Copyright (C) 2005-2009 Laurent Destailleur * Copyright (C) 2005-2007 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -20,10 +20,10 @@ */ /** - \file htdocs/admin/societe.php - \ingroup company - \brief Page d'administration/configuration du module Societe - \version $Id$ + * \file htdocs/admin/societe.php + * \ingroup company + * \brief Third party module setup page + * \version $Id$ */ require("./pre.inc.php"); diff --git a/htdocs/includes/modules/societe/mod_codeclient_leopard.php b/htdocs/includes/modules/societe/mod_codeclient_leopard.php index 3ea9452e94f..fbc660eb583 100644 --- a/htdocs/includes/modules/societe/mod_codeclient_leopard.php +++ b/htdocs/includes/modules/societe/mod_codeclient_leopard.php @@ -1,6 +1,6 @@ - * Copyright (C) 2006-2007 Laurent Destailleur + * Copyright (C) 2006-2009 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 @@ -38,8 +38,7 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode * Attention ce module est utilise par defaut si aucun module n'a * ete definit dans la configuration * - * Le fonctionnement de celui-ci doit dont rester le plus ouvert - * possible + * Le fonctionnement de celui-ci doit dont rester le plus ouvert possible */ var $nom; // Nom du modele @@ -48,7 +47,7 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode var $code_modifiable_null; // Code modifiables si il est null var $code_null; // Code facultatif var $version; // 'development', 'experimental', 'dolibarr' - var $code_auto; // Numerotation automatique + var $code_auto; // Numerotation automatique /** \brief Constructeur classe @@ -75,10 +74,20 @@ class mod_codeclient_leopard extends ModeleThirdPartyCode } + /** \brief Return next value available + * \return string Value + */ + function getNextValue($objsoc=0,$type=-1) + { + global $langs; + return ''; + } + + /** - * \brief V�rifie la validit� du code + * \brief check validity of code * \param $db Handler acces base - * \param $code Code a v�rifier + * \param $code Code to check * \param $soc Objet societe */ function verif($db, &$code, $soc) diff --git a/htdocs/includes/modules/societe/modules_societe.class.php b/htdocs/includes/modules/societe/modules_societe.class.php index 1ef0ffe3be5..67f278c4d12 100644 --- a/htdocs/includes/modules/societe/modules_societe.class.php +++ b/htdocs/includes/modules/societe/modules_societe.class.php @@ -73,13 +73,13 @@ class ModeleThirdPartyCode return true; } - /** \brief Renvoi prochaine valeur attribu�e - * \return string Valeur + /** \brief Return next value available + * \return string Value */ function getNextValue($objsoc=0,$type=-1) { global $langs; - return $langs->trans("NotAvailable"); + return $langs->trans("Function_getNextValue_InModuleNotWorking"); } @@ -149,8 +149,8 @@ class ModeleThirdPartyCode $s.=$langs->trans("CanBeModifiedIfKo").': '.yn($this->code_modifiable_invalide,1,2).'
'; $s.=$langs->trans("AutomaticCode").': '.yn($this->code_auto,1,2).'
'; $s.='
'; - if ($type == 0 || $type == -1) $s.=$langs->trans("NextValue").': '.$this->getNextValue($soc,0).'
'; - if ($type == 1 || $type == -1) $s.=$langs->trans("NextValue").': '.$this->getNextValue($soc,1).''; + if ($type == 0 || $type == -1) $s.=$langs->trans("NextValue").' ('.$langs->trans("Customer").') : '.$this->getNextValue($soc,0).'
'; + if ($type == 1 || $type == -1) $s.=$langs->trans("NextValue").' ('.$langs->trans("Supplier").') : '.$this->getNextValue($soc,1).''; return $s; } diff --git a/mysql/migration/2.5.0-2.6.0.sql b/mysql/migration/2.5.0-2.6.0.sql index 6ddef63ca8a..17d83ed5347 100644 --- a/mysql/migration/2.5.0-2.6.0.sql +++ b/mysql/migration/2.5.0-2.6.0.sql @@ -90,6 +90,10 @@ alter table llx_facture_fourn_det add column date_end datetime DEFAUL -- V4.1 delete from llx_projet_task where fk_projet not in (select rowid from llx_projet); -- V4.1 ALTER TABLE llx_projet_task ADD CONSTRAINT fk_projet_task_fk_projet FOREIGN KEY (fk_projet) REFERENCES llx_projet (rowid); +ALTER TABLE llx_adherent modify fk_adherent_type integer NOT NULL; +ALTER TABLE llx_adherent ADD INDEX idx_adherent_fk_adherent_type (fk_adherent_type); +-- V4.1 delete from llx_adherent where fk_adherent_type not in (select rowid from llx_adherent_type); +-- V4.1 ALTER TABLE llx_adherent ADD CONSTRAINT fk_adherent_adherent_type FOREIGN KEY (fk_adherent_type) REFERENCES llx_adherent_type (rowid); -- Put at the end. Cas have duplicate values ALTER TABLE llx_categorie_association drop index idx_categorie_association_fk_categorie_fille; diff --git a/mysql/tables/llx_adherent.key.sql b/mysql/tables/llx_adherent.key.sql index 3fd841adcf8..c6f467c6dcd 100644 --- a/mysql/tables/llx_adherent.key.sql +++ b/mysql/tables/llx_adherent.key.sql @@ -20,6 +20,9 @@ ALTER TABLE llx_adherent ADD UNIQUE INDEX uk_adherent_login (login); + ALTER TABLE llx_adherent ADD INDEX idx_adherent_fk_soc (fk_soc); +ALTER TABLE llx_adherent ADD INDEX idx_adherent_fk_adherent_type (fk_adherent_type); ALTER TABLE llx_adherent ADD CONSTRAINT adherent_fk_soc FOREIGN KEY (fk_soc) REFERENCES llx_societe (rowid); +ALTER TABLE llx_adherent ADD CONSTRAINT fk_adherent_adherent_type FOREIGN KEY (fk_adherent_type) REFERENCES llx_adherent_type (rowid); diff --git a/mysql/tables/llx_adherent.sql b/mysql/tables/llx_adherent.sql index 526f68930b1..d19d676b9dd 100644 --- a/mysql/tables/llx_adherent.sql +++ b/mysql/tables/llx_adherent.sql @@ -32,7 +32,7 @@ create table llx_adherent prenom varchar(50), login varchar(50) NOT NULL, -- login pass varchar(50), -- password - fk_adherent_type smallint, + fk_adherent_type integer NOT NULL, morphy varchar(3) NOT NULL, -- personne morale / personne physique societe varchar(50), fk_soc integer NULL, -- Link to third party linked to member