Subversion Repositories Applications.projet

Rev

Rev 118 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 118 Rev 431
1
<?php
1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */ 
3
// +------------------------------------------------------------------------------------------------------+
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
7
// +------------------------------------------------------------------------------------------------------+
8
// | This library is free software; you can redistribute it and/or                                        |
8
// | This library is free software; you can redistribute it and/or                                        |
9
// | modify it under the terms of the GNU General Public                                                  |
9
// | modify it under the terms of the GNU General Public                                                  |
10
// | License as published by the Free Software Foundation; either                                         |
10
// | License as published by the Free Software Foundation; either                                         |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
12
// |                                                                                                      |
12
// |                                                                                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
16
// | General Public License for more details.                                                             |
16
// | General Public License for more details.                                                             |
17
// |                                                                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU General Public                                            |
18
// | You should have received a copy of the GNU General Public                                            |
19
// | License along with this library; if not, write to the Free Software                                  |
19
// | License along with this library; if not, write to the Free Software                                  |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
21
// +------------------------------------------------------------------------------------------------------+
22
// CVS : $Id: annuaire.class.php,v 1.5 2006-07-04 09:25:38 alexandre_tb Exp $
22
// CVS : $Id: annuaire.class.php,v 1.5 2006/07/04 09:25:38 alexandre_tb Exp $
23
/**
23
/**
24
* Application annuaire
24
* Application annuaire
25
*
25
*
26
* La classe annuaire
26
* La classe annuaire
27
*
27
*
28
*@package annuaire
28
*@package annuaire
29
//Auteur original :
29
//Auteur original :
30
*@author        Alexandre Granier <alexandre@tela-botanica.org>
30
*@author        Alexandre Granier <alexandre@tela-botanica.org>
31
//Autres auteurs :
31
//Autres auteurs :
32
*@author        Aucun
32
*@author        Aucun
33
*@copyright     Tela-Botanica 2000-2004
33
*@copyright     Tela-Botanica 2000-2004
34
*@version       $Revision: 1.5 $
34
*@version       $Revision: 1.5 $
35
// +------------------------------------------------------------------------------------------------------+
35
// +------------------------------------------------------------------------------------------------------+
36
*/
36
*/
37
 
37
 
38
 
38
 
39
// +------------------------------------------------------------------------------------------------------+
39
// +------------------------------------------------------------------------------------------------------+
40
// |                                            ENTETE du PROGRAMME                                       |
40
// |                                            ENTETE du PROGRAMME                                       |
41
// +------------------------------------------------------------------------------------------------------+
41
// +------------------------------------------------------------------------------------------------------+
42
 
42
 
43
include_once 'PEAR.php' ;
43
include_once 'PEAR.php' ;
44
 
44
 
45
/**
45
/**
46
 * class annuaire
46
 * class annuaire
47
 * 
47
 * 
48
 */
48
 */
