Subversion Repositories Applications.papyrus

Rev

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

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