Subversion Repositories Applications.projet

Rev

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