Subversion Repositories Applications.projet

Rev

Rev 408 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 ddelon 1
<?php
59 ddelon 2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
2 ddelon 3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
8
// | This library is free software; you can redistribute it and/or                                        |
9
// | modify it under the terms of the GNU General Public                                                  |
10
// | License as published by the Free Software Foundation; either                                         |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
12
// |                                                                                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
16
// | General Public License for more details.                                                             |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU General Public                                            |
19
// | License along with this library; if not, write to the Free Software                                  |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
11 alexandre_ 22
 
347 aperonnet 23
// CVS : $Id: projetControleur.class.php,v 1.50 2008-10-22 08:21:58 aperonnet Exp $
11 alexandre_ 24
 
2 ddelon 25
/**
26
* Application projet
27
*
28
* La classe controleur projet
29
*
30
*@package projet
31
//Auteur original :
32
*@author        Alexandre Granier <alexandre@tela-botanica.org>
33
//Autres auteurs :
34
*@author        Aucun
35
*@copyright     Tela-Botanica 2000-2004
347 aperonnet 36
*@version       $Revision: 1.50 $
2 ddelon 37
// +------------------------------------------------------------------------------------------------------+
38
*/
39
 
40
// +------------------------------------------------------------------------------------------------------+
41
// |                                            ENTETE du PROGRAMME                                       |
42
// +------------------------------------------------------------------------------------------------------+
43
 
44
if (isset ($GLOBALS['lang'])) {
45
    /** le fichier de langue, par defaut PROJET_LANGUE_DEFAUT */
46
    include_once 'client/projet/langues/pro_langue_'.$GLOBALS['lang'].'.inc.php' ;
47
} else {
48
    include_once 'client/projet/langues/pro_langue_'.PROJET_LANGUE_DEFAUT.'.inc.php' ;
49
}
50
 
249 alexandre_ 51
require_once GEN_CHEMIN_API.'sql/SQL_manipulation.fonct.php' ;
323 alexandre_ 52
 
2 ddelon 53
// +------------------------------------------------------------------------------------------------------+
54
// |                                           LISTE des constantes                                       |
55
// +------------------------------------------------------------------------------------------------------+
56
 
323 alexandre_ 57
define ('PROJET_ACTION_COUPER', 3) ;
58
define ('PROJET_ACTION_MODIFIER', 4) ;
59
define ('PROJET_SUPPRESSION_FICHIER', 5) ;
60
define ('PROJET_NOUVEAU', 6) ;
61
define ('PROJET_NOUVEAU_V', 7) ;
2 ddelon 62
define ('PROJET_MODIFIER_DESCRIPTION', 19) ;
63
define ('PROJET_MODIFIER_DESCRIPTION_V', 20) ;
323 alexandre_ 64
define ('PROJET_NOUVEAU_FICHIER', 8) ;
65
define ('PROJET_NOUVEAU_FICHIER_V', 9) ;
66
define ('PROJET_NOUVEAU_REPERTOIRE', 11) ;
67
define ('PROJET_NOUVEAU_REPERTOIRE_V', 12) ;
68
define ('PROJET_SUPPRESSION_PROJET', 10) ;
69
define ('PROJET_ENVOYER_UN_MAIL', 13) ;
70
define ('PROJET_ENVOYER_UN_MAIL_V', 14) ;
71
define ('PROJET_ACTION_MODIFIER_V', 15) ;
2 ddelon 72
define ('PROJET_ACTION_NOUVELLE_LISTE', 16) ;
73
define ('PROJET_ACTION_NOUVELLE_LISTE_V', 17) ;
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
    /**
249 alexandre_ 166
     * L'identifiant du repertoire que l'on est en train d'observer. Il sera passé en
167
     * parametre a la classe HTML_listeDocuments.
2 ddelon 168
     * @access private
169
     */
170
    var $_id_repertoire;
171
 
172
     /**
173
     * L'identifiant du fichier que l'on est en train de modifier / supprimer.
174
     * @access private
175
     */
176
    var $_id_document;
177
 
178
    /**
347 aperonnet 179
     * La presentation de la liste des projets, par defaut en liste.
2 ddelon 180
     * Valeurs possibles: arbre
181
     * @access private
182
     */
347 aperonnet 183
    var $_presentation = 'liste' ;
2 ddelon 184
 
11 alexandre_ 185
   /**
249 alexandre_ 186
     * Le type du projets, par defaut 0, signifie en pas de type particumier.
11 alexandre_ 187
     * Valeurs possibles: 0, 1, 2, 3 ...
188
     * @access private
189
     */
59 ddelon 190
 
54 alexandre_ 191
     var $_type ;
11 alexandre_ 192
   /**
249 alexandre_ 193
     * Le tableau des projets a ne pas afficher, ni dans l'arbre, ni dans les listes
11 alexandre_ 194
     * @access private
195
     */
54 alexandre_ 196
 	var $_projet_exclu = array();
59 ddelon 197
 
54 alexandre_ 198
 	/**
199
     * parametre indiquant le type d'inscription possible
200
     * @access private
201
     */
202
 	var $_prive = 0 ;
59 ddelon 203
 
204 alexandre_ 204
	/**
205
     * parametre pour gere l appel a un service en rapport avec ajax
206
     * @access private
207
     */
208
	var $_service ;
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
     *
352
     * @param int action L'action à passer provient de l'URL.
353
     * @return void
354
     * @access public
355
     */
356
    function setAction( $action )
357
    {
358
        $this->_action = $action ;
323 alexandre_ 359
    }
2 ddelon 360
 
204 alexandre_ 361
	/**
362
     * Permet de fixer la valeur de du service pour l'objet projetControleur. Ce service
363
     * provient généralement de $_POST['service'] ou $_GET['service']
364
     *
365
     * @param int service Le service à appeler provient de l'URL.
366
     * @return void
367
     * @access public
368
     */
369
    function setService( $service )
370
    {
371
        $this->_service = $service ;
323 alexandre_ 372
    }
204 alexandre_ 373
 
