Subversion Repositories Applications.projet

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 ddelon 1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
8
// | This library is free software; you can redistribute it and/or                                        |
9
// | modify it under the terms of the GNU General Public                                                  |
10
// | License as published by the Free Software Foundation; either                                         |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
12
// |                                                                                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
16
// | General Public License for more details.                                                             |
17
// |                                                                                                      |
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                                  |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
11 alexandre_ 22
// CVS : $Id: statut.class.php,v 1.2 2005-09-27 16:42:00 alexandre_tb Exp $
2 ddelon 23
/**
24
* Application projet
25
*
26
* La classe statut
27
*
28
*@package projet
29
//Auteur original :
30
*@author        Alexandre Granier <alexandre@tela-botanica.org>
31
//Autres auteurs :
32
*@author        Aucun
33
*@copyright     Tela-Botanica 2000-2004
11 alexandre_ 34
*@version       $Revision: 1.2 $
2 ddelon 35
// +------------------------------------------------------------------------------------------------------+
36
*/
37
 
38
 
39
// +------------------------------------------------------------------------------------------------------+
40
// |                                            ENTETE du PROGRAMME                                       |
41
// +------------------------------------------------------------------------------------------------------+
42
 
43
define ('PROJET_STATUT_TOUS', 1) ;
44
define ('PROJET_STATUT_SAUF_ADM', 2) ;
45
define ('PROJET_STATUT_SAUF_ADM_COORD', 3) ;
46
 
47
/**
48
 * class statut
49
 *
50
 */
51
class statut
52
{
53
 
54
    /** Aggregations: */
55
 
56
    /** Compositions: */
57
 
58
    /*** Attributes: ***/
59
 
60
    /**
61
     * L'identifiant du statut
62
     * @access private
63
     */
64
    var $_id_statut;
65
    /**
66
     * Le label du statut, dans la table.
67
     * @access private
68
     */
69
    var $_label;
70
    /**
71
     * Un objet PEAR::DB
72
     * @access private
73
     */
74
    var $_db;
75
 
76
    /**
77
     * Constructeur.
78
     *
79
     * @param int id_statut L'identifiant du statut créé.
80
     * @param DB objetDB Un objet PEAR::DB
81
     * @return void
82
     * @access public
83
     */
84
    function statut( $id_statut, &$objetDB )
85
    {
86
        $requete = "select * from projet_statut where ps_id_statut=$id_statut" ;
87
        $resultat = $objetDB->query ($requete) ;
88
        if (PEAR::isError ($resultat)) {
89
            die ($resultat->getMessage()."<br />".$requete."<br />") ;
90
        }
91
        $ligne = $resultat->fetchRow (DB_FETCHMODE_OBJECT) ;
92
        $this->_db = $objetDB ;
93
        $this->_id_statut = $ligne->pd_id_statut ;
94
        $this->_label = $ligne->ps_statut_nom;
95
    } // end of member function statut
96
 
97
    /**
98
     * Renvoie le label du statut.
99
     *
100
     * @return string
101
     * @access public
102
     */
103
    function getLabel( )
104
    {
105
        return $this->_label ;
106
    } // end of member function getLabel
107
    /**
108
     *
109
     *
110
     * @param int type_statut Indique quels statuts l'on désire voir retourner PROJET_STATUT_TOUS
111
     *  PROJET_STATUT_SAUF_ADM PROJET_STATUT_SAUF_ADM_COORD
112
     * @return Array
113
     * @static
114
     * @access public
115
     */
116
    function getTousLesStatuts( $type_statut = PROJET_STATUT_TOUS, &$objetDB)
117
    {
118
        $requete = 'select * from projet_statut' ;
119
        if ($type_statut == PROJET_STATUT_SAUF_ADM) {
120
            $requete .= ' where ps_id_statut <> 0' ;
121
        }
122
        if ($type_statut == PROJET_STATUT_SAUF_ADM_COORD) {
123
            $requete .= ' where ps_id_statut > 1' ;
124
        }
125
        $resultat = $objetDB->query ($requete) ;
126
        $tableau_resultat = array();
127
        while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
128
            $tableau_resultat[$ligne->ps_id_statut] = $ligne->ps_statut_nom ;
129
        }
130
        return $tableau_resultat;
131
    } // end of member function getTousLesStatuts
132
 
133
 
134
 
135
 
136
 
137
} // end of statut
138
?>