Subversion Repositories Applications.projet

Rev

Rev 335 | Rev 341 | 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
 
337 alexandre_ 23
// CVS : $Id: projetControleur.class.php,v 1.48 2008-09-15 07:41:16 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
337 alexandre_ 36
*@version       $Revision: 1.48 $
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">' ;
332 alexandre_ 567
				// L'action modifier les proprietes du projet
63 alexandre_ 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) ;
332 alexandre_ 916
            // On passe aussi le numero de repertoire 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
   /**
332 alexandre_ 1097
     * Renvoie le formulaire de creation d'une liste.
2 ddelon 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
    /**
332 alexandre_ 1116
     * Transmet au serveur la demande de creation d'une nouvelle liste.
2 ddelon 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
 
332 alexandre_ 1133
            // On verifie que le nom de la liste soit unique
2 ddelon 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
    /**
332 alexandre_ 1166
     * Supprime la liste de discussion associee au projet
2 ddelon 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
     *
332 alexandre_ 1187
     * @param string presentation Pour affecter une presentation au projet
2 ddelon 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
 
1208
    /**
249 alexandre_ 1209
     * Inscrit un utilisateur a un projet avec le statut observateur
2 ddelon 1210
     *
1211
     * @return void
1212
     * @access public
1213
     */
1214
    function inscriptionProjet( )