374
 
2 ddelon 375
    /**
59 ddelon 376
     * Constructeur.
2 ddelon 377
     *
378
     * @return void
379
     * @access public
380
     */
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
    /**
706
     * Valide le formulaire et appelle la fonction de mise à jour.
707
     *
708
     * @return void
709
     * @access public
710
     */
711
    function modifierProjet( )
712
    {
288 alexandre_ 713
        // creation de l'objet projet courant
208 neiluj 714
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 715
        $projet = new projet ($this->_db, $this->_id_projet) ;
716
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_ACTION_MODIFIER_V) ;
208 neiluj 717
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireProjet.class.php' ;
2 ddelon 718
        $formulaire_projet = new HTML_formulaireProjet('formulaire_projet', 'post', str_replace ('&amp;', '&', $this->_url->getURL())) ;
719
        $formulaire_projet->construitFormulaire(projet::getTousLesProjets($this->_db)) ;
720
        if ($formulaire_projet->validate()) {
721
            $projet->majSQL($formulaire_projet->getSubmitValues()) ;
722
        } else {
723
            return $formulaire_projet->toHTML() ;
724
        }
725
        unset ($projet) ;
208 neiluj 726
    }
2 ddelon 727
 
728
    /**
729
     * Renvoie le formulaire d'upload d'un fichier.
730
     *
731
     * @return void
732
     * @access public
733
     */
734
    function formulaireFichier($action)
735
    {
736
        $res = '<h1>'.PROJET_FICHIER_MISE_EN_LIGNE.'</h1>'."\n" ;
737
        if (isset($_SESSION['formulaire_document'])) {
738
            unset ($_SESSION['formulaire_document']) ;
739
        }
740
        $action_future = $action == PROJET_NOUVEAU_FICHIER ? PROJET_NOUVEAU_FICHIER_V : PROJET_ACTION_MODIFIER_V ;
741
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, $action_future) ;
742
        if ($this->_id_repertoire != '') $this->_url->addQueryString (PROJET_VARIABLE_ID_REPERTOIRE, $this->_id_repertoire) ;
208 neiluj 743
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireDocument.class.php' ;
2 ddelon 744
        $formulaire_document = new HTML_formulaireDocument('formulaire_document', 'post',preg_replace ("/&amp;/", "&", $this->_url->getURL())) ;
745
        $formulaire_document->construitFormulaire($action) ;
746
        if ($action == PROJET_ACTION_MODIFIER) {
249 alexandre_ 747
			include_once PROJET_CHEMIN_CLASSES.'document.class.php' ;
2 ddelon 748
            $document = new document($this->_id_document, $this->_db, PROJET_CHEMIN_FICHIER, PROJET_CHEMIN_ICONES) ;
249 alexandre_ 749
            // On affecte dans un tableau les valeurs de chaque champs du formulaire avec le nom de chaque element de formulaire
2 ddelon 750
            // voir HTML_formulaireDocument
751
            $valeurs_par_defaut = array ('document_nom' => $document->getNomLong(),
752
                                         'document_description' => $document->getDescription(),
753
                                         'document_visibilite' => $document->getVisibilite()) ;
59 ddelon 754
 
249 alexandre_ 755
            // On rajoute un champs cache avec l'identifiant du document
2 ddelon 756
            $formulaire_document->addElement ('hidden', 'id_document', $this->_id_document) ;
757
            $formulaire_document->setDefaults($valeurs_par_defaut) ;
758
        } else {
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) ;
59 ddelon 1151
 
249 alexandre_ 1152
                // Creation de la liste
22 alexandre_ 1153
                $resultat_creation = file_get_contents (PROJET_SERVEUR_VPOPMAIL.'/creation_liste.php?domaine='.
2 ddelon 1154
                                    $liste->getDomaine().'&liste='.$liste->getNom().'&parametres=aBiud') ;
59 ddelon 1155
 
249 alexandre_ 1156
                // Ajout du moderateur
22 alexandre_ 1157
                $resultat_ajout_moderateur = file_get_contents (PROJET_SERVEUR_VPOPMAIL.'/ajout_moderateur.php?domaine='.
2 ddelon 1158
                                    $liste->getDomaine().'&liste='.$liste->getNom().'&mail='.$this->_auth->getUserName()) ;
249 alexandre_ 1159
                // Ajout du moderateur en tant qu'utilisateur
22 alexandre_ 1160
                $resultat_ajout_utilisateur = file_get_contents (PROJET_SERVEUR_VPOPMAIL.'/ajout_abonne.php?domaine='.
2 ddelon 1161
                                    $liste->getDomaine().'&liste='.$liste->getNom().'&mail='.$this->_auth->getUserName()) ;
1162
 
1163
            } else {
1164
                return PROJET_MESSAGE_LISTE_DOUBLE.$formulaire_liste->toHTML() ;
1165
            }
1166
            return $resultat_creation.$resultat_ajout_moderateur.$resultat_ajout_utilisateur;
59 ddelon 1167
 
2 ddelon 1168
        } else {
1169
            return $formulaire_liste->toHTML() ;
1170
        }
1171
    } // end of member function nouvelleListeValidation
59 ddelon 1172
 
2 ddelon 1173
    /**
332 alexandre_ 1174
     * Supprime la liste de discussion associee au projet
2 ddelon 1175
     *
1176
     * @return void
1177
     * @access public
1178
     */
1179
    function supprimerListe( )
1180
    {
208 neiluj 1181
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1182
        $projet = new projet($this->_db, $this->_id_projet) ;
1183
        $projet->getListesAssociees() ;
59 ddelon 1184
 
22 alexandre_ 1185
        $resultat_suppression = file_get_contents(PROJET_SERVEUR_VPOPMAIL.'/suppression_liste.php?domaine='.
2 ddelon 1186
                                    $projet->_listes_associes[0]->getDomaine().'&liste='.$projet->_listes_associes[0]->getNom()) ;
1187
        $projet->supprimerListe($projet->_listes_associes[0]) ;
1188
        return $resultat_suppression;
1189
    } // end of member function supprimerListe
