Subversion Repositories Applications.projet

Rev

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