Subversion Repositories Applications.projet

Rev

Rev 98 | Rev 139 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 ddelon 1
<?php
59 ddelon 2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
2 ddelon 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
 
122 alexandre_ 23
// CVS : $Id: projetControleur.class.php,v 1.28 2006-07-04 09:29:49 alexandre_tb Exp $
11 alexandre_ 24
 
2 ddelon 25
/**
26
* Application projet
27
*
28
* La classe controleur projet
29
*
30
*@package projet
31
//Auteur original :
32
*@author        Alexandre Granier <alexandre@tela-botanica.org>
33
//Autres auteurs :
34
*@author        Aucun
35
*@copyright     Tela-Botanica 2000-2004
122 alexandre_ 36
*@version       $Revision: 1.28 $
2 ddelon 37
// +------------------------------------------------------------------------------------------------------+
38
*/
39
 
40
// +------------------------------------------------------------------------------------------------------+
41
// |                                            ENTETE du PROGRAMME                                       |
42
// +------------------------------------------------------------------------------------------------------+
43
 
44
if (isset ($GLOBALS['lang'])) {
45
    /** le fichier de langue, par defaut PROJET_LANGUE_DEFAUT */
46
    include_once 'client/projet/langues/pro_langue_'.$GLOBALS['lang'].'.inc.php' ;
47
} else {
48
    include_once 'client/projet/langues/pro_langue_'.PROJET_LANGUE_DEFAUT.'.inc.php' ;
49
}
50
 
51
include_once PROJET_CHEMIN_CLASSES.'participe.class.php' ;
52
include_once PROJET_CHEMIN_CLASSES.'HTML_listeProjet.class.php' ;
53
include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
54
include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireProjet.class.php' ;
55
include_once PROJET_CHEMIN_CLASSES.'statut.class.php' ;
56
include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireDocument.class.php' ;
57
include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireMail.class.php' ;
58
include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireListe.class.php' ;
59
include_once PROJET_CHEMIN_CLASSES.'commande_serveur.class.php' ;
60
include_once PROJET_CHEMIN_CLASSES_LISTES.'ezmlm.php' ;
61
 
16 ddelon 62
require_once GEN_CHEMIN_API.'html/HTML_TableFragmenteur.php' ;
2 ddelon 63
// +------------------------------------------------------------------------------------------------------+
64
// |                                           LISTE des constantes                                       |
65
// +------------------------------------------------------------------------------------------------------+
66
 
67
define ("PROJET_ACTION_COUPER", 3) ;
68
define ("PROJET_ACTION_MODIFIER", 4) ;
69
define ("PROJET_SUPPRESSION_FICHIER", 5) ;
70
define ("PROJET_NOUVEAU", 6) ;
71
define ("PROJET_NOUVEAU_V", 7) ;
72
define ('PROJET_MODIFIER_DESCRIPTION', 19) ;
73
define ('PROJET_MODIFIER_DESCRIPTION_V', 20) ;
74
define ("PROJET_NOUVEAU_FICHIER", 8) ;
75
define ("PROJET_NOUVEAU_FICHIER_V", 9) ;
76
define ("PROJET_NOUVEAU_REPERTOIRE", 11) ;
77
define ("PROJET_NOUVEAU_REPERTOIRE_V", 12) ;
78
define ("PROJET_SUPPRESSION_PROJET", 10) ;
79
define ("PROJET_ENVOYER_UN_MAIL", 13) ;
80
define ("PROJET_ENVOYER_UN_MAIL_V", 14) ;
81
define ("PROJET_ACTION_MODIFIER_V", 15) ;
82
define ('PROJET_ACTION_NOUVELLE_LISTE', 16) ;
83
define ('PROJET_ACTION_NOUVELLE_LISTE_V', 17) ;
84
define ('PROJET_ACTION_S_INSCRIRE', 21) ;
85
define ('PROJET_ACTION_CREER_WIKI', 22) ;
86
define ('PROJET_ACTION_SUPPRIMER_WIKI', 23) ;
87
define ('PROJET_ACTION_CREER_WIKI_V', 24) ;
88
define ('PROJET_ACTION_SUPPRIMER_LISTE', 25) ;
89
define ('PROJET_ACTION_DESINSCRIPTION_PROJET', 26) ;
90
define ('PROJET_ACTION_INSCRIPTION_LISTE', 27) ;
91
define ('PROJET_ACTION_DESINSCRIPTION_LISTE', 28) ;
92
define ('PROJET_ACTION_REFERENCER_LISTE', 29) ;
93
define ('PROJET_ACTION_REFERENCER_LISTE_V', 30) ;
94
define ('PROJET_ACTION_COLLER', 32) ;
16 ddelon 95
define ('PROJET_ACTION_ASSOCIER_WIKI', 36) ;
96
define ('PROJET_ACTION_ASSOCIER_WIKI_V', 37) ;
2 ddelon 97
 
98
define ('PROJET_ACTION_VOIR_RESUME', 'resume') ;
99
define ('PROJET_ACTION_VOIR_DESCRIPTION', 'description') ;
100
define ('PROJET_ACTION_VOIR_DOCUMENT', 'documents') ;
101
define ('PROJET_ACTION_VOIR_FORUM', 'forums') ;
102
define ('PROJET_ACTION_VOIR_PARTICIPANT', 'participants') ;
103
define ('PROJET_ACTION_VOIR_WIKINI', 'wikini') ;
104
/**
105
 * Code erreur pour l'interface projetControleur qui trouveront leur message
106
 * correspondant via la fonction projetControleur::messageErreur()
107
 */
108
define ("PROJETCONTROLEUR_ACTION_INVALIDE", -1) ;
109
define ("PROJETCONTROLEUR_ERREUR_SUPPRESSION_REPERTOIRE", -2) ;
110
define ("PROJETCONTROLEUR_PAS_DE_DOCUMENT_SELECTIONNE", -3) ;
111
define ("PROJETCONTROLEUR_ERREUR_CREATION_REPERTOIRE", -4) ;
112
 
113
/**
114
 *  Constantes pour définir les droits
115
 *
116
 */
117
define ('PROJET_DROIT_ADMINISTRATEUR', 1) ;
118
define ('PROJET_DROIT_COORDINATEUR', 2) ;
119
define ('PROJET_DROIT_PROPRIETAIRE', 4) ;
120
define ('PROJET_DROIT_CONTRIBUTEUR', 8) ;
121
define ('PROJET_DROIT_AUCUN', 16) ;
122 alexandre_ 122
define ('PROJET_DROIT_EN_ATTENTE', 32);
2 ddelon 123
/**
124
 * class projetControleur
125
 * Cette classe sert à lancer les diverses applications du module projet, en
126
 * fonction des paramêtre de l'URL GET ou POST. La méthode principale est run()
127
 */