1190
 
1191
 
1192
    /**
1193
     *
59 ddelon 1194
     *
332 alexandre_ 1195
     * @param string presentation Pour affecter une presentation au projet
2 ddelon 1196
     * @return void
1197
     * @access public
1198
     */
1199
    function setPresentation( $presentation )
1200
    {
1201
        $this->_presentation = $presentation ;
1202
    } // end of member function setPresentation
1203
 
11 alexandre_ 1204
    /**
1205
     *
59 ddelon 1206
     *
11 alexandre_ 1207
     * @param string type Pour affecter un type au projet
1208
     * @return void
1209
     * @access public
1210
     */
1211
    function setType( $type)
1212
    {
1213
        $this->_type = $type ;
1214
    } // end of member function setPresentation
2 ddelon 1215
 
1216
    /**
249 alexandre_ 1217
     * Inscrit un utilisateur a un projet avec le statut observateur
2 ddelon 1218
     *
1219
     * @return void
1220
     * @access public
1221
     */
1222
    function inscriptionProjet( )
1223
    {
1224
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireInscriptionProjet.class.php' ;
208 neiluj 1225
		include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1226
        $projet = new projet ($this->_db, $this->_id_projet) ;
59 ddelon 1227
 
2 ddelon 1228
        // Si le projet n'a pas de liste, on inscrit directement
1229
        if (isset ($this->_id_projet)) {
208 neiluj 1230
            include_once PROJET_CHEMIN_CLASSES.'participe.class.php' ;
2 ddelon 1231
            $participant = new participe($this->_db) ;
414 aurelien 1232
 
297 alexandre_ 1233
			// On controle si la liste est externe (yahoo) auquel cas on ne presente pas l inscription
1234
			include_once PROJET_CHEMIN_CLASSES.'liste_externe.class.php' ;
1235
			$liste_ext = new liste_externe($this->_db);
1236
			$listes = $liste_ext->getListesAssociees($this->_id_projet);
335 alexandre_ 1237
			if (count ($listes))$info_liste = $liste_ext->getInfoListe($listes[0]);
297 alexandre_ 1238
			if (count ($listes) != 0) {
1239
				$avoir_liste_externe = true;
1240
				$msg = '';
1241
				$msg = 'Pour vous inscrire &agrave; la liste de discussion, h&eacute;berg&eacute;e par Yahoo Groupes, <a href="mailto:';
1242
				$msg .= $info_liste->AGO_A_MAILABO.'">cliquez ici</a>';
1243
			} else {
1244
				$avoir_liste_externe = false;
1245
			}
1246
            if (!$projet->avoirListe() || $avoir_liste_externe) {
122 alexandre_ 1247
            	if ($projet->isModere()) {
1248
                	$participant->setStatut(3, $this->_auth->getAuthData (PROJET_CHAMPS_ID), $this->_id_projet) ;
1249
            	} else {
414 aurelien 1250
            		$participant->setStatut(2, $this->_auth->getAuthData (PROJET_CHAMPS_ID), $this->_id_projet) ;
297 alexandre_ 1251
            		$message_retour = '<p class="information">Votre inscription a bien &eacute;t&eacute; prise en compte'.$msg.'</p>';
122 alexandre_ 1252
            	}
297 alexandre_ 1253
            	$message_retour = '<p class="information">Votre inscription a bien &eacute;t&eacute; prise en compte. '.$msg.'</p>';
1254
    			include_once PROJET_CHEMIN_APPLI.'actions/resume.php' ;
1255
    			return $retour;
2 ddelon 1256
            }
1257
        }
1258
        if (isset($_POST['valider_inscription_projet'])) {
1259
            if (isset($_POST['radio_inscription_liste'])) {
122 alexandre_ 1260
            	include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
414 aurelien 1261
            	$utilisateur = new annuaire($this->_db, array('identifiant' => PROJET_CHAMPS_ID,
122 alexandre_ 1262
								'mail' => PROJET_CHAMPS_MAIL, 'table' => PROJET_ANNUAIRE,
1263
								'nom'=> PROJET_CHAMPS_NOM, 'prenom' => PROJET_CHAMPS_PRENOM)) ;
1264
	            $utilisateur->setId($this->_auth->getAuthData(PROJET_CHAMPS_ID)) ;
414 aurelien 1265
 
297 alexandre_ 1266
	                if ($_POST['radio_inscription_liste'] == 2) {
1267
		                include_once PROJET_CHEMIN_CLASSES.'inscription_liste.class.php' ;
1268
		                $projet->getListesAssociees() ;
1269
		                $inscription_liste = new inscription_liste($this->_db) ;
1270
		                $inscription_liste->inscrireUtilisateur( $utilisateur,
1271
	                                                        $projet->_listes_associes[0],
1272
	                                                        $_POST['radio_inscription_liste']) ;
1273
	                }
414 aurelien 1274
 
1275
	            if (!$projet->isModere()) {
1276
	                $participant->setStatut(2, $this->_auth->getAuthData (PROJET_CHAMPS_ID), $this->_id_projet) ;
1277
 
297 alexandre_ 1278
                    $this->notifierCoordinateurs(PROJET_NOTIFICATION_INSCRIPTION_NOUVELLE, $utilisateur);
122 alexandre_ 1279
            	} else {
1280
            		$participant->setStatut(3, $this->_auth->getAuthData (PROJET_CHAMPS_ID), $this->_id_projet) ;
414 aurelien 1281
 
297 alexandre_ 1282
            		$this->notifierCoordinateurs(PROJET_NOTIFICATION_DEMANDE_INSCRIPTION, $utilisateur);
122 alexandre_ 1283
            	}
2 ddelon 1284
            }
59 ddelon 1285
 
2 ddelon 1286
            if ($this->_presentation != 'arbre') {
272 alexandre_ 1287
                if ($projet->isModere()) return '<h1>'.$projet->getTitre().'</h1>'.
249 alexandre_ 1288
                		str_replace ('nom_du_projet', $projet->getTitre(), PROJET_LAIUS_INSCRIPTION_MODERE);
297 alexandre_ 1289
                		else {
1290
                			$message_retour = '<p class="information">Votre inscription a bien &eacute;t&eacute; prise en compte'.$msg.'</p>';
1291
                			include_once PROJET_CHEMIN_APPLI.'actions/resume.php' ;
1292
                			return $retour;
1293
                		}
2 ddelon 1294
            } else {
1295
                $this->_action = PROJET_ACTION_VOIR_RESUME;
1296
            }
249 alexandre_ 1297
            return PROJET_LAIUS_INSCRIPTION_MODERE;
2 ddelon 1298
        }
1299
        $res = '<h1>'.PROJET_INSCRIPTION_PROJET.' : '.$projet->getTitre().'</h1>'."\n" ;
1300
        if ($projet->avoirListe()) $res .= '<h2>'.PROJET_MESSAGE_LISTE.'</h2>'."\n" ;
1301
        //$participant = new participe($this->_db) ;
1302
        $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_S_INSCRIRE) ;
