Subversion Repositories Applications.projet

Rev

Rev 347 | Rev 397 | 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
 */
109
define ('PROJET_DROIT_ADMINISTRATEUR', 1) ;
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
     */
388
    function projetControleur(&$dbObjet, &$authObjet, $urlObjet = "")
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)) ;
904
            $this->notifierCoordinateurs(PROJET_NOTIFICATION_NOUVEAU_DOC, $utilisateur);
2 ddelon 905
        } else {
906
            return $formulaire_document->toHTML() ;
907
        }
249 alexandre_ 908
        return $retour;
297 alexandre_ 909
    }
2 ddelon 910
 
911
    /**
912
     * Valide le formulaire et appelle la fonction d'insertion.
913
     *
914
     * @return void
915
     * @access public
916
     */
917
    function modifierFichier( )
918
    {
249 alexandre_ 919
        // creation de l'objet projet courant
208 neiluj 920
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 921
        $projet = new projet ($this->_db, $this->_id_projet) ;
922
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_ACTION_MODIFIER_V) ;
208 neiluj 923
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireDocument.class.php' ;
2 ddelon 924
        $formulaire_document = new HTML_formulaireDocument('formulaire_document', 'post',preg_replace ("/&amp;/", "&", $this->_url->getURL())) ;
925
        $formulaire_document->construitFormulaire(PROJET_ACTION_MODIFIER_V) ;
926
        if ($formulaire_document->validate()) {
249 alexandre_ 927
            // Creation d'un objet document vide
2 ddelon 928
            $document = new document ($this->_id_document, $this->_db) ;
332 alexandre_ 929
            // On passe aussi le numero de repertoire s'il existe
2 ddelon 930
            if ($this->_id_repertoire != '') $document->setIdRepertoire($this->_id_repertoire) ;
931
            $document->majSQL($formulaire_document->getSubmitValues()) ;
932
        } else {
933
            return $formulaire_document->toHTML() ;
934
        }
935
        unset ($projet) ;
936
    } // end of member function nouveauFichierValidation
937
 
938
    /**
939
     * Valide le formulaire et appelle la fonction d'insertion.
940
     *
941
     * @return void
942
     * @access public
943
     */
944
    function nouveauRepertoireValidation( )
945
    {
249 alexandre_ 946
        // creation de l'objet projet courant
208 neiluj 947
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 948
        $projet = new projet ($this->_db, $this->_id_projet) ;
59 ddelon 949
 
2 ddelon 950
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_NOUVEAU_FICHIER_V) ;
208 neiluj 951
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireDocument.class.php' ;
2 ddelon 952
        $formulaire_repertoire = new HTML_formulaireDocument('formulaire_repertoire', 'post',preg_replace ("/&amp;/", "&", $this->_url->getURL())) ;
953
        $formulaire_repertoire->setType ('repertoire') ;
954
        $formulaire_repertoire->construitFormulaire() ;
955
        if ($formulaire_repertoire->validate()) {
249 alexandre_ 956
            // Creation d'un objet
2 ddelon 957
            $document = new document ("", $this->_db) ;
249 alexandre_ 958
            // avant d'appeler la methode enregistrerSQL, il faut indiquer l'identifiant du projet et l'identifiant du proprietaire
2 ddelon 959
            $document->setIdProjet ($this->_id_projet) ;
960
            $document->setIdProprietaire ($this->_auth->getAuthData (PROJET_CHAMPS_ID)) ;
59 ddelon 961
 
249 alexandre_ 962
            // On passe aussi le numero de repertoire s'il existe
2 ddelon 963
            if ($this->_id_repertoire != '') $document->setIdRepertoire($this->_id_repertoire) ;
249 alexandre_ 964
			if ($this->_id_repertoire == 0) $document->setIdRepertoire(0) ;
965
            $chemin_upload = $document->calculeCheminUploaded($projet->getNomRepertoire()) ;
966
            $nom_repertoire = $document->enregistrerSQL($formulaire_repertoire->getSubmitValues(), $projet->getNomRepertoire()) ;
59 ddelon 967
 
249 alexandre_ 968
            // La creation du repertoire sur le disque, chemin / nom_repertoire_projet / id_repertoire
269 alexandre_ 969
            $GLOBALS['log'] = '<br />chemin_upload:'.$chemin_upload.'<br />';
249 alexandre_ 970
            $GLOBALS['log'] .= '<br />mkdir('.PROJET_CHEMIN_FICHIER.$chemin_upload.$nom_repertoire.')<br />';
288 alexandre_ 971
            if (!mkdir (PROJET_CHEMIN_FICHIER.$chemin_upload.'/'.rtrim ($nom_repertoire, '/'))) {
59 ddelon 972
 
2 ddelon 973
                $document->suppressionSQL() ;
249 alexandre_ 974
                return $this->messageErreur(PROJETCONTROLEUR_ERREUR_CREATION_REPERTOIRE).'<br />'.
975
                						PROJET_CHEMIN_FICHIER.$chemin_upload.'/'.$nom_repertoire;
2 ddelon 976
            }
208 neiluj 977
            // On place a 1 la colonne p_avoir_document
978
            if (!$projet->avoirDocument()) $projet->setAvoirDocument(true);
2 ddelon 979
        } else {
980
            return $formulaire_repertoire->toHTML() ;
981
        }
249 alexandre_ 982
    }
2 ddelon 983
 
984
 
985
    /**
249 alexandre_ 986
     * Permet de specifier au controleur sur quel projet l'on travaille.
2 ddelon 987
     *
988
     * @param int id_projet L'identifiant du projet.
989
     * @return void
990
     * @access public
991
     */
992
    function setIdProjet( $id_projet )
993
    {
994
        $this->_id_projet = $id_projet ;
323 alexandre_ 995
    }
59 ddelon 996
 
2 ddelon 997
    /**
249 alexandre_ 998
     * Permet de specifier quel repertoire, dans la vue de document afficher. Il sera
999
     * passe en parametre a la classe HTML_listeDocuments.
2 ddelon 1000
     *
249 alexandre_ 1001
     * @param int id_repertoire L'identifiant du repertoire a afficher.
2 ddelon 1002
     * @return void
1003
     * @access public
1004
     */
1005
    function setIdRepertoire( $id_repertoire )
1006
    {
1007
        $this->_id_repertoire = $id_repertoire ;
249 alexandre_ 1008
    }
2 ddelon 1009
 
1010
    /**
1011
     * Supprime un projet et tout ce qui va avec.
1012
     *
1013
     * @return void
1014
     * @access public
1015
     */
1016
    function suppressionProjet( )