128
class projetControleur
129
{
130
    /*** Attributes: ***/
131
 
132
    /**
133
     * Contient l'action du controleur, qui correspond à une action du module projet.
134
     * @access private
135
     */
136
    var $_action;
137
    /**
138
     * Une connexion à une base de donnée DB.
139
     * @access private
140
     */
141
    var $_db;
142
 
143
    /**
144
     * Un objet PEAR:Auth
145
     * @access private
146
     */
147
    var $_auth;
59 ddelon 148
 
2 ddelon 149
    /**
59 ddelon 150
     *
2 ddelon 151
     * @access private
152
     */
153
    var $_url;
59 ddelon 154
 
2 ddelon 155
    /**
156
     * L'identifiant du projet sur lequel on travaille. Dans l'action par défaut, cet
157
     * attribut n'a pas de valeur.
158
     * @access private
159
     */
160
    var $_id_projet;
161
 
162
    /**
163
     * L'identifiant du répertoire que l'on est en train d'observer. Il sera passé en
164
     * paramètre à la classe HTML_listeDocuments.
165
     * @access private
166
     */
167
    var $_id_repertoire;
168
 
169
     /**
170
     * L'identifiant du fichier que l'on est en train de modifier / supprimer.
171
     * @access private
172
     */
173
    var $_id_document;
174
 
175
    /**
176
     * La présentation de la liste des projets, par défaut vide, signifie en liste.
177
     * Valeurs possibles: arbre
178
     * @access private
179
     */
180
    var $_presentation;
181
 
11 alexandre_ 182
   /**
183
     * Le type du projets, par défaut 0, signifie en pas de type particumier.
184
     * Valeurs possibles: 0, 1, 2, 3 ...
185
     * @access private
186
     */
59 ddelon 187
 
54 alexandre_ 188
     var $_type ;
11 alexandre_ 189
   /**
54 alexandre_ 190
     * Le tableau des projets à ne pas afficher, ni dans l'arbre, ni dans les listes
11 alexandre_ 191
     * @access private
192
     */
54 alexandre_ 193
 	var $_projet_exclu = array();
59 ddelon 194
 
54 alexandre_ 195
 	/**
196
     * parametre indiquant le type d'inscription possible
197
     * @access private
198
     */
199
 	var $_prive = 0 ;
59 ddelon 200
 
2 ddelon 201
    /**
202
     * Méthode principale de la classe. Elle permet d'appeler les méthodes du modules
203
     * projet en fonction de l'action.
204
     *
205
     * @return string
206
     * @access public
207
     */
208
 
209
    function run( )
210
    {
211
        if ($this->_action == '') {
212
            return $this->messageErreur(PROJETCONTROLEUR_ACTION_INVALIDE) ;
213
        }
59 ddelon 214
 
2 ddelon 215
        // Si il n'y a pas d'action mais un projet, on transmet par défaut l'action PROJET_VOIR
216
        if ($this->_id_projet != "" && $this->_action == PROJET_DEFAUT) {
217
            $this->_action = PROJET_ACTION_VOIR_RESUME ;
218
            $this->_url->addQueryString (PROJET_VARIABLE_ID_PROJET, $this->_id_projet) ;
219
        }
220
        if ($this->_id_document != "") {
221
            $this->_url->addQueryString (PROJET_VARIABLE_ID_DOCUMENT, $this->_id_document) ;
222
        }
11 alexandre_ 223
        if ($this->_id_repertoire != '') {
224
            $this->_url->addQueryString (PROJET_VARIABLE_ID_REPERTOIRE, $this->_id_repertoire) ;
225
        }
2 ddelon 226
        $retour = '' ;
227
        if (!defined('PROJET_MENU_AFFICHER_CONTENU_CORPS')) $retour = $this->menuGeneral() ;
59 ddelon 228
 
2 ddelon 229
        switch ($this->_action) {
230
            case PROJET_DEFAUT :
231
                $retour .= $this->mesProjets() ;
232
            break ;
233
            case PROJET_VOIR :
234
                $retour .= $this->accueilProjet();
235
            break ;
236
            case PROJET_NOUVEAU :
237
                $retour .= $this->formulaireProjet(PROJET_NOUVEAU_V) ;
238
            break ;
239
            case PROJET_NOUVEAU_V :
240
                $retour .= $this->nouveauProjetValidation().$this->mesProjets() ;
241
            break ;
242
            case PROJET_NOUVEAU_FICHIER :
243
                $retour .= $this->formulaireFichier(PROJET_NOUVEAU_FICHIER) ;
244
            break ;
245
            case PROJET_ACTION_MODIFIER :
246
                $retour .= $this->formulaireFichier (PROJET_ACTION_MODIFIER) ;
247
            break ;
248
            case PROJET_ACTION_MODIFIER_V :
249
                $retour .= $this->modifierFichier () ;
250
                $this->_action = PROJET_ACTION_VOIR_DOCUMENT ;
251
            break ;
252
            case PROJET_NOUVEAU_FICHIER_V :
253
                $retour .= $this->nouveauFichierValidation() ;
254
                $this->_action = PROJET_ACTION_VOIR_DOCUMENT ;
255
            break ;
256
            case PROJET_ACTION_COUPER :
257
                $retour .= $this->fichierCouper() ;
258
                $this->_action = PROJET_ACTION_VOIR_DOCUMENT ;
259
            break ;
260
            case PROJET_SUPPRESSION_PROJET :
261
                $retour .= $this->suppressionProjet().$this->mesProjets() ;
262
            break ;
263
            case PROJET_NOUVEAU_REPERTOIRE :
264
                $retour .= $this->nouveauRepertoire() ;
265
            break ;
266
            case PROJET_NOUVEAU_REPERTOIRE_V :
11 alexandre_ 267
                $retour .= $this->nouveauRepertoireValidation() ;
268
                $this->_action = PROJET_ACTION_VOIR_DOCUMENT ;
2 ddelon 269
            break ;
270
            case PROJET_SUPPRESSION_FICHIER :
271
                $retour .=$this->suppressionFichier() ;
272
                $this->_action = PROJET_ACTION_VOIR_DOCUMENT ;
273
            break ;
274
            case PROJET_ENVOYER_UN_MAIL :
275
                $retour .= $this->envoyerUnMailFormulaire() ;
276
            break ;
277
            case PROJET_ENVOYER_UN_MAIL_V :
278
                $retour .= $this->envoyerUnMailValidation() ;
279
                $this->_action = PROJET_ACTION_VOIR_FORUM ;
280
            break ;
281
            case PROJET_ACTION_NOUVELLE_LISTE : $retour .= $this->formulaireListe(PROJET_ACTION_NOUVELLE_LISTE) ;
282
            break ;
283
            case PROJET_ACTION_NOUVELLE_LISTE_V : $retour .= $this->nouvelleListeValidation() ;
284
                $this->_action = PROJET_ACTION_VOIR_FORUM ;
285
            break ;
286
            case PROJET_ACTION_SUPPRIMER_LISTE : $retour .= $this->supprimerListe() ;
287
                $this->_action = PROJET_ACTION_VOIR_RESUME ;
288
            break ;
289
            case PROJET_MODIFIER_DESCRIPTION : $retour .= $this->formulaireProjet(PROJET_MODIFIER_DESCRIPTION_V) ;
290
            break ;
291
            case PROJET_MODIFIER_DESCRIPTION_V : $retour .= $this->modifierProjet() ;
292
                $this->_action = PROJET_ACTION_VOIR_RESUME ;
293
            break ;
294
            case  PROJET_ACTION_S_INSCRIRE : $retour .= $this->inscriptionProjet() ;
59 ddelon 295
 
2 ddelon 296
            break ;
297
            case PROJET_ACTION_DESINSCRIPTION_PROJET : $retour .= $this->desinscriptionProjet() ;
298
            break ;
299
            case PROJET_ACTION_CREER_WIKI : $retour .= $this->formulaireWiki() ;
300
            break ;
11 alexandre_ 301
            case PROJET_ACTION_CREER_WIKI_V : $retour .= $this->creationWiki() ;
302
                $this->_action = PROJET_ACTION_VOIR_RESUME ;
2 ddelon 303
            break ;
16 ddelon 304
            case PROJET_ACTION_ASSOCIER_WIKI : $retour .= $this->associerWiki() ;
305
            break ;
306
            case PROJET_ACTION_ASSOCIER_WIKI_V : $retour .= $this->associationWiki() ;
79 alexandre_ 307
            	$this->_action = PROJET_ACTION_VOIR_RESUME ;
16 ddelon 308
            break ;
11 alexandre_ 309
            case PROJET_ACTION_SUPPRIMER_WIKI : $retour .= $this->supprimerWiki();
310
                $this->_action = PROJET_ACTION_VOIR_RESUME ;
2 ddelon 311
            break ;
312
            case PROJET_ACTION_INSCRIPTION_LISTE : $retour .= $this->inscriptionListe() ;
68 alexandre_ 313
                $this->_action = PROJET_ACTION_VOIR_FORUM ;
2 ddelon 314
            break ;
315
            case PROJET_ACTION_DESINSCRIPTION_LISTE : $retour .= $this->desinscriptionListe() ;
68 alexandre_ 316
                $this->_action = PROJET_ACTION_VOIR_FORUM ;
2 ddelon 317
            break ;
318
            case PROJET_ACTION_REFERENCER_LISTE : $retour .= $this->referencerListeExterne() ;
319
            break ;
11 alexandre_ 320
            case PROJET_ACTION_REFERENCER_LISTE_V : $retour .= $this->referencerListeExterneValidation() ;
321
                $this->_action = PROJET_ACTION_VOIR_RESUME ;
2 ddelon 322
            break ;
59 ddelon 323
 
2 ddelon 324
        }
325
        if (!is_int($this->_action)) {
326
            if (file_exists(PROJET_CHEMIN_APPLI.'actions/'.$this->_action.'.php')) {
327
                include_once PROJET_CHEMIN_APPLI.'actions/'.$this->_action.'.php' ;
328
            }
329
        }
330
        return $retour ;
331
    } // end of member function run
332
 
333
    /**
334
     * Permet de fixer la valeur de l'action pour l'objet projetControleur. Cette action
335
     * provient généralement de $_POST['action'] ou $_GET['action']
336
     *
337
     * @param int action L'action à passer provient de l'URL.
338
     * @return void
339
     * @access public
340
     */
341
    function setAction( $action )
342
    {
343
        $this->_action = $action ;
344
    } // end of member function setAction
345
 
346
    /**
59 ddelon 347
     * Constructeur.
2 ddelon 348
     *
349
     * @return void
350
     * @access public
351
     */
352
    function projetControleur(&$dbObjet, &$authObjet, $urlObjet = "")
353
    {
354
        $this->_db = $dbObjet ;
355
        $this->_auth = $authObjet ;
356
        $this->_id_repertoire = 0 ;
11 alexandre_ 357
        $this->_type = '' ;
2 ddelon 358
        if (is_object ($urlObjet)) {
359
            $this->_url = $urlObjet ;
360
        }
361
    } // end of member function projetControleur
59 ddelon 362
 
2 ddelon 363
    /**
364
     * Renvoie la liste des projets auquel participe la personne logguée, avec son
365
     * statut et un lien vers l'action pour gérer le projet.
366
     *
367
     * @return string
368
     * @access public
369
     */
370
    function mesProjets( )
371
    {
34 alexandre_ 372
    	$res = '' ;
2 ddelon 373
        include_once PROJET_CHEMIN_CLASSES.'statut_liste.class.php' ;
374
        include_once PROJET_CHEMIN_CLASSES.'inscription_liste.class.php' ;
375
        $participant = new participe ($this->_db) ;
59 ddelon 376
 
11 alexandre_ 377
        if (PROJET_UTILISE_TYPE && $this->_type != '') {
378
            $projetListe = projet::getProjetDuType($this->_type, $this->_db) ;
28 alexandre_ 379
            if ($this->_presentation == 'arbre')array_push ($projetListe, projet::getProjetRacine($this->_db)) ;
11 alexandre_ 380
        } else {
381
            // Un tableau de tous les projets dans $projetListe
382
            $projetListe = projet::getTousLesProjets($this->_db) ;
383
        }
28 alexandre_ 384
        // Si la liste est vide, on renvoie un texte
385
        if (count($projetListe) == 0) {
34 alexandre_ 386
        	// On inclue un fichier local
387
	        if (file_exists(PROJET_CHEMIN_APPLI.'langues/pro_langues_fr.local.inc.php'))
388
	        	include_once PROJET_CHEMIN_APPLI.'langues/pro_langues_fr.local.inc.php' ;
59 ddelon 389
        	return $res .= PROJET_PAS_DE_LISTE;
390
        }
11 alexandre_ 391
        // Si certain projet sont à exclure, on les exclu
34 alexandre_ 392
        $projet_a_exclure = array() ;
11 alexandre_ 393
        if (count($this->_projet_exclu)) {
34 alexandre_ 394
        	arsort($this->_projet_exclu) ;
11 alexandre_ 395
            foreach ($this->_projet_exclu as $valeur) {
34 alexandre_ 396
            	for ($i = 0; $i < count($projetListe); $i++) {
397
            		if ($projetListe[$i]->getId() == $valeur)  array_push ($projet_a_exclure, $i);}
11 alexandre_ 398
            }
399
        }
34 alexandre_ 400
        foreach ($projet_a_exclure as $valeur) unset ($projetListe[$valeur]) ;
59 ddelon 401
 
34 alexandre_ 402
        // Les entêtes des tableaux
2 ddelon 403
        $tableau_label_statut_action = array (PROJET_GERER, PROJET_GERER, PROJET_GERER_FICHIER, PROJET_VOIR_FICHIER, "---") ;
59 ddelon 404
 
2 ddelon 405
        $auth = $this->_auth->getAuth() ;                       // Pour raccourcir le code
406
        $id_u = $this->_auth->getAuthData(PROJET_CHAMPS_ID) ;   // --------------
68 alexandre_ 407
 
408
		return include_once PROJET_CHEMIN_APPLI.'presentation/'.$this->_presentation.'.php' ;
409
 
410
 
2 ddelon 411
    } // end of member function mesProjets
412
 
413
    /**
414
     * Renvoie le menu général de l'application projet. Avec différents liens selon le
415
     * statut de l'utilisateur.
416
     *
417
     * @return string
418
     * @access public
419
     */
420
    function menuGeneral( )
421
    {
422
        $res = '' ;
423
        $auth = $this->_auth->getAuth() ;
424
        if (!$auth) return ;
425
        $res .= '<div class="menu_projet">'."\n";
426
        $participant = new participe($this->_db) ;
91 alexandre_ 427
        if ($participant->isAdministrateur($this->_auth->getAuthData(PROJET_CHAMPS_ID))) {
428
            $isAdm = 1; $isCoord = 1 ; $isContri = 1 ;
2 ddelon 429
            $label_statut = PROJET_ADMINISTRATEUR;
430
        } else {
431
            $isAdm = 0 ; $isCoord = 0 ; $isContri = 0 ;
432
        }
433
 
434
        // Les menus spécifiques aux projets
91 alexandre_ 435
        if ($this->_id_projet != '') {
2 ddelon 436
            if (!$isCoord) {
437
                $isCoord = $participant->isCoordinateur($this->_auth->getAuthData(PROJET_CHAMPS_ID), $this->_id_projet, $this->_db) ;
438
                if ($isCoord) {
439
                    $label_statut = PROJET_CHEF ;
440
                    $isContri = true ;
441
                }
442
            }
63 alexandre_ 443
            if (!$isContri && !$isAdm) {
2 ddelon 444
                $isContri = $participant->isContributeur($this->_auth->getAuthData(PROJET_CHAMPS_ID), $this->_id_projet, $this->_db) ;
445
                if ($isContri) {
446
                    $label_statut = PROJET_VOUS_PARTICIPEZ ;
447
                } else {
448
                    $label_statut = PROJET_VOUS_N_ETES_PAS_INSCRIT ;
449
                }
450
            }
122 alexandre_ 451
            if ($participant->isEnAttente($this->_auth->getAuthData(PROJET_CHAMPS_ID),$this->_id_projet,$this->_db)) {
452
            	$isEnAttente = true ;
453
            	$label_statut = PROJET_EN_ATTENTE ;
454
            } else {
455
            	$isEnAttente = false ;
456
            }
2 ddelon 457
        }
458
 
459
        if ($isContri || $isAdm) {
460
            $res .= '<h2>' ;
461
            if ($isAdm) $res .= PROJET_VOUS_ETES.' ' ;
462
            $res .= $label_statut.'</h2>'."\n" ;
63 alexandre_ 463
 
2 ddelon 464
        } else {
465
            if ($this->_id_projet != '') $res .= '<h2>'.$label_statut.'</h2>'."\n" ;
466
        }
63 alexandre_ 467
 
2 ddelon 468
        if ($this->_id_projet != '') {
63 alexandre_ 469
        	$projet = new projet ($this->_db, $this->_id_projet) ;
470
			// Participant
122 alexandre_ 471
			if (!$isEnAttente) {
472
				$res .= '<ul id ="projet_groupe_niv1"><li class="projet_niv1">'.PROJET_CONTRIBUTEUR ;
473
				$res .= '<ul id="projet_groupe_niv2_con">' ;
474
			}
63 alexandre_ 475
	        if ($isCoord || $isContri) {
476
	        	$this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_DESINSCRIPTION_PROJET) ;
98 alexandre_ 477
	        	$res .= '<li class="projet_niv2"><a href="'.$this->_url->getURL().'">'.PROJET_SE_DESINSCRIRE."</a></li>\n" ;
63 alexandre_ 478
	        } else {
479
	        	$this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_S_INSCRIRE) ;
122 alexandre_ 480
	        	if (!$isEnAttente) $res .= '<li class="projet_niv2"><a href="'.
481
	        						$this->_url->getURL().'">'.PROJET_S_INSCRIRE_AU_PROJET."</a></li>\n" ;
63 alexandre_ 482
	        }
483
	        // L'action gérer les utilisateurs
484
	        if ($isCoord || $isAdm) {
485
	            $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_VOIR_PARTICIPANT) ;
98 alexandre_ 486
	            $res .= '<li class="projet_niv2"><a href="'.$this->_url->getURL().'">'.PROJET_GESTION_UTILISATEUR."</a></li>\n" ;
63 alexandre_ 487
	        }