1215
    {
1216
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireInscriptionProjet.class.php' ;
208 neiluj 1217
		include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1218
        $projet = new projet ($this->_db, $this->_id_projet) ;
59 ddelon 1219
 
2 ddelon 1220
        // Si le projet n'a pas de liste, on inscrit directement
1221
        if (isset ($this->_id_projet)) {
208 neiluj 1222
            include_once PROJET_CHEMIN_CLASSES.'participe.class.php' ;
2 ddelon 1223
            $participant = new participe($this->_db) ;
297 alexandre_ 1224
 
1225
			// On controle si la liste est externe (yahoo) auquel cas on ne presente pas l inscription
1226
			include_once PROJET_CHEMIN_CLASSES.'liste_externe.class.php' ;
1227
			$liste_ext = new liste_externe($this->_db);
1228
			$listes = $liste_ext->getListesAssociees($this->_id_projet);
335 alexandre_ 1229
			if (count ($listes))$info_liste = $liste_ext->getInfoListe($listes[0]);
297 alexandre_ 1230
			if (count ($listes) != 0) {
1231
				$avoir_liste_externe = true;
1232
				$msg = '';
1233
				$msg = 'Pour vous inscrire &agrave; la liste de discussion, h&eacute;berg&eacute;e par Yahoo Groupes, <a href="mailto:';
1234
				$msg .= $info_liste->AGO_A_MAILABO.'">cliquez ici</a>';
1235
			} else {
1236
				$avoir_liste_externe = false;
1237
			}
1238
            if (!$projet->avoirListe() || $avoir_liste_externe) {
122 alexandre_ 1239
            	if ($projet->isModere()) {
1240
                	$participant->setStatut(3, $this->_auth->getAuthData (PROJET_CHAMPS_ID), $this->_id_projet) ;
1241
            	} else {
297 alexandre_ 1242
            		$participant->setStatut(2, $this->_auth->getAuthData (PROJET_CHAMPS_ID), $this->_id_projet) ;
1243
            		$message_retour = '<p class="information">Votre inscription a bien &eacute;t&eacute; prise en compte'.$msg.'</p>';
122 alexandre_ 1244
            	}
297 alexandre_ 1245
            	$message_retour = '<p class="information">Votre inscription a bien &eacute;t&eacute; prise en compte. '.$msg.'</p>';
1246
    			include_once PROJET_CHEMIN_APPLI.'actions/resume.php' ;
1247
    			return $retour;
2 ddelon 1248
            }
1249
        }
1250
        if (isset($_POST['valider_inscription_projet'])) {
1251
            if (isset($_POST['radio_inscription_liste'])) {
122 alexandre_ 1252
            	include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
1253
            	$utilisateur = new annuaire($this->_db, array('identifiant' => PROJET_CHAMPS_ID,
1254
								'mail' => PROJET_CHAMPS_MAIL, 'table' => PROJET_ANNUAIRE,
1255
								'nom'=> PROJET_CHAMPS_NOM, 'prenom' => PROJET_CHAMPS_PRENOM)) ;
1256
	            $utilisateur->setId($this->_auth->getAuthData(PROJET_CHAMPS_ID)) ;
1257
 
1258
            	if (!$projet->isModere()) {
1259
	                $participant->setStatut(2, $this->_auth->getAuthData (PROJET_CHAMPS_ID), $this->_id_projet) ;
1260
 
297 alexandre_ 1261
	                if ($_POST['radio_inscription_liste'] == 2) {
1262
		                include_once PROJET_CHEMIN_CLASSES.'inscription_liste.class.php' ;
1263
		                $projet->getListesAssociees() ;
1264
		                $inscription_liste = new inscription_liste($this->_db) ;
1265
		                $inscription_liste->inscrireUtilisateur( $utilisateur,
1266
	                                                        $projet->_listes_associes[0],
1267
	                                                        $_POST['radio_inscription_liste']) ;
1268
	                }
1269
                    $this->notifierCoordinateurs(PROJET_NOTIFICATION_INSCRIPTION_NOUVELLE, $utilisateur);
122 alexandre_ 1270
            	} else {
1271
            		$participant->setStatut(3, $this->_auth->getAuthData (PROJET_CHAMPS_ID), $this->_id_projet) ;
249 alexandre_ 1272
 
297 alexandre_ 1273
            		$this->notifierCoordinateurs(PROJET_NOTIFICATION_DEMANDE_INSCRIPTION, $utilisateur);
122 alexandre_ 1274
            	}
2 ddelon 1275
            }
59 ddelon 1276
 
2 ddelon 1277
            if ($this->_presentation != 'arbre') {
272 alexandre_ 1278
                if ($projet->isModere()) return '<h1>'.$projet->getTitre().'</h1>'.
249 alexandre_ 1279
                		str_replace ('nom_du_projet', $projet->getTitre(), PROJET_LAIUS_INSCRIPTION_MODERE);
297 alexandre_ 1280
                		else {
1281
                			$message_retour = '<p class="information">Votre inscription a bien &eacute;t&eacute; prise en compte'.$msg.'</p>';
1282
                			include_once PROJET_CHEMIN_APPLI.'actions/resume.php' ;
1283
                			return $retour;
1284
                		}
2 ddelon 1285
            } else {
1286
                $this->_action = PROJET_ACTION_VOIR_RESUME;
1287
            }
249 alexandre_ 1288
            return PROJET_LAIUS_INSCRIPTION_MODERE;
2 ddelon 1289
        }
1290
        $res = '<h1>'.PROJET_INSCRIPTION_PROJET.' : '.$projet->getTitre().'</h1>'."\n" ;
1291
        if ($projet->avoirListe()) $res .= '<h2>'.PROJET_MESSAGE_LISTE.'</h2>'."\n" ;
1292
        //$participant = new participe($this->_db) ;
1293
        $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_S_INSCRIRE) ;
1294
        $HTML_formulaireInscriptionProjet = new HTML_formulaireInscriptionProjet('inscription_projet', 'post', str_replace ('&amp;', '&', $this->_url->getURL())) ;
1295
        $HTML_formulaireInscriptionProjet->construitFormulaire($projet) ;
1296
        $HTML_formulaireInscriptionProjet->setDefaults(array('radio_inscription_liste' => 2)) ;
1297
        return $res.$HTML_formulaireInscriptionProjet->toHTML() ;
1298
    } // end of member function inscriptionProjet
1299
 
1300
    /**
249 alexandre_ 1301
     * Inscrit l'utilisateur loggue a la liste dont le parametre est en post.
2 ddelon 1302
     *
1303
     * @return void
1304
     * @access public
1305
     */
1306
    function inscriptionListe( )
