Subversion Repositories eFlore/Archives.herbiers

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 jp_milcent 1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2005 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
8
// | This file is part of Herbier.                                                                        |
9
// |                                                                                                      |
10
// | Foobar is free software; you can redistribute it and/or modify                                       |
11
// | it under the terms of the GNU General Public License as published by                                 |
12
// | the Free Software Foundation; either version 2 of the License, or                                    |
13
// | (at your option) any later version.                                                                  |
14
// |                                                                                                      |
15
// | Foobar is distributed in the hope that it will be useful,                                            |
16
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
17
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                                        |
18
// | GNU General Public License for more details.                                                         |
19
// |                                                                                                      |
20
// | You should have received a copy of the GNU General Public License                                    |
21
// | along with Foobar; if not, write to the Free Software                                                |
22
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
23
// +------------------------------------------------------------------------------------------------------+
24
// CVS : $Id: hb_organisation.class.php,v 1.1 2005-11-23 10:32:32 jp_milcent Exp $
25
/**
26
* Classe H_organisation
27
*
28
* Classe permettant de récupérer les données concernant les organisations de la base de données.
29
*
30
*@package Herbier
31
*@subpackage Classes
32
//Auteur original :
33
*@author        Alexandre GRANIER <alexandre@tela-botanica.org>
34
//Autres auteurs :
35
*@author        Jean-Pascal MILCENT <jpm@clapas.org>
36
*@copyright     Tela-Botanica 2000-2005
37
*@version       $Revision: 1.1 $ $Date: 2005-11-23 10:32:32 $
38
// +------------------------------------------------------------------------------------------------------+
39
*/
40
 
41
// +------------------------------------------------------------------------------------------------------+
42
// |                                            ENTETE du PROGRAMME                                       |
43
// +------------------------------------------------------------------------------------------------------+
44
 
45
// +------------------------------------------------------------------------------------------------------+
46
// |                                            CORPS du PROGRAMME                                        |
47
// +------------------------------------------------------------------------------------------------------+
48
/**
49
* class H_organisation()
50
*
51
* class H_organisation contient la structure nécessaire pour
52
* représenter une table HERBIERS_ORGANISATION dont voici
53
* la structure
54
* @package herbiers
55
*/
56
class H_organisation {
57
    /** @var integer l'identifiant de l'organisation.*/
58
    var $id;
59
    /** @var string contient le nom de l'organisation.*/
60
    var $nom;
61
    /** @var string contient l'adrese de l'organisation.*/
62
    var $adresse;
63
    /** @var string contient l'adrese 01 de l'organisation.*/
64
    var $adresse_02;
65
    /** @var H_collection  un objet de type H_collection{@link H_collection}.*/
66
    var $collections;
67
    /** @var string contiendra l'intitulé du pays.*/
68
    var $pays;
69
    /** @var array contient un tableau d'objet equipe appartenant à l'organisation.*/
70
    var $equipe_liste;
71
 
72
    /**
73
    *  Constructeur de H_organisation
74
    *
75
    * @param  aucun
76
    * @return void
77
    * @access public
78
    */
79
    function H_organisation($id_organisation = null)
80
    {
81
        if (!is_null($id_organisation)) {
82
            $this->setId($id_organisation);
83
            $this->setNom($this->recupererNomOrganisation($id_organisation));
84
        }
85
        $collections = array();
86
        $equipe_liste = array();
87
        $organisation_utilisateur = array();
88
    }
89
    /** Accesseur getId() - Retourner l'id de l'organisation.
90
    *
91
    * @return integer l'identifiant de l'organisation.
92
    * @access public
93
    */
94
    function getId()
95
    {
96
        return $this->id;
97
    }
98
    /** Accesseur setId() - Attribuer un id à l'organisation.
99
    *
100
    * @param integer l'identifiant de l'organisation.
101
    * @return void l'identifiant est ajouté à l'objet.
102
    * @access public
103
    */
104
    function setId($id)
105
    {
106
        $this->id = $id;
107
    }
108
    /** Accesseur setNom() - Attribuer un nom à l'organisation.
109
    *
110
    * @param string le nom de l'organisation.
111
    * @return void le nom est ajouté à l'objet.
112
    * @access public
113
    */
114
    function setNom($nom)
115
    {
116
        $this->nom = $nom;
117
    }
118
    /** Accesseur getNom() - Retourner le nom de l'organisation.
119
    *
120
    * @return string le nom de l'organisation.
121
    * @access public
122
    */
123
    function getNom()
124
    {
125
        return $this->nom;
126
    }
127
 
128
    /**
129
    *  Méthode getFromSQL() - Initialise objet H_organisation
130
    *
131
    *  Initialise un objet H_organisation dont les propriétés
132
    *  contiennent l'information rataché à une organisation
133
    *  caractérisé par son $id (un entier positif) qui correspond
134
    *  à la clé primaire ID_ORG de la table HERBIERS_ORGANISATION
135
    *
136
    * @param int la clé primaire de la table HERBIERS_ORGANISATION
137
    * @return void
138
    * @access public
139
    */
140
    function getFromSQL($id)
141
    {
142
        $requete =  'SELECT * '.
143
                    'FROM '.HB_BDD_NOM.'.HERBIERS_ORGANISATION '.
144
                    'WHERE ID_ORG='.$id.' '.
145
                    'ORDER BY TOWN';
146
        $resultat = mysql_query($requete) or die(BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $requete));
147
        $ligne = mysql_fetch_object($resultat);
148
        foreach (get_object_vars($ligne) as $cle => $valeur) {
149
            $this->$cle = $valeur;
150
        }
151
 
152
        // Récupération des collections
153
        $requete_02 =   'SELECT ID '.
154
                        'FROM '.HB_BDD_NOM.'.HERBIERS_COLLECTION '.
155
                        'WHERE PARENT_ID = '.$id;
156
 
157
        $resultat_02 = mysql_query($requete_02) or die (BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $requete_02));
