Subversion Repositories Applications.projet

Rev

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