1017
    {
208 neiluj 1018
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1019
        $projet = new projet ($this->_db, $this->_id_projet) ;
1020
        $projet->setCheminRepertoire (PROJET_CHEMIN_FICHIER) ;
1021
        $projet->getListesAssociees() ;
1022
        if ($projet->avoirListe()) $projet->supprimerListe($projet->_listes_associes[0]) ;
1023
        $msg = $projet->suppressionSQL() ;
1024
        unset ($this->_id_projet) ; unset($_GET['id_projet']);
1025
        return $msg ;
208 neiluj 1026
    }
2 ddelon 1027
 
1028
    /**
1029
     * Permet d'indiquer au controleur sur quel document on travaille.
1030
     *
59 ddelon 1031
     * @param int id_document
2 ddelon 1032
     * @return void
1033
     * @access public
1034
     */
1035
    function setIdDocument( $id_document )
1036
    {
1037
        $this->_id_document = $id_document ;
208 neiluj 1038
    }
2 ddelon 1039
 
1040
 
1041
    /**
1042
     * Renvoie le formulaire d'envoie de mail
1043
     *
1044
     * @return void
1045
     * @access public
1046
     */
1047
    function envoyerUnMailFormulaire( )
1048
    {
74 alexandre_ 1049
    	if (!$this->_auth->getAuth()) {
389 aurelien 1050
    		return PROJET_LISTE_PROJET;
74 alexandre_ 1051
    	}
96 alexandre_ 1052
    	if (isset($_SESSION['formulaire_mail'])) {
1053
            unset ($_SESSION['formulaire_mail']) ;
1054
        }
2 ddelon 1055
        $res = '<h1>'.PROJET_ECRIRE_LISTE.'</h1>'."\n" ;
1056
        $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ENVOYER_UN_MAIL_V) ;
208 neiluj 1057
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireMail.class.php' ;
2 ddelon 1058
        $formulaire_mail = new HTML_formulaireMail('formulaire_mail', 'post',preg_replace ("/&amp;/", "&", $this->_url->getURL())) ;
1059
        $formulaire_mail->construitFormulaire() ;
1060
        return $res.$formulaire_mail->toHTML() ;
208 neiluj 1061
    }
2 ddelon 1062
 
1063
    /**
1064
     * Envoie le mail
1065
     *
1066
     * @return void
1067
     * @access public
1068
     */
1069
    function envoyerUnMailValidation( )
1070
    {
249 alexandre_ 1071
        // Verifications
96 alexandre_ 1072
        if (isset($_SESSION['formulaire_mail']) && $_SESSION['formulaire_mail'] == 'valide') {
208 neiluj 1073
            return include_once PROJET_CHEMIN_APPLI.'actions/forums.php' ;
96 alexandre_ 1074
        }
389 aurelien 1075
 
2 ddelon 1076
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_ENVOYER_UN_MAIL_V );
208 neiluj 1077
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireMail.class.php' ;
2 ddelon 1078
        $formulaire_mail = new HTML_formulaireMail('formulaire_mail', 'post', preg_replace ("/&amp;/", "&", $this->_url->getURL())) ;
1079
        $formulaire_mail->construitFormulaire() ;
1080
        if ($formulaire_mail->validate()) {
249 alexandre_ 1081
            // creation de l'objet projet courant
208 neiluj 1082
            include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1083
            $projet = new projet ($this->_db, $this->_id_projet) ;
1084
            $info_liste = $projet->getListesAssociees() ;
1085
            $valeurs_mail = $formulaire_mail->getSubmitValues() ;
1086
            // Pour envoyer le mail on utilise la classe Mail de PEAR
1087
            // on a besoin du mail de l'inscrit
1088
 
1089
            $entetes['From'] = $this->_auth->getUserName();
1090
            $entetes['To'] = $projet->_listes_associes[0]->getAdresseEnvoi() ;
1091
            $entetes['Subject'] = $valeurs_mail['mail_titre'] ;
63 alexandre_ 1092
            $entetes['Date'] = date ('D, M j G:i:s \C\E\S\T Y') ;
2 ddelon 1093
            $entetes['Message-ID'] = md5(time()).'@'.$projet->_listes_associes[0]->getNom().'.'.$projet->_listes_associes[0]->getDomaine() ;
1094
            $entetes['reply-to'] = $projet->_listes_associes[0]->getAdresseEnvoi() ;
1095
            $entetes['Content-Type'] = 'text/plain' ;
249 alexandre_ 1096
            // Traitement de la reference s'il s'agit d'une reponse
2 ddelon 1097
            if (isset ($_POST['messageid'])) {
1098
                $entetes['In-Reply-To'] = $_POST['messageid'] ;
1099
            }
1100
            $objet_mail =& Mail::factory('smtp');
1101
            $objet_mail->send($entetes['To'], $entetes, $valeurs_mail['mail_corps']);
96 alexandre_ 1102
            $_SESSION['formulaire_mail'] = 'valide';
2 ddelon 1103
            return  ;
1104
        } else {
1105
            return $formulaire_mail->toHTML() ;
1106
        }
1107
    } // end of member function envoyerUnMailValidation
1108
 
1109
   /**
332 alexandre_ 1110
     * Renvoie le formulaire de creation d'une liste.
2 ddelon 1111
     *
1112
     * @param int action Indique le type d'action,  PROJET_ACTION_NOUVELLE_LISTE
1113
     * @return string
1114
     * @access public
1115
     */
1116
    function formulaireListe( $action )
1117
    {
1118
        $res = '<h1>'.PROJET_CREATION_LISTE.'</h1>'."\n" ;
1119
        $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_NOUVELLE_LISTE_V) ;
208 neiluj 1120
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireListe.class.php' ;
2 ddelon 1121
        $formulaire_liste = new HTML_formulaireListe('formulaire_liste', 'post',preg_replace ("/&amp;/", "&", $this->_url->getURL())) ;
1122
        $formulaire_liste->construitFormulaire() ;
1123
        $formulaire_liste->setDefaults(array('domaine_liste' => PROJET_DOMAINE_LISTE)) ;
1124
        $formulaire_liste->updateElementAttr('domaine_liste', array('readonly' => 'readonly')) ;
1125
        return $res.$formulaire_liste->toHTML() ;
389 aurelien 1126
    }
2 ddelon 1127
 
389 aurelien 1128
    function formulaireModificationListe($id_projet) {
1129
 
1130
    	include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
1131
		$projet = new projet ($this->_db, $this->_id_projet) ;
1132
 
1133
		$projet->getListesAssociees();
1134
		//var_dump($projet);
1135
		$liste_visible = $projet->_listes_associes[0]->getVisibilite();
1136
 
1137
    	$res = '<h1> Modification de la visibilité de la liste </h1><br />'."\n" ;
1138
        $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_MODIFIER_LISTE_V) ;
1139
        $res .= '<form action="'.$this->_url->getURL().'" method="post">'.
1140
        '<label for="liste_visible">Visibilité de la liste </label><input type="checkbox" name="liste_visible" id="liste_visible"';
