Subversion Repositories Applications.projet

Rev

Rev 260 | Rev 344 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 260 Rev 300
1
<?php
1
<?php
2
// +------------------------------------------------------------------------------------------------------+
2
// +------------------------------------------------------------------------------------------------------+
3
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
3
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
4
// +------------------------------------------------------------------------------------------------------+
4
// +------------------------------------------------------------------------------------------------------+
5
// | This library is free software; you can redistribute it and/or                                        |
5
// | This library is free software; you can redistribute it and/or                                        |
6
// | modify it under the terms of the GNU General Public                                                  |
6
// | modify it under the terms of the GNU General Public                                                  |
7
// | License as published by the Free Software Foundation; either                                         |
7
// | License as published by the Free Software Foundation; either                                         |
8
// | version 2.1 of the License, or (at your option) any later version.                                   |
8
// | version 2.1 of the License, or (at your option) any later version.                                   |
9
// |                                                                                                      |
9
// |                                                                                                      |
10
// | This library is distributed in the hope that it will be useful,                                      |
10
// | This library is distributed in the hope that it will be useful,                                      |
11
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
11
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
12
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
12
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
13
// | General Public License for more details.                                                             |
13
// | General Public License for more details.                                                             |
14
// |                                                                                                      |
14
// |                                                                                                      |
15
// | You should have received a copy of the GNU General Public                                            |
15
// | You should have received a copy of the GNU General Public                                            |
16
// | License along with this library; if not, write to the Free Software                                  |
16
// | License along with this library; if not, write to the Free Software                                  |
17
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
17
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
18
// +------------------------------------------------------------------------------------------------------+
18
// +------------------------------------------------------------------------------------------------------+
19
// CVS : $Id: participe.class.php,v 1.5 2007-10-10 13:56:23 alexandre_tb Exp $
19
// CVS : $Id: participe.class.php,v 1.6 2008-08-25 15:11:56 alexandre_tb Exp $
20
/**
20
/**
21
* Application projet
21
* Application projet
22
*
22
*
23
* La classe partiicpe assure la jointure entre projet et Auth
23
* La classe partiicpe assure la jointure entre projet et Auth
24
* Elle se base sur la table projet_statut_utilisateur
24
* Elle se base sur la table projet_statut_utilisateur
25
*
25
*
26
*@package projet
26
*@package projet
27
//Auteur original :
27
//Auteur original :
28
*@author        Alexandre Granier <alexandre@tela-botanica.org>
28
*@author        Alexandre Granier <alexandre@tela-botanica.org>
29
//Autres auteurs :
29
//Autres auteurs :
30
*@author        Aucun
30
*@author        Aucun
31
*@copyright     Tela-Botanica 2000-2004
31
*@copyright     Tela-Botanica 2000-2004
32
*@version       $Revision: 1.5 $
32
*@version       $Revision: 1.6 $
33
// +------------------------------------------------------------------------------------------------------+
33
// +------------------------------------------------------------------------------------------------------+
34
*/
34
*/
35
 
35
 
36
 
36
 
37
// +------------------------------------------------------------------------------------------------------+
37
// +------------------------------------------------------------------------------------------------------+
38
// |                                            ENTETE du PROGRAMME                                       |
38
// |                                            ENTETE du PROGRAMME                                       |
39
// +------------------------------------------------------------------------------------------------------+
39
// +------------------------------------------------------------------------------------------------------+
40
 
40
 
41
 
41
 
42
/**
42
/**
43
 * class participe
43
 * class participe
44
 * 
44
 * 
45
 */
45
 */