1303
        $HTML_formulaireInscriptionProjet = new HTML_formulaireInscriptionProjet('inscription_projet', 'post', str_replace ('&amp;', '&', $this->_url->getURL())) ;
1304
        $HTML_formulaireInscriptionProjet->construitFormulaire($projet) ;
1305
        $HTML_formulaireInscriptionProjet->setDefaults(array('radio_inscription_liste' => 2)) ;
1306
        return $res.$HTML_formulaireInscriptionProjet->toHTML() ;
1307
    } // end of member function inscriptionProjet
1308
 
1309
    /**
249 alexandre_ 1310
     * Inscrit l'utilisateur loggue a la liste dont le parametre est en post.
2 ddelon 1311
     *
1312
     * @return void
1313
     * @access public
1314
     */
1315
    function inscriptionListe( )
1316
    {
208 neiluj 1317
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1318
        $projet = new projet ($this->_db, $this->_id_projet) ;
1319
        include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
1320
        include_once PROJET_CHEMIN_CLASSES.'inscription_liste.class.php' ;
1321
        $projet->getListesAssociees() ;
1322
        $utilisateur = new annuaire($this->_db, array('identifiant' => PROJET_CHAMPS_ID, 'mail' => PROJET_CHAMPS_MAIL, 'table' => PROJET_ANNUAIRE)) ;
1323
        $utilisateur->setId($this->_auth->getAuthData(PROJET_CHAMPS_ID)) ;
1324
        $inscription_liste = new inscription_liste($this->_db) ;
1325
        $inscription_liste->inscrireUtilisateur( $utilisateur, $projet->_listes_associes[0], 2) ;  // 2 est la statut inscription normale
297 alexandre_ 1326
        return '<p class="information">Vous &ecirc;tes inscrit &agrave; la liste</p>';
2 ddelon 1327
    } // end of member function inscriptionListe
1328
 
1329
    /**
297 alexandre_ 1330
     * Inscrit l'utilisateur loggue a la liste dont le parametre est en post.
2 ddelon 1331
     *
1332
     * @return void
1333
     * @access public
1334
     */
1335
    function desinscriptionListe( )
1336
    {
1337
        if (isset($_GET['inscription_liste']) || $this->_action = PROJET_ACTION_DESINSCRIPTION_LISTE) {
208 neiluj 1338
            include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1339
            $projet = new projet ($this->_db, $this->_id_projet) ;
1340
            include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
1341
            include_once PROJET_CHEMIN_CLASSES.'inscription_liste.class.php' ;
1342
            $projet->getListesAssociees() ;
31 alexandre_ 1343
            $utilisateur = new annuaire($this->_db, array('identifiant' => PROJET_CHAMPS_ID,
1344
            								 'mail' => PROJET_CHAMPS_MAIL,
1345
            								 'table' => PROJET_ANNUAIRE)) ;
2 ddelon 1346
            $utilisateur->setId($this->_auth->getAuthData(PROJET_CHAMPS_ID)) ;
1347
            $inscription_liste = new inscription_liste($this->_db) ;
1348
            $inscription_liste->desinscrireUtilisateur( $utilisateur, $projet->_listes_associes[0], $_GET['inscription_liste']) ;
297 alexandre_ 1349
            return '<p class="information">Vous avez &eacute;t&eacute; d&eacute;sinscrit de la liste</p>';
2 ddelon 1350
        }
1351
    } // end of member function inscriptionListe
1352
    /**
297 alexandre_ 1353
     * desinscrit un utilisateur d un projet
2 ddelon 1354
     *
1355
     * @return void
1356
     * @access public
1357
     */
1358
    function desinscriptionProjet( )