1141
		if($liste_visible == 1) {
1142
			$res .= ' checked="checked" ';
1143
		}
1144
 		$res .= ' /> <br /><br />'.
1145
        '<input type="submit" value="valider" /> '.
1146
        '</form>';
1147
 
1148
		return $res;
1149
    }
1150
 
2 ddelon 1151
    /**
332 alexandre_ 1152
     * Transmet au serveur la demande de creation d'une nouvelle liste.
2 ddelon 1153
     *
1154
     * @return void
1155
     * @access public
1156
     */
1157
    function nouvelleListeValidation( )
1158
    {
249 alexandre_ 1159
        // Verifications
2 ddelon 1160
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_ACTION_NOUVELLE_LISTE_V );
208 neiluj 1161
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireListe.class.php' ;
2 ddelon 1162
        $formulaire_liste = new HTML_formulaireListe('formulaire_liste', 'post', preg_replace ("/&amp;/", "&", $this->_url->getURL())) ;
1163
        $formulaire_liste->construitFormulaire() ;
1164
        if ($formulaire_liste->validate()) {
249 alexandre_ 1165
            // creation de l'objet liste_discussion
1166
            include_once PROJET_CHEMIN_CLASSES.'liste_discussion.class.php';
2 ddelon 1167
            $liste = new liste_discussion('', $this->_db) ;
59 ddelon 1168
 
332 alexandre_ 1169
            // On verifie que le nom de la liste soit unique
2 ddelon 1170
            if (liste_discussion::verifieDoubleListe($formulaire_liste->getSubmitValue('nom_liste').'@'.
1171
                                                            $formulaire_liste->getSubmitValue('domaine_liste'), $this->_db)) {
59 ddelon 1172
                // On rajoute la liste dans la base
2 ddelon 1173
                $liste->enregistrerSQL($formulaire_liste->getSubmitValues()) ;
59 ddelon 1174
 
2 ddelon 1175
                // On la relie au projet
208 neiluj 1176
                include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1177
                $projet = new projet ($this->_db, $this->_id_projet) ;
1178
                $projet->ajouterListe($liste) ;
59 ddelon 1179
 
249 alexandre_ 1180
                // Creation de la liste
22 alexandre_ 1181
                $resultat_creation = file_get_contents (PROJET_SERVEUR_VPOPMAIL.'/creation_liste.php?domaine='.
2 ddelon 1182
                                    $liste->getDomaine().'&liste='.$liste->getNom().'&parametres=aBiud') ;
59 ddelon 1183
 
249 alexandre_ 1184
                // Ajout du moderateur
22 alexandre_ 1185
                $resultat_ajout_moderateur = file_get_contents (PROJET_SERVEUR_VPOPMAIL.'/ajout_moderateur.php?domaine='.
2 ddelon 1186
                                    $liste->getDomaine().'&liste='.$liste->getNom().'&mail='.$this->_auth->getUserName()) ;
249 alexandre_ 1187
                // Ajout du moderateur en tant qu'utilisateur
22 alexandre_ 1188
                $resultat_ajout_utilisateur = file_get_contents (PROJET_SERVEUR_VPOPMAIL.'/ajout_abonne.php?domaine='.
2 ddelon 1189
                                    $liste->getDomaine().'&liste='.$liste->getNom().'&mail='.$this->_auth->getUserName()) ;
1190
 
1191
            } else {
1192
                return PROJET_MESSAGE_LISTE_DOUBLE.$formulaire_liste->toHTML() ;
1193
            }
1194
            return $resultat_creation.$resultat_ajout_moderateur.$resultat_ajout_utilisateur;
59 ddelon 1195
 
2 ddelon 1196
        } else {
1197
            return $formulaire_liste->toHTML() ;
1198
        }
1199
    } // end of member function nouvelleListeValidation
59 ddelon 1200
 
389 aurelien 1201
    function modifierListeValidation($id_projet) {
1202
 
1203
        if(isset($_POST['liste_visible'])) {
1204
			$visibilite = true;
1205
        } else {
1206
        	$visibilite = false;
1207
        }
1208
 
1209
		$projet->getListesAssociees();
1210
		$id_liste = $projet->_listes_associes[0]->getId();
1211
		$projet->majSQLVisibilite($id_projet,$visibilite);
1212
 
1213
		return true;
1214
    }
1215
 
2 ddelon 1216
    /**
332 alexandre_ 1217
     * Supprime la liste de discussion associee au projet
2 ddelon 1218
     *
1219
     * @return void
1220
     * @access public
1221
     */
1222
    function supprimerListe( )
1223
    {
208 neiluj 1224
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1225
        $projet = new projet($this->_db, $this->_id_projet) ;
1226
        $projet->getListesAssociees() ;
59 ddelon 1227
 
22 alexandre_ 1228
        $resultat_suppression = file_get_contents(PROJET_SERVEUR_VPOPMAIL.'/suppression_liste.php?domaine='.
2 ddelon 1229
                                    $projet->_listes_associes[0]->getDomaine().'&liste='.$projet->_listes_associes[0]->getNom()) ;
1230
        $projet->supprimerListe($projet->_listes_associes[0]) ;
1231
        return $resultat_suppression;
1232
    } // end of member function supprimerListe
1233
 
1234
 
1235
    /**
1236
     *
59 ddelon 1237
     *
332 alexandre_ 1238
     * @param string presentation Pour affecter une presentation au projet
2 ddelon 1239
     * @return void
1240
     * @access public
1241
     */
1242
    function setPresentation( $presentation )
1243
    {
1244
        $this->_presentation = $presentation ;
1245
    } // end of member function setPresentation
1246
 
11 alexandre_ 1247
    /**
1248
     *
59 ddelon 1249
     *
11 alexandre_ 1250
     * @param string type Pour affecter un type au projet
1251
     * @return void
1252
     * @access public
1253
     */
1254
    function setType( $type)
1255
    {
1256
        $this->_type = $type ;
1257
    } // end of member function setPresentation
2 ddelon 1258
 
1259
    /**
249 alexandre_ 1260
     * Inscrit un utilisateur a un projet avec le statut observateur
2 ddelon 1261
     *
1262
     * @return void
1263
     * @access public
1264
     */
1265
    function inscriptionProjet( )