46
class participe
46
class participe
47
{
47
{
48
    /*** Attributes: ***/
48
    /*** Attributes: ***/
49
 
49
 
50
    /**
50
    /**
51
     * Date d'inscription au projet de l'utilisateur.
51
     * Date d'inscription au projet de l'utilisateur.
52
     * @access private
52
     * @access private
53
     */
53
     */
54
    var $_date_inscription;
54
    var $_date_inscription;
55
    /**
55
    /**
56
     * Statut de l'utilisateur, un entier.
56
     * Statut de l'utilisateur, un entier.
57
     * @access private
57
     * @access private
58
     */
58
     */
59
    var $_statut;
59
    var $_statut;
60
    /**
60
    /**
61
     * Connexion à la base de donnée.
61
     * Connexion à la base de donnée.
62
     * @access private
62
     * @access private
63
     */
63
     */
64
    var $_db;
64
    var $_db;
65
 
65
 
66
    /**
66
    /**
67
     * Constructeur. Nécessite un objet DB valide connecté à la base contenant les
67
     * Constructeur. Nécessite un objet DB valide connecté à la base contenant les
68
     * tables projets.
68
     * tables projets.
69
     *
69
     *
70
     * @param DB objetDB Un objet PEAR:DB valide.
70
     * @param DB objetDB Un objet PEAR:DB valide.
71
     * @return void
71
     * @return void
72
     * @access public
72
     * @access public
73
     */
73
     */
74
    function participe( &$objetDB )
74
    function participe( &$objetDB )
75
    {
75
    {
76
        $this->_db = $objetDB ;
76
        $this->_db = $objetDB ;
77
    } // end of member function participe
77
    } // end of member function participe
78
 
78
 
79
    /**
79
    /**
80
     * Renvoie la liste des inscrit à un projet avec leur statut.
80
     * Renvoie la liste des inscrit à un projet avec leur statut.
81
     *
81
     *
82
     * @return Array
82
     * @return Array
83
     * @access public
83
     * @access public
84
     */
84
     */
85
    function getInscrits($id_projet, $droits )
85
    function getInscrits($id_projet, $droits )
86
    {
86
    {
87
        $tableau_resultat = array() ;
87
        $tableau_resultat = array() ;
88
        
88
        
89
        $requete = 'select psu_id_utilisateur,'.PROJET_CHAMPS_NOM.','.PROJET_CHAMPS_PRENOM.',' ;
89
        $requete = 'select psu_id_utilisateur,'.PROJET_CHAMPS_NOM.','.PROJET_CHAMPS_PRENOM.',' ;
90
        $requete .= PROJET_CHAMPS_MAIL.', ' ;
90
        $requete .= PROJET_CHAMPS_MAIL.', ' ;
91
        $requete .= 'psu_date_inscription,  ps_id_statut '.
91
        $requete .= 'psu_date_inscription,  ps_id_statut '.
92
                    ' from projet_statut_utilisateurs, projet_statut,'.PROJET_ANNUAIRE.
92
                    ' from projet_statut_utilisateurs, projet_statut,'.PROJET_ANNUAIRE.
93
                    ' where psu_id_projet='.$id_projet.' and psu_id_utilisateur='.PROJET_CHAMPS_ID.
93
                    ' where psu_id_projet='.$id_projet.' and psu_id_utilisateur='.PROJET_CHAMPS_ID.
94
                    ' and psu_id_statut=ps_id_statut order by ps_id_statut,'.PROJET_CHAMPS_NOM;
94
                    ' and psu_id_statut=ps_id_statut order by ps_id_statut,'.PROJET_CHAMPS_NOM;
95
        $resultat = $this->_db->query ($requete) ;
95
        $resultat = $this->_db->query ($requete) ;
96
        if (DB::isError($resultat)) {
96
        if (DB::isError($resultat)) {
97
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
97
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
98
        }
98
        }
99
        while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ORDERED)) {
99
        while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ORDERED)) {
100
            array_push ($tableau_resultat, $ligne) ;
100
            array_push ($tableau_resultat, $ligne) ;
-
 
101
            $id = $ligne[0];
-
 
102
            $inscrits[$id]['nom'] = $ligne[1];
-
 
103
            $inscrits[$id]['prenom'] = $ligne[2];
-
 
104
            $inscrits[$id]['mail'] = $ligne[3];
-
 
105
            $inscrits[$id]['date'] = $ligne[4];
-
 
106
            $inscrits[$id]['id_statut'] = $ligne[5]; 
101
        }
107
        }
102
        $resultat->free() ;
108
        $resultat->free() ;
103
        return $tableau_resultat ;
109
        return $tableau_resultat ;
104
    } // end of member function getInscrits
110
    } // end of member function getInscrits
105
 
111
 