158
        while ($ligne_02 = mysql_fetch_object($resultat_02)) {
159
            $temp_coll = new H_collection() ;
160
            $this->collections[] = $temp_coll->getFromSQL($ligne_02->ID);
161
            unset($temp_coll);
162
        }
163
        $this->pays = getCountryName($this->COUNTRY_CODE);
164
        unset($this->COUNTRY_CODE);
165
 
166
        // Récupération de l'équipe
167
        $requete_03 =   'SELECT * '.
168
                        'FROM '.HB_BDD_NOM.'.HERBIERS_ont_un_staff '.
169
                        'WHERE ID_ORG = '.$id;
170
        $resultat_03 = mysql_query($requete_03) or die(BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $requete_03));
171
 
172
        while ($ligne_03 = mysql_fetch_object($resultat_03)) {
173
            $temp_equipe = new H_equipe();
174
            $this->equipe_liste[] = $temp_equipe->getFromSQL($ligne_03->ID_STAFF);
175
            unset($temp_equipe);
176
        }
177
 
178
        // Recherche de l'auteur de la saisie
179
        $requete_saisie =   'SELECT U_NAME, U_SURNAME '.
180
                            'FROM '.HB_BDD_NOM_ANNUAIRE.'.annuaire_tela, '.HB_BDD_NOM.'.HERBIERS_ADMINISTRER, '.HB_BDD_NOM.'.HERBIERS_ORGANISATION '.
181
                            'WHERE HERBIERS_ADMINISTRER.HA_ID_ORG = '.$id.' '.
182
                            'AND HERBIERS_ADMINISTRER.HA_ID_ANNUAIRE = annuaire_tela.U_ID';
183
        $resultat_saisie = mysql_query($requete_saisie) or die(BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $requete_saisie));
184
        $ligne_saisie = mysql_fetch_object($resultat_saisie);
185
        $this->U_NAME = $ligne_saisie->U_NAME;
186
        $this->U_SURNAME = $ligne_saisie->U_SURNAME;
187
 
188
       //$this = H_Herbier::remplacerEsperluette($this);
189
			foreach (get_object_vars(H_Herbier::remplacerEsperluette($this)) as $key => $value) {
190
				$this->$key = $value;
191
			}
192
    }
193
 
194
    /**
195
    *  Méthode recupererNomOrganisation() - Retourne le nom d'une organisation.
196
    *
197
    * Permet de récupérer dans la base de données le nom d'une organisation dont on passe l'identifiant
198
    * en paramêtre.
199
    *
200
    * @param integer l'identifiant d'une organisation.
201
    * @return string le nom de l'institution.
202
    * @access public
203
    */
204
    function recupererNomOrganisation($id_organisation)
205
    {
206
        $requete =  'SELECT INSTITUTION_NAME '.
207
                    'FROM HERBIERS_ORGANISATION '.
208
                    'WHERE ID_ORG = "'.$id_organisation.'"';
209
        $resultat = mysql_query($requete) or die(BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $requete));
210
        $ligne = mysql_fetch_object($resultat);
211
        $organisation_nom = $ligne->INSTITUTION_NAME;
212
        mysql_free_result($resultat);
213
        return $organisation_nom;
214
    }
215
 
216
        /**
217
    *  Méthode insererMembreEquipe() - Insère un nouveau membre dans l'organisation.
218
    *
219
    * Permet d'insérer dans la base de données un lien entre une organisation et un membre d'équipe.
220
    *
221
    * @param integer l'identifiant d'un membre d'une équipe.
222
    * @return void
223
    * @access public
224
    */
225
    function insererMembreEquipe($id_equipe)
226
    {
227
        $requete =  'INSERT INTO HERBIERS_ont_un_staff '.
228
                    'SET ID_ORG = '.$this->getId().', ID_STAFF = '.$id_equipe;
229
        $resultat = mysql_query($requete) or die(BOG_afficherErreurSql(__FILE__, __LINE__, mysql_error(), $requete));
230
    }
231
}
232
 
233
// +------------------------------------------------------------------------------------------------------+
234
// |                                            PIED du PROGRAMME                                         |
235
// +------------------------------------------------------------------------------------------------------+
236
 
237
 
238
/* +--Fin du code ----------------------------------------------------------------------------------------+
239
*
240
* $Log: not supported by cvs2svn $
241
* Revision 1.3  2005/04/06 13:29:17  jpm
242
* Ajout et modifications des objets représentant la base de données Herbier.
243
*
244
* Revision 1.2  2005/03/09 15:57:33  jpm
245
* Modification de la forme.
246
*
247
*
248
* +-- Fin du code ----------------------------------------------------------------------------------------+
249
*/
250
?>