488
	        $res .= '</ul></li>' ;
489
 
490
	        //document
491
	        if ($isContri || $isCoord || $isAdm) {
98 alexandre_ 492
		        $res .= '<li class="projet_niv2">'.PROJET_DOCUMENT ;
63 alexandre_ 493
		        // L'action "Mettre un fichier en ligne"
494
		        $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_NOUVEAU_FICHIER) ;
98 alexandre_ 495
		        $res .= '<ul><li class="projet_niv2"><a href="'.$this->_url->getURL().'">'.PROJET_METTRE_FICHIER."</a></li>\n" ;
63 alexandre_ 496
 
497
		        // L'action créer un répertoire
498
		        $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_NOUVEAU_REPERTOIRE) ;
98 alexandre_ 499
		        $res .= '<li class="projet_niv2"><a href="'.$this->_url->getURL().'">'.PROJET_CREER_REP."</a></li>\n" ;
63 alexandre_ 500
				$res .= '</ul></li>' ;
501
 
502
				// Forum
98 alexandre_ 503
				$res .= '<li class="projet_niv1">'.PROJET_FORUM ;
91 alexandre_ 504
				$res .= '<ul id="projet_groupe_niv2_for">' ;
63 alexandre_ 505
				if ($projet->avoirListe()) {
506
 
507
					// On vérifie si l'utilisateur est inscrit ou non à la liste et on ajoute le lien
508
		            //$projet->getListesAssociees();
509
 
510
		            include_once PROJET_CHEMIN_CLASSES.'inscription_liste.class.php';
511
		            foreach ($projet->_listes_associes as $info_liste) {
512
 
513
		                $inscription_liste = new inscription_liste($this->_db) ;
514
		                if ($inscription_liste->getStatutInscrit($info_liste->getId(),  $this->_auth) == 0) {
515
		                    $action_inscription = PROJET_ACTION_INSCRIPTION_LISTE ;
516
		                    $label_inscription = PROJET_RECEVOIR_MESSAGES ;
517
		                } else {
518
		                    // L'action envoyer un mail
519
		                    $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ENVOYER_UN_MAIL) ;
98 alexandre_ 520
		                    $res .= '<li class="projet_niv2"><a href="'.$this->_url->getURL().'">'.PROJET_ECRIRE_LISTE.'</a></li>'."\n" ;
63 alexandre_ 521
		                    $action_inscription = PROJET_ACTION_DESINSCRIPTION_LISTE ;
522
		                    $label_inscription = PROJET_NE_PAS_RECEVOIR_MESSAGES ;
523
		                }
524
		                $this->_url->addQueryString(PROJET_VARIABLE_ACTION, $action_inscription) ;
98 alexandre_ 525
		                $res .= '<li class="projet_niv2"><a href="'.$this->_url->getURL().'">';
63 alexandre_ 526
		                $res .= $label_inscription.'</a></li> ';
527
		            }
96 alexandre_ 528
		            if ($isAdm || PROJET_UTILISATEURS_COORD) {
63 alexandre_ 529
		                $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_SUPPRIMER_LISTE) ;
530
		                $texte_liste = PROJET_SUPPRIMER_LISTE ;
531
		                $onclic = ' onclick="javascript:return confirm(\''.PROJET_SUPPRIMER_LISTE_CONFIRMATION.'\');"' ;
98 alexandre_ 532
		                $res .= '<li class="projet_niv2"><a href="'.$this->_url->getURL().'"'.$onclic.'>'.$texte_liste.'</a></li>'."\n" ;
63 alexandre_ 533
		            }
91 alexandre_ 534
 
63 alexandre_ 535
				} else {
89 alexandre_ 536
					if ($isAdm || $isCoord) {
63 alexandre_ 537
			        	$this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_NOUVELLE_LISTE) ;
538
		                $texte_liste = PROJET_CREER_LISTE ;
539
		                $onclic = '' ;
98 alexandre_ 540
		                $res .= '<li class="projet_niv2"><a href="'.$this->_url->getURL().'"'.$onclic.'>'.$texte_liste.'</a></li>'."\n" ;
63 alexandre_ 541
					}
542
				}
543
				if ($isAdm) {
544
					$this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_REFERENCER_LISTE) ;
98 alexandre_ 545
			        $res .= '<li class="projet_niv2"><a href="'.$this->_url->getURL().'">'.PROJET_REFERENCER_LISTE.'</a></li>'."\n" ;
91 alexandre_ 546
 
63 alexandre_ 547
				}
91 alexandre_ 548
				$res .= '</ul></li>' ;
63 alexandre_ 549
	        }
550
			// Gestion projet
551
			if ($isCoord || $isAdm) {
98 alexandre_ 552
				$res .= '<li class="projet_niv1">'.PROJET_GESTION_PROJET ;
91 alexandre_ 553
				$res .= '<ul id="projet_group_niv2_ges">' ;
63 alexandre_ 554
				// L'action modifier les propriétés du projet
555
	            $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_MODIFIER_DESCRIPTION) ;
98 alexandre_ 556
	            $res .= '<li class="projet_niv2"><a href="'.$this->_url->getURL().'">'.PROJET_MODIFIER_PROPRIETES."</a></li>\n" ;
63 alexandre_ 557
	            if ($isAdm) {
558
		            $this->_url->removeQueryString (PROJET_VARIABLE_ID_PROJET) ;
559
		            $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_NOUVEAU) ;
98 alexandre_ 560
		            $res .= '<li class="projet_niv2"><a href="'.$this->_url->getURL().'">'.PROJET_NOUVEAU_PROJET.'</a></li>'."\n" ;
63 alexandre_ 561
		            $this->_url->removeQueryString(PROJET_VARIABLE_ACTION) ;
562
 
563
		                // L'action supprimer le projet
2 ddelon 564
                    $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_SUPPRESSION_PROJET) ;
565
                    $this->_url->addQueryString(PROJET_VARIABLE_ID_PROJET, $this->_id_projet) ;
98 alexandre_ 566
                    $res .= '<li class="projet_niv2"><a href="'.$this->_url->getURL().'" onclick="javascript:return confirm(\''.PROJET_SUPPRIMER_PROJET_CONFIRMATION.'\');">'
2 ddelon 567
                                .PROJET_SUPPRIMER_LE_PROJET."</a></li>\n" ;
63 alexandre_ 568
		        }
569
	            $res .= '</ul></li>' ;
570
			}
571
 
572
			// Wikini
91 alexandre_ 573
			if ($isAdm || $isCoord) {
98 alexandre_ 574
				$res .= '<li class="projet_niv1">'.PROJET_WIKINI ;
63 alexandre_ 575
	           	$this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_CREER_WIKI) ;
98 alexandre_ 576
	           	$res .= '<ul><li class="projet_niv2"><a href="'.$this->_url->getURL()."\">".PROJET_CREER_WIKI."</a></li>\n" ;
63 alexandre_ 577
				// L'action choisir un wikini
578
	            $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_ASSOCIER_WIKI) ;
98 alexandre_ 579
	            $res .= '<li class="projet_niv2"><a href="'.$this->_url->getURL()."\">".PROJET_ASSOCIER_WIKI."</a></li>\n" ;
63 alexandre_ 580
	            $res .= '</ul></li>' ;
581
			}
582
        } else {
583
        	if ($isAdm) {
98 alexandre_ 584
        		$res .= '<li class="projet_niv1">'.PROJET_GESTION_PROJET ;
63 alexandre_ 585
		 		$res .= '<ul>' ;
586
      			$this->_url->removeQueryString (PROJET_VARIABLE_ID_PROJET) ;
587
		        $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_NOUVEAU) ;
98 alexandre_ 588
		        $res .= '<li class="projet_niv2"><a href="'.$this->_url->getURL().'">'.PROJET_NOUVEAU_PROJET.'</a></li>'."\n" ;
63 alexandre_ 589
		        $this->_url->removeQueryString(PROJET_VARIABLE_ACTION) ;
590
		        $res .= '</ul></li>' ;
591
        	}
2 ddelon 592
        }
63 alexandre_ 593
        $res .= '</ul>' ;
2 ddelon 594
        $res .= "</div>\n" ;
68 alexandre_ 595
        $this->_url->removeQueryString (PROJET_VARIABLE_ACTION) ;
2 ddelon 596
        return $res ;
597
    } // end of member function menuGeneral
598
 
599
    /**
600
     * Renvoie le formulaire de création d'un projet.
601
     *
602
     * @return string
603
     * @access public
604
     */
605
    function formulaireProjet($action)
606
    {
34 alexandre_ 607
    	if (!$this->_auth->getAuth()) {
608
    		return PROJET_TEXTE_NON_IDENTIFIE;
609
    	}
2 ddelon 610
        $this->_url->addQueryString(PROJET_VARIABLE_ACTION, $action) ;
611
        $formulaire_projet = new HTML_formulaireProjet('formulaire_projet', 'post',str_replace ("&amp;", "&", $this->_url->getURL())) ;
11 alexandre_ 612
        $tableau_type = '' ;
613
        if (PROJET_UTILISE_TYPE) {
614
            include_once PROJET_CHEMIN_CLASSES.'projet_type.class.php' ;
615
            $tableau_type = projet_type::getTousLesTypes($this->_db) ;
616
        }
617
        $formulaire_projet->construitFormulaire(projet::getTousLesProjets($this->_db), $tableau_type) ;
2 ddelon 618
        if ($action == PROJET_MODIFIER_DESCRIPTION_V) {
619
            $projet = new projet($this->_db, $this->_id_projet) ;
620
            $valeurs_par_defaut = array (   'projet_titre' => $projet->getTitre(),
621
                                            'projet_description' => $projet->getDescription(),
622
                                            'projet_asso' => $projet->getIdPere(),
623
                                            'projet_wikini' => $projet->getWikini(),
624
                                            'projet_resume' => $projet->getResume(),
11 alexandre_ 625
                                            'projet_espace_internet' => $projet->getEspaceInternet(),
122 alexandre_ 626
                                            'projet_type'=> $projet->getType(),
627
                                            'projet_moderation' => $projet->isModere()
2 ddelon 628
                                        ) ;
629
            $formulaire_projet->setDefaults($valeurs_par_defaut) ;
122 alexandre_ 630
        } else {
631
        	$formulaire_projet->setDefaults (array ('projet_moderation'=> '0')) ;
2 ddelon 632
        }
89 alexandre_ 633
        $res = PROJET_PROPOSER_PROJET ;
634
        return $res . $formulaire_projet->toHTML() ;
2 ddelon 635
    } // end of member function nouveauProjet
636
 
637
    /**
638
     * Valide le formulaire et appelle la fonction d'insertion.
639
     *
640
     * @return string
641
     * @access public
642
     */
643
    function nouveauProjetValidation( )
644
    {
645
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_NOUVEAU_V) ;
646
        $formulaire_projet = new HTML_formulaireProjet('formulaire_projet', 'post', str_replace ('&amp;', '&', $this->_url->getURL())) ;
647
        $formulaire_projet->construitFormulaire(projet::getTousLesProjets($this->_db)) ;
648
        if ($formulaire_projet->validate()) {
59 ddelon 649
 
2 ddelon 650
            $projet = new projet ($this->_db) ;
651
            $projet->setCheminRepertoire (PROJET_CHEMIN_FICHIER) ;
652
            if (!$projet->enregistrerSQL($formulaire_projet->getSubmitValues())) {
653
                return 'erreur' ;
654
            }
34 alexandre_ 655
            // On inscrit le déposant du projet en tant que coordinateur
656
            if (PROJET_UTILISATEURS_COORD) {
657
		        // Si le projet n'a pas de liste, on inscrit directement
658
		        $participant = new participe($this->_db) ;
659
	            $participant->setStatut(1, $this->_auth->getAuthData (PROJET_CHAMPS_ID), $projet->getId()) ;
660
            }
2 ddelon 661
        } else {
662
            return $formulaire_projet->toHTML() ;
663
        }
664
    } // end of member function nouveauProjetValidation
665
 