106
    /**
112
    /**
107
     * Renvoie un tableau contenant la liste des identifiants des projets et des statuts
113
     * Renvoie un tableau contenant la liste des identifiants des projets et des statuts
108
     * d'un inscrit. 0 => ['psu_id_utilisateur']          ['psu_id_statut'] 1 => ...
114
     * d'un inscrit. 0 => ['psu_id_utilisateur']          ['psu_id_statut'] 1 => ...
109
     *
115
     *
110
     * @param int id_utilisateur Un identifiant d'utilisateur pour le champs
116
     * @param int id_utilisateur Un identifiant d'utilisateur pour le champs
111
     * projet_statut_utilisateurs:psu_id_utilisateur
117
     * projet_statut_utilisateurs:psu_id_utilisateur
112
     * @return Array
118
     * @return Array
113
     * @access public
119
     * @access public
114
     */
120
     */
115
    function getIdProjetsStatuts( $id_utilisateur )
121
    function getIdProjetsStatuts( $id_utilisateur )
116
    {
122
    {
117
        $tableau_resultat = array() ;
123
        $tableau_resultat = array() ;
118
        $requete = "select psu_id_utilisateur, psu_id_statut from projet_statut_utilisateurs".
124
        $requete = "select psu_id_utilisateur, psu_id_statut from projet_statut_utilisateurs".
119
                    " where psu_id_utilisateur=".$id_utilisateur ;
125
                    " where psu_id_utilisateur=".$id_utilisateur ;
120
        $resultat = $this->_db->query ($requete) ;
126
        $resultat = $this->_db->query ($requete) ;
121
        if (DB::isError($resultat)) {
127
        if (DB::isError($resultat)) {
122
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
128
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
123
        }
129
        }
124
        while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
130
        while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
125
            array_push ($tableau_resultat, $ligne) ;
131
            array_push ($tableau_resultat, $ligne) ;
126
        }
132
        }
127
        $resultat->free() ;
133
        $resultat->free() ;
128
        return $tableau_resultat ;
134
        return $tableau_resultat ;
129
    } // end of member function getIdProjetsStatuts
135
    } // end of member function getIdProjetsStatuts
130
 
136
 
131
 
137
 
132
    /**
138
    /**
133
     * Renvoie un tableau à 2 dimensions avec les informations sur l'inscription aux
139
     * Renvoie un tableau à 2 dimensions avec les informations sur l'inscription aux
134
     * différents projets d'un utilisateur. 0 => ['p_titre']         Le titre du projet 
140
     * différents projets d'un utilisateur. 0 => ['p_titre']         Le titre du projet 
135
     *         ['ps_label']    Le statut de l'utilisateur 1 => .... (autant que de
141
     *         ['ps_label']    Le statut de l'utilisateur 1 => .... (autant que de
136
     * projets)
142
     * projets)
137
     *
143
     *
138
     * @param int id_utilisateur L'identifiant d'un utilisateur.
144
     * @param int id_utilisateur L'identifiant d'un utilisateur.
139
     * @return Array
145
     * @return Array
140
     * @access public
146
     * @access public
141
     */
147
     */
142
    function getInformationsUtilisateurs( $id_utilisateur )
148
    function getInformationsUtilisateurs( $id_utilisateur )
143
    {
149
    {
144
        $tableau_resultat = array() ;
150
        $tableau_resultat = array() ;
145
        $requete = "select p_titre, ps_statut_nom, psu_id_statut, psu_id_projet from projet_statut_utilisateurs, projet, projet_statut".
151
        $requete = "select p_titre, ps_statut_nom, psu_id_statut, psu_id_projet from projet_statut_utilisateurs, projet, projet_statut".
146
                    " where psu_id_utilisateur=".$id_utilisateur.
152
                    " where psu_id_utilisateur=".$id_utilisateur.
147
                    " and psu_id_projet = p_id and psu_id_statut = ps_id_statut" ;
153
                    " and psu_id_projet = p_id and psu_id_statut = ps_id_statut" ;
148
        $resultat = $this->_db->query ($requete) ;
154
        $resultat = $this->_db->query ($requete) ;
149
        if (DB::isError($resultat)) {
155
        if (DB::isError($resultat)) {
150
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
156
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
151
        }
157
        }
152
        while ($ligne = $resultat->fetchRow()) {
158
        while ($ligne = $resultat->fetchRow()) {
153
            array_push ($tableau_resultat, $ligne) ;
159
            array_push ($tableau_resultat, $ligne) ;
154
        }
160
        }
155
        $resultat->free() ;
161
        $resultat->free() ;
156
        return $tableau_resultat ;
162
        return $tableau_resultat ;
157
    } // end of member function getInformationsUtilisateurs
163
    } // end of member function getInformationsUtilisateurs
