Subversion Repositories Applications.projet

Rev

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