1307
    {
208 neiluj 1308
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1309
        $projet = new projet ($this->_db, $this->_id_projet) ;
1310
        include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
1311
        include_once PROJET_CHEMIN_CLASSES.'inscription_liste.class.php' ;
1312
        $projet->getListesAssociees() ;
1313
        $utilisateur = new annuaire($this->_db, array('identifiant' => PROJET_CHAMPS_ID, 'mail' => PROJET_CHAMPS_MAIL, 'table' => PROJET_ANNUAIRE)) ;
1314
        $utilisateur->setId($this->_auth->getAuthData(PROJET_CHAMPS_ID)) ;
1315
        $inscription_liste = new inscription_liste($this->_db) ;
1316
        $inscription_liste->inscrireUtilisateur( $utilisateur, $projet->_listes_associes[0], 2) ;  // 2 est la statut inscription normale
297 alexandre_ 1317
        return '<p class="information">Vous &ecirc;tes inscrit &agrave; la liste</p>';
2 ddelon 1318
    } // end of member function inscriptionListe
1319
 
1320
    /**
297 alexandre_ 1321
     * Inscrit l'utilisateur loggue a la liste dont le parametre est en post.
2 ddelon 1322
     *
1323
     * @return void
1324
     * @access public
1325
     */
1326
    function desinscriptionListe( )
1327
    {
1328
        if (isset($_GET['inscription_liste']) || $this->_action = PROJET_ACTION_DESINSCRIPTION_LISTE) {
208 neiluj 1329
            include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1330
            $projet = new projet ($this->_db, $this->_id_projet) ;
1331
            include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
1332
            include_once PROJET_CHEMIN_CLASSES.'inscription_liste.class.php' ;
1333
            $projet->getListesAssociees() ;
31 alexandre_ 1334
            $utilisateur = new annuaire($this->_db, array('identifiant' => PROJET_CHAMPS_ID,
1335
            								 'mail' => PROJET_CHAMPS_MAIL,
1336
            								 'table' => PROJET_ANNUAIRE)) ;
2 ddelon 1337
            $utilisateur->setId($this->_auth->getAuthData(PROJET_CHAMPS_ID)) ;
1338
            $inscription_liste = new inscription_liste($this->_db) ;
1339
            $inscription_liste->desinscrireUtilisateur( $utilisateur, $projet->_listes_associes[0], $_GET['inscription_liste']) ;
297 alexandre_ 1340
            return '<p class="information">Vous avez &eacute;t&eacute; d&eacute;sinscrit de la liste</p>';
2 ddelon 1341
        }
1342
    } // end of member function inscriptionListe
1343
    /**
297 alexandre_ 1344
     * desinscrit un utilisateur d un projet
2 ddelon 1345
     *
1346
     * @return void
1347
     * @access public
1348
     */
1349
    function desinscriptionProjet( )
