Subversion Repositories Applications.projet

Rev

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