Subversion Repositories Applications.projet

Rev

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

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