Subversion Repositories Applications.projet

Rev

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