1359
    {
1360
        include_once PROJET_CHEMIN_CLASSES.'participe.class.php' ;
297 alexandre_ 1361
        include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
2 ddelon 1362
        $participant = new participe($this->_db) ;
414 aurelien 1363
		$utilisateur = new annuaire($this->_db, array('identifiant' => PROJET_CHAMPS_ID,
297 alexandre_ 1364
								'mail' => PROJET_CHAMPS_MAIL, 'table' => PROJET_ANNUAIRE,
1365
								'nom'=> PROJET_CHAMPS_NOM, 'prenom' => PROJET_CHAMPS_PRENOM)) ;
1366
	    $utilisateur->setId($this->_auth->getAuthData(PROJET_CHAMPS_ID)) ;
414 aurelien 1367
 
297 alexandre_ 1368
        // Le statut 4 desinscrit l'utilisateur, dans la methode setStatut
2 ddelon 1369
        $participant->setStatut(4, $this->_auth->getAuthData (PROJET_CHAMPS_ID), $this->_id_projet) ;
208 neiluj 1370
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1371
        $projet = new projet ($this->_db, $this->_id_projet) ;
1372
        $projet->getListesAssociees() ;
1373
        if ($projet->avoirListe()) {
1374
            include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
1375
            $annuaire = new annuaire($this->_db, array('identifiant' => PROJET_CHAMPS_ID, 'mail' => PROJET_CHAMPS_MAIL, 'table' => PROJET_ANNUAIRE)) ;
1376
            $annuaire->setId($this->_auth->getAuthData(PROJET_CHAMPS_ID)) ;
1377
            include_once PROJET_CHEMIN_CLASSES.'inscription_liste.class.php' ;
1378
            $desinscription= new inscription_liste($this->_db) ;
1379
            $desinscription->desinscrireUtilisateur($annuaire, $projet->_listes_associes[0]) ;
1380
        }
297 alexandre_ 1381
        $this->notifierCoordinateurs(PROJET_NOTIFICATION_DESINSCRIPTION_PROJET, $utilisateur);
414 aurelien 1382
 
341 alexandre_ 1383
        // On verifie si l utilisateur est le dernier coordinateur
1384
        // auquel cas on previent les administrateurs
1385
        if ($participant->isCoordinateur($this->_auth->getAuthData(PROJET_CHAMPS_ID), $this->_id_projet, $this->_db)) {
1386
        	$coord = $participant->getCoordinateurs($this->_id_projet);
1387
        	if (count($coord) == 0) {
1388
        		$this->notifierCoordinateurs(PROJET_NOTIFICATION_DESINSCRIPTION_PROJET_DERNIER_COORD, $utilisateur);
1389
        	}
1390
        }
414 aurelien 1391
        //
297 alexandre_ 1392
        include_once PROJET_CHEMIN_CLASSES.'liste_externe.class.php';
1393
        $liste_ext = new liste_externe($this->_db);
1394
		$listes = $liste_ext->getListesAssociees($this->_id_projet);
414 aurelien 1395
 
297 alexandre_ 1396
		$msg = '';
1397
		if (count ($listes) != 0) {
341 alexandre_ 1398
			$info_liste = $liste_ext->getInfoListe($listes[0]);
297 alexandre_ 1399
			$msg = 'Pensez si vous le souhaitez à vous d&eacute;sinscrire de la liste de discussion, h&eacute;berg&eacute;e par Yahoo Groupes.';
1400
			$msg .= ' Vous pouvez le faire en <a href="mailto:';
1401
			$msg .= $info_liste->AGO_A_MAILDESA.'">cliquez ici</a>';
1402
		}
2 ddelon 1403
        if ($this->_presentation != 'arbre') {
297 alexandre_ 1404
            $message_retour = '<p class="information">Votre d&eacute;sinscription a bien &eacute;t&eacute; prise en compte. '.$msg.'</p>';
122 alexandre_ 1405
            include_once PROJET_CHEMIN_APPLI.'actions/resume.php' ;
1406
            return $retour ;
2 ddelon 1407
        } else {
1408
            $this->_action = PROJET_ACTION_VOIR_RESUME;
1409
        }
297 alexandre_ 1410
    }
2 ddelon 1411
 
1412
    /**
297 alexandre_ 1413
     * Renvoie le formulaire de creation d'un wiki
2 ddelon 1414
     *
1415
     * @return void
1416
     * @access public
1417
     */
1418
    function formulaireWiki( )
414 aurelien 1419
    {
1420
		$GLOBALS['url']->addQueryString ('act', PROJET_ACTION_CREER_WIKI) ;
1421
		$GLOBALS['url']->addQueryString (PROJET_VARIABLE_ID_PROJET, $this->_id_projet) ;
59 ddelon 1422
		require_once 'client/integrateur_wikini/bibliotheque/iw_admin_wikini.fonct.php';
1423
		$res =admin_afficherContenuCorps();
79 alexandre_ 1424
		$res .= '<br /><a href="'.$this->_url->getURL().'">'.PROJET_RETOUR_RESUME.'</a>';
59 ddelon 1425
    	return $res;
1426
 
332 alexandre_ 1427
    }
2 ddelon 1428
 
16 ddelon 1429
 
1430
	function associerWiki( )
1431
    {
1432
        $res = '<h1>'.PROJET_ASSOCIER_WIKI.'</h1>'."\n" ;
59 ddelon 1433
 
1434
	 	$db = &$GLOBALS['_GEN_commun']['pear_db'] ;
16 ddelon 1435
    	$res='';
59 ddelon 1436
 
332 alexandre_ 1437
         // Comportement par defaut
59 ddelon 1438
	    // requete sur la table gen_wikini pour affichage de la liste des Wikini
16 ddelon 1439
	    $requete = "select  gewi_id_wikini, gewi_code_alpha_wikini, gewi_page from gen_wikini" ;
59 ddelon 1440
 
16 ddelon 1441
	    $resultat = $db->query ($requete) ;
1442
	    if (DB::isError ($resultat)) {
1443
	        $GLOBALS['_GEN_commun']['debogage_erreur']->gererErreur(E_USER_WARNING, "Echec de la requete : $requete<br />".$resultat->getMessage(),
1444
	                                                                        __FILE__, __LINE__, 'admin_wikini')   ;
1445
	        return ;
1446
	    }
59 ddelon 1447
 
337 alexandre_ 1448
		include_once 'api/html/HTML_TableFragmenteur.php';
16 ddelon 1449
	    $liste = new HTML_TableFragmenteur () ;
40 ddelon 1450
	    $liste->construireEntete(array (PROJET_NOM_WIKINI,PROJET_PAGE_WIKINI, PROJET_SELECTIONNER_WIKINI)) ;
59 ddelon 1451
 
16 ddelon 1452
	    $tableau_wikini = array() ;
59 ddelon 1453
 
16 ddelon 1454
	    while ($ligne = $resultat->fetchRow()) {
1455
	        $this->_url->addQueryString ('id_wikini', $ligne[0]) ;
332 alexandre_ 1456
	        array_push ($tableau_wikini, array ($ligne[1]."\n",    // Premiere colonne, le nom de l'application
16 ddelon 1457
										        $ligne[2]."\n",    // Deuxieme colonne, la page par defaut
40 ddelon 1458
	        								  '<a href="'.$this->_url->getURL()."&amp;".PROJET_VARIABLE_ACTION."=".PROJET_ACTION_ASSOCIER_WIKI_V."".'">'.PROJET_CHOISIR_WIKINI.'</a>'."\n",
16 ddelon 1459
	                                            ));
1460
	    }
1461
	    $liste->construireListe($tableau_wikini) ;
1462
	    $res .= $liste->toHTML();
68 alexandre_ 1463
	    $this->_url->removeQueryString(PROJET_VARIABLE_ACTION) ;
16 ddelon 1464
	    return $res ;
59 ddelon 1465
 
1466
 
1467
 
16 ddelon 1468
    } // end of member function formulaireWiki