158
 
164
 
159
 
165
 
160
    /**
166
    /**
161
     * Renvoie le statut du projet passé en paramètre.
167
     * Renvoie le statut du projet passé en paramètre.
162
     *
168
     *
163
     * @param int id_utilisateur 
169
     * @param int id_utilisateur 
164
     * @param int id_projet 
170
     * @param int id_projet 
165
     * @param int dbObject 
171
     * @param int dbObject 
166
     * @return int
172
     * @return int
167
     * @static
173
     * @static
168
     * @access public
174
     * @access public
169
     */
175
     */
170
    function getStatutSurProjetCourant( $id_utilisateur,  $id_projet,  &$dbObject )
176
    function getStatutSurProjetCourant( $id_utilisateur,  $id_projet,  &$dbObject )
171
    {
177
    {
-
 
178
        
-
 
179
        if (participe::isAdministrateur($id_utilisateur, $dbObject)) return PROJET_DROIT_ADMINISTRATEUR;
172
        $requete = 'select psu_id_statut from projet_statut_utilisateurs'.
180
        $requete = 'select psu_id_statut from projet_statut_utilisateurs'.
173
                    ' where psu_id_utilisateur="'.$id_utilisateur.'" and psu_id_projet ='.$id_projet ;
181
                    ' where psu_id_utilisateur="'.$id_utilisateur.'" and psu_id_projet ='.$id_projet ;
174
        $resultat = $dbObject->query ($requete) ;
182
        $resultat = $dbObject->query ($requete) ;
175
        if (DB::isError ($resultat)) {
183
        if (DB::isError ($resultat)) {
176
            echo ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
184
            return DB::raiseError('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
177
            return;
-
 
178
        }
185
        }
179
        $ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ;
186
        $ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT) ;
180
        if (!$resultat->numRows()) {
187
        if (!$resultat->numRows()) {
181
            return 4 ;      // Le statut ne participe pas
188
            return 4 ;      // Le statut ne participe pas
182
        }
189
        }
183
        return $ligne->psu_id_statut ;
190
        return $ligne->psu_id_statut ;
184
    } // end of member function getStatutSurProjetCourant
191
    } // end of member function getStatutSurProjetCourant
185
 
192
 
186
    /**
193
    /**
187
     * Réalise une requête dans projet_statut_utilisateurs et renvoie true si l'utilisateur
194
     * Réalise une requête dans projet_statut_utilisateurs et renvoie true si l'utilisateur
188
     * est administrateur de l'application projet.
195
     * est administrateur de l'application projet.
189
     *
196
     *
190
     * @param int id_utilisateur L'identifiant d'un utilisateur.
197
     * @param int id_utilisateur L'identifiant d'un utilisateur.
191
     * @param DB objetDB Un objet PEAR::DB
198
     * @param DB objetDB Un objet PEAR::DB
192
     * @return bool
199
     * @return bool
193
     * @access public
200
     * @access public
194
     */
201
     */
195
    function isAdministrateur( $id_utilisateur, $objetDB = "" )
202
    function isAdministrateur( $id_utilisateur, $objetDB = "" )