1350
    {
1351
        include_once PROJET_CHEMIN_CLASSES.'participe.class.php' ;
297 alexandre_ 1352
        include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
2 ddelon 1353
        $participant = new participe($this->_db) ;
297 alexandre_ 1354
		$utilisateur = new annuaire($this->_db, array('identifiant' => PROJET_CHAMPS_ID,
1355
								'mail' => PROJET_CHAMPS_MAIL, 'table' => PROJET_ANNUAIRE,
1356
								'nom'=> PROJET_CHAMPS_NOM, 'prenom' => PROJET_CHAMPS_PRENOM)) ;
1357
	    $utilisateur->setId($this->_auth->getAuthData(PROJET_CHAMPS_ID)) ;
1358
 
1359
        // Le statut 4 desinscrit l'utilisateur, dans la methode setStatut
2 ddelon 1360
        $participant->setStatut(4, $this->_auth->getAuthData (PROJET_CHAMPS_ID), $this->_id_projet) ;
208 neiluj 1361
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1362
        $projet = new projet ($this->_db, $this->_id_projet) ;
1363
        $projet->getListesAssociees() ;
1364
        if ($projet->avoirListe()) {
1365
            include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
1366
            $annuaire = new annuaire($this->_db, array('identifiant' => PROJET_CHAMPS_ID, 'mail' => PROJET_CHAMPS_MAIL, 'table' => PROJET_ANNUAIRE)) ;
1367
            $annuaire->setId($this->_auth->getAuthData(PROJET_CHAMPS_ID)) ;
1368
            include_once PROJET_CHEMIN_CLASSES.'inscription_liste.class.php' ;
1369
            $desinscription= new inscription_liste($this->_db) ;
1370
            $desinscription->desinscrireUtilisateur($annuaire, $projet->_listes_associes[0]) ;
1371
        }
297 alexandre_ 1372
        $this->notifierCoordinateurs(PROJET_NOTIFICATION_DESINSCRIPTION_PROJET, $utilisateur);
1373
        include_once PROJET_CHEMIN_CLASSES.'liste_externe.class.php';
1374
        $liste_ext = new liste_externe($this->_db);
1375
		$listes = $liste_ext->getListesAssociees($this->_id_projet);
1376
		$info_liste = $liste_ext->getInfoListe($listes[0]);
1377
		$msg = '';
1378
		if (count ($listes) != 0) {
1379
			$msg = 'Pensez si vous le souhaitez à vous d&eacute;sinscrire de la liste de discussion, h&eacute;berg&eacute;e par Yahoo Groupes.';
1380
			$msg .= ' Vous pouvez le faire en <a href="mailto:';
1381
			$msg .= $info_liste->AGO_A_MAILDESA.'">cliquez ici</a>';
1382
		}
2 ddelon 1383
        if ($this->_presentation != 'arbre') {
297 alexandre_ 1384
            $message_retour = '<p class="information">Votre d&eacute;sinscription a bien &eacute;t&eacute; prise en compte. '.$msg.'</p>';
122 alexandre_ 1385
            include_once PROJET_CHEMIN_APPLI.'actions/resume.php' ;
1386
            return $retour ;
2 ddelon 1387
        } else {
1388
            $this->_action = PROJET_ACTION_VOIR_RESUME;
1389
        }
297 alexandre_ 1390
    }
2 ddelon 1391
 
1392
    /**
297 alexandre_ 1393
     * Renvoie le formulaire de creation d'un wiki
2 ddelon 1394
     *
1395
     * @return void
1396
     * @access public
1397
     */
1398
    function formulaireWiki( )
1399
    {
59 ddelon 1400
 
1401
		require_once 'client/integrateur_wikini/bibliotheque/iw_admin_wikini.fonct.php';
1402
 
60 ddelon 1403
 
61 ddelon 1404
  		$url = &$GLOBALS['_GEN_commun']['url'] ;
60 ddelon 1405
		$url->addQueryString ('act', PROJET_ACTION_CREER_WIKI) ;
79 alexandre_ 1406
		$url->addQueryString (PROJET_VARIABLE_ID_PROJET, $this->_id_projet) ;
59 ddelon 1407
		$res =admin_afficherContenuCorps();
79 alexandre_ 1408
		$res .= '<br /><a href="'.$this->_url->getURL().'">'.PROJET_RETOUR_RESUME.'</a>';
59 ddelon 1409
    	return $res;
1410
 
332 alexandre_ 1411
    }
2 ddelon 1412
 
16 ddelon 1413
 
1414
	function associerWiki( )