1469
 
2 ddelon 1470
 
40 ddelon 1471
    /**
1472
     * Associe un wiki au projet courant
1473
     *
1474
     * @return void
1475
     * @access public
1476
     */
2 ddelon 1477
 
40 ddelon 1478
	function associationWiki( )  {
59 ddelon 1479
 
1480
 
40 ddelon 1481
    	if (isset($_GET['id_wikini'])) {
1482
    		$db = &$GLOBALS['_GEN_commun']['pear_db'] ;
1483
		    $requete = "select gewi_code_alpha_wikini from gen_wikini where gewi_id_wikini = ".$_GET['id_wikini'] ;
1484
	    	$resultat = $db->query ($requete) ;
1485
	    	if (DB::isError ($resultat)) {
1486
	        	$GLOBALS['_GEN_commun']['debogage_erreur']->gererErreur(E_USER_WARNING, "Echec de la requete : $requete<br />".$resultat->getMessage(),
1487
	            	                                                            __FILE__, __LINE__, 'admin_wikini')   ;
1488
	        	return ;
1489
	    	}
59 ddelon 1490
 
40 ddelon 1491
	    	$ligne = $resultat->fetchRow();
208 neiluj 1492
	    	include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
40 ddelon 1493
			$projet = new projet($this->_db, $this->_id_projet) ;
1494
        	$projet->majNomWikini($ligne[0]);
1495
    	}
59 ddelon 1496
 
40 ddelon 1497
	}
1498
 
2 ddelon 1499
    /**
1500
     * Supprime le wiki du projet courant
1501
     *
1502
     * @return void
1503
     * @access public
1504
     */
1505
    function supprimerWiki( )
1506
    {
1507
        include_once PROJET_CHEMIN_CLASSES.'gestion_wikini.class.php' ;
1508
        // On crée une nouvelle connexion avec les paramètres spécifiques aux wikinis
1509
        $connexion_bd = DB::connect('mysql://'.PROJET_UTILISATEUR_WIKINI.':'.PROJET_MDP_WIKINI.'@'.PROJET_HOTE_WIKINI.'/'.PROJET_DB_WIKINI) ;
1510
        $gerantWiki = new gestion_wikini($connexion_bd) ;
208 neiluj 1511
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1512
        $projet = new projet ($this->_db, $this->_id_projet) ;
1513
        $gerantWiki->suppression_tables(strtolower($projet->getWikini())) ;
1514
        $projet->majNomWikini('') ;
1515
    } // end of member function supprimerWiki
1516
 
1517
    /**
1518
     * Permet de lier une ou plusieurs listes de la table agora à un projet.
1519
     *
1520
     * @return string
1521
     * @access public
1522
     */
1523
    function referencerListeExterne( )
1524
    {
158 alexandre_ 1525
        $requete = 'show tables like \'agora\'' ;
1526
        $resultat = $this->_db->query ($requete);
1527
        if ($resultat->numRows() == 0) {
1528
        	return 'Cette fonctionnalité n\'est pas active' ;
1529
        }
2 ddelon 1530
        $res = '<h1>'.PROJET_REFERENCER_LISTE.'</h1>' ;
1531
        include_once PROJET_CHEMIN_CLASSES.'liste_externe.class.php' ;
1532
        $liste_externe = new liste_externe($this->_db) ;
1533
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireListeExterne.class.php' ;
1534
        $this->_url->addQueryString(PROJET_VARIABLE_ID_PROJET, $this->_id_projet) ;
1535
        $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_REFERENCER_LISTE_V) ;
1536
        $HTML_formulaireListeExterne = new HTML_formulaireListeExterne('formulaire_liste_externe', 'post', str_replace('&amp;', '&', $this->_url->getURL())) ;
1537
        $HTML_formulaireListeExterne->construitFormulaire($liste_externe->getListeNom()) ;
1538
        $liste_assoc = $liste_externe->getListesAssociees($this->_id_projet) ;
1539
        $default = array() ;
1540
        foreach ($liste_assoc as $val) $default['liste_'.$val] = 1 ;
1541
 
1542
        $HTML_formulaireListeExterne->setDefaults($default) ;
1543
        return $res.$HTML_formulaireListeExterne->toHTML() ;
1544
    } // end of member function referencerListeExterne
1545
 
1546
    /**
332 alexandre_ 1547
     * Realise les mises a jours dans la table projet_lien_liste_externe
2 ddelon 1548
     *
1549
     * @return void
1550
     * @access public
1551
     */
1552
    function referencerListeExterneValidation( )
1553
    {
1554
        include_once PROJET_CHEMIN_CLASSES.'liste_externe.class.php' ;
1555
        $liste_externe = new liste_externe($this->_db) ;
1556
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireListeExterne.class.php' ;
1557
        $HTML_formulaireListeExterne = new HTML_formulaireListeExterne('formulaire_liste_externe', 'post', str_replace('&amp;', '&', $this->_url->getURL())) ;
1558
        $HTML_formulaireListeExterne->construitFormulaire($liste_externe->getListeNom()) ;
59 ddelon 1559
 
2 ddelon 1560
        $liste_externe->enregistrerSQL($HTML_formulaireListeExterne->getSubmitValues(), $this->_id_projet) ;
1561
    } // end of member function referencerListeExterneValidation
1562
 
