Subversion Repositories Applications.projet

Rev

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

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