196
    {
203
    {
197
        // La table projet_statut_utilisateurs possède une entré avec psu_id_projet = 0
204
        // La table projet_statut_utilisateurs possède une entré avec psu_id_projet = 0
198
        // pour indiquer un administrateur
205
        // pour indiquer un administrateur
199
        $requete = "select psu_id_statut from projet_statut_utilisateurs where psu_id_utilisateur=$id_utilisateur".
206
        $requete = "select psu_id_statut from projet_statut_utilisateurs where psu_id_utilisateur=$id_utilisateur".
200
                    " and psu_id_projet=0" ;
207
                    " and psu_id_projet=0" ;
201
                    
208
                    
202
        if (is_object ($objetDB)) {
209
        if (is_object ($objetDB)) {
203
            $resultat = $objetDB->query ($requete) ;
210
            $resultat = $objetDB->query ($requete) ;
204
        } else {
211
        } else {
205
            $resultat = $this->_db->query ($requete) ;
212
            $resultat = $this->_db->query ($requete) ;
206
        }
213
        }
207
        if ($resultat->numRows () != 0) {
214
        if ($resultat->numRows () != 0) {
208
            return true;
215
            return true;
209
        }
216
        }
210
        return false ;
217
        return false ;
211
    } // end of member function isAdministrateur
218
    } // end of member function isAdministrateur
212
 
219
 
213
    /**
220
    /**
214
     * Met à jour le statut d'un utilisateur sur un projet
221
     * Met à jour le statut d'un utilisateur sur un projet
215
     *
222
     *
216
     * @param int id_statut L'identifiant du statut à ajouter ou mettre à jour
223
     * @param int id_statut L'identifiant du statut à ajouter ou mettre à jour
217
     * @param int id_utilisateur Identifiant de l'utilisateur
224
     * @param int id_utilisateur Identifiant de l'utilisateur
218
     * @param int id_projet Identifiant du projet
225
     * @param int id_projet Identifiant du projet
219
     * @return bool
226
     * @return bool
220
     * @access public
227
     * @access public
221
     */
228
     */
222
    function setStatut( $id_statut,  $id_utilisateur,  $id_projet )
229
    function setStatut( $id_statut,  $id_utilisateur,  $id_projet )
223
    {
230
    {
224
        $requete = 'update projet_statut_utilisateurs set psu_id_statut='.$id_statut.
231
        $requete = 'update projet_statut_utilisateurs set psu_id_statut='.$id_statut.
225
                    ' where psu_id_utilisateur='.$id_utilisateur.' and psu_id_projet='.$id_projet;
232
                    ' where psu_id_utilisateur='.$id_utilisateur.' and psu_id_projet='.$id_projet;
226
        
233
        
227
        if (participe::getStatutSurProjetCourant($id_utilisateur, $id_projet, $this->_db) == 4) {
234
        if (participe::getStatutSurProjetCourant($id_utilisateur, $id_projet, $this->_db) == 4) {
228
            $requete = 'insert into projet_statut_utilisateurs set psu_id_statut='.$id_statut.
235
            $requete = 'insert into projet_statut_utilisateurs set psu_id_statut='.$id_statut.
229
                    ', psu_id_utilisateur='.$id_utilisateur.',psu_id_projet='.$id_projet.
236
                    ', psu_id_utilisateur='.$id_utilisateur.',psu_id_projet='.$id_projet.
230
                    ', psu_date_inscription=NOW()';
237
                    ', psu_date_inscription=NOW()';
231
        }
238
        }
232
        if ($id_statut == 4) {  // Si le statut est ne participe pas, on supprime l'inscrit
239
        if ($id_statut == 4) {  // Si le statut est ne participe pas, on supprime l'inscrit
233
            $requete = 'delete from projet_statut_utilisateurs where psu_id_utilisateur='.$id_utilisateur.' and psu_id_projet='.$id_projet ;
240
            $requete = 'delete from projet_statut_utilisateurs where psu_id_utilisateur='.$id_utilisateur.' and psu_id_projet='.$id_projet ;
234
        }
241
        }
235
        $resultat = $this->_db->query ($requete) ;
242
        $resultat = $this->_db->query ($requete) ;
236
        if (DB::isError ($resultat)) {
243
        if (DB::isError ($resultat)) {
237
            die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
244
            die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
238
        }
245
        }
239
        return true ;
246
        return true ;
240
    } // end of member function setStatut
247
    } // end of member function setStatut
241
 
248
 