11 alexandre_ 1563
    /**
1564
     * permet d'exclure un projet de l'affichage
1565
     *
1566
     * @return void
1567
     * @access public
1568
     */
1569
    function exclure($id_projet)
1570
    {
1571
       array_push ($this->_projet_exclu, $id_projet) ;
1572
    } // end of member function exclure
2 ddelon 1573
 
54 alexandre_ 1574
    /**
1575
     * permet d'exclure un projet de l'affichage
1576
     *
1577
     * @return void
1578
     * @access public
1579
     */
1580
    function setPrive()
1581
    {
1582
       $this->_prive = 1 ;
1583
    } // end of member function exclure
2 ddelon 1584
 
288 alexandre_ 1585
	/**
1586
	 * 	retourne une variable locale si la variable $_GET existe
414 aurelien 1587
	 *
288 alexandre_ 1588
	 */
1589
	function traiterVariableGet($var, $valeur_par_defaut ='') {
1590
		if (isset($_GET[$var]) && $_GET[$var] != '') {
1591
			return $_GET[$var];
1592
		} else {
1593
			return $valeur_par_defaut;
1594
		}
1595
	}
11 alexandre_ 1596
 
2 ddelon 1597
    /**
1598
     * Renvoie un message d'erreur, en fonction du code de l'erreur.
1599
     *
1600
     * @param int valeur Le code du message d'erreur.
1601
     * @return string
1602
     * @access public
1603
     */
1604
    function messageErreur( $valeur )
1605
    {
1606
        $messageErreur = array (
1607
                    PROJETCONTROLEUR_ACTION_INVALIDE => "Action non valide",
249 alexandre_ 1608
                    PROJETCONTROLEUR_ERREUR_SUPPRESSION_REPERTOIRE => "Impossible de supprimer le r&eacute;pertoire",
1609
                    PROJETCONTROLEUR_PAS_DE_DOCUMENT_SELECTIONNE => 'Pas de fichier s&eacute;lectionn&eacute;',
1610
                    PROJETCONTROLEUR_ERREUR_CREATION_REPERTOIRE => 'Impossible de cr&eacute;er le r&eacute;pertoire'
2 ddelon 1611
        ) ;
1612
        return '<p class="erreur">'.$messageErreur[$valeur].'</p>' ;
1613
    } // end of member function messageErreur
414 aurelien 1614
 
297 alexandre_ 1615
	/** Envoie de mail pour prevenir les coordinateurs d une action sur le projet
341 alexandre_ 1616
	 *  Lorsqu un projet n a plus de coordinateur, la notification est
1617
	 *  envoyee aux administrateurs
414 aurelien 1618
	 *
297 alexandre_ 1619
	 */
2 ddelon 1620
 
402 raphael 1621
    function notifierCoordinateurs ($notification, $utilisateur, $lien = false) {
414 aurelien 1622
 
297 alexandre_ 1623
		include_once PROJET_CHEMIN_CLASSES.'projetTemplate.class.php';
414 aurelien 1624
 
297 alexandre_ 1625
		switch ($notification) {
414 aurelien 1626
			case PROJET_NOTIFICATION_DEMANDE_INSCRIPTION :
297 alexandre_ 1627
				$sujet = PROJET_TEMPLATE_DEMANDE_INSCRIPTION_SUJET;
1628
				$corps = PROJET_TEMPLATE_DEMANDE_INSCRIPTION_CORPS;
1629
			break;
1630
			case PROJET_NOTIFICATION_INSCRIPTION_NOUVELLE :
1631
				$sujet = PROJET_TEMPLATE_INSCRIPTION_NOUVELLE_SUJET;
1632
				$corps = PROJET_TEMPLATE_INSCRIPTION_NOUVELLE_CORPS;
1633
			break;
1634
			case PROJET_NOTIFICATION_DESINSCRIPTION_PROJET :
1635
				$sujet = PROJET_TEMPLATE_DESINSCRIPTION_SUJET;
1636
				$corps = PROJET_TEMPLATE_DESINSCRIPTION_CORPS;
1637
			break;
1638
			case PROJET_NOTIFICATION_NOUVEAU_DOC:
1639
				$sujet = PROJET_TEMPLATE_NOUVEAU_DOC_SUJET;
1640
				$corps = PROJET_TEMPLATE_NOUVEAU_DOC_CORPS;
1641
			break;
341 alexandre_ 1642
			case PROJET_NOTIFICATION_DESINSCRIPTION_PROJET_DERNIER_COORD:
1643
				$sujet = PROJET_TEMPLATE_DESINSCRIPTION_DERNIER_COORD_SUJET;
1644
				$corps = PROJET_TEMPLATE_DESINSCRIPTION_DERNIER_COORD_CORPS;
1645
			break;
414 aurelien 1646
 
297 alexandre_ 1647
		}
414 aurelien 1648
 
297 alexandre_ 1649
		include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
1650
        $projet = new projet ($this->_db, $this->_id_projet) ;
1651
        include_once PROJET_CHEMIN_CLASSES.'participe.class.php';
1652
		$participant = new participe($this->_db) ;
1653
		$tableau_coordinateur = $participant->getCoordinateurs($this->_id_projet) ;
414 aurelien 1654
 
297 alexandre_ 1655
		$objet_mail =& Mail::factory('smtp');
414 aurelien 1656
 
297 alexandre_ 1657
		$modele = new projetTemplate($GLOBALS['projet_db']);
2 ddelon 1658
 
297 alexandre_ 1659
		$sujet_mail = $modele->getTemplate($sujet, PROJET_LANGUE_DEFAUT);
1660
		$corps_mail = $modele->getTemplate($corps, PROJET_LANGUE_DEFAUT);
414 aurelien 1661
 
297 alexandre_ 1662
	    if (PEAR::isError($sujet_mail)) $sujet_mail->raiseError ($sujet_mail->getMessage().'<br />'.$sujet_mail->getDebugInfo());
414 aurelien 1663
 
297 alexandre_ 1664
	    $corps_mail = str_replace ('{nom}', $utilisateur->getInfo( 'nom'), $corps_mail);
1665
	    $corps_mail = str_replace ('{prenom}', $utilisateur->getInfo( 'prenom'), $corps_mail);
1666
	    $corps_mail = str_replace ('{nom_projet}', $projet->getTitre(), $corps_mail);
402 raphael 1667
	    if($notification == PROJET_NOTIFICATION_NOUVEAU_DOC && $lien) {
1668
		$corps_mail = str_replace ('{lien}', $lien, $corps_mail);
1669
	    }
1670
	    else {
1671
		$corps_mail = str_replace ('{lien}', str_replace ('&amp;', '&', $this->_url->getURL()), $corps_mail);
1672
	    }
414 aurelien 1673
 
297 alexandre_ 1674
		$entetes['From'] = PROJET_MAIL_ADMINISTRATEUR;
1675
        $entetes['To'] = '';
414 aurelien 1676
        $entetes['Subject'] = trim ($sujet_mail) ;  // le trim est necessaire pour enlever d eventuels retour-chariot qui foutent el l air le message
297 alexandre_ 1677
        $entetes['Date'] = date ('D, M j G:i:s \C\E\S\T Y') ;
1678
        $entetes['Message-ID'] = md5(time()) ;
1679
        $entetes['reply-to'] = $this->_auth->getUserName();
1680
        $entetes['Content-Type'] = 'text/plain' ;
414 aurelien 1681
 
341 alexandre_ 1682
        // 2 cas : 1. il reste des coordinateurs ou notification pour administrateur
1683
        // 2. plus de coordinateur ou notification pour administrateur
1684
        if (count ($tableau_coordinateur) != 0 && $notification != PROJET_NOTIFICATION_DESINSCRIPTION_PROJET_DERNIER_COORD) {
1685
			foreach ($tableau_coordinateur as $coordinateur) {
1686
				$entetes['To'] .= $coordinateur[3].',';	// Le champs 3 est le mail
414 aurelien 1687
 
341 alexandre_ 1688
			}
1689
			// On enleve la virgule finale
414 aurelien 1690
 
341 alexandre_ 1691
			$entetes['To'] = substr ($entetes['To'], 0, -1);
414 aurelien 1692
 
341 alexandre_ 1693
			// on envoie le mail
1694
			$objet_mail->send($entetes['To'], $entetes, html_entity_decode ($corps_mail));
1695
        } else {  // Pour le cas ou il n y a plus de coordinateur, on envoie un message aux administrateurs
1696
        	$tableau_administrateur = $participant->getAdministrateurs();
1697
        	trigger_error(print_r($tableau_administrateur, true));
1698
        	foreach ($tableau_administrateur as $administrateur) {
1699
				$entetes['To'] .= $administrateur[3].',';	// Le champs 3 est le mail
414 aurelien 1700
 
341 alexandre_ 1701
			}
1702
			// On enleve la virgule finale
414 aurelien 1703
 
341 alexandre_ 1704
			$entetes['To'] = substr ($entetes['To'], 0, -1);
414 aurelien 1705
 
341 alexandre_ 1706
			// on envoie le mail
1707
			$objet_mail->send($entetes['To'], $entetes, html_entity_decode ($corps_mail));
1708
        }
297 alexandre_ 1709
	}
