Subversion Repositories Applications.projet

Rev

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