1415
    {
1416
        $res = '<h1>'.PROJET_ASSOCIER_WIKI.'</h1>'."\n" ;
59 ddelon 1417
 
1418
	 	$db = &$GLOBALS['_GEN_commun']['pear_db'] ;
16 ddelon 1419
    	$res='';
59 ddelon 1420
 
332 alexandre_ 1421
         // Comportement par defaut
59 ddelon 1422
	    // requete sur la table gen_wikini pour affichage de la liste des Wikini
16 ddelon 1423
	    $requete = "select  gewi_id_wikini, gewi_code_alpha_wikini, gewi_page from gen_wikini" ;
59 ddelon 1424
 
16 ddelon 1425
	    $resultat = $db->query ($requete) ;
1426
	    if (DB::isError ($resultat)) {
1427
	        $GLOBALS['_GEN_commun']['debogage_erreur']->gererErreur(E_USER_WARNING, "Echec de la requete : $requete<br />".$resultat->getMessage(),
1428
	                                                                        __FILE__, __LINE__, 'admin_wikini')   ;
1429
	        return ;
1430
	    }
59 ddelon 1431
 
337 alexandre_ 1432
		include_once 'api/html/HTML_TableFragmenteur.php';
16 ddelon 1433
	    $liste = new HTML_TableFragmenteur () ;
40 ddelon 1434
	    $liste->construireEntete(array (PROJET_NOM_WIKINI,PROJET_PAGE_WIKINI, PROJET_SELECTIONNER_WIKINI)) ;
59 ddelon 1435
 
16 ddelon 1436
	    $tableau_wikini = array() ;
59 ddelon 1437
 
16 ddelon 1438
	    while ($ligne = $resultat->fetchRow()) {
1439
	        $this->_url->addQueryString ('id_wikini', $ligne[0]) ;
332 alexandre_ 1440
	        array_push ($tableau_wikini, array ($ligne[1]."\n",    // Premiere colonne, le nom de l'application
16 ddelon 1441
										        $ligne[2]."\n",    // Deuxieme colonne, la page par defaut
40 ddelon 1442
	        								  '<a href="'.$this->_url->getURL()."&amp;".PROJET_VARIABLE_ACTION."=".PROJET_ACTION_ASSOCIER_WIKI_V."".'">'.PROJET_CHOISIR_WIKINI.'</a>'."\n",
16 ddelon 1443
	                                            ));
1444
	    }
1445
	    $liste->construireListe($tableau_wikini) ;
1446
	    $res .= $liste->toHTML();
68 alexandre_ 1447
	    $this->_url->removeQueryString(PROJET_VARIABLE_ACTION) ;
16 ddelon 1448
	    return $res ;
59 ddelon 1449
 
1450
 
1451
 
16 ddelon 1452
    } // end of member function formulaireWiki
1453
 
2 ddelon 1454
 
40 ddelon 1455
    /**
1456
     * Associe un wiki au projet courant
1457
     *
1458
     * @return void
1459
     * @access public
1460
     */
2 ddelon 1461
 
40 ddelon 1462
	function associationWiki( )  {
59 ddelon 1463
 
1464
 
40 ddelon 1465
    	if (isset($_GET['id_wikini'])) {
1466
    		$db = &$GLOBALS['_GEN_commun']['pear_db'] ;
1467
		    $requete = "select gewi_code_alpha_wikini from gen_wikini where gewi_id_wikini = ".$_GET['id_wikini'] ;
1468
	    	$resultat = $db->query ($requete) ;
1469
	    	if (DB::isError ($resultat)) {
1470
	        	$GLOBALS['_GEN_commun']['debogage_erreur']->gererErreur(E_USER_WARNING, "Echec de la requete : $requete<br />".$resultat->getMessage(),
1471
	            	                                                            __FILE__, __LINE__, 'admin_wikini')   ;
1472
	        	return ;
1473
	    	}
59 ddelon 1474
 
40 ddelon 1475
	    	$ligne = $resultat->fetchRow();
208 neiluj 1476
	    	include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
40 ddelon 1477
			$projet = new projet($this->_db, $this->_id_projet) ;
1478
        	$projet->majNomWikini($ligne[0]);
1479
    	}
59 ddelon 1480
 
40 ddelon 1481
	}
1482
 
2 ddelon 1483
    /**
1484
     * Supprime le wiki du projet courant
1485
     *
1486
     * @return void
1487
     * @access public
1488
     */
1489
    function supprimerWiki( )
1490
    {
1491
        include_once PROJET_CHEMIN_CLASSES.'gestion_wikini.class.php' ;
1492
        // On crée une nouvelle connexion avec les paramètres spécifiques aux wikinis
1493
        $connexion_bd = DB::connect('mysql://'.PROJET_UTILISATEUR_WIKINI.':'.PROJET_MDP_WIKINI.'@'.PROJET_HOTE_WIKINI.'/'.PROJET_DB_WIKINI) ;
1494
        $gerantWiki = new gestion_wikini($connexion_bd) ;
208 neiluj 1495
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1496
        $projet = new projet ($this->_db, $this->_id_projet) ;
1497
        $gerantWiki->suppression_tables(strtolower($projet->getWikini())) ;
1498
        $projet->majNomWikini('') ;
1499
    } // end of member function supprimerWiki