242
    /**
249
    /**
243
     * Renvoie vrai si l'utilisateur est coordinateur, faux dans les autres cas
250
     * Renvoie vrai si l'utilisateur est coordinateur, faux dans les autres cas
244
     *
251
     *
245
     * @param int id_utilisateur L'identifiant d'un utilisateur
252
     * @param int id_utilisateur L'identifiant d'un utilisateur
246
     * @param DB objetDB Optionnel, nécessaire si on appelle cette méthode statiquement
253
     * @param DB objetDB Optionnel, nécessaire si on appelle cette méthode statiquement
247
     * @return bool
254
     * @return bool
248
     * @static
255
     * @static
249
     * @access public
256
     * @access public
250
     */
257
     */
251
    function isCoordinateur( $id_utilisateur, $id_projet, &$objetDB )
258
    function isCoordinateur( $id_utilisateur, $id_projet, &$objetDB )
252
    {
259
    {
253
        if (!is_object($objetDB)) $objetDB = $this->_db;
260
        if (!is_object($objetDB)) $objetDB = $this->_db;
254
        $statut = $this->getStatutSurProjetCourant($id_utilisateur,  $id_projet, $objetDB) ;
261
        $statut = $this->getStatutSurProjetCourant($id_utilisateur,  $id_projet, $objetDB) ;
255
        if ($statut == 1) {
262
        if ($statut == 1) {
256
            return true;
263
            return true;
257
        }
264
        }
258
        return false ;
265
        return false ;
259
    } // end of member function isCoordinateur
266
    } // end of member function isCoordinateur
260
 
267
 
261
    /**
268
    /**
262
     * Renvoie la liste des projets auquels l'utilisateur passé en paramètre ne
269
     * Renvoie la liste des projets auquels l'utilisateur passé en paramètre ne
263
     * participe pas.
270
     * participe pas.
264
     *
271
     *
265
     * @param int id_utilisateur L'identifiant de l'utilisateur.
272
     * @param int id_utilisateur L'identifiant de l'utilisateur.
266
     * @return Array
273
     * @return Array
267
     * @access public
274
     * @access public
268
     */
275
     */
269
    function getProjetsNonParticipant( $id_utilisateur )
276
    function getProjetsNonParticipant( $id_utilisateur )
270
    {
277
    {
271
        $tableau_resultat = array() ;
278
        $tableau_resultat = array() ;
272
        $requete = 'select p_id from projet'.
279
        $requete = 'select p_id from projet'.
273
                    ' where p_id not in (select psu_id_projet from projet_statut_utilisateurs where psu_id_utilisateur="'.$id_utilisateur.'")' ;
280
                    ' where p_id not in (select psu_id_projet from projet_statut_utilisateurs where psu_id_utilisateur="'.$id_utilisateur.'")' ;
274
        $resultat = $this->_db->query ($requete) ;
281
        $resultat = $this->_db->query ($requete) ;
275
        if (DB::isError($resultat)) {
282
        if (DB::isError($resultat)) {
276
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
283
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
277
        }
284
        }
278
        while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
285
        while ($ligne = $resultat->fetchRow(DB_FETCHMODE_OBJECT)) {
279
            array_push ($tableau_resultat, new projet ($this->_db, $ligne->p_id)) ;
286
            array_push ($tableau_resultat, new projet ($this->_db, $ligne->p_id)) ;
280
        }
287
        }
281
        $resultat->free() ;
288
        $resultat->free() ;
282
        return $tableau_resultat ;
289
        return $tableau_resultat ;
283
    } // end of member function getProjetsNonParticipant
290
    } // end of member function getProjetsNonParticipant
284
 
291
 
285
    /**
292
    /**
286
     * Renvoie true si l'utilisateur passé en paramètre est observateur du projet passé
293
     * Renvoie true si l'utilisateur passé en paramètre est observateur du projet passé
287
     * en paramètre.
294
     * en paramètre.
288
     *
295
     *
289
     * @param int id_utilisateur L'identifiant de l'utilisateur
296
     * @param int id_utilisateur L'identifiant de l'utilisateur
290
     * @param int id_projet L'identifiant du projet
297
     * @param int id_projet L'identifiant du projet
291
     * @return bool
298
     * @return bool
292
     * @access public
299
     * @access public
293
     */
300
     */
294
    function isObservateur( $id_utilisateur,  $id_projet, &$objetDB )
301
    function isObservateur( $id_utilisateur,  $id_projet, &$objetDB )