666
    /**
667
     * Valide le formulaire et appelle la fonction de mise à jour.
668
     *
669
     * @return void
670
     * @access public
671
     */
672
    function modifierProjet( )
673
    {
674
        // création de l'objet projet courant
675
        $projet = new projet ($this->_db, $this->_id_projet) ;
676
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_ACTION_MODIFIER_V) ;
677
        $formulaire_projet = new HTML_formulaireProjet('formulaire_projet', 'post', str_replace ('&amp;', '&', $this->_url->getURL())) ;
678
        $formulaire_projet->construitFormulaire(projet::getTousLesProjets($this->_db)) ;
679
        if ($formulaire_projet->validate()) {
680
            $projet->majSQL($formulaire_projet->getSubmitValues()) ;
681
        } else {
682
            return $formulaire_projet->toHTML() ;
683
        }
684
        unset ($projet) ;
685
    } // end of member function nouveauFichierValidation
686
 
687
    /**
688
     * Renvoie le formulaire d'upload d'un fichier.
689
     *
690
     * @return void
691
     * @access public
692
     */
693
    function formulaireFichier($action)
694
    {
695
        $res = '<h1>'.PROJET_FICHIER_MISE_EN_LIGNE.'</h1>'."\n" ;
696
        if (isset($_SESSION['formulaire_document'])) {
697
            unset ($_SESSION['formulaire_document']) ;
698
        }
699
        $action_future = $action == PROJET_NOUVEAU_FICHIER ? PROJET_NOUVEAU_FICHIER_V : PROJET_ACTION_MODIFIER_V ;
700
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, $action_future) ;
701
        if ($this->_id_repertoire != '') $this->_url->addQueryString (PROJET_VARIABLE_ID_REPERTOIRE, $this->_id_repertoire) ;
702
        $formulaire_document = new HTML_formulaireDocument('formulaire_document', 'post',preg_replace ("/&amp;/", "&", $this->_url->getURL())) ;
703
        $formulaire_document->construitFormulaire($action) ;
704
        if ($action == PROJET_ACTION_MODIFIER) {
59 ddelon 705
 
2 ddelon 706
            $document = new document($this->_id_document, $this->_db, PROJET_CHEMIN_FICHIER, PROJET_CHEMIN_ICONES) ;
707
            // On affecte dans un tableau les valeurs de chaque champs du formulaire avec le nom de chaque élément de formulaire
708
            // voir HTML_formulaireDocument
709
            $valeurs_par_defaut = array ('document_nom' => $document->getNomLong(),
710
                                         'document_description' => $document->getDescription(),
711
                                         'document_visibilite' => $document->getVisibilite()) ;
59 ddelon 712
 
713
            // On rajoute un champs caché avec l'identifiant du document
2 ddelon 714
            $formulaire_document->addElement ('hidden', 'id_document', $this->_id_document) ;
715
            $formulaire_document->setDefaults($valeurs_par_defaut) ;
716
        } else {
717
            $formulaire_document->setDefaults (array ('document_visibilite'=> 'public')) ;
718
        }
719
        return $res.$formulaire_document->toHTML() ;
720
 
721
    } // end of member function nouveauFichier
59 ddelon 722
 
2 ddelon 723
    /**
724
    *   Présente un formulaire pour déplacer un fichier
725
    *
726
    *
727
    */
728
    function fichierCouper() {
729
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
730
        $projet = new projet ($this->_db, $this->_id_projet) ;
59 ddelon 731
 
2 ddelon 732
        $res = '<h1>'.PROJET_PROJET.' : '.$projet->getTitre().'</h1>' ;
733
        $document = new document($this->_id_document, $this->_db, PROJET_CHEMIN_FICHIER) ;
734
        // On traite le cas où l'on vient de déplacer un fichier
59 ddelon 735
 
2 ddelon 736
        if (isset ($_POST['projet_repertoire'])) {
737
            if (!$document -> deplace ($_POST['projet_repertoire'], $projet->getNomRepertoire())) {
738
                echo 'echec du déplacement' ;
739
            }
740
            return ;
741
        }
742
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireCouperColler.class.php' ;
743
        $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_COUPER) ;
744
        $HTML_formulaireCouperColler = new HTML_formulaireCouperColler('formulaire_couper_coller', 'post', str_replace('&amp;', '&', $this->_url->getURL())) ;
745
        $HTML_formulaireCouperColler -> construitFormulaire($projet->getListeRepertoireHierarchisee()) ;
746
        return $res.$HTML_formulaireCouperColler->toHTML('<img src="'.PROJET_CHEMIN_ICONES.$document->getCheminIcone().'" /> '.$document->getNomLong());
747
    }
748
    /**
749
     * Supprime un fichier.
750
     *
751
     * @return void
752
     * @access public
753
     */
754
    function suppressionFichier( )
755
    {
756
        if ($this->_id_document == "") {
757
            return $this->messageErreur(PROJETCONTROLEUR_PAS_DE_DOCUMENT_SELECTIONNE) ;
758
        }
759
        $projet = new projet ($this->_db, $this->_id_projet) ;
760
        $document = new document($this->_id_document, $this->_db, PROJET_CHEMIN_FICHIER) ;
761
        $document->suppression() ;
762
        $document->suppressionSQL() ;
763
        return ;
764
 
765
    } // end of member function nouveauFichier
766
 
767
    /**
768
     * Renvoie le formulaire de création d'un répertoire.
769
     *
770
     * @return void
771
     * @access public
772
     */
773
    function nouveauRepertoire( )
774
    {
775
        $res = '<h1>'.PROJET_REP_CREER.'</h1>'."\n" ;
776
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_NOUVEAU_REPERTOIRE_V) ;
777
        $formulaire_repertoire = new HTML_formulaireDocument('formulaire_repertoire', 'post',preg_replace ("/&amp;/", "&", $this->_url->getURL())) ;
778
        $formulaire_repertoire->setType ('repertoire') ;
779
        $formulaire_repertoire->construitFormulaire() ;
780
        $formulaire_repertoire->setDefaults (array ('document_visibilite'=> 'public')) ;
781
        return $res.$formulaire_repertoire->toHTML() ;
782
 
783
    } // end of member function nouveauFichier
784
 
785
    /**
786
     * Valide le formulaire et appelle la fonction d'insertion.
787
     *
788
     * @return void
789
     * @access public
790
     */
791
    function nouveauFichierValidation( )
792
    {
793
        // création de l'objet projet courant
794
        $projet = new projet ($this->_db, $this->_id_projet) ;
795
        if (isset($_SESSION['formulaire_document']) && $_SESSION['formulaire_document'] == 'valide') {
796
            include_once PROJET_CHEMIN_APPLI.'actions/documents.php' ;
797
            return $retour;
798
        }
799
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_NOUVEAU_FICHIER_V) ;
800
        $formulaire_document = new HTML_formulaireDocument('formulaire_document', 'post', preg_replace ("/&amp;/", "&", $this->_url->getURL())) ;
801
        $formulaire_document->construitFormulaire() ;
802
        if ($formulaire_document->validate()) {
803
            // Création d'un objet document vide
804
            $document = new document ("", $this->_db) ;
805
            // avant d'appeler la méthode enregistrerSQL, il faut indiquer l'identifiant du projet et l'identifiant du propriétaire
806
            $document->setIdProjet ($this->_id_projet) ;
807
            $document->setIdProprietaire ($this->_auth->getAuthData (PROJET_CHAMPS_ID)) ;
59 ddelon 808
 
2 ddelon 809
            // On passe aussi le numéro de répertoire s'il existe
810
            if ($this->_id_repertoire != '') $document->setIdRepertoire($this->_id_repertoire) ;
59 ddelon 811
 
2 ddelon 812
            $chemin_upload = $document->calculeCheminUploaded($projet->getNomRepertoire()) ;
59 ddelon 813
 
2 ddelon 814
            if (!$document->upload (PROJET_CHEMIN_FICHIER.$projet->getNomRepertoire().'/'.$chemin_upload)) {
815
                echo 'Echec de l\'upload' ;
816
                trigger_error('echec d\'upload !', E_USER_ERROR) ;
817
            }
59 ddelon 818
 
819
 
2 ddelon 820
            $document->enregistrerSQL($formulaire_document->getSubmitValues(), $projet->getNomRepertoire().'/'.$chemin_upload) ;
821
            // On ajoute une information de session
822
            $_SESSION['formulaire_document'] = 'valide';
823
        } else {
824
            return $formulaire_document->toHTML() ;
825
        }
826
        unset ($projet) ;
827
    } // end of member function nouveauFichierValidation
828
 
829
    /**
830
     * Valide le formulaire et appelle la fonction d'insertion.
831
     *
832
     * @return void
833
     * @access public
834
     */
835
    function modifierFichier( )
836
    {
837
        // création de l'objet projet courant
838
        $projet = new projet ($this->_db, $this->_id_projet) ;
839
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_ACTION_MODIFIER_V) ;
840
        $formulaire_document = new HTML_formulaireDocument('formulaire_document', 'post',preg_replace ("/&amp;/", "&", $this->_url->getURL())) ;
841
        $formulaire_document->construitFormulaire(PROJET_ACTION_MODIFIER_V) ;
842
        if ($formulaire_document->validate()) {
843
            // Création d'un objet document vide
844
            $document = new document ($this->_id_document, $this->_db) ;
845
            // On passe aussi le numéro de répertoire s'il existe
846
            if ($this->_id_repertoire != '') $document->setIdRepertoire($this->_id_repertoire) ;
847
            $document->majSQL($formulaire_document->getSubmitValues()) ;
848
        } else {
849
            return $formulaire_document->toHTML() ;
850
        }
851
        unset ($projet) ;
852
    } // end of member function nouveauFichierValidation
853
 
854
    /**
855
     * Valide le formulaire et appelle la fonction d'insertion.
856
     *
857
     * @return void
858
     * @access public
859
     */
860
    function nouveauRepertoireValidation( )
861
    {
862
        // création de l'objet projet courant
863
        $projet = new projet ($this->_db, $this->_id_projet) ;
59 ddelon 864
 
2 ddelon 865
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_NOUVEAU_FICHIER_V) ;
866
        $formulaire_repertoire = new HTML_formulaireDocument('formulaire_repertoire', 'post',preg_replace ("/&amp;/", "&", $this->_url->getURL())) ;
867
        $formulaire_repertoire->setType ('repertoire') ;
868
        $formulaire_repertoire->construitFormulaire() ;
869
        if ($formulaire_repertoire->validate()) {
59 ddelon 870
            // Création d'un objet
2 ddelon 871
            $document = new document ("", $this->_db) ;
872
            // avant d'appeler la méthode enregistrerSQL, il faut indiquer l'identifiant du projet et l'identifiant du propriétaire
873
            $document->setIdProjet ($this->_id_projet) ;
874
            $document->setIdProprietaire ($this->_auth->getAuthData (PROJET_CHAMPS_ID)) ;
59 ddelon 875
 
2 ddelon 876
            // On passe aussi le numéro de répertoire s'il existe
877
            if ($this->_id_repertoire != '') $document->setIdRepertoire($this->_id_repertoire) ;
59 ddelon 878
 
2 ddelon 879
            $lien = $document->enregistrerSQL($formulaire_repertoire->getSubmitValues(), $projet->getNomRepertoire()) ;
59 ddelon 880
 
2 ddelon 881
            // La création du répertoire sur le disque, chemin / nom_repertoire_projet / id_repertoire
882
            if (!mkdir (PROJET_CHEMIN_FICHIER.$lien)) {
59 ddelon 883
 
2 ddelon 884
                $document->suppressionSQL() ;
885
                return $this->messageErreur(PROJETCONTROLEUR_ERREUR_CREATION_REPERTOIRE).'<br />'.PROJET_CHEMIN_FICHIER.$lien  ;
886
            }
887
        } else {
888
            return $formulaire_repertoire->toHTML() ;
889
        }
890
    } // end of member function nouveauFichierValidation
891
 
892
 
893
    /**
894
     * Permet de spécifier au controleur sur quel projet l'on travaille.
895
     *
896
     * @param int id_projet L'identifiant du projet.
897
     * @return void
898
     * @access public
899
     */
900
    function setIdProjet( $id_projet )
901
    {
902
        $this->_id_projet = $id_projet ;
59 ddelon 903
 
2 ddelon 904
    } // end of member function setIdProjet
905
 
906
    /**
907
     * Renvoie la page d'accueil d'un projet.
908
     *
909
     * @return string
910
     * @access public
911
     */
