Subversion Repositories Applications.projet

Rev

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