295
    {
302
    {
296
        if (!is_object($objetDB)) $objetDB = $this->_db;
303
        if (!is_object($objetDB)) $objetDB = $this->_db;
297
        if ($this->getStatutSurProjetCourant($id_utilisateur, $id_projet, $objetDB) == 3) {
304
        if ($this->getStatutSurProjetCourant($id_utilisateur, $id_projet, $objetDB) == 3) {
298
            return true;
305
            return true;
299
        }
306
        }
300
        return false ;
307
        return false ;
301
    } // end of member function isObservateur
308
    } // end of member function isObservateur
302
 
309
 
303
    /**
310
    /**
304
     * Renvoie true si l'utilisateur passé en paramètre est contributeur du projet passé
311
     * Renvoie true si l'utilisateur passé en paramètre est contributeur du projet passé
305
     * en paramètre.
312
     * en paramètre.
306
     *
313
     *
307
     * @param int id_utilisateur L'identifiant de l'utilisateur
314
     * @param int id_utilisateur L'identifiant de l'utilisateur
308
     * @param int id_projet L'identifiant du projet
315
     * @param int id_projet L'identifiant du projet
309
     * @return bool
316
     * @return bool
310
     * @access public
317
     * @access public
311
     */
318
     */
312
    function isContributeur( $id_utilisateur,  $id_projet, &$objetDB )
319
    function isContributeur( $id_utilisateur,  $id_projet, &$objetDB )
313
    {
320
    {
314
        if (!is_object($objetDB)) $objetDB = $this->_db;
321
        if (!is_object($objetDB)) $objetDB = $this->_db;
315
        if ($this->getStatutSurProjetCourant($id_utilisateur, $id_projet, $objetDB) == 4) return false; 
322
        if ($this->getStatutSurProjetCourant($id_utilisateur, $id_projet, $objetDB) == 4) return false; 
316
        if ($this->getStatutSurProjetCourant($id_utilisateur, $id_projet, $objetDB) == 2) {
323
        if ($this->getStatutSurProjetCourant($id_utilisateur, $id_projet, $objetDB) == 2) {
317
            return true;
324
            return true;
318
        }
325
        }
319
        return false ;
326
        return false ;
320
    } // end of member function isObservateur
327
    } // end of member function isObservateur
321
 
328
 
322
    /**
329
    /**
323
     * Renvoie true si l'utilisateur passé en paramètre est contributeur du projet passé
330
     * Renvoie true si l'utilisateur passé en paramètre est contributeur du projet passé
324
     * en paramètre.
331
     * en paramètre.
325
     *
332
     *
326
     * @param int id_utilisateur L'identifiant de l'utilisateur
333
     * @param int id_utilisateur L'identifiant de l'utilisateur
327
     * @param int id_projet L'identifiant du projet
334
     * @param int id_projet L'identifiant du projet
328
     * @return bool
335
     * @return bool
329
     * @access public
336
     * @access public
330
     */
337
     */
331
    function isEnAttente( $id_utilisateur,  $id_projet, &$objetDB )
338
    function isEnAttente( $id_utilisateur,  $id_projet, &$objetDB )
332
    {
339
    {
333
        if ($this->getStatutSurProjetCourant($id_utilisateur, $id_projet, $objetDB) == 3) {
340
        if ($this->getStatutSurProjetCourant($id_utilisateur, $id_projet, $objetDB) == 3) {
334
            return true;
341
            return true;
335
        }
342
        }
336
        return false ;
343
        return false ;
337
    } // end of member function isObservateur
344
    } // end of member function isObservateur
338
 
345
 
339
	/**
346
	/**
340
     * Renvoie les infos sur les coordinateurs d'un projet
347
     * Renvoie les infos sur les coordinateurs d'un projet
341
     *
348
     *
342
     * @param int id_projet L'identifiant du projet
349
     * @param int id_projet L'identifiant du projet
343
     * @return array	Un tableau contenant les infos concernants les coordinateurs du projet
350
     * @return array	Un tableau contenant les infos concernants les coordinateurs du projet
344
     * @access public
351
     * @access public
345
     */
352
     */
346
    function getCoordinateurs($id_projet)
353
    function getCoordinateurs($id_projet)