912
    function accueilProjet( )
913
    {
914
        $res = '' ;
915
        // création de l'objet projet courant
916
        $projet = new projet ($this->_db, $this->_id_projet) ;
59 ddelon 917
 
2 ddelon 918
        // récupération de la liste des documents associés
919
        $liste_documents = $projet->getListesDocuments(PROJET_CHEMIN_FICHIER, PROJET_CHEMIN_ICONES) ;
59 ddelon 920
 
2 ddelon 921
        // création de la vue liste de document, on nettoie l'url
922
        $this->_url->removeQueryString(PROJET_VARIABLE_ACTION) ;
923
        include_once PROJET_CHEMIN_CLASSES.'HTML_listeDocuments.class.php' ;
924
        $vue_liste_document = new HTML_listeDocuments($this->_url, false, $this->_id_repertoire) ;
59 ddelon 925
 
2 ddelon 926
        // réglage de paramètres de la vue
927
        $vue_liste_document->setAction (array ("couper" => PROJET_ACTION_COUPER, "modifier" => PROJET_ACTION_MODIFIER, "supprimer" => PROJET_SUPPRESSION_FICHIER)) ;
928
        $vue_liste_document->setCheminIcones(PROJET_CHEMIN_ICONES) ;
59 ddelon 929
 
930
 
2 ddelon 931
        $tableau_navigation = document::getCheminIdRepertoire($this->_id_repertoire, $this->_db) ;
59 ddelon 932
 
2 ddelon 933
        $vue_liste_document->setCheminNavigation ($tableau_navigation) ;
934
        // vérification des droits de l'utilisateur
935
        $entete_liste = array (PROJET_FICHIERS_NOM, PROJET_FICHIERS_TAILLE, PROJET_FICHIERS_CREE_LE) ;
59 ddelon 936
 
2 ddelon 937
        if ($this->_auth->getAuth()) {
938
            $participant = new participe($this->_db) ;
939
            $id_u = $this->_auth->getAuthData(PROJET_CHAMPS_ID) ;
940
            $isCoord = $participant->isCoordinateur($id_u, $this->_id_projet, $this->_db) ;
941
            if ($isCoord) $droits = PROJET_DROIT_COORDINATEUR ;
942
            $isAdm = participe::isAdministrateur($this->_auth->getAuthData(PROJET_CHAMPS_ID), $this->_db) ;
943
            if ($isAdm) $droits = PROJET_DROIT_ADMINISTRATEUR ;
944
            if ($isAdm) $isCoord = true ;
59 ddelon 945
 
2 ddelon 946
            $statut = participe::getStatutSurProjetCourant ($this->_auth->getAuthData(PROJET_CHAMPS_ID), $this->_id_projet, $this->_db) ;
947
            // si participant, on ajoute le champs visibilite
59 ddelon 948
 
2 ddelon 949
            if ($statut !='' || $isAdm) {
950
                array_push ($entete_liste, PROJET_FICHIERS_VISIBILITE) ;
951
            }
952
            // si chef de projet ou si propriétaire d'au moins 1 document
953
            $proprietaire_un_document = false ;
59 ddelon 954
 
2 ddelon 955
            foreach ($liste_documents as $document) {
956
                if ($this->_auth->getAuthData(PROJET_CHAMPS_ID) == $document) {
957
                    $proprietaire_un_document = true ;
958
                    $droits = PROJET_DROIT_PROPRIETAIRE ;
959
                }
960
            }
961
            if ($statut > 0 || $proprietaire_un_document) {
962
                array_push ($entete_liste, PROJET_ACTION) ;
963
            }
964
        } else {
965
            $droits = PROJET_DROIT_AUCUN ;
966
        }
967
        if (!isset($droits)) $droits = PROJET_DROIT_AUCUN ;
59 ddelon 968
 
2 ddelon 969
        $vue_liste_document->construitEntete($entete_liste) ;
970
        $vue_liste_document->construitListe ($liste_documents, $droits) ;
59 ddelon 971
 
2 ddelon 972
        $wiki_res = '' ;
973
        // Les wikinis associés au projet
974
        if ($projet->getWikini()) {
975
            $wiki_res .= '<div><a href="'.PROJET_URL_WIKINI.'wakka.php?wiki=PagePrincipale&wikini='.$projet->getWikini().'">'.PROJET_URL_WIKINI.'</a>' ;
976
            if ($this->_auth->getAuth() && $isCoord) {
977
                $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_SUPPRIMER_WIKI) ;
978
                $wiki_res .= ' <a href="'.$this->_url->getURL().'" onclick="javascript:return confirm(\''.PROJET_WIKINI_SUPPRIMER.' ?\')">'.PROJET_WIKINI_SUPPRIMER.'</a>' ;
979
            }
980
            $wiki_res .= '</div>' ;
981
        } else {
982
            $wiki_res .= '<div>'.PROJET_WIKINI_PAS.'</div>'."\n" ;
983
        }
984
        // On charge les listes de discussion du projet
985
        // Pour le moment seul ezmlm est supportée
59 ddelon 986
 
2 ddelon 987
        $projet->getListesAssociees();
988
        $sortie_liste = '' ;
59 ddelon 989
 
2 ddelon 990
        if ($projet->avoirListe()) {
991
            foreach ($projet->_listes_associes as $info_liste) {
59 ddelon 992
 
2 ddelon 993
                $liste = new ezmlm_php() ;
994
                // Paramétrage de la liste
59 ddelon 995
 
2 ddelon 996
                $liste->listdir = PROJET_CHEMIN_LISTES.$info_liste->getDomaine().'/'.$info_liste->getNom();
997
                $liste->listname = $info_liste->getNom() ;
998
                $liste->listdomain = $info_liste->getDomaine();
59 ddelon 999
 
2 ddelon 1000
                if (isset ($GLOBALS['action']) && $GLOBALS['action'] != '') {
1001
                    $liste->set_action($GLOBALS['action']) ;
1002
                    $liste->set_actionargs($GLOBALS['actionargs']) ;
1003
                } else {
1004
                    $liste->set_action('list_info') ;
1005
                }
1006
                $liste->sendheaders	= false;
1007
                $liste->sendbody        = false;
1008
                $liste->sendfooters    = false;
1009
                $liste->forcehref = $this->_url->getURL() ;
59 ddelon 1010
 
2 ddelon 1011
                ob_start() ;
1012
                print '<span class="heading">Liste <strong>' . $info_liste->getAdresseEnvoi() ;
1013
                print "</strong></span><br />\n";
1014
                if ($this->_auth->getAuth()) {
1015
                    include_once PROJET_CHEMIN_CLASSES.'inscription_liste.class.php';
1016
                    $inscription_liste = new inscription_liste($this->_db) ;
11 alexandre_ 1017
                    if ($inscription_liste->getStatutInscrit( $info_liste->getId(),  $this->_auth) == '') {
2 ddelon 1018
                        $action_inscription = PROJET_ACTION_INSCRIPTION_LISTE ;
1019
                        $label_inscription = PROJET_S_INSCRIRE ;
1020
                    } else {
1021
                        $action_inscription = PROJET_ACTION_DESINSCRIPTION_LISTE ;
1022
                        $label_inscription = PROJET_SE_DESINSCRIRE ;
1023
                    }
1024
                    $this->_url->addQueryString(PROJET_VARIABLE_ACTION, $action_inscription) ;
1025
                    print '<a href="'.$this->_url->getURL().'">';
1026
                    print $label_inscription.'</a><br /> ';
1027
                }
1028
                print "\n<hr noshade><br />\n";
1029
                $this->_url->removeQueryString(PROJET_VARIABLE_ACTION) ;
1030
                switch ($liste->action) {
1031
                    case "show_msg":
1032
                        if (count($liste->actionargs) < 2) {
1033
                            $liste->error(EZMLM_INVALID_SYNTAX,TRUE);
1034
                        }
1035
                        $show_msg = new ezmlm_msgdisplay();
1036
                        $show_msg->listdir = $liste->listdir ;
1037
                        $show_msg->forcehref = $this->_url->getURL();
1038
                        // actionargs[0] contient le nom du répertoire et actionargs[1] le nom du fichier
1039
                        // On appelle la fonction qui affiche un fichier
1040
                        $show_msg->display($liste->actionargs[0] . "/" . $liste->actionargs[1]);
1041
                        break;
59 ddelon 1042
 
2 ddelon 1043
                    case "list_info":
1044
                        $info = new ezmlm_listinfo();
1045
                        if (!$info) return 'Les fichiers de la liste ne sont pas visible sur le serveur' ;
1046
                        $info->forcehref = $this->_url->getURL();
1047
                        $info->listdir = $liste->listdir ;
1048
                        $info->listname = $info_liste->getNom();
1049
                        $info->listdomain = $info_liste->getDomaine() ;
59 ddelon 1050
 
2 ddelon 1051
                        if (!$info->display()) {
1052
                            echo 'Pas de message dans cette liste' ;
1053
                        }
1054
                        break;
1055
                    case "show_threads":
1056
                        $threads = new ezmlm_threads();
1057
                        $threads->forcehref = $this->_url->getURL() ;
1058
                        $threads->listdir = $liste->listdir ;
1059
                        $threads->listname = $info_liste->getNom() ;
1060
                        $threads->listdomain = $info_liste->getDomaine() ;
1061
                        $threads->tempdir = PROJET_CHEMIN_APPLI.'/tmp' ;
1062
                        $threads->load($liste->actionargs[0]);
1063
                        break;
1064
                    case "show_author_msgs" :
1065
                        $author = new ezmlm_author();
1066
                        $author->listdir = $liste->listdir ;
1067
                        $author->listname = $info_liste->getNom() ;
1068
                        $author->listdomain = $info_liste->getDomaine() ;
1069
                        $author->forcehref = $this->_url->getURL() ;
1070
                        $author->display($liste->actionargs[0]);
1071
                    break ;
1072
                }
1073
                $sortie_liste = ob_get_contents() ;
1074
                ob_end_clean() ;
1075
            }
1076
        } else {
1077
            $sortie_liste = '<div>'.PROJET_PAS_DE_LISTE.'</div>'."\n" ;
1078
        }
59 ddelon 1079
 
2 ddelon 1080
        $res .= "<h1>".$projet->getTitre()."</h1>" ;
1081
        $res .= '<div>'.$projet->getDescription().'</div>'."\n" ;
1082
        $res .= '<h2>'.PROJET_WIKI_ASSOCIE.'</h2>' ;
1083
        $res .= $wiki_res ;
1084
        $res .= '<h2>'.PROJET_FICHIERS_ASSOCIES.'</h2>'."\n" ;
1085
        $res .= $vue_liste_document->toHTML() ;
1086
        $res .= '<h2>'.PROJET_LISTES_ASSOCIEES.'</h2>'."\n" ;
1087
        $res .= $sortie_liste ;
59 ddelon 1088
 
2 ddelon 1089
        include_once PROJET_CHEMIN_CLASSES.'liste_externe.class.php' ;
1090
        $listes_ext = new liste_externe ($this->_db) ;
1091
        $tableau_liste = $listes_ext->getListesAssociees($this->_id_projet) ;
59 ddelon 1092
 
2 ddelon 1093
        if (count ($tableau_liste) != 0) {
1094
            $res .= '<h2>'.PROJET_LISTES_EXTERNES_ASSOCIEES.'</h2>'."\n" ;
1095
            for ($i = 0; $i < count ($tableau_liste); $i++) {
1096
                $info_liste = $listes_ext->getInfoListe($tableau_liste[$i]) ;
1097
                $res .= '<h2>'.$info_liste->AGO_A_NOMGRPLG.'</h2>'."\n" ;
1098
                $res .= '<p>'.$info_liste->AGO_A_RESUMLG.'</p>'."\n" ;
1099
                $res .= '<p><a href="'.$info_liste->AGO_A_URLGRP.'">'.$info_liste->AGO_A_URLGRP.'</a></p>'."\n" ;
1100
                $res .= '<br />'."\n" ;
1101
            }
1102
        }
1103
        return $res ;
1104
    } // end of member function accueilProjet
1105
 
1106
    /**
1107
     * Permet de spécifier quel répertoire, dans la vue de document afficher. Il sera
1108
     * passé en paramètre à la classe HTML_listeDocuments.
1109
     *
1110
     * @param int id_repertoire L'identifiant du répertoire à afficher.
1111
     * @return void
1112
     * @access public
1113
     */