1500
 
1501
    /**
1502
     * Permet de lier une ou plusieurs listes de la table agora à un projet.
1503
     *
1504
     * @return string
1505
     * @access public
1506
     */
1507
    function referencerListeExterne( )
1508
    {
158 alexandre_ 1509
        $requete = 'show tables like \'agora\'' ;
1510
        $resultat = $this->_db->query ($requete);
1511
        if ($resultat->numRows() == 0) {
1512
        	return 'Cette fonctionnalité n\'est pas active' ;
1513
        }
2 ddelon 1514
        $res = '<h1>'.PROJET_REFERENCER_LISTE.'</h1>' ;
1515
        include_once PROJET_CHEMIN_CLASSES.'liste_externe.class.php' ;
1516
        $liste_externe = new liste_externe($this->_db) ;
1517
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireListeExterne.class.php' ;
1518
        $this->_url->addQueryString(PROJET_VARIABLE_ID_PROJET, $this->_id_projet) ;
1519
        $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_REFERENCER_LISTE_V) ;
1520
        $HTML_formulaireListeExterne = new HTML_formulaireListeExterne('formulaire_liste_externe', 'post', str_replace('&amp;', '&', $this->_url->getURL())) ;
1521
        $HTML_formulaireListeExterne->construitFormulaire($liste_externe->getListeNom()) ;
1522
        $liste_assoc = $liste_externe->getListesAssociees($this->_id_projet) ;
1523
        $default = array() ;
1524
        foreach ($liste_assoc as $val) $default['liste_'.$val] = 1 ;
1525
 
1526
        $HTML_formulaireListeExterne->setDefaults($default) ;
1527
        return $res.$HTML_formulaireListeExterne->toHTML() ;
1528
    } // end of member function referencerListeExterne
1529
 
1530
    /**
332 alexandre_ 1531
     * Realise les mises a jours dans la table projet_lien_liste_externe
2 ddelon 1532
     *
1533
     * @return void
1534
     * @access public
1535
     */
1536
    function referencerListeExterneValidation( )
1537
    {
1538
        include_once PROJET_CHEMIN_CLASSES.'liste_externe.class.php' ;
1539
        $liste_externe = new liste_externe($this->_db) ;
1540
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireListeExterne.class.php' ;
1541
        $HTML_formulaireListeExterne = new HTML_formulaireListeExterne('formulaire_liste_externe', 'post', str_replace('&amp;', '&', $this->_url->getURL())) ;
1542
        $HTML_formulaireListeExterne->construitFormulaire($liste_externe->getListeNom()) ;
59 ddelon 1543
 
2 ddelon 1544
        $liste_externe->enregistrerSQL($HTML_formulaireListeExterne->getSubmitValues(), $this->_id_projet) ;
1545
    } // end of member function referencerListeExterneValidation
1546
 
11 alexandre_ 1547
    /**
1548
     * permet d'exclure un projet de l'affichage
1549
     *
1550
     * @return void
1551
     * @access public
1552
     */
1553
    function exclure($id_projet)
1554
    {
1555
       array_push ($this->_projet_exclu, $id_projet) ;
1556
    } // end of member function exclure
2 ddelon 1557
 
54 alexandre_ 1558
    /**
1559
     * permet d'exclure un projet de l'affichage
1560
     *
1561
     * @return void
1562
     * @access public
1563
     */
1564
    function setPrive()
1565
    {
1566
       $this->_prive = 1 ;
1567
    } // end of member function exclure
2 ddelon 1568
 
288 alexandre_ 1569
	/**
1570
	 * 	retourne une variable locale si la variable $_GET existe
1571
	 *
1572
	 */
