Subversion Repositories Applications.projet

Rev

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