Subversion Repositories Applications.projet

Rev

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