1114
    function setIdRepertoire( $id_repertoire )
1115
    {
1116
        $this->_id_repertoire = $id_repertoire ;
1117
    } // end of member function setIdRepertoire
1118
 
1119
    /**
1120
     * Supprime un projet et tout ce qui va avec.
1121
     *
1122
     * @return void
1123
     * @access public
1124
     */
1125
    function suppressionProjet( )
1126
    {
1127
        $projet = new projet ($this->_db, $this->_id_projet) ;
1128
        $projet->setCheminRepertoire (PROJET_CHEMIN_FICHIER) ;
1129
        $projet->getListesAssociees() ;
1130
        if ($projet->avoirListe()) $projet->supprimerListe($projet->_listes_associes[0]) ;
1131
        $msg = $projet->suppressionSQL() ;
1132
        unset ($this->_id_projet) ; unset($_GET['id_projet']);
1133
        return $msg ;
1134
    } // end of member function suppressionProjet
1135
 
1136
    /**
1137
     * Permet d'indiquer au controleur sur quel document on travaille.
1138
     *
59 ddelon 1139
     * @param int id_document
2 ddelon 1140
     * @return void
1141
     * @access public
1142
     */
1143
    function setIdDocument( $id_document )
1144
    {
1145
        $this->_id_document = $id_document ;
1146
    } // end of member function setIdDocument
1147
 
1148
 
1149
    /**
1150
     * Renvoie le formulaire d'envoie de mail
1151
     *
1152
     * @return void
1153
     * @access public
1154
     */
1155
    function envoyerUnMailFormulaire( )
1156
    {
74 alexandre_ 1157
    	if (!$this->_auth->getAuth()) {
1158
    		return PROJET_LISTE_PROJET;
1159
    	}
96 alexandre_ 1160
    	if (isset($_SESSION['formulaire_mail'])) {
1161
            unset ($_SESSION['formulaire_mail']) ;
1162
        }
2 ddelon 1163
        $res = '<h1>'.PROJET_ECRIRE_LISTE.'</h1>'."\n" ;
1164
        $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ENVOYER_UN_MAIL_V) ;
1165
        $formulaire_mail = new HTML_formulaireMail('formulaire_mail', 'post',preg_replace ("/&amp;/", "&", $this->_url->getURL())) ;
1166
        $formulaire_mail->construitFormulaire() ;
1167
        return $res.$formulaire_mail->toHTML() ;
1168
    } // end of member function envoyerUnMailFormulaire
1169
 
1170
    /**
1171
     * Envoie le mail
1172
     *
1173
     * @return void
1174
     * @access public
1175
     */
1176
    function envoyerUnMailValidation( )
1177
    {
1178
        // Vérifications
96 alexandre_ 1179
        if (isset($_SESSION['formulaire_mail']) && $_SESSION['formulaire_mail'] == 'valide') {
1180
            include_once PROJET_CHEMIN_APPLI.'actions/forums.php' ;
1181
            return $retour;
1182
        }
122 alexandre_ 1183
 
2 ddelon 1184
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_ENVOYER_UN_MAIL_V );
1185
        $formulaire_mail = new HTML_formulaireMail('formulaire_mail', 'post', preg_replace ("/&amp;/", "&", $this->_url->getURL())) ;
1186
        $formulaire_mail->construitFormulaire() ;
1187
        if ($formulaire_mail->validate()) {
1188
            // création de l'objet projet courant
1189
            $projet = new projet ($this->_db, $this->_id_projet) ;
1190
            $info_liste = $projet->getListesAssociees() ;
1191
            $valeurs_mail = $formulaire_mail->getSubmitValues() ;
1192
            // Pour envoyer le mail on utilise la classe Mail de PEAR
1193
            // on a besoin du mail de l'inscrit
1194
 
1195
            $entetes['From'] = $this->_auth->getUserName();
1196
            $entetes['To'] = $projet->_listes_associes[0]->getAdresseEnvoi() ;
1197
            $entetes['Subject'] = $valeurs_mail['mail_titre'] ;
63 alexandre_ 1198
            $entetes['Date'] = date ('D, M j G:i:s \C\E\S\T Y') ;
2 ddelon 1199
            $entetes['Message-ID'] = md5(time()).'@'.$projet->_listes_associes[0]->getNom().'.'.$projet->_listes_associes[0]->getDomaine() ;
1200
            $entetes['reply-to'] = $projet->_listes_associes[0]->getAdresseEnvoi() ;
1201
            $entetes['Content-Type'] = 'text/plain' ;
1202
            // Traitement de la reference s'il s'agit d'une réponse
1203
            if (isset ($_POST['messageid'])) {
1204
                $entetes['In-Reply-To'] = $_POST['messageid'] ;
1205
            }
1206
            $objet_mail =& Mail::factory('smtp');
1207
            $objet_mail->send($entetes['To'], $entetes, $valeurs_mail['mail_corps']);
96 alexandre_ 1208
            $_SESSION['formulaire_mail'] = 'valide';
2 ddelon 1209
            return  ;
1210
        } else {
1211
            return $formulaire_mail->toHTML() ;
1212
        }
1213
    } // end of member function envoyerUnMailValidation
1214
 
1215
   /**
1216
     * Renvoie le formulaire de création d'une liste.
1217
     *
1218
     * @param int action Indique le type d'action,  PROJET_ACTION_NOUVELLE_LISTE
1219
     * @return string
1220
     * @access public
1221
     */
1222
    function formulaireListe( $action )
1223
    {
1224
        $res = '<h1>'.PROJET_CREATION_LISTE.'</h1>'."\n" ;
1225
        $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_NOUVELLE_LISTE_V) ;
1226
        $formulaire_liste = new HTML_formulaireListe('formulaire_liste', 'post',preg_replace ("/&amp;/", "&", $this->_url->getURL())) ;
1227
        $formulaire_liste->construitFormulaire() ;
1228
        $formulaire_liste->setDefaults(array('domaine_liste' => PROJET_DOMAINE_LISTE)) ;
1229
        $formulaire_liste->updateElementAttr('domaine_liste', array('readonly' => 'readonly')) ;
1230
        return $res.$formulaire_liste->toHTML() ;
1231
    } // end of member function formulaireListe
1232
 
1233
    /**
1234
     * Transmet au serveur la demande de création d'une nouvelle liste.
1235
     *
1236
     * @return void
1237
     * @access public
1238
     */
1239
    function nouvelleListeValidation( )
1240
    {
1241
        // Vérifications
1242
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_ACTION_NOUVELLE_LISTE_V );
1243
        $formulaire_liste = new HTML_formulaireListe('formulaire_liste', 'post', preg_replace ("/&amp;/", "&", $this->_url->getURL())) ;
1244
        $formulaire_liste->construitFormulaire() ;
1245
        if ($formulaire_liste->validate()) {
59 ddelon 1246
            // création de l'objet liste_discussion
2 ddelon 1247
            $liste = new liste_discussion('', $this->_db) ;
59 ddelon 1248
 
2 ddelon 1249
            // On vérifie que le nom de la liste soit unique
1250
            if (liste_discussion::verifieDoubleListe($formulaire_liste->getSubmitValue('nom_liste').'@'.
1251
                                                            $formulaire_liste->getSubmitValue('domaine_liste'), $this->_db)) {
59 ddelon 1252
                // On rajoute la liste dans la base
2 ddelon 1253
                $liste->enregistrerSQL($formulaire_liste->getSubmitValues()) ;
59 ddelon 1254
 
2 ddelon 1255
                // On la relie au projet
1256
                $projet = new projet ($this->_db, $this->_id_projet) ;
1257
                $projet->ajouterListe($liste) ;
59 ddelon 1258
 
2 ddelon 1259
                // Création de la liste
22 alexandre_ 1260
                $resultat_creation = file_get_contents (PROJET_SERVEUR_VPOPMAIL.'/creation_liste.php?domaine='.
2 ddelon 1261
                                    $liste->getDomaine().'&liste='.$liste->getNom().'&parametres=aBiud') ;
59 ddelon 1262
 
2 ddelon 1263
                // Ajout du modérateur
22 alexandre_ 1264
                $resultat_ajout_moderateur = file_get_contents (PROJET_SERVEUR_VPOPMAIL.'/ajout_moderateur.php?domaine='.
2 ddelon 1265
                                    $liste->getDomaine().'&liste='.$liste->getNom().'&mail='.$this->_auth->getUserName()) ;
1266
                // Ajout du modérateur en tant qu'utilisateur
22 alexandre_ 1267
                $resultat_ajout_utilisateur = file_get_contents (PROJET_SERVEUR_VPOPMAIL.'/ajout_abonne.php?domaine='.
2 ddelon 1268
                                    $liste->getDomaine().'&liste='.$liste->getNom().'&mail='.$this->_auth->getUserName()) ;
1269
 
1270
            } else {
1271
                return PROJET_MESSAGE_LISTE_DOUBLE.$formulaire_liste->toHTML() ;
1272
            }
1273
            return $resultat_creation.$resultat_ajout_moderateur.$resultat_ajout_utilisateur;
59 ddelon 1274
 
2 ddelon 1275
        } else {
1276
            return $formulaire_liste->toHTML() ;
1277
        }
1278
    } // end of member function nouvelleListeValidation
59 ddelon 1279
 
2 ddelon 1280
    /**
1281
     * Supprime la liste de discussion associée au projet
1282
     *
1283
     * @return void
1284
     * @access public
1285
     */
1286
    function supprimerListe( )
1287
    {
1288
        $projet = new projet($this->_db, $this->_id_projet) ;
1289
        $projet->getListesAssociees() ;
59 ddelon 1290
 
2 ddelon 1291
        // ajouter un commande de suppression
59 ddelon 1292
 
2 ddelon 1293
        $commande = new commande_serveur(PROJET_CHEMIN_APPLI.'script_cron/ezmlm.sh') ;
1294
        if (PEAR::isError($commande)) {
1295
            echo $commande->getMessage() ;
1296
        }
59 ddelon 1297
 
2 ddelon 1298
        // Suppression des listes synchronisés
1299
        $commande_supression_3 = 'rm -rf '.PROJET_CHEMIN_LISTES.$projet->_listes_associes[0]->getDomaine().
1300
                                '/'.$projet->_listes_associes[0]->getNom() ;
1301
        $commande->ajouterCommande($commande_supression_3) ;
59 ddelon 1302
 
22 alexandre_ 1303
        $resultat_suppression = file_get_contents(PROJET_SERVEUR_VPOPMAIL.'/suppression_liste.php?domaine='.
2 ddelon 1304
                                    $projet->_listes_associes[0]->getDomaine().'&liste='.$projet->_listes_associes[0]->getNom()) ;
1305
        $projet->supprimerListe($projet->_listes_associes[0]) ;
1306
        return $resultat_suppression;
1307
    } // end of member function supprimerListe
1308
 
1309
 
1310
    /**
1311
     *
59 ddelon 1312
     *
2 ddelon 1313
     * @param string presentation Pour affecter une présentation au projet
1314
     * @return void
1315
     * @access public
1316
     */
1317
    function setPresentation( $presentation )
1318
    {
1319
        $this->_presentation = $presentation ;
1320
    } // end of member function setPresentation
1321
 
11 alexandre_ 1322
    /**
1323
     *
59 ddelon 1324
     *
11 alexandre_ 1325
     * @param string type Pour affecter un type au projet
1326
     * @return void
1327
     * @access public
1328
     */
1329
    function setType( $type)
1330
    {
1331
        $this->_type = $type ;
1332
    } // end of member function setPresentation
2 ddelon 1333
 
11 alexandre_ 1334
 
2 ddelon 1335
    /**
46 ddelon 1336
     * Fonction affichant les participants à un projet
2 ddelon 1337
     *
1338
     * @return string
1339
     * @access public
1340
     */
1341
    function voirParticipants( )