1573
	function traiterVariableGet($var, $valeur_par_defaut ='') {
1574
		if (isset($_GET[$var]) && $_GET[$var] != '') {
1575
			return $_GET[$var];
1576
		} else {
1577
			return $valeur_par_defaut;
1578
		}
1579
	}
11 alexandre_ 1580
 
2 ddelon 1581
    /**
1582
     * Renvoie un message d'erreur, en fonction du code de l'erreur.
1583
     *
1584
     * @param int valeur Le code du message d'erreur.
1585
     * @return string
1586
     * @access public
1587
     */
1588
    function messageErreur( $valeur )
1589
    {
1590
        $messageErreur = array (
1591
                    PROJETCONTROLEUR_ACTION_INVALIDE => "Action non valide",
249 alexandre_ 1592
                    PROJETCONTROLEUR_ERREUR_SUPPRESSION_REPERTOIRE => "Impossible de supprimer le r&eacute;pertoire",
1593
                    PROJETCONTROLEUR_PAS_DE_DOCUMENT_SELECTIONNE => 'Pas de fichier s&eacute;lectionn&eacute;',
1594
                    PROJETCONTROLEUR_ERREUR_CREATION_REPERTOIRE => 'Impossible de cr&eacute;er le r&eacute;pertoire'
2 ddelon 1595
        ) ;
1596
        return '<p class="erreur">'.$messageErreur[$valeur].'</p>' ;
1597
    } // end of member function messageErreur
297 alexandre_ 1598
 
1599
	/** Envoie de mail pour prevenir les coordinateurs d une action sur le projet
1600
	 *
1601
	 *
1602
	 */
2 ddelon 1603
 
297 alexandre_ 1604
	function notifierCoordinateurs ($notification, $utilisateur) {
1605
 
1606
		include_once PROJET_CHEMIN_CLASSES.'projetTemplate.class.php';
1607
 
1608
		switch ($notification) {
1609
			case PROJET_NOTIFICATION_DEMANDE_INSCRIPTION :
1610
				$sujet = PROJET_TEMPLATE_DEMANDE_INSCRIPTION_SUJET;
1611
				$corps = PROJET_TEMPLATE_DEMANDE_INSCRIPTION_CORPS;
1612
			break;
1613
			case PROJET_NOTIFICATION_INSCRIPTION_NOUVELLE :
1614
				$sujet = PROJET_TEMPLATE_INSCRIPTION_NOUVELLE_SUJET;
1615
				$corps = PROJET_TEMPLATE_INSCRIPTION_NOUVELLE_CORPS;
1616
			break;
1617
			case PROJET_NOTIFICATION_DESINSCRIPTION_PROJET :
1618
				$sujet = PROJET_TEMPLATE_DESINSCRIPTION_SUJET;
1619
				$corps = PROJET_TEMPLATE_DESINSCRIPTION_CORPS;
1620
			break;
1621
			case PROJET_NOTIFICATION_NOUVEAU_DOC:
1622
				$sujet = PROJET_TEMPLATE_NOUVEAU_DOC_SUJET;
1623
				$corps = PROJET_TEMPLATE_NOUVEAU_DOC_CORPS;
1624
			break;
1625
 
1626
		}
1627
 
1628
		include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
1629
        $projet = new projet ($this->_db, $this->_id_projet) ;
1630
        include_once PROJET_CHEMIN_CLASSES.'participe.class.php';
1631
		$participant = new participe($this->_db) ;
1632
		$tableau_coordinateur = $participant->getCoordinateurs($this->_id_projet) ;
1633
 
1634
		$objet_mail =& Mail::factory('smtp');
1635
 
1636
 
1637
 
1638
		$modele = new projetTemplate($GLOBALS['projet_db']);
2 ddelon 1639
 
297 alexandre_ 1640
		$sujet_mail = $modele->getTemplate($sujet, PROJET_LANGUE_DEFAUT);
1641
		$corps_mail = $modele->getTemplate($corps, PROJET_LANGUE_DEFAUT);
1642
 
1643
	    if (PEAR::isError($sujet_mail)) $sujet_mail->raiseError ($sujet_mail->getMessage().'<br />'.$sujet_mail->getDebugInfo());
1644
 
1645
	    $corps_mail = str_replace ('{nom}', $utilisateur->getInfo( 'nom'), $corps_mail);
1646
	    $corps_mail = str_replace ('{prenom}', $utilisateur->getInfo( 'prenom'), $corps_mail);
1647
	    $corps_mail = str_replace ('{nom_projet}', $projet->getTitre(), $corps_mail);
1648
	    $corps_mail = str_replace ('{lien}', str_replace ('&amp;', '&', $this->_url->getURL()), $corps_mail);
1649
 
1650
		$entetes['From'] = PROJET_MAIL_ADMINISTRATEUR;
1651
        $entetes['To'] = '';
1652
        $entetes['Subject'] = trim ($sujet_mail) ;  // le trim est necessaire pour enlever d eventuels retour-chariot qui foutent el l air le message
1653
        $entetes['Date'] = date ('D, M j G:i:s \C\E\S\T Y') ;
1654
        $entetes['Message-ID'] = md5(time()) ;
1655
        $entetes['reply-to'] = $this->_auth->getUserName();
1656
        $entetes['Content-Type'] = 'text/plain' ;
1657
 
1658
		foreach ($tableau_coordinateur as $coordinateur) {
1659
			$entetes['To'] .= $coordinateur[3].',';	// Le champs 3 est le mail
1660
 
1661
		}
1662
		// On enleve la virgule finale
1663
 
1664
		$entetes['To'] = substr ($entetes['To'], 0, -1);
2 ddelon 1665
 
297 alexandre_ 1666
		// on envoie le mail
1667
		$objet_mail->send($entetes['To'], $entetes, html_entity_decode ($corps_mail));
1668
	}
