Fix: Removed of a column

This commit is contained in:
Laurent Destailleur 2009-01-26 23:58:37 +00:00
parent ab711a3ead
commit e817b6891b
2 changed files with 38 additions and 36 deletions

View File

@ -166,12 +166,15 @@ class AdherentOptions
} }
/** /**
\brief fonction qui cr<EFBFBD>e un label * \brief Fonction qui cree un label
\param attrname nom de l'atribut * \param attrname nom de l'atribut
\param label nom du label * \param label nom du label
*/ */
function create_label($attrname,$label='',$type='',$pos=0,$size=0) function create_label($attrname,$label='',$type='',$pos=0,$size=0)
{ {
// Clean parameters
if (empty($pos)) $pos=0;
if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)) if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname))
{ {
@ -192,36 +195,36 @@ class AdherentOptions
} }
} }
/*! /**
\brief fonction qui supprime un attribut * \brief Fonction qui supprime un attribut
\param attrname nom de l'atribut * \param attrname nom de l'atribut
*/ */
function delete($attrname) function delete($attrname)
{ {
if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)){ if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname))
$sql = "ALTER TABLE ".MAIN_DB_PREFIX."adherent_options DROP COLUMN $attrname"; {
$result=$this->db->DDLDropField(MAIN_DB_PREFIX."adherent_options",$attrname);
if ($result < 0)
{
$this->error=$this->db->lasterror();
dolibarr_syslog("AdherentOption::delete ".$this->error, LOG_ERR);
}
if ( $this->db->query( $sql) ) $result=$this->delete_label($attrname);
{
return $this->delete_label($attrname); return $result;
} }
else else
{ {
print dolibarr_print_error($this->db);
return 0;
}
}else{
return 0; return 0;
} }
} }
/*! /**
\brief fonction qui supprime un label * \brief Fonction qui supprime un label
\param attrname nom du label * \param attrname nom du label
*/ */
function delete_label($attrname) function delete_label($attrname)
{ {
if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)){ if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)){
@ -242,13 +245,12 @@ class AdherentOptions
} }
/*! /**
\brief fonction qui modifie un attribut optionnel \brief fonction qui modifie un attribut optionnel
\param attrname nom de l'atribut \param attrname nom de l'atribut
\param type type de l'attribut \param type type de l'attribut
\param length longuer de l'attribut \param length longuer de l'attribut
*/ */
function update($attrname,$type='varchar',$length=255) function update($attrname,$type='varchar',$length=255)
{ {
if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)){ if (isset($attrname) && $attrname != '' && preg_match("/^\w[a-zA-Z0-9-_]*$/",$attrname)){
@ -342,10 +344,10 @@ class AdherentOptions
{ {
while ($tab = $this->db->fetch_object($resql)) while ($tab = $this->db->fetch_object($resql))
{ {
// we can add this attribute to adherent object // we can add this attribute to adherent object
$array_name_label[$tab->name]=$tab->label; $array_name_label[$tab->name]=$tab->label;
$this->attribute_name[$tab->name]=$tab->type; $this->attribute_name[$tab->name]=$tab->type;
$this->attribute_label[$tab->name]=$tab->label; $this->attribute_label[$tab->name]=$tab->label;
} }
return $array_name_label; return $array_name_label;
}else{ }else{

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2001-2002 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org> * Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by