1342
    {
1343
        include_once PROJET_CHEMIN_CLASSES.'HTML_listeParticipants.class.php' ;
1344
        $projet = new projet ($this->_db, $this->_id_projet) ;
1345
        $titre = '<h1>'.$projet->getTitre().'</h1>'."\n" ;
1346
        $titre .= '<h2>'.PROJET_LISTE_PARTICIPANT.'</h2>'."\n" ;
1347
        $participants = new participe($this->_db) ;
59 ddelon 1348
 
2 ddelon 1349
        // On teste ici s'il y a une mise à jour de statut
1350
        if (isset($_POST['statut'])) {
1351
            // $_GET['id_utilisateur'] et $_GET['statut'] proviennent du formulaire voir HTML_listeParticipants
1352
            $participants->setStatut($_POST['statut'], $_GET['id_utilisateur'], $this->_id_projet) ;
1353
        }
59 ddelon 1354
 
2 ddelon 1355
        // Ce qui suit doit être amélioré pour sortir la requête sur l'annuaire
1356
        // On teste s'il y a un ajout d'utilisateur voir HTML_listeParticipants
1357
        if (isset($_POST['mail_utilisateur'])) {
1358
            $requete = 'select '.PROJET_CHAMPS_ID.' from '.PROJET_ANNUAIRE.' where '.PROJET_CHAMPS_MAIL.'="'.$_POST['mail_utilisateur'].'"';
1359
            $resultat = $this->_db->query ($requete) ;
1360
            if (DB::isError ($resultat)) {
1361
                die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
1362
            }
1363
            if (!$resultat->numRows()) {
1364
                $msg = PROJET_MAIL_ABSENT;
1365
            } else {
1366
                $ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
1367
                $participants->setStatut(3, $ligne[PROJET_CHAMPS_ID], $this->_id_projet) ;
1368
            }
1369
        }
59 ddelon 1370
 
2 ddelon 1371
        if ($this->_auth->getAuth()) {
1372
            $statut = participe::getStatutSurProjetCourant($this->_auth->getAuthData(PROJET_CHAMPS_ID),  $this->_id_projet, $this->_db) ;
1373
            if ($statut == 2) $droits = PROJET_DROIT_CONTRIBUTEUR ;
1374
            if ($statut == 1) $droits = PROJET_DROIT_COORDINATEUR ;
1375
            if (participe::isAdministrateur($this->_auth->getAuthData(PROJET_CHAMPS_ID), $this->_db)) $droits = PROJET_DROIT_ADMINISTRATEUR  ;
1376
            $HTML_listeParticipants = new HTML_listeParticipants(true) ;
1377
            if ($statut < 2) $HTML_listeParticipants->setModeModification() ;
1378
            // Mise en place de l'url
1379
            $this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_ACTION_VOIR_PARTICIPANT) ;
1380
            $HTML_listeParticipants->setURL($this->_url) ;
1381
            // Construction de l'entete
1382
            $entete = array (PROJET_NOM, PROJET_PRENOM) ;
59 ddelon 1383
 
2 ddelon 1384
            if ($this->_auth->getAuth()) {
1385
                array_push ($entete, PROJET_MAIL) ;
1386
            } else {
1387
               $droits = PROJET_DROIT_AUCUN ;
1388
            }
1389
            $info_utilisateur = $participants->getInscrits($this->_id_projet, $droits) ;
1390
            array_push ($entete, PROJET_DATE_INSCRIPTION) ;
1391
            $HTML_listeParticipants->construitEntete($entete) ;
59 ddelon 1392
 
2 ddelon 1393
            $HTML_listeParticipants->construitListe($info_utilisateur, statut::getTousLesStatuts(PROJET_STATUT_SAUF_ADM_COORD, $this->_db)) ;
59 ddelon 1394
 
2 ddelon 1395
            $res = $HTML_listeParticipants->toHTML() ;
59 ddelon 1396
 
2 ddelon 1397
            if ($statut < 2) {
1398
                $res .= PROJET_NOUVEAU_UTILISATEUR_LAIUS ;
1399
                $res .= '<form action="'.$this->_url->getURL().'" method="post">'."\n" ;
1400
                if (isset ($msg) && $msg != '') {
1401
                    $res .= '<div>'.$msg.'</div>' ;
1402
                }
1403
                $res .= '<input type="text" name="mail_utilisateur" size="32" />' ;
1404
                $res .= '<input type="submit" value="'.PROJET_NOUVEAU_UTILISATEUR.'" />'."\n" ;
1405
                $res .= '</form>'."\n" ;
1406
            }
1407
        } else {
1408
            $res .= '<p>'.PROJET_TEXTE_NON_IDENTIFIE.'</p>'."\n" ;
1409
        }
1410
        return $titre.$res ;
59 ddelon 1411
 
2 ddelon 1412
    } // end of member function voirParticipants
1413
 
1414
    /**
1415
     * Inscrit un utilisateur à un projet avec le statut observateur
1416
     *
1417
     * @return void
1418
     * @access public
1419
     */
1420
    function inscriptionProjet( )
1421
    {
1422
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireInscriptionProjet.class.php' ;
59 ddelon 1423
 
2 ddelon 1424
        $projet = new projet ($this->_db, $this->_id_projet) ;
59 ddelon 1425
 
2 ddelon 1426
        // Si le projet n'a pas de liste, on inscrit directement
1427
        if (isset ($this->_id_projet)) {
1428
            $participant = new participe($this->_db) ;
59 ddelon 1429
 
2 ddelon 1430
            if (!$projet->avoirListe()) {
122 alexandre_ 1431
            	if ($projet->isModere()) {
1432
                	$participant->setStatut(3, $this->_auth->getAuthData (PROJET_CHAMPS_ID), $this->_id_projet) ;
1433
            	} else {
1434
            		$participant->setStatut(2, $this->_auth->getAuthData (PROJET_CHAMPS_ID), $this->_id_projet) ;
1435
            	}
2 ddelon 1436
                return $this->mesProjets() ;
1437
            }
1438
        }
1439
        if (isset($_POST['valider_inscription_projet'])) {
1440
            if (isset($_POST['radio_inscription_liste'])) {
122 alexandre_ 1441
            	include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
1442
            	$utilisateur = new annuaire($this->_db, array('identifiant' => PROJET_CHAMPS_ID,
1443
								'mail' => PROJET_CHAMPS_MAIL, 'table' => PROJET_ANNUAIRE,
1444
								'nom'=> PROJET_CHAMPS_NOM, 'prenom' => PROJET_CHAMPS_PRENOM)) ;
1445
	            $utilisateur->setId($this->_auth->getAuthData(PROJET_CHAMPS_ID)) ;
1446
 
1447
            	if (!$projet->isModere()) {
1448
	                $participant->setStatut(2, $this->_auth->getAuthData (PROJET_CHAMPS_ID), $this->_id_projet) ;
1449
 
1450
	                include_once PROJET_CHEMIN_CLASSES.'inscription_liste.class.php' ;
1451
	                $projet->getListesAssociees() ;
1452
	                $inscription_liste = new inscription_liste($this->_db) ;
1453
	                $inscription_liste->inscrireUtilisateur( $utilisateur,
2 ddelon 1454
                                                        $projet->_listes_associes[0],
1455
                                                        $_POST['radio_inscription_liste']) ;
122 alexandre_ 1456
            	} else {
1457
            		$participant->setStatut(3, $this->_auth->getAuthData (PROJET_CHAMPS_ID), $this->_id_projet) ;
1458
            		$tableau_coordinateur = $participant->getCoordinateurs($this->_id_projet) ;
1459
            		#include_once PROJET_CHEMIN_API.'pear/Mail.php';
1460
            		$entetes['From'] = $this->_auth->getUserName();
1461
		            $entetes['To'] = '';
1462
		            $entetes['Subject'] = PROJET_DEMANDE_INSCRIPTION ;
1463
		            $entetes['Date'] = date ('D, M j G:i:s \C\E\S\T Y') ;
1464
		            $entetes['Message-ID'] = md5(time()) ;
1465
		            $entetes['reply-to'] = '' ;
1466
		            $entetes['Content-Type'] = 'text/plain' ;
1467
 
1468
		            $objet_mail =& Mail::factory('smtp');
1469
		            require_once PROJET_CHEMIN_BIBLIOTHEQUE_API.'pear/HTML/Template/IT.php';
1470
				    $tpl = new HTML_Template_IT() ;
1471
				    // Le gabarit du mail est dans un template
1472
				    // template 1
1473
				    $requete = 'select pt_template from projet_template where pt_id_template=1'.
1474
				    			' and pt_i18n like "%'.PROJET_LANGUE_DEFAUT.'"' ;
1475
 
1476
				    if (!$tpl -> setTemplate($this->_db->getOne ($requete))) {
1477
				    	echo 'erreur' ;
1478
				    }
1479
					$tpl->setVariable('nom', $utilisateur->getInfo( 'nom')) ;
1480
					$tpl->setVariable('prenom', $utilisateur->getInfo( 'prenom')) ;
1481
					$tpl->setVariable('nom_projet', $projet->getTitre()) ;
1482
					$tpl->setVariable('lien', str_replace ('&amp;', '&', $this->_url->getURL())) ;
1483
 
1484
            		foreach ($tableau_coordinateur as $coordinateur) {
1485
            			$entetes['To'] .= $coordinateur[3];	// Le champs 3 est le mail
1486
            		}
1487
            		$objet_mail->send($entetes['To'], $entetes, $tpl->get());
1488
            	}
2 ddelon 1489
            }
59 ddelon 1490
 
2 ddelon 1491
            if ($this->_presentation != 'arbre') {
122 alexandre_ 1492
                include_once PROJET_CHEMIN_APPLI.'actions/resume.php' ;
1493
                return $retour ;
2 ddelon 1494
            } else {
1495
                $this->_action = PROJET_ACTION_VOIR_RESUME;
1496
            }
1497
            return ;
1498
        }
1499
        $res = '<h1>'.PROJET_INSCRIPTION_PROJET.' : '.$projet->getTitre().'</h1>'."\n" ;
1500
        if ($projet->avoirListe()) $res .= '<h2>'.PROJET_MESSAGE_LISTE.'</h2>'."\n" ;
1501
        //$participant = new participe($this->_db) ;
1502
        $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_S_INSCRIRE) ;
1503
        $HTML_formulaireInscriptionProjet = new HTML_formulaireInscriptionProjet('inscription_projet', 'post', str_replace ('&amp;', '&', $this->_url->getURL())) ;
1504
        $HTML_formulaireInscriptionProjet->construitFormulaire($projet) ;
1505
        $HTML_formulaireInscriptionProjet->setDefaults(array('radio_inscription_liste' => 2)) ;
1506
        return $res.$HTML_formulaireInscriptionProjet->toHTML() ;
1507
    } // end of member function inscriptionProjet
1508
 
1509
    /**
1510
     * Inscrit l'utilisateur loggué à la liste dont le paraètre est en post.
1511
     *
1512
     * @return void
1513
     * @access public
1514
     */
1515
    function inscriptionListe( )
1516
    {
1517
        $projet = new projet ($this->_db, $this->_id_projet) ;
1518
        include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
1519
        include_once PROJET_CHEMIN_CLASSES.'inscription_liste.class.php' ;
1520
        $projet->getListesAssociees() ;
1521
        $utilisateur = new annuaire($this->_db, array('identifiant' => PROJET_CHAMPS_ID, 'mail' => PROJET_CHAMPS_MAIL, 'table' => PROJET_ANNUAIRE)) ;
1522
        $utilisateur->setId($this->_auth->getAuthData(PROJET_CHAMPS_ID)) ;
1523
        $inscription_liste = new inscription_liste($this->_db) ;
1524
        $inscription_liste->inscrireUtilisateur( $utilisateur, $projet->_listes_associes[0], 2) ;  // 2 est la statut inscription normale
1525
    } // end of member function inscriptionListe
1526
 
1527
    /**
1528
     * Inscrit l'utilisateur loggué à la liste dont le paraètre est en post.
1529
     *
1530
     * @return void
1531
     * @access public
1532
     */
1533
    function desinscriptionListe( )
1534
    {
1535
        if (isset($_GET['inscription_liste']) || $this->_action = PROJET_ACTION_DESINSCRIPTION_LISTE) {
1536
            $projet = new projet ($this->_db, $this->_id_projet) ;
1537
            include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
1538
            include_once PROJET_CHEMIN_CLASSES.'inscription_liste.class.php' ;
1539
            $projet->getListesAssociees() ;
31 alexandre_ 1540
            $utilisateur = new annuaire($this->_db, array('identifiant' => PROJET_CHAMPS_ID,
1541
            								 'mail' => PROJET_CHAMPS_MAIL,
1542
            								 'table' => PROJET_ANNUAIRE)) ;
2 ddelon 1543
            $utilisateur->setId($this->_auth->getAuthData(PROJET_CHAMPS_ID)) ;
1544
            $inscription_liste = new inscription_liste($this->_db) ;
1545
            $inscription_liste->desinscrireUtilisateur( $utilisateur, $projet->_listes_associes[0], $_GET['inscription_liste']) ;
1546
        }
1547
    } // end of member function inscriptionListe