1266
    {
1267
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireInscriptionProjet.class.php' ;
208 neiluj 1268
		include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1269
        $projet = new projet ($this->_db, $this->_id_projet) ;
59 ddelon 1270
 
2 ddelon 1271
        // Si le projet n'a pas de liste, on inscrit directement
1272
        if (isset ($this->_id_projet)) {
208 neiluj 1273
            include_once PROJET_CHEMIN_CLASSES.'participe.class.php' ;
2 ddelon 1274
            $participant = new participe($this->_db) ;
389 aurelien 1275
 
297 alexandre_ 1276
			// On controle si la liste est externe (yahoo) auquel cas on ne presente pas l inscription
1277
			include_once PROJET_CHEMIN_CLASSES.'liste_externe.class.php' ;
1278
			$liste_ext = new liste_externe($this->_db);
1279
			$listes = $liste_ext->getListesAssociees($this->_id_projet);
335 alexandre_ 1280
			if (count ($listes))$info_liste = $liste_ext->getInfoListe($listes[0]);
297 alexandre_ 1281
			if (count ($listes) != 0) {
1282
				$avoir_liste_externe = true;
1283
				$msg = '';
1284
				$msg = 'Pour vous inscrire &agrave; la liste de discussion, h&eacute;berg&eacute;e par Yahoo Groupes, <a href="mailto:';
1285
				$msg .= $info_liste->AGO_A_MAILABO.'">cliquez ici</a>';
1286
			} else {
1287
				$avoir_liste_externe = false;
1288
			}
1289
            if (!$projet->avoirListe() || $avoir_liste_externe) {
122 alexandre_ 1290
            	if ($projet->isModere()) {
1291
                	$participant->setStatut(3, $this->_auth->getAuthData (PROJET_CHAMPS_ID), $this->_id_projet) ;
1292
            	} else {
389 aurelien 1293
            		$participant->setStatut(2, $this->_auth->getAuthData (PROJET_CHAMPS_ID), $this->_id_projet) ;
297 alexandre_ 1294
            		$message_retour = '<p class="information">Votre inscription a bien &eacute;t&eacute; prise en compte'.$msg.'</p>';
122 alexandre_ 1295
            	}
297 alexandre_ 1296
            	$message_retour = '<p class="information">Votre inscription a bien &eacute;t&eacute; prise en compte. '.$msg.'</p>';
1297
    			include_once PROJET_CHEMIN_APPLI.'actions/resume.php' ;
1298
    			return $retour;
2 ddelon 1299
            }
1300
        }
1301
        if (isset($_POST['valider_inscription_projet'])) {
1302
            if (isset($_POST['radio_inscription_liste'])) {
122 alexandre_ 1303
            	include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
389 aurelien 1304
            	$utilisateur = new annuaire($this->_db, array('identifiant' => PROJET_CHAMPS_ID,
122 alexandre_ 1305
								'mail' => PROJET_CHAMPS_MAIL, 'table' => PROJET_ANNUAIRE,
1306
								'nom'=> PROJET_CHAMPS_NOM, 'prenom' => PROJET_CHAMPS_PRENOM)) ;
1307
	            $utilisateur->setId($this->_auth->getAuthData(PROJET_CHAMPS_ID)) ;
389 aurelien 1308
 
122 alexandre_ 1309
            	if (!$projet->isModere()) {
1310
	                $participant->setStatut(2, $this->_auth->getAuthData (PROJET_CHAMPS_ID), $this->_id_projet) ;
389 aurelien 1311
 
297 alexandre_ 1312
	                if ($_POST['radio_inscription_liste'] == 2) {
1313
		                include_once PROJET_CHEMIN_CLASSES.'inscription_liste.class.php' ;
1314
		                $projet->getListesAssociees() ;
1315
		                $inscription_liste = new inscription_liste($this->_db) ;
1316
		                $inscription_liste->inscrireUtilisateur( $utilisateur,
1317
	                                                        $projet->_listes_associes[0],
1318
	                                                        $_POST['radio_inscription_liste']) ;
1319
	                }
1320
                    $this->notifierCoordinateurs(PROJET_NOTIFICATION_INSCRIPTION_NOUVELLE, $utilisateur);
122 alexandre_ 1321
            	} else {
1322
            		$participant->setStatut(3, $this->_auth->getAuthData (PROJET_CHAMPS_ID), $this->_id_projet) ;
389 aurelien 1323
 
297 alexandre_ 1324
            		$this->notifierCoordinateurs(PROJET_NOTIFICATION_DEMANDE_INSCRIPTION, $utilisateur);
122 alexandre_ 1325
            	}
2 ddelon 1326
            }
59 ddelon 1327
 
2 ddelon 1328
            if ($this->_presentation != 'arbre') {
272 alexandre_ 1329
                if ($projet->isModere()) return '<h1>'.$projet->getTitre().'</h1>'.
249 alexandre_ 1330
                		str_replace ('nom_du_projet', $projet->getTitre(), PROJET_LAIUS_INSCRIPTION_MODERE);
297 alexandre_ 1331
                		else {
1332
                			$message_retour = '<p class="information">Votre inscription a bien &eacute;t&eacute; prise en compte'.$msg.'</p>';
1333
                			include_once PROJET_CHEMIN_APPLI.'actions/resume.php' ;
1334
                			return $retour;
1335
                		}
2 ddelon 1336
            } else {
1337
                $this->_action = PROJET_ACTION_VOIR_RESUME;
1338
            }
249 alexandre_ 1339
            return PROJET_LAIUS_INSCRIPTION_MODERE;
2 ddelon 1340
        }
1341
        $res = '<h1>'.PROJET_INSCRIPTION_PROJET.' : '.$projet->getTitre().'</h1>'."\n" ;
1342
        if ($projet->avoirListe()) $res .= '<h2>'.PROJET_MESSAGE_LISTE.'</h2>'."\n" ;
1343
        //$participant = new participe($this->_db) ;
1344
        $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_S_INSCRIRE) ;
1345
        $HTML_formulaireInscriptionProjet = new HTML_formulaireInscriptionProjet('inscription_projet', 'post', str_replace ('&amp;', '&', $this->_url->getURL())) ;
1346
        $HTML_formulaireInscriptionProjet->construitFormulaire($projet) ;
1347
        $HTML_formulaireInscriptionProjet->setDefaults(array('radio_inscription_liste' => 2)) ;
1348
        return $res.$HTML_formulaireInscriptionProjet->toHTML() ;
1349
    } // end of member function inscriptionProjet
1350
 
1351
    /**
249 alexandre_ 1352
     * Inscrit l'utilisateur loggue a la liste dont le parametre est en post.
2 ddelon 1353
     *
1354
     * @return void
1355
     * @access public
1356
     */
1357
    function inscriptionListe( )
1358
    {
208 neiluj 1359
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1360
        $projet = new projet ($this->_db, $this->_id_projet) ;
1361
        include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
1362
        include_once PROJET_CHEMIN_CLASSES.'inscription_liste.class.php' ;
1363
        $projet->getListesAssociees() ;
1364
        $utilisateur = new annuaire($this->_db, array('identifiant' => PROJET_CHAMPS_ID, 'mail' => PROJET_CHAMPS_MAIL, 'table' => PROJET_ANNUAIRE)) ;
1365
        $utilisateur->setId($this->_auth->getAuthData(PROJET_CHAMPS_ID)) ;
1366
        $inscription_liste = new inscription_liste($this->_db) ;
1367
        $inscription_liste->inscrireUtilisateur( $utilisateur, $projet->_listes_associes[0], 2) ;  // 2 est la statut inscription normale
297 alexandre_ 1368
        return '<p class="information">Vous &ecirc;tes inscrit &agrave; la liste</p>';
2 ddelon 1369
    } // end of member function inscriptionListe