2 ddelon 1710
 
297 alexandre_ 1711
 
2 ddelon 1712
} // end of projetControleur
288 alexandre_ 1713
 
1714
class bouton {
297 alexandre_ 1715
	static function toHTML($lien, $label, $id, $class='projet_bouton_action') {
414 aurelien 1716
 
297 alexandre_ 1717
		if ($lien != '#') {
1718
			$balise_a_debut = '<a href="'.$lien.'"'.($id == 'cross'? ' onclick="javascript:return confirm(\''.$label.' ?\');"':'').'>';
414 aurelien 1719
			$balise_a_fin = '</a>';
297 alexandre_ 1720
		} else {
1721
			$balise_a_debut = '';
1722
			$balise_a_fin = '';
1723
		}
1724
		return '<div id="bouton_'.$id.'" class="'.$class.'">' .
1725
				$balise_a_debut.'<img src="'.PROJET_CHEMIN_ICONES.$id.'.png" alt="'.$label.'" />'.$label.$balise_a_fin.'</div>';
288 alexandre_ 1726
	}
1727
}
297 alexandre_ 1728
/* +--Fin du code ----------------------------------------------------------------------------------------+
1729
*
1730
* $Log: not supported by cvs2svn $
347 aperonnet 1731
* Revision 1.49  2008-09-16 14:10:20  alexandre_tb
1732
* verification du statut de l utilisateur lors d une desinscription.
1733
* Si coordinateur, message aux admins
1734
*
341 alexandre_ 1735
* Revision 1.48  2008-09-15 07:41:16  alexandre_tb
1736
* ajout de HTML_TableFragmenteur
1737
*
337 alexandre_ 1738
* Revision 1.47  2008-09-01 14:38:00  alexandre_tb
1739
* correction de bug inscription projet
1740
*
335 alexandre_ 1741
* Revision 1.46  2008-08-28 14:48:54  alexandre_tb
1742
* encodage et suppression d une methode inutile
1743
*
332 alexandre_ 1744
* Revision 1.45  2008-08-26 12:42:10  alexandre_tb
1745
* nettoyage url apres suppression d un fichier
1746
*
331 alexandre_ 1747
* Revision 1.44  2008-08-26 08:52:28  alexandre_tb
1748
* suppression de la methode accueilProjet desormais remplacee par resume.php
1749
*
323 alexandre_ 1750
* Revision 1.43  2008-08-25 15:06:59  alexandre_tb
1751
* ajout:
1752
* - des notifications
1753
* - des messages en retour
1754
* - correction inscription a un projet avec liste externe
297 alexandre_ 1755
*
323 alexandre_ 1756
*
297 alexandre_ 1757
* +-- Fin du code ----------------------------------------------------------------------------------------+
1758
*/
1759
?>