Subversion Repositories Applications.papyrus

Rev

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

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