2 ddelon 1669
 
297 alexandre_ 1670
 
2 ddelon 1671
} // end of projetControleur
288 alexandre_ 1672
 
1673
class bouton {
297 alexandre_ 1674
	static function toHTML($lien, $label, $id, $class='projet_bouton_action') {
1675
 
1676
		if ($lien != '#') {
1677
			$balise_a_debut = '<a href="'.$lien.'"'.($id == 'cross'? ' onclick="javascript:return confirm(\''.$label.' ?\');"':'').'>';
1678
			$balise_a_fin = '</a>';
1679
		} else {
1680
			$balise_a_debut = '';
1681
			$balise_a_fin = '';
1682
		}
1683
		return '<div id="bouton_'.$id.'" class="'.$class.'">' .
1684
				$balise_a_debut.'<img src="'.PROJET_CHEMIN_ICONES.$id.'.png" alt="'.$label.'" />'.$label.$balise_a_fin.'</div>';
288 alexandre_ 1685
	}
1686
}
297 alexandre_ 1687
/* +--Fin du code ----------------------------------------------------------------------------------------+
1688
*
1689
* $Log: not supported by cvs2svn $
337 alexandre_ 1690
* Revision 1.47  2008-09-01 14:38:00  alexandre_tb
1691
* correction de bug inscription projet
1692
*
335 alexandre_ 1693
* Revision 1.46  2008-08-28 14:48:54  alexandre_tb
1694
* encodage et suppression d une methode inutile
1695
*
332 alexandre_ 1696
* Revision 1.45  2008-08-26 12:42:10  alexandre_tb
1697
* nettoyage url apres suppression d un fichier
1698
*
331 alexandre_ 1699
* Revision 1.44  2008-08-26 08:52:28  alexandre_tb
1700
* suppression de la methode accueilProjet desormais remplacee par resume.php
1701
*
323 alexandre_ 1702
* Revision 1.43  2008-08-25 15:06:59  alexandre_tb
1703
* ajout:
1704
* - des notifications
1705
* - des messages en retour
1706
* - correction inscription a un projet avec liste externe
297 alexandre_ 1707
*
323 alexandre_ 1708
*
297 alexandre_ 1709
* +-- Fin du code ----------------------------------------------------------------------------------------+
1710
*/
1711
?>