Subversion Repositories Applications.projet

Rev

Rev 4 | Go to most recent revision | Details | Last modification | View Log | RSS feed

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