1370
 
1371
    /**
297 alexandre_ 1372
     * Inscrit l'utilisateur loggue a la liste dont le parametre est en post.
2 ddelon 1373
     *
1374
     * @return void
1375
     * @access public
1376
     */
1377
    function desinscriptionListe( )
1378
    {
1379
        if (isset($_GET['inscription_liste']) || $this->_action = PROJET_ACTION_DESINSCRIPTION_LISTE) {
208 neiluj 1380
            include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1381
            $projet = new projet ($this->_db, $this->_id_projet) ;
1382
            include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
1383
            include_once PROJET_CHEMIN_CLASSES.'inscription_liste.class.php' ;
1384
            $projet->getListesAssociees() ;
31 alexandre_ 1385
            $utilisateur = new annuaire($this->_db, array('identifiant' => PROJET_CHAMPS_ID,
1386
            								 'mail' => PROJET_CHAMPS_MAIL,
1387
            								 'table' => PROJET_ANNUAIRE)) ;
2 ddelon 1388
            $utilisateur->setId($this->_auth->getAuthData(PROJET_CHAMPS_ID)) ;
1389
            $inscription_liste = new inscription_liste($this->_db) ;
1390
            $inscription_liste->desinscrireUtilisateur( $utilisateur, $projet->_listes_associes[0], $_GET['inscription_liste']) ;
297 alexandre_ 1391
            return '<p class="information">Vous avez &eacute;t&eacute; d&eacute;sinscrit de la liste</p>';
2 ddelon 1392
        }
1393
    } // end of member function inscriptionListe
1394
    /**
297 alexandre_ 1395
     * desinscrit un utilisateur d un projet
2 ddelon 1396
     *
1397
     * @return void
1398
     * @access public
1399
     */
1400
    function desinscriptionProjet( )
1401
    {
1402
        include_once PROJET_CHEMIN_CLASSES.'participe.class.php' ;
297 alexandre_ 1403
        include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
2 ddelon 1404
        $participant = new participe($this->_db) ;
389 aurelien 1405
		$utilisateur = new annuaire($this->_db, array('identifiant' => PROJET_CHAMPS_ID,
297 alexandre_ 1406
								'mail' => PROJET_CHAMPS_MAIL, 'table' => PROJET_ANNUAIRE,
1407
								'nom'=> PROJET_CHAMPS_NOM, 'prenom' => PROJET_CHAMPS_PRENOM)) ;
1408
	    $utilisateur->setId($this->_auth->getAuthData(PROJET_CHAMPS_ID)) ;
389 aurelien 1409
 
297 alexandre_ 1410
        // Le statut 4 desinscrit l'utilisateur, dans la methode setStatut
2 ddelon 1411
        $participant->setStatut(4, $this->_auth->getAuthData (PROJET_CHAMPS_ID), $this->_id_projet) ;
208 neiluj 1412
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1413
        $projet = new projet ($this->_db, $this->_id_projet) ;
1414
        $projet->getListesAssociees() ;
1415
        if ($projet->avoirListe()) {
1416
            include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
1417
            $annuaire = new annuaire($this->_db, array('identifiant' => PROJET_CHAMPS_ID, 'mail' => PROJET_CHAMPS_MAIL, 'table' => PROJET_ANNUAIRE)) ;
1418
            $annuaire->setId($this->_auth->getAuthData(PROJET_CHAMPS_ID)) ;
1419
            include_once PROJET_CHEMIN_CLASSES.'inscription_liste.class.php' ;
1420
            $desinscription= new inscription_liste($this->_db) ;
1421
            $desinscription->desinscrireUtilisateur($annuaire, $projet->_listes_associes[0]) ;
1422
        }
297 alexandre_ 1423
        $this->notifierCoordinateurs(PROJET_NOTIFICATION_DESINSCRIPTION_PROJET, $utilisateur);
389 aurelien 1424
 
341 alexandre_ 1425
        // On verifie si l utilisateur est le dernier coordinateur
1426
        // auquel cas on previent les administrateurs
1427
        if ($participant->isCoordinateur($this->_auth->getAuthData(PROJET_CHAMPS_ID), $this->_id_projet, $this->_db)) {
1428
        	$coord = $participant->getCoordinateurs($this->_id_projet);
1429
        	if (count($coord) == 0) {
1430
        		$this->notifierCoordinateurs(PROJET_NOTIFICATION_DESINSCRIPTION_PROJET_DERNIER_COORD, $utilisateur);
1431
        	}
1432
        }
389 aurelien 1433
        //
297 alexandre_ 1434
        include_once PROJET_CHEMIN_CLASSES.'liste_externe.class.php';
1435
        $liste_ext = new liste_externe($this->_db);
1436
		$listes = $liste_ext->getListesAssociees($this->_id_projet);
389 aurelien 1437
 
297 alexandre_ 1438
		$msg = '';
1439
		if (count ($listes) != 0) {
341 alexandre_ 1440
			$info_liste = $liste_ext->getInfoListe($listes[0]);
297 alexandre_ 1441
			$msg = 'Pensez si vous le souhaitez à vous d&eacute;sinscrire de la liste de discussion, h&eacute;berg&eacute;e par Yahoo Groupes.';
1442
			$msg .= ' Vous pouvez le faire en <a href="mailto:';
1443
			$msg .= $info_liste->AGO_A_MAILDESA.'">cliquez ici</a>';
1444
		}
2 ddelon 1445
        if ($this->_presentation != 'arbre') {
297 alexandre_ 1446
            $message_retour = '<p class="information">Votre d&eacute;sinscription a bien &eacute;t&eacute; prise en compte. '.$msg.'</p>';
122 alexandre_ 1447
            include_once PROJET_CHEMIN_APPLI.'actions/resume.php' ;
1448
            return $retour ;
2 ddelon 1449
        } else {
1450
            $this->_action = PROJET_ACTION_VOIR_RESUME;
1451
        }
297 alexandre_ 1452
    }
2 ddelon 1453
 
1454
    /**
297 alexandre_ 1455
     * Renvoie le formulaire de creation d'un wiki
2 ddelon 1456
     *
1457
     * @return void
1458
     * @access public
1459
     */
1460
    function formulaireWiki( )