49
class annuaire extends PEAR
49
class annuaire extends PEAR
50
{
50
{
51
 
51
 
52
     /*** Attributes: ***/
52
     /*** Attributes: ***/
53
 
53
 
54
    /**
54
    /**
55
     * 
55
     * 
56
     * @access private
56
     * @access private
57
     */
57
     */
58
    var $_db;
58
    var $_db;
59
    /**
59
    /**
60
     * 
60
     * 
61
     * @access private
61
     * @access private
62
     */
62
     */
63
    var $_id_utilisateur;
63
    var $_id_utilisateur;
64
    /**
64
    /**
65
     * Tableau contenant les noms des champs
65
     * Tableau contenant les noms des champs
66
     * @access private
66
     * @access private
67
     */
67
     */
68
    var $_champs_base;
68
    var $_champs_base;
69
 
69
 
70
    /**
70
    /**
71
     * 
71
     * 
72
     *
72
     *
73
     * @param int objetDB Une ressource PEAR::DB
73
     * @param int objetDB Une ressource PEAR::DB
74
     * @param Array param un tableau indiquant les noms des champs dans la base. 'nom' => 'CHAMPS_NOM',
74
     * @param Array param un tableau indiquant les noms des champs dans la base. 'nom' => 'CHAMPS_NOM',
75
'prenom' => .. 'date_inscription' => .. 'identifiant' => ... 'ville' => ...
75
'prenom' => .. 'date_inscription' => .. 'identifiant' => ... 'ville' => ...
76
'pays' => ...
76
'pays' => ...
77
     * @return void
77
     * @return void
78
     * @access public
78
     * @access public
79
     */
79
     */
80
    function annuaire( &$objetDB,  $param )
80
    function annuaire( &$objetDB,  $param )
81
    {
81
    {
82
        $this->_db = $objetDB ;
82
        $this->_db = $objetDB ;
83
        $this->_champs_base = $param ;
83
        $this->_champs_base = $param ;
84
    } // end of member function annuaire
84
    } // end of member function annuaire
85
 
85
 
86
    /**
86
    /**
87
     * Spécifie l'identifiant d'un utilisateur ou plusieurs utilisateurs
87
     * Spécifie l'identifiant d'un utilisateur ou plusieurs utilisateurs
88
     *
88
     *
89
     * @param mixed id_utilisateur L'identifiant d'un utilisateur
89
     * @param mixed id_utilisateur L'identifiant d'un utilisateur
90
     * @return void
90
     * @return void
91
     * @access public
91
     * @access public
92
     */
92
     */
93
    function setId( $id_utilisateur )
93
    function setId( $id_utilisateur )
94
    {
94
    {
95
        $this->_id_utilisateur = $id_utilisateur ;
95
        $this->_id_utilisateur = $id_utilisateur ;
96
    } // end of member function setId
96
    } // end of member function setId
97
 
97
 
98
    /**
98
    /**
99
     * Renvoie l'info de l'utilisateur courant. Sans paramètre, renvoie un tableau avec
99
     * Renvoie l'info de l'utilisateur courant. Sans paramètre, renvoie un tableau avec
100
     * tous les champs.
100
     * tous les champs.
101
     *
101
     *
102
     * @param string parametre Un paramètre de l'objet : - 'nom', 'prenom' ....
102
     * @param string parametre Un paramètre de l'objet : - 'nom', 'prenom' ....
103
     * @return void
103
     * @return void
104
     * @access public
104
     * @access public
105
     */
105
     */
106
    function getInfo( $parametre )
106
    function getInfo( $parametre )
107
    {
107
    {
108
        $requete = 'select '.$this->_champs_base[$parametre].
108
        $requete = 'select '.$this->_champs_base[$parametre].
109
                    ' from '.$this->_champs_base['table'].
109
                    ' from '.$this->_champs_base['table'].
110
                    ' where '.$this->_champs_base['identifiant'].'='.$this->_id_utilisateur ;
110
                    ' where '.$this->_champs_base['identifiant'].'='.$this->_id_utilisateur ;
111
        $resultat = $GLOBALS['projet_db']->query($requete) ;
111
        $resultat = $GLOBALS['projet_db']->query($requete) ;
112
        if (DB::isError($resultat)) {
112
        if (DB::isError($resultat)) {
113
            echo $requete.' erreur '.$resultat->getMessage() ;
113
            echo $requete.' erreur '.$resultat->getMessage() ;
114
        }
114
        }
115
        $ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC) ;
115
        $ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC) ;
116
        return $ligne[$this->_champs_base[$parametre]] ;
116
        return $ligne[$this->_champs_base[$parametre]] ;
117
    } // end of member function getInfo
117
    } // end of member function getInfo
118
 
118
 
119
    /**
119
    /**
120
     * Renvoie la liste de tous el inscris ou celle dont le champs passé en paramètre
120
     * Renvoie la liste de tous el inscris ou celle dont le champs passé en paramètre
121
     * ressemble à la valeur souhaité. Ex : $maliste->getListe (array('nom' => '%toto'))
121
     * ressemble à la valeur souhaité. Ex : $maliste->getListe (array('nom' => '%toto'))
122
     * ; renvoie la liste des adhérents dont le nom commence par toto.
122
     * ; renvoie la liste des adhérents dont le nom commence par toto.
123
     *
123
     *
124
     * @param Array param Un tableau du type 'nom' => 'chaine'
124
     * @param Array param Un tableau du type 'nom' => 'chaine'
125
     * @return void
125
     * @return void
126
     * @access public
126
     * @access public
127
     */
127
     */
128
    function getListe( $param )
128
    function getListe( $param )
129
    {
129
    {
130
        
130
        
131
    } // end of member function getListe
131
    } // end of member function getListe
132
 
132
 
133
    /**
133
    /**
134
     * Renvoie la liste des inscrits dont le nom commence par lettre
134
     * Renvoie la liste des inscrits dont le nom commence par lettre
135
     *
135
     *
136
     * @param char lettre La lettre
136
     * @param char lettre La lettre
137
     * @return void
137
     * @return void
138
     * @access public
138
     * @access public
139
     */
139
     */
140
    function getListeAlphabetique( $lettre )
140
    function getListeAlphabetique( $lettre )
141
    {
141
    {
142
        
142
        
143
    } // end of member function getListeAlphabetique
143
    } // end of member function getListeAlphabetique
144
 
144
 
145
 
145
 
146
 
146
 
147
 
147
 
148
 
148
 
149
} // end of annuaire
149
} // end of annuaire
150
?>
150
?>