1548
    /**
1549
     * desinscrit un utilisateur à un projet
1550
     *
1551
     * @return void
1552
     * @access public
1553
     */
1554
    function desinscriptionProjet( )
1555
    {
1556
        include_once PROJET_CHEMIN_CLASSES.'participe.class.php' ;
1557
        $participant = new participe($this->_db) ;
59 ddelon 1558
 
2 ddelon 1559
        // Le statut 4 désinscrit l'utilisateur, dans la méthode setStatut
1560
        $participant->setStatut(4, $this->_auth->getAuthData (PROJET_CHAMPS_ID), $this->_id_projet) ;
1561
        $projet = new projet ($this->_db, $this->_id_projet) ;
1562
        $projet->getListesAssociees() ;
1563
        if ($projet->avoirListe()) {
1564
            include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
1565
            $annuaire = new annuaire($this->_db, array('identifiant' => PROJET_CHAMPS_ID, 'mail' => PROJET_CHAMPS_MAIL, 'table' => PROJET_ANNUAIRE)) ;
1566
            $annuaire->setId($this->_auth->getAuthData(PROJET_CHAMPS_ID)) ;
1567
            include_once PROJET_CHEMIN_CLASSES.'inscription_liste.class.php' ;
1568
            $desinscription= new inscription_liste($this->_db) ;
1569
            $desinscription->desinscrireUtilisateur($annuaire, $projet->_listes_associes[0]) ;
1570
        }
1571
        if ($this->_presentation != 'arbre') {
122 alexandre_ 1572
            include_once PROJET_CHEMIN_APPLI.'actions/resume.php' ;
1573
            return $retour ;
2 ddelon 1574
        } else {
1575
            $this->_action = PROJET_ACTION_VOIR_RESUME;
1576
        }
1577
    } // end of member function inscriptionProjet
1578
 
1579
    /**
1580
     * Renvoie le formulaire de création d'un wiki
1581
     *
1582
     * @return void
1583
     * @access public
1584
     */
1585
    function formulaireWiki( )
1586
    {
59 ddelon 1587
 
1588
		require_once 'client/integrateur_wikini/bibliotheque/iw_admin_wikini.fonct.php';
1589
 
60 ddelon 1590
 
61 ddelon 1591
  		$url = &$GLOBALS['_GEN_commun']['url'] ;
60 ddelon 1592
		$url->addQueryString ('act', PROJET_ACTION_CREER_WIKI) ;
79 alexandre_ 1593
		$url->addQueryString (PROJET_VARIABLE_ID_PROJET, $this->_id_projet) ;
59 ddelon 1594
		$res =admin_afficherContenuCorps();
79 alexandre_ 1595
		$res .= '<br /><a href="'.$this->_url->getURL().'">'.PROJET_RETOUR_RESUME.'</a>';
59 ddelon 1596
    	return $res;
1597
 
2 ddelon 1598
    } // end of member function formulaireWiki
1599
 
16 ddelon 1600
 
1601
	function associerWiki( )
1602
    {
1603
        $res = '<h1>'.PROJET_ASSOCIER_WIKI.'</h1>'."\n" ;
59 ddelon 1604
 
1605
	 	$db = &$GLOBALS['_GEN_commun']['pear_db'] ;
16 ddelon 1606
    	$res='';
59 ddelon 1607
 
16 ddelon 1608
         // Comportement par défaut
59 ddelon 1609
	    // requete sur la table gen_wikini pour affichage de la liste des Wikini
16 ddelon 1610
	    $requete = "select  gewi_id_wikini, gewi_code_alpha_wikini, gewi_page from gen_wikini" ;
59 ddelon 1611
 
16 ddelon 1612
	    $resultat = $db->query ($requete) ;
1613
	    if (DB::isError ($resultat)) {
1614
	        $GLOBALS['_GEN_commun']['debogage_erreur']->gererErreur(E_USER_WARNING, "Echec de la requete : $requete<br />".$resultat->getMessage(),
1615
	                                                                        __FILE__, __LINE__, 'admin_wikini')   ;
1616
	        return ;
1617
	    }
59 ddelon 1618
 
1619
 
16 ddelon 1620
	    $liste = new HTML_TableFragmenteur () ;
40 ddelon 1621
	    $liste->construireEntete(array (PROJET_NOM_WIKINI,PROJET_PAGE_WIKINI, PROJET_SELECTIONNER_WIKINI)) ;
59 ddelon 1622
 
16 ddelon 1623
	    $tableau_wikini = array() ;
59 ddelon 1624
 
16 ddelon 1625
	    while ($ligne = $resultat->fetchRow()) {
1626
	        $this->_url->addQueryString ('id_wikini', $ligne[0]) ;
1627
	        array_push ($tableau_wikini, array ($ligne[1]."\n",    // Première colonne, le nom de l'application
1628
										        $ligne[2]."\n",    // Deuxieme colonne, la page par defaut
40 ddelon 1629
	        								  '<a href="'.$this->_url->getURL()."&amp;".PROJET_VARIABLE_ACTION."=".PROJET_ACTION_ASSOCIER_WIKI_V."".'">'.PROJET_CHOISIR_WIKINI.'</a>'."\n",
16 ddelon 1630
	                                            ));
1631
	    }
1632
	    $liste->construireListe($tableau_wikini) ;
1633
	    $res .= $liste->toHTML();
68 alexandre_ 1634
	    $this->_url->removeQueryString(PROJET_VARIABLE_ACTION) ;
16 ddelon 1635
	    return $res ;
59 ddelon 1636
 
1637
 
1638
 
16 ddelon 1639
    } // end of member function formulaireWiki
1640
 
2 ddelon 1641
 
40 ddelon 1642
    /**
1643
     * Associe un wiki au projet courant
1644
     *
1645
     * @return void
1646
     * @access public
1647
     */
2 ddelon 1648
 
40 ddelon 1649
	function associationWiki( )  {
59 ddelon 1650
 
1651
 
40 ddelon 1652
    	if (isset($_GET['id_wikini'])) {
1653
    		$db = &$GLOBALS['_GEN_commun']['pear_db'] ;
1654
		    $requete = "select gewi_code_alpha_wikini from gen_wikini where gewi_id_wikini = ".$_GET['id_wikini'] ;
1655
	    	$resultat = $db->query ($requete) ;
1656
	    	if (DB::isError ($resultat)) {
1657
	        	$GLOBALS['_GEN_commun']['debogage_erreur']->gererErreur(E_USER_WARNING, "Echec de la requete : $requete<br />".$resultat->getMessage(),
1658
	            	                                                            __FILE__, __LINE__, 'admin_wikini')   ;
1659
	        	return ;
1660
	    	}
59 ddelon 1661
 
40 ddelon 1662
	    	$ligne = $resultat->fetchRow();
1663
			$projet = new projet($this->_db, $this->_id_projet) ;
1664
        	$projet->majNomWikini($ligne[0]);
1665
    	}
59 ddelon 1666
 
40 ddelon 1667
	}
1668
 
2 ddelon 1669
    /**
1670
     * Supprime le wiki du projet courant
1671
     *
1672
     * @return void
1673
     * @access public
1674
     */
1675
    function supprimerWiki( )
1676
    {
1677
        include_once PROJET_CHEMIN_CLASSES.'gestion_wikini.class.php' ;
1678
        // On crée une nouvelle connexion avec les paramètres spécifiques aux wikinis
1679
        $connexion_bd = DB::connect('mysql://'.PROJET_UTILISATEUR_WIKINI.':'.PROJET_MDP_WIKINI.'@'.PROJET_HOTE_WIKINI.'/'.PROJET_DB_WIKINI) ;
1680
        $gerantWiki = new gestion_wikini($connexion_bd) ;
1681
        $projet = new projet ($this->_db, $this->_id_projet) ;
1682
        $gerantWiki->suppression_tables(strtolower($projet->getWikini())) ;
1683
        $projet->majNomWikini('') ;
1684
    } // end of member function supprimerWiki
1685
 
1686
    /**
1687
     * Permet de lier une ou plusieurs listes de la table agora à un projet.
1688
     *
1689
     * @return string
1690
     * @access public
1691
     */
1692
    function referencerListeExterne( )
1693
    {
1694
        $res = '<h1>'.PROJET_REFERENCER_LISTE.'</h1>' ;
1695
        include_once PROJET_CHEMIN_CLASSES.'liste_externe.class.php' ;
1696
        $liste_externe = new liste_externe($this->_db) ;
1697
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireListeExterne.class.php' ;
1698
        $this->_url->addQueryString(PROJET_VARIABLE_ID_PROJET, $this->_id_projet) ;
1699
        $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_REFERENCER_LISTE_V) ;
1700
        $HTML_formulaireListeExterne = new HTML_formulaireListeExterne('formulaire_liste_externe', 'post', str_replace('&amp;', '&', $this->_url->getURL())) ;
1701
        $HTML_formulaireListeExterne->construitFormulaire($liste_externe->getListeNom()) ;
1702
        $liste_assoc = $liste_externe->getListesAssociees($this->_id_projet) ;
1703
        $default = array() ;
1704
        foreach ($liste_assoc as $val) $default['liste_'.$val] = 1 ;
1705
 
1706
        $HTML_formulaireListeExterne->setDefaults($default) ;
1707
        return $res.$HTML_formulaireListeExterne->toHTML() ;
1708
    } // end of member function referencerListeExterne
1709
 
1710
    /**
1711
     * Réalise les mises à jours dans la table projet_lien_liste_externe
1712
     *
1713
     * @return void
1714
     * @access public
1715
     */
1716
    function referencerListeExterneValidation( )
1717
    {
1718
        include_once PROJET_CHEMIN_CLASSES.'liste_externe.class.php' ;
1719
        $liste_externe = new liste_externe($this->_db) ;
1720
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireListeExterne.class.php' ;
1721
        $HTML_formulaireListeExterne = new HTML_formulaireListeExterne('formulaire_liste_externe', 'post', str_replace('&amp;', '&', $this->_url->getURL())) ;
1722
        $HTML_formulaireListeExterne->construitFormulaire($liste_externe->getListeNom()) ;
59 ddelon 1723
 
2 ddelon 1724
        $liste_externe->enregistrerSQL($HTML_formulaireListeExterne->getSubmitValues(), $this->_id_projet) ;
1725
    } // end of member function referencerListeExterneValidation
1726
 
11 alexandre_ 1727
    /**
1728
     * permet d'exclure un projet de l'affichage
1729
     *
1730
     * @return void
1731
     * @access public
1732
     */
1733
    function exclure($id_projet)
1734
    {
1735
       array_push ($this->_projet_exclu, $id_projet) ;
1736
    } // end of member function exclure
2 ddelon 1737
 
54 alexandre_ 1738
    /**
1739
     * permet d'exclure un projet de l'affichage
1740
     *
1741
     * @return void
1742
     * @access public
1743
     */
1744
    function setPrive()
1745
    {
1746
       $this->_prive = 1 ;
1747
    } // end of member function exclure
2 ddelon 1748
 
11 alexandre_ 1749
 
54 alexandre_ 1750
 
2 ddelon 1751
    /**
1752
     * Renvoie un message d'erreur, en fonction du code de l'erreur.
1753
     *
1754
     * @param int valeur Le code du message d'erreur.
1755
     * @return string
1756
     * @access public
1757
     */
1758
    function messageErreur( $valeur )
1759
    {
1760
        $messageErreur = array (
1761
                    PROJETCONTROLEUR_ACTION_INVALIDE => "Action non valide",
1762
                    PROJETCONTROLEUR_ERREUR_SUPPRESSION_REPERTOIRE => "Impossible de supprimer le répertoire",
1763
                    PROJETCONTROLEUR_PAS_DE_DOCUMENT_SELECTIONNE => 'Pas de fichier sélectionné',
1764
                    PROJETCONTROLEUR_ERREUR_CREATION_REPERTOIRE => 'Impossible de créer le répertoire'
1765
        ) ;
1766
        return '<p class="erreur">'.$messageErreur[$valeur].'</p>' ;
1767
    } // end of member function messageErreur
1768
 
1769
 
1770
 
1771
 
1772
} // end of projetControleur
1773
?>