1461
    {
59 ddelon 1462
 
1463
		require_once 'client/integrateur_wikini/bibliotheque/iw_admin_wikini.fonct.php';
1464
 
60 ddelon 1465
 
61 ddelon 1466
  		$url = &$GLOBALS['_GEN_commun']['url'] ;
60 ddelon 1467
		$url->addQueryString ('act', PROJET_ACTION_CREER_WIKI) ;
79 alexandre_ 1468
		$url->addQueryString (PROJET_VARIABLE_ID_PROJET, $this->_id_projet) ;
59 ddelon 1469
		$res =admin_afficherContenuCorps();
79 alexandre_ 1470
		$res .= '<br /><a href="'.$this->_url->getURL().'">'.PROJET_RETOUR_RESUME.'</a>';
59 ddelon 1471
    	return $res;
1472
 
332 alexandre_ 1473
    }
2 ddelon 1474
 
16 ddelon 1475
 
1476
	function associerWiki( )
1477
    {
1478
        $res = '<h1>'.PROJET_ASSOCIER_WIKI.'</h1>'."\n" ;
59 ddelon 1479
 
1480
	 	$db = &$GLOBALS['_GEN_commun']['pear_db'] ;
16 ddelon 1481
    	$res='';
59 ddelon 1482
 
332 alexandre_ 1483
         // Comportement par defaut
59 ddelon 1484
	    // requete sur la table gen_wikini pour affichage de la liste des Wikini
16 ddelon 1485
	    $requete = "select  gewi_id_wikini, gewi_code_alpha_wikini, gewi_page from gen_wikini" ;
59 ddelon 1486
 
16 ddelon 1487
	    $resultat = $db->query ($requete) ;
1488
	    if (DB::isError ($resultat)) {
1489
	        $GLOBALS['_GEN_commun']['debogage_erreur']->gererErreur(E_USER_WARNING, "Echec de la requete : $requete<br />".$resultat->getMessage(),
1490
	                                                                        __FILE__, __LINE__, 'admin_wikini')   ;
1491
	        return ;
1492
	    }
59 ddelon 1493
 
337 alexandre_ 1494
		include_once 'api/html/HTML_TableFragmenteur.php';
16 ddelon 1495
	    $liste = new HTML_TableFragmenteur () ;
40 ddelon 1496
	    $liste->construireEntete(array (PROJET_NOM_WIKINI,PROJET_PAGE_WIKINI, PROJET_SELECTIONNER_WIKINI)) ;
59 ddelon 1497
 
16 ddelon 1498
	    $tableau_wikini = array() ;
59 ddelon 1499
 
16 ddelon 1500
	    while ($ligne = $resultat->fetchRow()) {
1501
	        $this->_url->addQueryString ('id_wikini', $ligne[0]) ;
332 alexandre_ 1502
	        array_push ($tableau_wikini, array ($ligne[1]."\n",    // Premiere colonne, le nom de l'application
16 ddelon 1503
										        $ligne[2]."\n",    // Deuxieme colonne, la page par defaut
40 ddelon 1504
	        								  '<a href="'.$this->_url->getURL()."&amp;".PROJET_VARIABLE_ACTION."=".PROJET_ACTION_ASSOCIER_WIKI_V."".'">'.PROJET_CHOISIR_WIKINI.'</a>'."\n",
16 ddelon 1505
	                                            ));
1506
	    }
1507
	    $liste->construireListe($tableau_wikini) ;
1508
	    $res .= $liste->toHTML();
68 alexandre_ 1509
	    $this->_url->removeQueryString(PROJET_VARIABLE_ACTION) ;
16 ddelon 1510
	    return $res ;
59 ddelon 1511
 
1512
 
1513
 
16 ddelon 1514
    } // end of member function formulaireWiki
1515
 
2 ddelon 1516
 
40 ddelon 1517
    /**
1518
     * Associe un wiki au projet courant
1519
     *
1520
     * @return void
1521
     * @access public
1522
     */
2 ddelon 1523
 
40 ddelon 1524
	function associationWiki( )  {
59 ddelon 1525
 
1526
 
40 ddelon 1527
    	if (isset($_GET['id_wikini'])) {
1528
    		$db = &$GLOBALS['_GEN_commun']['pear_db'] ;
1529
		    $requete = "select gewi_code_alpha_wikini from gen_wikini where gewi_id_wikini = ".$_GET['id_wikini'] ;
1530
	    	$resultat = $db->query ($requete) ;
1531
	    	if (DB::isError ($resultat)) {
1532
	        	$GLOBALS['_GEN_commun']['debogage_erreur']->gererErreur(E_USER_WARNING, "Echec de la requete : $requete<br />".$resultat->getMessage(),
1533
	            	                                                            __FILE__, __LINE__, 'admin_wikini')   ;
1534
	        	return ;
1535
	    	}
59 ddelon 1536
 
40 ddelon 1537
	    	$ligne = $resultat->fetchRow();
208 neiluj 1538
	    	include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
40 ddelon 1539
			$projet = new projet($this->_db, $this->_id_projet) ;
1540
        	$projet->majNomWikini($ligne[0]);
1541
    	}
59 ddelon 1542
 
40 ddelon 1543
	}
1544
 
2 ddelon 1545
    /**
1546
     * Supprime le wiki du projet courant
1547
     *
1548
     * @return void
1549
     * @access public
1550
     */
1551
    function supprimerWiki( )
1552
    {
1553
        include_once PROJET_CHEMIN_CLASSES.'gestion_wikini.class.php' ;
1554
        // On crée une nouvelle connexion avec les paramètres spécifiques aux wikinis
1555
        $connexion_bd = DB::connect('mysql://'.PROJET_UTILISATEUR_WIKINI.':'.PROJET_MDP_WIKINI.'@'.PROJET_HOTE_WIKINI.'/'.PROJET_DB_WIKINI) ;
1556
        $gerantWiki = new gestion_wikini($connexion_bd) ;
208 neiluj 1557
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1558
        $projet = new projet ($this->_db, $this->_id_projet) ;
1559
        $gerantWiki->suppression_tables(strtolower($projet->getWikini())) ;
1560
        $projet->majNomWikini('') ;
1561
    } // end of member function supprimerWiki
1562
 
1563
    /**
1564
     * Permet de lier une ou plusieurs listes de la table agora à un projet.
1565
     *
1566
     * @return string
1567
     * @access public
1568
     */
1569
    function referencerListeExterne( )
1570
    {
158 alexandre_ 1571
        $requete = 'show tables like \'agora\'' ;
1572
        $resultat = $this->_db->query ($requete);
1573
        if ($resultat->numRows() == 0) {
1574
        	return 'Cette fonctionnalité n\'est pas active' ;
1575
        }
2 ddelon 1576
        $res = '<h1>'.PROJET_REFERENCER_LISTE.'</h1>' ;
1577
        include_once PROJET_CHEMIN_CLASSES.'liste_externe.class.php' ;
1578
        $liste_externe = new liste_externe($this->_db) ;
1579
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireListeExterne.class.php' ;
1580
        $this->_url->addQueryString(PROJET_VARIABLE_ID_PROJET, $this->_id_projet) ;
1581
        $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_REFERENCER_LISTE_V) ;
