Subversion Repositories Applications.projet

Rev

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

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