Subversion Repositories Applications.projet

Rev

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

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