1582
        $HTML_formulaireListeExterne = new HTML_formulaireListeExterne('formulaire_liste_externe', 'post', str_replace('&amp;', '&', $this->_url->getURL())) ;
1583
        $HTML_formulaireListeExterne->construitFormulaire($liste_externe->getListeNom()) ;
1584
        $liste_assoc = $liste_externe->getListesAssociees($this->_id_projet) ;
1585
        $default = array() ;
1586
        foreach ($liste_assoc as $val) $default['liste_'.$val] = 1 ;
1587
 
1588
        $HTML_formulaireListeExterne->setDefaults($default) ;
1589
        return $res.$HTML_formulaireListeExterne->toHTML() ;
1590
    } // end of member function referencerListeExterne
1591
 
1592
    /**
332 alexandre_ 1593
     * Realise les mises a jours dans la table projet_lien_liste_externe
2 ddelon 1594
     *
1595
     * @return void
1596
     * @access public
1597
     */
1598
    function referencerListeExterneValidation( )
1599
    {
1600
        include_once PROJET_CHEMIN_CLASSES.'liste_externe.class.php' ;
1601
        $liste_externe = new liste_externe($this->_db) ;
1602
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireListeExterne.class.php' ;
1603
        $HTML_formulaireListeExterne = new HTML_formulaireListeExterne('formulaire_liste_externe', 'post', str_replace('&amp;', '&', $this->_url->getURL())) ;
1604
        $HTML_formulaireListeExterne->construitFormulaire($liste_externe->getListeNom()) ;
59 ddelon 1605
 
2 ddelon 1606
        $liste_externe->enregistrerSQL($HTML_formulaireListeExterne->getSubmitValues(), $this->_id_projet) ;
1607
    } // end of member function referencerListeExterneValidation
1608
 
11 alexandre_ 1609
    /**
1610
     * permet d'exclure un projet de l'affichage
1611
     *
1612
     * @return void
1613
     * @access public
1614
     */
1615
    function exclure($id_projet)
1616
    {
1617
       array_push ($this->_projet_exclu, $id_projet) ;
1618
    } // end of member function exclure
2 ddelon 1619
 
54 alexandre_ 1620
    /**
1621
     * permet d'exclure un projet de l'affichage
1622
     *
1623
     * @return void
1624
     * @access public
1625
     */
1626
    function setPrive()
1627
    {
1628
       $this->_prive = 1 ;
1629
    } // end of member function exclure
2 ddelon 1630
 
288 alexandre_ 1631
	/**
1632
	 * 	retourne une variable locale si la variable $_GET existe
389 aurelien 1633
	 *
288 alexandre_ 1634
	 */
1635
	function traiterVariableGet($var, $valeur_par_defaut ='') {
1636
		if (isset($_GET[$var]) && $_GET[$var] != '') {
1637
			return $_GET[$var];
1638
		} else {
1639
			return $valeur_par_defaut;
1640
		}
1641
	}
11 alexandre_ 1642
 
2 ddelon 1643
    /**
1644
     * Renvoie un message d'erreur, en fonction du code de l'erreur.
1645
     *
1646
     * @param int valeur Le code du message d'erreur.
1647
     * @return string
1648
     * @access public
1649
     */
1650
    function messageErreur( $valeur )
1651
    {
1652
        $messageErreur = array (
1653
                    PROJETCONTROLEUR_ACTION_INVALIDE => "Action non valide",
249 alexandre_ 1654
                    PROJETCONTROLEUR_ERREUR_SUPPRESSION_REPERTOIRE => "Impossible de supprimer le r&eacute;pertoire",
1655
                    PROJETCONTROLEUR_PAS_DE_DOCUMENT_SELECTIONNE => 'Pas de fichier s&eacute;lectionn&eacute;',
1656
                    PROJETCONTROLEUR_ERREUR_CREATION_REPERTOIRE => 'Impossible de cr&eacute;er le r&eacute;pertoire'
2 ddelon 1657
        ) ;
1658
        return '<p class="erreur">'.$messageErreur[$valeur].'</p>' ;
1659
    } // end of member function messageErreur
389 aurelien 1660
 
297 alexandre_ 1661
	/** Envoie de mail pour prevenir les coordinateurs d une action sur le projet
341 alexandre_ 1662
	 *  Lorsqu un projet n a plus de coordinateur, la notification est
1663
	 *  envoyee aux administrateurs
389 aurelien 1664
	 *
297 alexandre_ 1665
	 */
2 ddelon 1666
 
