Subversion Repositories Applications.projet

Rev

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