347
    {
354
    {
348
        $tableau_resultat = array() ;
355
        $tableau_resultat = array() ;
349
        
356
        
350
        $requete = 'select psu_id_utilisateur,'.PROJET_CHAMPS_NOM.','.PROJET_CHAMPS_PRENOM.',' ;
357
        $requete = 'select psu_id_utilisateur,'.PROJET_CHAMPS_NOM.','.PROJET_CHAMPS_PRENOM.',' ;
351
        $requete .= PROJET_CHAMPS_MAIL.', ' ;
358
        $requete .= PROJET_CHAMPS_MAIL.', ' ;
352
        $requete .= 'psu_date_inscription,  ps_id_statut '.
359
        $requete .= 'psu_date_inscription,  ps_id_statut '.
353
                    ' from projet_statut_utilisateurs, projet_statut,'.PROJET_ANNUAIRE.
360
                    ' from projet_statut_utilisateurs, projet_statut,'.PROJET_ANNUAIRE.
354
                    ' where psu_id_projet='.$id_projet.' and psu_id_utilisateur='.PROJET_CHAMPS_ID.
361
                    ' where psu_id_projet='.$id_projet.' and psu_id_utilisateur='.PROJET_CHAMPS_ID.
355
                    ' and psu_id_statut=ps_id_statut and psu_id_statut=1 order by ps_id_statut,'.PROJET_CHAMPS_NOM;
362
                    ' and psu_id_statut=ps_id_statut and psu_id_statut=1 order by ps_id_statut,'.PROJET_CHAMPS_NOM;
356
        $resultat = $this->_db->query ($requete) ;
363
        $resultat = $this->_db->query ($requete) ;
357
        if (DB::isError($resultat)) {
364
        if (DB::isError($resultat)) {
358
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
365
            die ("Echec de la requete<br />".$resultat->getMessage()."<br />".$resultat->getDebugInfo()) ;
359
        }
366
        }
360
        while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ORDERED)) {
367
        while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ORDERED)) {
361
            array_push ($tableau_resultat, $ligne) ;
368
            array_push ($tableau_resultat, $ligne) ;
362
        }
369
        }
363
        $resultat->free() ;
370
        $resultat->free() ;
364
        return $tableau_resultat ;
371
        return $tableau_resultat ;
365
    } // end of member function getCoordinateurs
372
    } // end of member function getCoordinateurs
-
 
373
    
-
 
374
    /** 
-
 
375
     * Renvoie la constante de statut d un utilisateur
-
 
376
     * 
-
 
377
     * define ('PROJET_DROIT_ADMINISTRATEUR', 1) ;
-
 
378
	 * define ('PROJET_DROIT_COORDINATEUR', 2) ;
-
 
379
	 * define ('PROJET_DROIT_PROPRIETAIRE', 4) ;
-
 
380
	 * define ('PROJET_DROIT_CONTRIBUTEUR', 8) ;
-
 
381
	 * define ('PROJET_DROIT_AUCUN', 16) ;
-
 
382
	 * define ('PROJET_DROIT_EN_ATTENTE', 32);
-
 
383
	 * 
-
 
384
	 * @access	public
-
 
385
	 * @return int	La constante de statut
-
 
386
     */
-
 
387
     
-
 
388
     function getStatut($id_utilisateur, $id_projet)
-
 
389
     {
-
 
390
     	$statut = $this->getStatutSurProjetCourant($id_utilisateur, $id_projet, $this->_db);
-
 
391
     	switch ($statut) 
-
 
392
     	{
-
 
393
     		case 0 : return PROJET_DROIT_ADMINISTRATEUR;
-
 
394
     		break;
-
 
395
     		case 1 : return PROJET_DROIT_COORDINATEUR;
-
 
396
     		break;
-
 
397
     		case 2 : return PROJET_DROIT_CONTRIBUTEUR;
-
 
398
     		break;
-
 
399
     		case 3 : return PROJET_DROIT_EN_ATTENTE;
-
 
400
     		break;
-
 
401
     		default : return PROJET_DROIT_AUCUN;
-
 
402
     	}
-
 
403
     }
366
} // end of participe
404
} // end of participe
367
?>
405
?>