297 alexandre_ 1667
	function notifierCoordinateurs ($notification, $utilisateur) {
389 aurelien 1668
 
297 alexandre_ 1669
		include_once PROJET_CHEMIN_CLASSES.'projetTemplate.class.php';
389 aurelien 1670
 
297 alexandre_ 1671
		switch ($notification) {
389 aurelien 1672
			case PROJET_NOTIFICATION_DEMANDE_INSCRIPTION :
297 alexandre_ 1673
				$sujet = PROJET_TEMPLATE_DEMANDE_INSCRIPTION_SUJET;
1674
				$corps = PROJET_TEMPLATE_DEMANDE_INSCRIPTION_CORPS;
1675
			break;
1676
			case PROJET_NOTIFICATION_INSCRIPTION_NOUVELLE :
1677
				$sujet = PROJET_TEMPLATE_INSCRIPTION_NOUVELLE_SUJET;
1678
				$corps = PROJET_TEMPLATE_INSCRIPTION_NOUVELLE_CORPS;
1679
			break;
1680
			case PROJET_NOTIFICATION_DESINSCRIPTION_PROJET :
1681
				$sujet = PROJET_TEMPLATE_DESINSCRIPTION_SUJET;
1682
				$corps = PROJET_TEMPLATE_DESINSCRIPTION_CORPS;
1683
			break;
1684
			case PROJET_NOTIFICATION_NOUVEAU_DOC:
1685
				$sujet = PROJET_TEMPLATE_NOUVEAU_DOC_SUJET;
1686
				$corps = PROJET_TEMPLATE_NOUVEAU_DOC_CORPS;
1687
			break;
341 alexandre_ 1688
			case PROJET_NOTIFICATION_DESINSCRIPTION_PROJET_DERNIER_COORD:
1689
				$sujet = PROJET_TEMPLATE_DESINSCRIPTION_DERNIER_COORD_SUJET;
1690
				$corps = PROJET_TEMPLATE_DESINSCRIPTION_DERNIER_COORD_CORPS;
1691
			break;
389 aurelien 1692
 
297 alexandre_ 1693
		}
389 aurelien 1694
 
297 alexandre_ 1695
		include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
1696
        $projet = new projet ($this->_db, $this->_id_projet) ;
1697
        include_once PROJET_CHEMIN_CLASSES.'participe.class.php';
1698
		$participant = new participe($this->_db) ;
1699
		$tableau_coordinateur = $participant->getCoordinateurs($this->_id_projet) ;
389 aurelien 1700
 
297 alexandre_ 1701
		$objet_mail =& Mail::factory('smtp');
389 aurelien 1702
 
297 alexandre_ 1703
		$modele = new projetTemplate($GLOBALS['projet_db']);
2 ddelon 1704
 
297 alexandre_ 1705
		$sujet_mail = $modele->getTemplate($sujet, PROJET_LANGUE_DEFAUT);
1706
		$corps_mail = $modele->getTemplate($corps, PROJET_LANGUE_DEFAUT);
389 aurelien 1707
 
297 alexandre_ 1708
	    if (PEAR::isError($sujet_mail)) $sujet_mail->raiseError ($sujet_mail->getMessage().'<br />'.$sujet_mail->getDebugInfo());
389 aurelien 1709
 
297 alexandre_ 1710
	    $corps_mail = str_replace ('{nom}', $utilisateur->getInfo( 'nom'), $corps_mail);
1711
	    $corps_mail = str_replace ('{prenom}', $utilisateur->getInfo( 'prenom'), $corps_mail);
1712
	    $corps_mail = str_replace ('{nom_projet}', $projet->getTitre(), $corps_mail);
1713
	    $corps_mail = str_replace ('{lien}', str_replace ('&amp;', '&', $this->_url->getURL()), $corps_mail);
389 aurelien 1714
 
297 alexandre_ 1715
		$entetes['From'] = PROJET_MAIL_ADMINISTRATEUR;
1716
        $entetes['To'] = '';
389 aurelien 1717
        $entetes['Subject'] = trim ($sujet_mail) ;  // le trim est necessaire pour enlever d eventuels retour-chariot qui foutent el l air le message
297 alexandre_ 1718
        $entetes['Date'] = date ('D, M j G:i:s \C\E\S\T Y') ;
1719
        $entetes['Message-ID'] = md5(time()) ;
1720
        $entetes['reply-to'] = $this->_auth->getUserName();
1721
        $entetes['Content-Type'] = 'text/plain' ;
389 aurelien 1722
 
341 alexandre_ 1723
        // 2 cas : 1. il reste des coordinateurs ou notification pour administrateur
1724
        // 2. plus de coordinateur ou notification pour administrateur
1725
        if (count ($tableau_coordinateur) != 0 && $notification != PROJET_NOTIFICATION_DESINSCRIPTION_PROJET_DERNIER_COORD) {
1726
			foreach ($tableau_coordinateur as $coordinateur) {
1727
				$entetes['To'] .= $coordinateur[3].',';	// Le champs 3 est le mail
389 aurelien 1728
 
341 alexandre_ 1729
			}
1730
			// On enleve la virgule finale
389 aurelien 1731
 
341 alexandre_ 1732
			$entetes['To'] = substr ($entetes['To'], 0, -1);
389 aurelien 1733
 
341 alexandre_ 1734
			// on envoie le mail
1735
			$objet_mail->send($entetes['To'], $entetes, html_entity_decode ($corps_mail));
1736
        } else {  // Pour le cas ou il n y a plus de coordinateur, on envoie un message aux administrateurs
1737
        	$tableau_administrateur = $participant->getAdministrateurs();
1738
        	trigger_error(print_r($tableau_administrateur, true));
1739
        	foreach ($tableau_administrateur as $administrateur) {
1740
				$entetes['To'] .= $administrateur[3].',';	// Le champs 3 est le mail
389 aurelien 1741
 
341 alexandre_ 1742
			}
1743
			// On enleve la virgule finale
389 aurelien 1744
 
341 alexandre_ 1745
			$entetes['To'] = substr ($entetes['To'], 0, -1);
389 aurelien 1746
 
341 alexandre_ 1747
			// on envoie le mail
1748
			$objet_mail->send($entetes['To'], $entetes, html_entity_decode ($corps_mail));
1749
        }
297 alexandre_ 1750
	}
2 ddelon 1751
 
297 alexandre_ 1752
 
2 ddelon 1753
} // end of projetControleur
288 alexandre_ 1754
 
1755
class bouton {
297 alexandre_ 1756
	static function toHTML($lien, $label, $id, $class='projet_bouton_action') {
389 aurelien 1757
 
297 alexandre_ 1758
		if ($lien != '#') {
1759
			$balise_a_debut = '<a href="'.$lien.'"'.($id == 'cross'? ' onclick="javascript:return confirm(\''.$label.' ?\');"':'').'>';
389 aurelien 1760
			$balise_a_fin = '</a>';
297 alexandre_ 1761
		} else {
1762
			$balise_a_debut = '';
1763
			$balise_a_fin = '';
1764
		}
1765
		return '<div id="bouton_'.$id.'" class="'.$class.'">' .
1766
				$balise_a_debut.'<img src="'.PROJET_CHEMIN_ICONES.$id.'.png" alt="'.$label.'" />'.$label.$balise_a_fin.'</div>';
288 alexandre_ 1767
	}
1768
}
297 alexandre_ 1769
/* +--Fin du code ----------------------------------------------------------------------------------------+
1770
*
1771
* $Log: not supported by cvs2svn $
347 aperonnet 1772
* Revision 1.49  2008-09-16 14:10:20  alexandre_tb
1773
* verification du statut de l utilisateur lors d une desinscription.
1774
* Si coordinateur, message aux admins
1775
*
341 alexandre_ 1776
* Revision 1.48  2008-09-15 07:41:16  alexandre_tb
1777
* ajout de HTML_TableFragmenteur
1778
*
337 alexandre_ 1779
* Revision 1.47  2008-09-01 14:38:00  alexandre_tb
1780
* correction de bug inscription projet
1781
*
335 alexandre_ 1782
* Revision 1.46  2008-08-28 14:48:54  alexandre_tb
1783
* encodage et suppression d une methode inutile
1784
*
332 alexandre_ 1785
* Revision 1.45  2008-08-26 12:42:10  alexandre_tb
1786
* nettoyage url apres suppression d un fichier
1787
*
331 alexandre_ 1788
* Revision 1.44  2008-08-26 08:52:28  alexandre_tb
1789
* suppression de la methode accueilProjet desormais remplacee par resume.php
1790
*
323 alexandre_ 1791
* Revision 1.43  2008-08-25 15:06:59  alexandre_tb
1792
* ajout:
1793
* - des notifications
1794
* - des messages en retour
1795
* - correction inscription a un projet avec liste externe
297 alexandre_ 1796
*
323 alexandre_ 1797
*
297 alexandre_ 1798
* +-- Fin du code ----------------------------------------------------------------------------------------+
1799
*/
1800
?>