Subversion Repositories Applications.projet

Rev

Rev 208 | Rev 261 | 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
 
249 alexandre_ 23
// CVS : $Id: projetControleur.class.php,v 1.37 2007-06-25 12:15:06 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
249 alexandre_ 36
*@version       $Revision: 1.37 $
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')) {
212
                include_once PROJET_CHEMIN_APPLI.'services/'.$this->_service.'.php' ;
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
91 alexandre_ 572
			if ($isAdm || $isCoord) {
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) {
611
	        $this->_url->addQueryString(PROJET_VARIABLE_ACTION, $action) ;
208 neiluj 612
	        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireProjet.class.php' ;
139 alexandre_ 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
	        }
208 neiluj 619
	        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
139 alexandre_ 620
	        $formulaire_projet->construitFormulaire(projet::getTousLesProjets($this->_db), $tableau_type) ;
621
	        if ($action == PROJET_MODIFIER_DESCRIPTION_V) {
622
	            $projet = new projet($this->_db, $this->_id_projet) ;
623
	            $valeurs_par_defaut = array (   'projet_titre' => $projet->getTitre(),
624
	                                            'projet_description' => $projet->getDescription(),
625
	                                            'projet_asso' => $projet->getIdPere(),
626
	                                            'projet_wikini' => $projet->getWikini(),
627
	                                            'projet_resume' => $projet->getResume(),
628
	                                            'projet_espace_internet' => $projet->getEspaceInternet(),
629
	                                            'projet_type'=> $projet->getType(),
630
	                                            'projet_moderation' => $projet->isModere()
631
	                                        ) ;
632
	            $formulaire_projet->setDefaults($valeurs_par_defaut) ;
633
	        } else {
634
	        	$formulaire_projet->setDefaults (array ('projet_moderation'=> '0')) ;
635
	        }
636
	        $res = PROJET_PROPOSER_PROJET ;
637
	        return $res . $formulaire_projet->toHTML() ;
638
	    	} else {
249 alexandre_ 639
	    		return 'Veuillez r&eacute;gler les permissions en &eacute;criture sur '.PROJET_CHEMIN_FICHIER ;
139 alexandre_ 640
	    	}
2 ddelon 641
    } // end of member function nouveauProjet
642
 
643
    /**
644
     * Valide le formulaire et appelle la fonction d'insertion.
645
     *
646
     * @return string
647
     * @access public
648
     */
649
    function nouveauProjetValidation( )
650
    {
651
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_NOUVEAU_V) ;
208 neiluj 652
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireProjet.class.php' ;
653
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 654
        $formulaire_projet = new HTML_formulaireProjet('formulaire_projet', 'post', str_replace ('&amp;', '&', $this->_url->getURL())) ;
655
        $formulaire_projet->construitFormulaire(projet::getTousLesProjets($this->_db)) ;
656
        if ($formulaire_projet->validate()) {
59 ddelon 657
 
2 ddelon 658
            $projet = new projet ($this->_db) ;
659
            $projet->setCheminRepertoire (PROJET_CHEMIN_FICHIER) ;
660
            if (!$projet->enregistrerSQL($formulaire_projet->getSubmitValues())) {
661
                return 'erreur' ;
662
            }
34 alexandre_ 663
            // On inscrit le déposant du projet en tant que coordinateur
664
            if (PROJET_UTILISATEURS_COORD) {
665
		        // Si le projet n'a pas de liste, on inscrit directement
208 neiluj 666
		        include_once PROJET_CHEMIN_CLASSES.'participe.class.php' ;
34 alexandre_ 667
		        $participant = new participe($this->_db) ;
668
	            $participant->setStatut(1, $this->_auth->getAuthData (PROJET_CHAMPS_ID), $projet->getId()) ;
669
            }
2 ddelon 670
        } else {
671
            return $formulaire_projet->toHTML() ;
672
        }
249 alexandre_ 673
    }
2 ddelon 674
 
675
    /**
676
     * Valide le formulaire et appelle la fonction de mise à jour.
677
     *
678
     * @return void
679
     * @access public
680
     */
681
    function modifierProjet( )
682
    {
683
        // création de l'objet projet courant
208 neiluj 684
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 685
        $projet = new projet ($this->_db, $this->_id_projet) ;
686
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_ACTION_MODIFIER_V) ;
208 neiluj 687
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireProjet.class.php' ;
2 ddelon 688
        $formulaire_projet = new HTML_formulaireProjet('formulaire_projet', 'post', str_replace ('&amp;', '&', $this->_url->getURL())) ;
689
        $formulaire_projet->construitFormulaire(projet::getTousLesProjets($this->_db)) ;
690
        if ($formulaire_projet->validate()) {
691
            $projet->majSQL($formulaire_projet->getSubmitValues()) ;
692
        } else {
693
            return $formulaire_projet->toHTML() ;
694
        }
695
        unset ($projet) ;
208 neiluj 696
    }
2 ddelon 697
 
698
    /**
699
     * Renvoie le formulaire d'upload d'un fichier.
700
     *
701
     * @return void
702
     * @access public
703
     */
704
    function formulaireFichier($action)
705
    {
706
        $res = '<h1>'.PROJET_FICHIER_MISE_EN_LIGNE.'</h1>'."\n" ;
707
        if (isset($_SESSION['formulaire_document'])) {
708
            unset ($_SESSION['formulaire_document']) ;
709
        }
710
        $action_future = $action == PROJET_NOUVEAU_FICHIER ? PROJET_NOUVEAU_FICHIER_V : PROJET_ACTION_MODIFIER_V ;
711
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, $action_future) ;
712
        if ($this->_id_repertoire != '') $this->_url->addQueryString (PROJET_VARIABLE_ID_REPERTOIRE, $this->_id_repertoire) ;
208 neiluj 713
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireDocument.class.php' ;
2 ddelon 714
        $formulaire_document = new HTML_formulaireDocument('formulaire_document', 'post',preg_replace ("/&amp;/", "&", $this->_url->getURL())) ;
715
        $formulaire_document->construitFormulaire($action) ;
716
        if ($action == PROJET_ACTION_MODIFIER) {
249 alexandre_ 717
			include_once PROJET_CHEMIN_CLASSES.'document.class.php' ;
2 ddelon 718
            $document = new document($this->_id_document, $this->_db, PROJET_CHEMIN_FICHIER, PROJET_CHEMIN_ICONES) ;
249 alexandre_ 719
            // On affecte dans un tableau les valeurs de chaque champs du formulaire avec le nom de chaque element de formulaire
2 ddelon 720
            // voir HTML_formulaireDocument
721
            $valeurs_par_defaut = array ('document_nom' => $document->getNomLong(),
722
                                         'document_description' => $document->getDescription(),
723
                                         'document_visibilite' => $document->getVisibilite()) ;
59 ddelon 724
 
249 alexandre_ 725
            // On rajoute un champs cache avec l'identifiant du document
2 ddelon 726
            $formulaire_document->addElement ('hidden', 'id_document', $this->_id_document) ;
727
            $formulaire_document->setDefaults($valeurs_par_defaut) ;
728
        } else {
729
            $formulaire_document->setDefaults (array ('document_visibilite'=> 'public')) ;
730
        }
731
        return $res.$formulaire_document->toHTML() ;
732
 
733
    } // end of member function nouveauFichier
59 ddelon 734
 
2 ddelon 735
    /**
249 alexandre_ 736
    *   Presente un formulaire pour deplacer un fichier
2 ddelon 737
    *
738
    *
739
    */
740
    function fichierCouper() {
741
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
742
        $projet = new projet ($this->_db, $this->_id_projet) ;
59 ddelon 743
 
2 ddelon 744
        $res = '<h1>'.PROJET_PROJET.' : '.$projet->getTitre().'</h1>' ;
249 alexandre_ 745
        include_once PROJET_CHEMIN_CLASSES.'document.class.php' ;
2 ddelon 746
        $document = new document($this->_id_document, $this->_db, PROJET_CHEMIN_FICHIER) ;
249 alexandre_ 747
        // On traite le cas ou l'on vient de deplacer un fichier
59 ddelon 748
 
2 ddelon 749
        if (isset ($_POST['projet_repertoire'])) {
750
            if (!$document -> deplace ($_POST['projet_repertoire'], $projet->getNomRepertoire())) {
249 alexandre_ 751
                return 'echec du d&eacute;placement' ;
2 ddelon 752
            }
753
            return ;
754
        }
755
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireCouperColler.class.php' ;
756
        $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_COUPER) ;
757
        $HTML_formulaireCouperColler = new HTML_formulaireCouperColler('formulaire_couper_coller', 'post', str_replace('&amp;', '&', $this->_url->getURL())) ;
758
        $HTML_formulaireCouperColler -> construitFormulaire($projet->getListeRepertoireHierarchisee()) ;
249 alexandre_ 759
        $tab = $projet->getListeRepertoireHierarchisee();
760
        //$res .=  '<pre>'.print_r ($tab, true).'</pre>';
761
        return $res .$HTML_formulaireCouperColler->toHTML('<img src="'.PROJET_CHEMIN_ICONES.$document->getCheminIcone().'" /> '.$document->getNomLong());
2 ddelon 762
    }
763
    /**
764
     * Supprime un fichier.
765
     *
766
     * @return void
767
     * @access public
768
     */
769
    function suppressionFichier( )
770
    {
771
        if ($this->_id_document == "") {
772
            return $this->messageErreur(PROJETCONTROLEUR_PAS_DE_DOCUMENT_SELECTIONNE) ;
773
        }
208 neiluj 774
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 775
        $projet = new projet ($this->_db, $this->_id_projet) ;
776
        $document = new document($this->_id_document, $this->_db, PROJET_CHEMIN_FICHIER) ;
777
        $document->suppression() ;
778
        $document->suppressionSQL() ;
208 neiluj 779
 
780
        // On verifie s il reste des documents associes au projet et si non on met
781
        // a jour projet.p_avoir_document
782
        if (count ($projet->getListesDocuments(PROJET_CHEMIN_FICHIER)) == 0) $projet->setAvoirDocument(false);
2 ddelon 783
        return ;
784
 
785
    } // end of member function nouveauFichier
786
 
787
    /**
249 alexandre_ 788
     * Renvoie le formulaire de creation d'un repertoire.
2 ddelon 789
     *
790
     * @return void
791
     * @access public
792
     */
793
    function nouveauRepertoire( )
794
    {
795
        $res = '<h1>'.PROJET_REP_CREER.'</h1>'."\n" ;
796
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_NOUVEAU_REPERTOIRE_V) ;
208 neiluj 797
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireDocument.class.php' ;
2 ddelon 798
        $formulaire_repertoire = new HTML_formulaireDocument('formulaire_repertoire', 'post',preg_replace ("/&amp;/", "&", $this->_url->getURL())) ;
799
        $formulaire_repertoire->setType ('repertoire') ;
800
        $formulaire_repertoire->construitFormulaire() ;
801
        $formulaire_repertoire->setDefaults (array ('document_visibilite'=> 'public')) ;
802
        return $res.$formulaire_repertoire->toHTML() ;
803
 
208 neiluj 804
    }
2 ddelon 805
 
806
    /**
807
     * Valide le formulaire et appelle la fonction d'insertion.
808
     *
809
     * @return void
810
     * @access public
811
     */
812
    function nouveauFichierValidation( )
813
    {
249 alexandre_ 814
        // creation de l'objet projet courant
208 neiluj 815
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 816
        $projet = new projet ($this->_db, $this->_id_projet) ;
817
        if (isset($_SESSION['formulaire_document']) && $_SESSION['formulaire_document'] == 'valide') {
208 neiluj 818
            return include_once PROJET_CHEMIN_APPLI.'actions/documents.php' ;
2 ddelon 819
        }
820
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_NOUVEAU_FICHIER_V) ;
208 neiluj 821
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireDocument.class.php' ;
2 ddelon 822
        $formulaire_document = new HTML_formulaireDocument('formulaire_document', 'post', preg_replace ("/&amp;/", "&", $this->_url->getURL())) ;
823
        $formulaire_document->construitFormulaire() ;
824
        if ($formulaire_document->validate()) {
249 alexandre_ 825
            // Creation d'un objet document vide
2 ddelon 826
            $document = new document ("", $this->_db) ;
249 alexandre_ 827
            // avant d'appeler la methode enregistrerSQL, il faut indiquer l'identifiant du projet et l'identifiant du proprietaire
2 ddelon 828
            $document->setIdProjet ($this->_id_projet) ;
829
            $document->setIdProprietaire ($this->_auth->getAuthData (PROJET_CHAMPS_ID)) ;
59 ddelon 830
 
249 alexandre_ 831
            // On passe aussi le numero de repertoire s'il existe
2 ddelon 832
            if ($this->_id_repertoire != '') $document->setIdRepertoire($this->_id_repertoire) ;
249 alexandre_ 833
            if ($this->_id_repertoire == 0) $document->setIdRepertoire(0) ;
834
			//$GLOBALS['log'] .= '<br>this->_id_repertoire: '.$this->_id_repertoire.'<br>';
2 ddelon 835
            $chemin_upload = $document->calculeCheminUploaded($projet->getNomRepertoire()) ;
249 alexandre_ 836
			//$GLOBALS['log'] .= '<br>chemin_upload: '.$chemin_upload.'<br>';
837
			//$GLOBALS['log'] .= 'projet->getRepertoire() : '.$projet->getNomRepertoire().'<br>';
838
			$id_document = SQL_obtenirNouveauId($this->_db, 'projet_documents', 'pd_id') ;
839
			$nouveau_nom = $document->genereNouveauNom($projet->getNomRepertoire(), $_FILES['fichier']['name'], $id_document);
840
 
841
            if (!$document->upload (PROJET_CHEMIN_FICHIER.$chemin_upload.'/'.$nouveau_nom)) {
842
                return 'Echec de l\'upload<br />'.
843
                		'Fichier source : '. $_FILES['fichier']['name'];
844
                		'Fichier destination : '.PROJET_CHEMIN_FICHIER.$projet->getNomRepertoire().'/'.$chemin_upload.'/'.$nouveau_nom ;
2 ddelon 845
            }
59 ddelon 846
 
847
 
249 alexandre_ 848
            //$document->enregistrerSQL($formulaire_document->getSubmitValues(), $projet->getNomRepertoire().'/'.$chemin_upload) ;
849
            $retour = $document->enregistrerSQL($formulaire_document->getSubmitValues(), $nouveau_nom);
208 neiluj 850
            // On place a 1 la colonne p_avoir_document
851
            if (!$projet->avoirDocument()) $projet->setAvoirDocument(true);
852
 
2 ddelon 853
            // On ajoute une information de session
854
            $_SESSION['formulaire_document'] = 'valide';
855
        } else {
856
            return $formulaire_document->toHTML() ;
857
        }
249 alexandre_ 858
        return $retour;
2 ddelon 859
        unset ($projet) ;
860
    } // end of member function nouveauFichierValidation
861
 
862
    /**
863
     * Valide le formulaire et appelle la fonction d'insertion.
864
     *
865
     * @return void
866
     * @access public
867
     */
868
    function modifierFichier( )
869
    {
249 alexandre_ 870
        // creation de l'objet projet courant
208 neiluj 871
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 872
        $projet = new projet ($this->_db, $this->_id_projet) ;
873
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_ACTION_MODIFIER_V) ;
208 neiluj 874
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireDocument.class.php' ;
2 ddelon 875
        $formulaire_document = new HTML_formulaireDocument('formulaire_document', 'post',preg_replace ("/&amp;/", "&", $this->_url->getURL())) ;
876
        $formulaire_document->construitFormulaire(PROJET_ACTION_MODIFIER_V) ;
877
        if ($formulaire_document->validate()) {
249 alexandre_ 878
            // Creation d'un objet document vide
2 ddelon 879
            $document = new document ($this->_id_document, $this->_db) ;
249 alexandre_ 880
            // On passe aussi le numero de répertoire s'il existe
2 ddelon 881
            if ($this->_id_repertoire != '') $document->setIdRepertoire($this->_id_repertoire) ;
882
            $document->majSQL($formulaire_document->getSubmitValues()) ;
883
        } else {
884
            return $formulaire_document->toHTML() ;
885
        }
886
        unset ($projet) ;
887
    } // end of member function nouveauFichierValidation
888
 
889
    /**
890
     * Valide le formulaire et appelle la fonction d'insertion.
891
     *
892
     * @return void
893
     * @access public
894
     */
895
    function nouveauRepertoireValidation( )
896
    {
249 alexandre_ 897
        // creation de l'objet projet courant
208 neiluj 898
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 899
        $projet = new projet ($this->_db, $this->_id_projet) ;
59 ddelon 900
 
2 ddelon 901
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_NOUVEAU_FICHIER_V) ;
208 neiluj 902
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireDocument.class.php' ;
2 ddelon 903
        $formulaire_repertoire = new HTML_formulaireDocument('formulaire_repertoire', 'post',preg_replace ("/&amp;/", "&", $this->_url->getURL())) ;
904
        $formulaire_repertoire->setType ('repertoire') ;
905
        $formulaire_repertoire->construitFormulaire() ;
906
        if ($formulaire_repertoire->validate()) {
249 alexandre_ 907
            // Creation d'un objet
2 ddelon 908
            $document = new document ("", $this->_db) ;
249 alexandre_ 909
            // avant d'appeler la methode enregistrerSQL, il faut indiquer l'identifiant du projet et l'identifiant du proprietaire
2 ddelon 910
            $document->setIdProjet ($this->_id_projet) ;
911
            $document->setIdProprietaire ($this->_auth->getAuthData (PROJET_CHAMPS_ID)) ;
59 ddelon 912
 
249 alexandre_ 913
            // On passe aussi le numero de repertoire s'il existe
2 ddelon 914
            if ($this->_id_repertoire != '') $document->setIdRepertoire($this->_id_repertoire) ;
249 alexandre_ 915
			if ($this->_id_repertoire == 0) $document->setIdRepertoire(0) ;
916
            $chemin_upload = $document->calculeCheminUploaded($projet->getNomRepertoire()) ;
917
            $nom_repertoire = $document->enregistrerSQL($formulaire_repertoire->getSubmitValues(), $projet->getNomRepertoire()) ;
59 ddelon 918
 
249 alexandre_ 919
            // La creation du repertoire sur le disque, chemin / nom_repertoire_projet / id_repertoire
920
            $GLOBALS['log'] .= '<br />chemin_upload:'.$chemin_upload.'<br />';
921
            $GLOBALS['log'] .= '<br />mkdir('.PROJET_CHEMIN_FICHIER.$chemin_upload.$nom_repertoire.')<br />';
922
            if (!mkdir (PROJET_CHEMIN_FICHIER.$chemin_upload.'/'.$nom_repertoire)) {
59 ddelon 923
 
2 ddelon 924
                $document->suppressionSQL() ;
249 alexandre_ 925
                return $this->messageErreur(PROJETCONTROLEUR_ERREUR_CREATION_REPERTOIRE).'<br />'.
926
                						PROJET_CHEMIN_FICHIER.$chemin_upload.'/'.$nom_repertoire;
2 ddelon 927
            }
208 neiluj 928
            // On place a 1 la colonne p_avoir_document
929
            if (!$projet->avoirDocument()) $projet->setAvoirDocument(true);
2 ddelon 930
        } else {
931
            return $formulaire_repertoire->toHTML() ;
932
        }
249 alexandre_ 933
    }
2 ddelon 934
 
935
 
936
    /**
249 alexandre_ 937
     * Permet de specifier au controleur sur quel projet l'on travaille.
2 ddelon 938
     *
939
     * @param int id_projet L'identifiant du projet.
940
     * @return void
941
     * @access public
942
     */
943
    function setIdProjet( $id_projet )
944
    {
945
        $this->_id_projet = $id_projet ;
59 ddelon 946
 
2 ddelon 947
    } // end of member function setIdProjet
948
 
949
    /**
950
     * Renvoie la page d'accueil d'un projet.
951
     *
952
     * @return string
953
     * @access public
954
     */
955
    function accueilProjet( )
956
    {
957
        $res = '' ;
249 alexandre_ 958
        // creation de l'objet projet courant
208 neiluj 959
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 960
        $projet = new projet ($this->_db, $this->_id_projet) ;
59 ddelon 961
 
249 alexandre_ 962
        // recuperation de la liste des documents associés
2 ddelon 963
        $liste_documents = $projet->getListesDocuments(PROJET_CHEMIN_FICHIER, PROJET_CHEMIN_ICONES) ;
59 ddelon 964
 
2 ddelon 965
        // création de la vue liste de document, on nettoie l'url
966
        $this->_url->removeQueryString(PROJET_VARIABLE_ACTION) ;
967
        include_once PROJET_CHEMIN_CLASSES.'HTML_listeDocuments.class.php' ;
968
        $vue_liste_document = new HTML_listeDocuments($this->_url, false, $this->_id_repertoire) ;
59 ddelon 969
 
249 alexandre_ 970
        // reglage de parametres de la vue
2 ddelon 971
        $vue_liste_document->setAction (array ("couper" => PROJET_ACTION_COUPER, "modifier" => PROJET_ACTION_MODIFIER, "supprimer" => PROJET_SUPPRESSION_FICHIER)) ;
972
        $vue_liste_document->setCheminIcones(PROJET_CHEMIN_ICONES) ;
59 ddelon 973
 
974
 
2 ddelon 975
        $tableau_navigation = document::getCheminIdRepertoire($this->_id_repertoire, $this->_db) ;
59 ddelon 976
 
2 ddelon 977
        $vue_liste_document->setCheminNavigation ($tableau_navigation) ;
249 alexandre_ 978
        // verification des droits de l'utilisateur
2 ddelon 979
        $entete_liste = array (PROJET_FICHIERS_NOM, PROJET_FICHIERS_TAILLE, PROJET_FICHIERS_CREE_LE) ;
59 ddelon 980
 
2 ddelon 981
        if ($this->_auth->getAuth()) {
208 neiluj 982
            include_once PROJET_CHEMIN_CLASSES.'participe.class.php' ;
2 ddelon 983
            $participant = new participe($this->_db) ;
984
            $id_u = $this->_auth->getAuthData(PROJET_CHAMPS_ID) ;
985
            $isCoord = $participant->isCoordinateur($id_u, $this->_id_projet, $this->_db) ;
986
            if ($isCoord) $droits = PROJET_DROIT_COORDINATEUR ;
987
            $isAdm = participe::isAdministrateur($this->_auth->getAuthData(PROJET_CHAMPS_ID), $this->_db) ;
988
            if ($isAdm) $droits = PROJET_DROIT_ADMINISTRATEUR ;
989
            if ($isAdm) $isCoord = true ;
59 ddelon 990
 
2 ddelon 991
            $statut = participe::getStatutSurProjetCourant ($this->_auth->getAuthData(PROJET_CHAMPS_ID), $this->_id_projet, $this->_db) ;
992
            // si participant, on ajoute le champs visibilite
59 ddelon 993
 
2 ddelon 994
            if ($statut !='' || $isAdm) {
995
                array_push ($entete_liste, PROJET_FICHIERS_VISIBILITE) ;
996
            }
997
            // si chef de projet ou si propriétaire d'au moins 1 document
998
            $proprietaire_un_document = false ;
59 ddelon 999
 
2 ddelon 1000
            foreach ($liste_documents as $document) {
1001
                if ($this->_auth->getAuthData(PROJET_CHAMPS_ID) == $document) {
1002
                    $proprietaire_un_document = true ;
1003
                    $droits = PROJET_DROIT_PROPRIETAIRE ;
1004
                }
1005
            }
1006
            if ($statut > 0 || $proprietaire_un_document) {
1007
                array_push ($entete_liste, PROJET_ACTION) ;
1008
            }
1009
        } else {
1010
            $droits = PROJET_DROIT_AUCUN ;
1011
        }
1012
        if (!isset($droits)) $droits = PROJET_DROIT_AUCUN ;
59 ddelon 1013
 
2 ddelon 1014
        $vue_liste_document->construitEntete($entete_liste) ;
1015
        $vue_liste_document->construitListe ($liste_documents, $droits) ;
59 ddelon 1016
 
2 ddelon 1017
        $wiki_res = '' ;
1018
        // Les wikinis associés au projet
1019
        if ($projet->getWikini()) {
1020
            $wiki_res .= '<div><a href="'.PROJET_URL_WIKINI.'wakka.php?wiki=PagePrincipale&wikini='.$projet->getWikini().'">'.PROJET_URL_WIKINI.'</a>' ;
1021
            if ($this->_auth->getAuth() && $isCoord) {
1022
                $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_SUPPRIMER_WIKI) ;
1023
                $wiki_res .= ' <a href="'.$this->_url->getURL().'" onclick="javascript:return confirm(\''.PROJET_WIKINI_SUPPRIMER.' ?\')">'.PROJET_WIKINI_SUPPRIMER.'</a>' ;
1024
            }
1025
            $wiki_res .= '</div>' ;
1026
        } else {
1027
            $wiki_res .= '<div>'.PROJET_WIKINI_PAS.'</div>'."\n" ;
1028
        }
1029
        // On charge les listes de discussion du projet
1030
        // Pour le moment seul ezmlm est supportée
59 ddelon 1031
 
2 ddelon 1032
        $projet->getListesAssociees();
1033
        $sortie_liste = '' ;
59 ddelon 1034
 
2 ddelon 1035
        if ($projet->avoirListe()) {
208 neiluj 1036
            include_once PROJET_CHEMIN_CLASSES_LISTES.'ezmlm.php' ;
2 ddelon 1037
            foreach ($projet->_listes_associes as $info_liste) {
59 ddelon 1038
 
2 ddelon 1039
                $liste = new ezmlm_php() ;
1040
                // Paramétrage de la liste
59 ddelon 1041
 
2 ddelon 1042
                $liste->listdir = PROJET_CHEMIN_LISTES.$info_liste->getDomaine().'/'.$info_liste->getNom();
1043
                $liste->listname = $info_liste->getNom() ;
1044
                $liste->listdomain = $info_liste->getDomaine();
59 ddelon 1045
 
2 ddelon 1046
                if (isset ($GLOBALS['action']) && $GLOBALS['action'] != '') {
1047
                    $liste->set_action($GLOBALS['action']) ;
1048
                    $liste->set_actionargs($GLOBALS['actionargs']) ;
1049
                } else {
1050
                    $liste->set_action('list_info') ;
1051
                }
1052
                $liste->sendheaders	= false;
1053
                $liste->sendbody        = false;
1054
                $liste->sendfooters    = false;
1055
                $liste->forcehref = $this->_url->getURL() ;
59 ddelon 1056
 
2 ddelon 1057
                ob_start() ;
1058
                print '<span class="heading">Liste <strong>' . $info_liste->getAdresseEnvoi() ;
1059
                print "</strong></span><br />\n";
1060
                if ($this->_auth->getAuth()) {
1061
                    include_once PROJET_CHEMIN_CLASSES.'inscription_liste.class.php';
1062
                    $inscription_liste = new inscription_liste($this->_db) ;
11 alexandre_ 1063
                    if ($inscription_liste->getStatutInscrit( $info_liste->getId(),  $this->_auth) == '') {
2 ddelon 1064
                        $action_inscription = PROJET_ACTION_INSCRIPTION_LISTE ;
1065
                        $label_inscription = PROJET_S_INSCRIRE ;
1066
                    } else {
1067
                        $action_inscription = PROJET_ACTION_DESINSCRIPTION_LISTE ;
1068
                        $label_inscription = PROJET_SE_DESINSCRIRE ;
1069
                    }
1070
                    $this->_url->addQueryString(PROJET_VARIABLE_ACTION, $action_inscription) ;
1071
                    print '<a href="'.$this->_url->getURL().'">';
1072
                    print $label_inscription.'</a><br /> ';
1073
                }
1074
                print "\n<hr noshade><br />\n";
1075
                $this->_url->removeQueryString(PROJET_VARIABLE_ACTION) ;
1076
                switch ($liste->action) {
1077
                    case "show_msg":
1078
                        if (count($liste->actionargs) < 2) {
1079
                            $liste->error(EZMLM_INVALID_SYNTAX,TRUE);
1080
                        }
1081
                        $show_msg = new ezmlm_msgdisplay();
1082
                        $show_msg->listdir = $liste->listdir ;
1083
                        $show_msg->forcehref = $this->_url->getURL();
1084
                        // actionargs[0] contient le nom du répertoire et actionargs[1] le nom du fichier
1085
                        // On appelle la fonction qui affiche un fichier
1086
                        $show_msg->display($liste->actionargs[0] . "/" . $liste->actionargs[1]);
1087
                        break;
59 ddelon 1088
 
2 ddelon 1089
                    case "list_info":
1090
                        $info = new ezmlm_listinfo();
1091
                        if (!$info) return 'Les fichiers de la liste ne sont pas visible sur le serveur' ;
1092
                        $info->forcehref = $this->_url->getURL();
1093
                        $info->listdir = $liste->listdir ;
1094
                        $info->listname = $info_liste->getNom();
1095
                        $info->listdomain = $info_liste->getDomaine() ;
59 ddelon 1096
 
2 ddelon 1097
                        if (!$info->display()) {
1098
                            echo 'Pas de message dans cette liste' ;
1099
                        }
1100
                        break;
1101
                    case "show_threads":
1102
                        $threads = new ezmlm_threads();
1103
                        $threads->forcehref = $this->_url->getURL() ;
1104
                        $threads->listdir = $liste->listdir ;
1105
                        $threads->listname = $info_liste->getNom() ;
1106
                        $threads->listdomain = $info_liste->getDomaine() ;
1107
                        $threads->tempdir = PROJET_CHEMIN_APPLI.'/tmp' ;
1108
                        $threads->load($liste->actionargs[0]);
1109
                        break;
1110
                    case "show_author_msgs" :
1111
                        $author = new ezmlm_author();
1112
                        $author->listdir = $liste->listdir ;
1113
                        $author->listname = $info_liste->getNom() ;
1114
                        $author->listdomain = $info_liste->getDomaine() ;
1115
                        $author->forcehref = $this->_url->getURL() ;
1116
                        $author->display($liste->actionargs[0]);
1117
                    break ;
1118
                }
1119
                $sortie_liste = ob_get_contents() ;
1120
                ob_end_clean() ;
1121
            }
1122
        } else {
1123
            $sortie_liste = '<div>'.PROJET_PAS_DE_LISTE.'</div>'."\n" ;
1124
        }
59 ddelon 1125
 
2 ddelon 1126
        $res .= "<h1>".$projet->getTitre()."</h1>" ;
1127
        $res .= '<div>'.$projet->getDescription().'</div>'."\n" ;
1128
        $res .= '<h2>'.PROJET_WIKI_ASSOCIE.'</h2>' ;
1129
        $res .= $wiki_res ;
1130
        $res .= '<h2>'.PROJET_FICHIERS_ASSOCIES.'</h2>'."\n" ;
1131
        $res .= $vue_liste_document->toHTML() ;
1132
        $res .= '<h2>'.PROJET_LISTES_ASSOCIEES.'</h2>'."\n" ;
1133
        $res .= $sortie_liste ;
59 ddelon 1134
 
2 ddelon 1135
        include_once PROJET_CHEMIN_CLASSES.'liste_externe.class.php' ;
1136
        $listes_ext = new liste_externe ($this->_db) ;
1137
        $tableau_liste = $listes_ext->getListesAssociees($this->_id_projet) ;
59 ddelon 1138
 
2 ddelon 1139
        if (count ($tableau_liste) != 0) {
1140
            $res .= '<h2>'.PROJET_LISTES_EXTERNES_ASSOCIEES.'</h2>'."\n" ;
1141
            for ($i = 0; $i < count ($tableau_liste); $i++) {
1142
                $info_liste = $listes_ext->getInfoListe($tableau_liste[$i]) ;
1143
                $res .= '<h2>'.$info_liste->AGO_A_NOMGRPLG.'</h2>'."\n" ;
1144
                $res .= '<p>'.$info_liste->AGO_A_RESUMLG.'</p>'."\n" ;
1145
                $res .= '<p><a href="'.$info_liste->AGO_A_URLGRP.'">'.$info_liste->AGO_A_URLGRP.'</a></p>'."\n" ;
1146
                $res .= '<br />'."\n" ;
1147
            }
1148
        }
1149
        return $res ;
1150
    } // end of member function accueilProjet
1151
 
1152
    /**
249 alexandre_ 1153
     * Permet de specifier quel repertoire, dans la vue de document afficher. Il sera
1154
     * passe en parametre a la classe HTML_listeDocuments.
2 ddelon 1155
     *
249 alexandre_ 1156
     * @param int id_repertoire L'identifiant du repertoire a afficher.
2 ddelon 1157
     * @return void
1158
     * @access public
1159
     */
1160
    function setIdRepertoire( $id_repertoire )
1161
    {
1162
        $this->_id_repertoire = $id_repertoire ;
249 alexandre_ 1163
    }
2 ddelon 1164
 
1165
    /**
1166
     * Supprime un projet et tout ce qui va avec.
1167
     *
1168
     * @return void
1169
     * @access public
1170
     */
1171
    function suppressionProjet( )
1172
    {
208 neiluj 1173
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1174
        $projet = new projet ($this->_db, $this->_id_projet) ;
1175
        $projet->setCheminRepertoire (PROJET_CHEMIN_FICHIER) ;
1176
        $projet->getListesAssociees() ;
1177
        if ($projet->avoirListe()) $projet->supprimerListe($projet->_listes_associes[0]) ;
1178
        $msg = $projet->suppressionSQL() ;
1179
        unset ($this->_id_projet) ; unset($_GET['id_projet']);
1180
        return $msg ;
208 neiluj 1181
    }
2 ddelon 1182
 
1183
    /**
1184
     * Permet d'indiquer au controleur sur quel document on travaille.
1185
     *
59 ddelon 1186
     * @param int id_document
2 ddelon 1187
     * @return void
1188
     * @access public
1189
     */
1190
    function setIdDocument( $id_document )
1191
    {
1192
        $this->_id_document = $id_document ;
208 neiluj 1193
    }
2 ddelon 1194
 
1195
 
1196
    /**
1197
     * Renvoie le formulaire d'envoie de mail
1198
     *
1199
     * @return void
1200
     * @access public
1201
     */
1202
    function envoyerUnMailFormulaire( )
1203
    {
74 alexandre_ 1204
    	if (!$this->_auth->getAuth()) {
1205
    		return PROJET_LISTE_PROJET;
1206
    	}
96 alexandre_ 1207
    	if (isset($_SESSION['formulaire_mail'])) {
1208
            unset ($_SESSION['formulaire_mail']) ;
1209
        }
2 ddelon 1210
        $res = '<h1>'.PROJET_ECRIRE_LISTE.'</h1>'."\n" ;
1211
        $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ENVOYER_UN_MAIL_V) ;
208 neiluj 1212
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireMail.class.php' ;
2 ddelon 1213
        $formulaire_mail = new HTML_formulaireMail('formulaire_mail', 'post',preg_replace ("/&amp;/", "&", $this->_url->getURL())) ;
1214
        $formulaire_mail->construitFormulaire() ;
1215
        return $res.$formulaire_mail->toHTML() ;
208 neiluj 1216
    }
2 ddelon 1217
 
1218
    /**
1219
     * Envoie le mail
1220
     *
1221
     * @return void
1222
     * @access public
1223
     */
1224
    function envoyerUnMailValidation( )
1225
    {
249 alexandre_ 1226
        // Verifications
96 alexandre_ 1227
        if (isset($_SESSION['formulaire_mail']) && $_SESSION['formulaire_mail'] == 'valide') {
208 neiluj 1228
            return include_once PROJET_CHEMIN_APPLI.'actions/forums.php' ;
96 alexandre_ 1229
        }
122 alexandre_ 1230
 
2 ddelon 1231
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_ENVOYER_UN_MAIL_V );
208 neiluj 1232
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireMail.class.php' ;
2 ddelon 1233
        $formulaire_mail = new HTML_formulaireMail('formulaire_mail', 'post', preg_replace ("/&amp;/", "&", $this->_url->getURL())) ;
1234
        $formulaire_mail->construitFormulaire() ;
1235
        if ($formulaire_mail->validate()) {
249 alexandre_ 1236
            // creation de l'objet projet courant
208 neiluj 1237
            include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1238
            $projet = new projet ($this->_db, $this->_id_projet) ;
1239
            $info_liste = $projet->getListesAssociees() ;
1240
            $valeurs_mail = $formulaire_mail->getSubmitValues() ;
1241
            // Pour envoyer le mail on utilise la classe Mail de PEAR
1242
            // on a besoin du mail de l'inscrit
1243
 
1244
            $entetes['From'] = $this->_auth->getUserName();
1245
            $entetes['To'] = $projet->_listes_associes[0]->getAdresseEnvoi() ;
1246
            $entetes['Subject'] = $valeurs_mail['mail_titre'] ;
63 alexandre_ 1247
            $entetes['Date'] = date ('D, M j G:i:s \C\E\S\T Y') ;
2 ddelon 1248
            $entetes['Message-ID'] = md5(time()).'@'.$projet->_listes_associes[0]->getNom().'.'.$projet->_listes_associes[0]->getDomaine() ;
1249
            $entetes['reply-to'] = $projet->_listes_associes[0]->getAdresseEnvoi() ;
1250
            $entetes['Content-Type'] = 'text/plain' ;
249 alexandre_ 1251
            // Traitement de la reference s'il s'agit d'une reponse
2 ddelon 1252
            if (isset ($_POST['messageid'])) {
1253
                $entetes['In-Reply-To'] = $_POST['messageid'] ;
1254
            }
1255
            $objet_mail =& Mail::factory('smtp');
1256
            $objet_mail->send($entetes['To'], $entetes, $valeurs_mail['mail_corps']);
96 alexandre_ 1257
            $_SESSION['formulaire_mail'] = 'valide';
2 ddelon 1258
            return  ;
1259
        } else {
1260
            return $formulaire_mail->toHTML() ;
1261
        }
1262
    } // end of member function envoyerUnMailValidation
1263
 
1264
   /**
1265
     * Renvoie le formulaire de création d'une liste.
1266
     *
1267
     * @param int action Indique le type d'action,  PROJET_ACTION_NOUVELLE_LISTE
1268
     * @return string
1269
     * @access public
1270
     */
1271
    function formulaireListe( $action )
1272
    {
1273
        $res = '<h1>'.PROJET_CREATION_LISTE.'</h1>'."\n" ;
1274
        $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_NOUVELLE_LISTE_V) ;
208 neiluj 1275
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireListe.class.php' ;
2 ddelon 1276
        $formulaire_liste = new HTML_formulaireListe('formulaire_liste', 'post',preg_replace ("/&amp;/", "&", $this->_url->getURL())) ;
1277
        $formulaire_liste->construitFormulaire() ;
1278
        $formulaire_liste->setDefaults(array('domaine_liste' => PROJET_DOMAINE_LISTE)) ;
1279
        $formulaire_liste->updateElementAttr('domaine_liste', array('readonly' => 'readonly')) ;
1280
        return $res.$formulaire_liste->toHTML() ;
249 alexandre_ 1281
    }
2 ddelon 1282
 
1283
    /**
1284
     * Transmet au serveur la demande de création d'une nouvelle liste.
1285
     *
1286
     * @return void
1287
     * @access public
1288
     */
1289
    function nouvelleListeValidation( )
1290
    {
249 alexandre_ 1291
        // Verifications
2 ddelon 1292
        $this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_ACTION_NOUVELLE_LISTE_V );
208 neiluj 1293
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireListe.class.php' ;
2 ddelon 1294
        $formulaire_liste = new HTML_formulaireListe('formulaire_liste', 'post', preg_replace ("/&amp;/", "&", $this->_url->getURL())) ;
1295
        $formulaire_liste->construitFormulaire() ;
1296
        if ($formulaire_liste->validate()) {
249 alexandre_ 1297
            // creation de l'objet liste_discussion
1298
            include_once PROJET_CHEMIN_CLASSES.'liste_discussion.class.php';
2 ddelon 1299
            $liste = new liste_discussion('', $this->_db) ;
59 ddelon 1300
 
2 ddelon 1301
            // On vérifie que le nom de la liste soit unique
1302
            if (liste_discussion::verifieDoubleListe($formulaire_liste->getSubmitValue('nom_liste').'@'.
1303
                                                            $formulaire_liste->getSubmitValue('domaine_liste'), $this->_db)) {
59 ddelon 1304
                // On rajoute la liste dans la base
2 ddelon 1305
                $liste->enregistrerSQL($formulaire_liste->getSubmitValues()) ;
59 ddelon 1306
 
2 ddelon 1307
                // On la relie au projet
208 neiluj 1308
                include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1309
                $projet = new projet ($this->_db, $this->_id_projet) ;
1310
                $projet->ajouterListe($liste) ;
59 ddelon 1311
 
249 alexandre_ 1312
                // Creation de la liste
22 alexandre_ 1313
                $resultat_creation = file_get_contents (PROJET_SERVEUR_VPOPMAIL.'/creation_liste.php?domaine='.
2 ddelon 1314
                                    $liste->getDomaine().'&liste='.$liste->getNom().'&parametres=aBiud') ;
59 ddelon 1315
 
249 alexandre_ 1316
                // Ajout du moderateur
22 alexandre_ 1317
                $resultat_ajout_moderateur = file_get_contents (PROJET_SERVEUR_VPOPMAIL.'/ajout_moderateur.php?domaine='.
2 ddelon 1318
                                    $liste->getDomaine().'&liste='.$liste->getNom().'&mail='.$this->_auth->getUserName()) ;
249 alexandre_ 1319
                // Ajout du moderateur en tant qu'utilisateur
22 alexandre_ 1320
                $resultat_ajout_utilisateur = file_get_contents (PROJET_SERVEUR_VPOPMAIL.'/ajout_abonne.php?domaine='.
2 ddelon 1321
                                    $liste->getDomaine().'&liste='.$liste->getNom().'&mail='.$this->_auth->getUserName()) ;
1322
 
1323
            } else {
1324
                return PROJET_MESSAGE_LISTE_DOUBLE.$formulaire_liste->toHTML() ;
1325
            }
1326
            return $resultat_creation.$resultat_ajout_moderateur.$resultat_ajout_utilisateur;
59 ddelon 1327
 
2 ddelon 1328
        } else {
1329
            return $formulaire_liste->toHTML() ;
1330
        }
1331
    } // end of member function nouvelleListeValidation
59 ddelon 1332
 
2 ddelon 1333
    /**
1334
     * Supprime la liste de discussion associée au projet
1335
     *
1336
     * @return void
1337
     * @access public
1338
     */
1339
    function supprimerListe( )
1340
    {
208 neiluj 1341
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1342
        $projet = new projet($this->_db, $this->_id_projet) ;
1343
        $projet->getListesAssociees() ;
59 ddelon 1344
 
22 alexandre_ 1345
        $resultat_suppression = file_get_contents(PROJET_SERVEUR_VPOPMAIL.'/suppression_liste.php?domaine='.
2 ddelon 1346
                                    $projet->_listes_associes[0]->getDomaine().'&liste='.$projet->_listes_associes[0]->getNom()) ;
1347
        $projet->supprimerListe($projet->_listes_associes[0]) ;
1348
        return $resultat_suppression;
1349
    } // end of member function supprimerListe
1350
 
1351
 
1352
    /**
1353
     *
59 ddelon 1354
     *
2 ddelon 1355
     * @param string presentation Pour affecter une présentation au projet
1356
     * @return void
1357
     * @access public
1358
     */
1359
    function setPresentation( $presentation )
1360
    {
1361
        $this->_presentation = $presentation ;
1362
    } // end of member function setPresentation
1363
 
11 alexandre_ 1364
    /**
1365
     *
59 ddelon 1366
     *
11 alexandre_ 1367
     * @param string type Pour affecter un type au projet
1368
     * @return void
1369
     * @access public
1370
     */
1371
    function setType( $type)
1372
    {
1373
        $this->_type = $type ;
1374
    } // end of member function setPresentation
2 ddelon 1375
 
11 alexandre_ 1376
 
2 ddelon 1377
    /**
46 ddelon 1378
     * Fonction affichant les participants à un projet
2 ddelon 1379
     *
1380
     * @return string
1381
     * @access public
1382
     */
1383
    function voirParticipants( )
1384
    {
1385
        include_once PROJET_CHEMIN_CLASSES.'HTML_listeParticipants.class.php' ;
208 neiluj 1386
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1387
        $projet = new projet ($this->_db, $this->_id_projet) ;
1388
        $titre = '<h1>'.$projet->getTitre().'</h1>'."\n" ;
1389
        $titre .= '<h2>'.PROJET_LISTE_PARTICIPANT.'</h2>'."\n" ;
208 neiluj 1390
        include_once PROJET_CHEMIN_CLASSES.'participe.class.php' ;
2 ddelon 1391
        $participants = new participe($this->_db) ;
59 ddelon 1392
 
2 ddelon 1393
        // On teste ici s'il y a une mise à jour de statut
1394
        if (isset($_POST['statut'])) {
1395
            // $_GET['id_utilisateur'] et $_GET['statut'] proviennent du formulaire voir HTML_listeParticipants
1396
            $participants->setStatut($_POST['statut'], $_GET['id_utilisateur'], $this->_id_projet) ;
1397
        }
59 ddelon 1398
 
208 neiluj 1399
        // Ce qui suit doit être amàliorà pour sortir la requête sur l'annuaire
2 ddelon 1400
        // On teste s'il y a un ajout d'utilisateur voir HTML_listeParticipants
1401
        if (isset($_POST['mail_utilisateur'])) {
1402
            $requete = 'select '.PROJET_CHAMPS_ID.' from '.PROJET_ANNUAIRE.' where '.PROJET_CHAMPS_MAIL.'="'.$_POST['mail_utilisateur'].'"';
1403
            $resultat = $this->_db->query ($requete) ;
1404
            if (DB::isError ($resultat)) {
1405
                die ('Echec de la requete : '.$requete.'<br />'.$resultat->getMessage()) ;
1406
            }
1407
            if (!$resultat->numRows()) {
1408
                $msg = PROJET_MAIL_ABSENT;
1409
            } else {
1410
                $ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
1411
                $participants->setStatut(3, $ligne[PROJET_CHAMPS_ID], $this->_id_projet) ;
1412
            }
1413
        }
59 ddelon 1414
 
2 ddelon 1415
        if ($this->_auth->getAuth()) {
1416
            $statut = participe::getStatutSurProjetCourant($this->_auth->getAuthData(PROJET_CHAMPS_ID),  $this->_id_projet, $this->_db) ;
1417
            if ($statut == 2) $droits = PROJET_DROIT_CONTRIBUTEUR ;
1418
            if ($statut == 1) $droits = PROJET_DROIT_COORDINATEUR ;
1419
            if (participe::isAdministrateur($this->_auth->getAuthData(PROJET_CHAMPS_ID), $this->_db)) $droits = PROJET_DROIT_ADMINISTRATEUR  ;
1420
            $HTML_listeParticipants = new HTML_listeParticipants(true) ;
1421
            if ($statut < 2) $HTML_listeParticipants->setModeModification() ;
1422
            // Mise en place de l'url
1423
            $this->_url->addQueryString (PROJET_VARIABLE_ACTION, PROJET_ACTION_VOIR_PARTICIPANT) ;
1424
            $HTML_listeParticipants->setURL($this->_url) ;
1425
            // Construction de l'entete
1426
            $entete = array (PROJET_NOM, PROJET_PRENOM) ;
59 ddelon 1427
 
2 ddelon 1428
            if ($this->_auth->getAuth()) {
1429
                array_push ($entete, PROJET_MAIL) ;
1430
            } else {
1431
               $droits = PROJET_DROIT_AUCUN ;
1432
            }
1433
            $info_utilisateur = $participants->getInscrits($this->_id_projet, $droits) ;
1434
            array_push ($entete, PROJET_DATE_INSCRIPTION) ;
1435
            $HTML_listeParticipants->construitEntete($entete) ;
59 ddelon 1436
 
2 ddelon 1437
            $HTML_listeParticipants->construitListe($info_utilisateur, statut::getTousLesStatuts(PROJET_STATUT_SAUF_ADM_COORD, $this->_db)) ;
59 ddelon 1438
 
2 ddelon 1439
            $res = $HTML_listeParticipants->toHTML() ;
59 ddelon 1440
 
2 ddelon 1441
            if ($statut < 2) {
1442
                $res .= PROJET_NOUVEAU_UTILISATEUR_LAIUS ;
1443
                $res .= '<form action="'.$this->_url->getURL().'" method="post">'."\n" ;
1444
                if (isset ($msg) && $msg != '') {
1445
                    $res .= '<div>'.$msg.'</div>' ;
1446
                }
1447
                $res .= '<input type="text" name="mail_utilisateur" size="32" />' ;
1448
                $res .= '<input type="submit" value="'.PROJET_NOUVEAU_UTILISATEUR.'" />'."\n" ;
1449
                $res .= '</form>'."\n" ;
1450
            }
1451
        } else {
1452
            $res .= '<p>'.PROJET_TEXTE_NON_IDENTIFIE.'</p>'."\n" ;
1453
        }
1454
        return $titre.$res ;
59 ddelon 1455
 
2 ddelon 1456
    } // end of member function voirParticipants
1457
 
1458
    /**
249 alexandre_ 1459
     * Inscrit un utilisateur a un projet avec le statut observateur
2 ddelon 1460
     *
1461
     * @return void
1462
     * @access public
1463
     */
1464
    function inscriptionProjet( )
1465
    {
1466
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireInscriptionProjet.class.php' ;
208 neiluj 1467
		include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1468
        $projet = new projet ($this->_db, $this->_id_projet) ;
59 ddelon 1469
 
2 ddelon 1470
        // Si le projet n'a pas de liste, on inscrit directement
1471
        if (isset ($this->_id_projet)) {
208 neiluj 1472
            include_once PROJET_CHEMIN_CLASSES.'participe.class.php' ;
2 ddelon 1473
            $participant = new participe($this->_db) ;
59 ddelon 1474
 
2 ddelon 1475
            if (!$projet->avoirListe()) {
122 alexandre_ 1476
            	if ($projet->isModere()) {
1477
                	$participant->setStatut(3, $this->_auth->getAuthData (PROJET_CHAMPS_ID), $this->_id_projet) ;
1478
            	} else {
1479
            		$participant->setStatut(2, $this->_auth->getAuthData (PROJET_CHAMPS_ID), $this->_id_projet) ;
1480
            	}
2 ddelon 1481
                return $this->mesProjets() ;
1482
            }
1483
        }
1484
        if (isset($_POST['valider_inscription_projet'])) {
1485
            if (isset($_POST['radio_inscription_liste'])) {
122 alexandre_ 1486
            	include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
1487
            	$utilisateur = new annuaire($this->_db, array('identifiant' => PROJET_CHAMPS_ID,
1488
								'mail' => PROJET_CHAMPS_MAIL, 'table' => PROJET_ANNUAIRE,
1489
								'nom'=> PROJET_CHAMPS_NOM, 'prenom' => PROJET_CHAMPS_PRENOM)) ;
1490
	            $utilisateur->setId($this->_auth->getAuthData(PROJET_CHAMPS_ID)) ;
1491
 
1492
            	if (!$projet->isModere()) {
1493
	                $participant->setStatut(2, $this->_auth->getAuthData (PROJET_CHAMPS_ID), $this->_id_projet) ;
1494
 
1495
	                include_once PROJET_CHEMIN_CLASSES.'inscription_liste.class.php' ;
1496
	                $projet->getListesAssociees() ;
1497
	                $inscription_liste = new inscription_liste($this->_db) ;
1498
	                $inscription_liste->inscrireUtilisateur( $utilisateur,
2 ddelon 1499
                                                        $projet->_listes_associes[0],
1500
                                                        $_POST['radio_inscription_liste']) ;
122 alexandre_ 1501
            	} else {
1502
            		$participant->setStatut(3, $this->_auth->getAuthData (PROJET_CHAMPS_ID), $this->_id_projet) ;
1503
            		$tableau_coordinateur = $participant->getCoordinateurs($this->_id_projet) ;
249 alexandre_ 1504
 
122 alexandre_ 1505
            		$entetes['From'] = $this->_auth->getUserName();
1506
		            $entetes['To'] = '';
1507
		            $entetes['Subject'] = PROJET_DEMANDE_INSCRIPTION ;
1508
		            $entetes['Date'] = date ('D, M j G:i:s \C\E\S\T Y') ;
1509
		            $entetes['Message-ID'] = md5(time()) ;
1510
		            $entetes['reply-to'] = '' ;
1511
		            $entetes['Content-Type'] = 'text/plain' ;
1512
 
1513
		            $objet_mail =& Mail::factory('smtp');
1514
		            require_once PROJET_CHEMIN_BIBLIOTHEQUE_API.'pear/HTML/Template/IT.php';
1515
				    $tpl = new HTML_Template_IT() ;
1516
				    // Le gabarit du mail est dans un template
1517
				    // template 1
1518
				    $requete = 'select pt_template from projet_template where pt_id_template=1'.
1519
				    			' and pt_i18n like "%'.PROJET_LANGUE_DEFAUT.'"' ;
1520
 
1521
				    if (!$tpl -> setTemplate($this->_db->getOne ($requete))) {
1522
				    	echo 'erreur' ;
1523
				    }
1524
					$tpl->setVariable('nom', $utilisateur->getInfo( 'nom')) ;
1525
					$tpl->setVariable('prenom', $utilisateur->getInfo( 'prenom')) ;
1526
					$tpl->setVariable('nom_projet', $projet->getTitre()) ;
1527
					$tpl->setVariable('lien', str_replace ('&amp;', '&', $this->_url->getURL())) ;
1528
 
1529
            		foreach ($tableau_coordinateur as $coordinateur) {
1530
            			$entetes['To'] .= $coordinateur[3];	// Le champs 3 est le mail
1531
            		}
1532
            		$objet_mail->send($entetes['To'], $entetes, $tpl->get());
1533
            	}
2 ddelon 1534
            }
59 ddelon 1535
 
2 ddelon 1536
            if ($this->_presentation != 'arbre') {
249 alexandre_ 1537
                return '<h1>'.$projet->getTitre().'</h1>'.
1538
                		str_replace ('nom_du_projet', $projet->getTitre(), PROJET_LAIUS_INSCRIPTION_MODERE);
2 ddelon 1539
            } else {
1540
                $this->_action = PROJET_ACTION_VOIR_RESUME;
1541
            }
249 alexandre_ 1542
            return PROJET_LAIUS_INSCRIPTION_MODERE;
2 ddelon 1543
        }
1544
        $res = '<h1>'.PROJET_INSCRIPTION_PROJET.' : '.$projet->getTitre().'</h1>'."\n" ;
1545
        if ($projet->avoirListe()) $res .= '<h2>'.PROJET_MESSAGE_LISTE.'</h2>'."\n" ;
1546
        //$participant = new participe($this->_db) ;
1547
        $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_S_INSCRIRE) ;
1548
        $HTML_formulaireInscriptionProjet = new HTML_formulaireInscriptionProjet('inscription_projet', 'post', str_replace ('&amp;', '&', $this->_url->getURL())) ;
1549
        $HTML_formulaireInscriptionProjet->construitFormulaire($projet) ;
1550
        $HTML_formulaireInscriptionProjet->setDefaults(array('radio_inscription_liste' => 2)) ;
1551
        return $res.$HTML_formulaireInscriptionProjet->toHTML() ;
1552
    } // end of member function inscriptionProjet
1553
 
1554
    /**
249 alexandre_ 1555
     * Inscrit l'utilisateur loggue a la liste dont le parametre est en post.
2 ddelon 1556
     *
1557
     * @return void
1558
     * @access public
1559
     */
1560
    function inscriptionListe( )
1561
    {
208 neiluj 1562
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1563
        $projet = new projet ($this->_db, $this->_id_projet) ;
1564
        include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
1565
        include_once PROJET_CHEMIN_CLASSES.'inscription_liste.class.php' ;
1566
        $projet->getListesAssociees() ;
1567
        $utilisateur = new annuaire($this->_db, array('identifiant' => PROJET_CHAMPS_ID, 'mail' => PROJET_CHAMPS_MAIL, 'table' => PROJET_ANNUAIRE)) ;
1568
        $utilisateur->setId($this->_auth->getAuthData(PROJET_CHAMPS_ID)) ;
1569
        $inscription_liste = new inscription_liste($this->_db) ;
1570
        $inscription_liste->inscrireUtilisateur( $utilisateur, $projet->_listes_associes[0], 2) ;  // 2 est la statut inscription normale
1571
    } // end of member function inscriptionListe
1572
 
1573
    /**
208 neiluj 1574
     * Inscrit l'utilisateur logué à la liste dont le paraître est en post.
2 ddelon 1575
     *
1576
     * @return void
1577
     * @access public
1578
     */
1579
    function desinscriptionListe( )
1580
    {
1581
        if (isset($_GET['inscription_liste']) || $this->_action = PROJET_ACTION_DESINSCRIPTION_LISTE) {
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() ;
31 alexandre_ 1587
            $utilisateur = new annuaire($this->_db, array('identifiant' => PROJET_CHAMPS_ID,
1588
            								 'mail' => PROJET_CHAMPS_MAIL,
1589
            								 'table' => PROJET_ANNUAIRE)) ;
2 ddelon 1590
            $utilisateur->setId($this->_auth->getAuthData(PROJET_CHAMPS_ID)) ;
1591
            $inscription_liste = new inscription_liste($this->_db) ;
1592
            $inscription_liste->desinscrireUtilisateur( $utilisateur, $projet->_listes_associes[0], $_GET['inscription_liste']) ;
1593
        }
1594
    } // end of member function inscriptionListe
1595
    /**
1596
     * desinscrit un utilisateur à un projet
1597
     *
1598
     * @return void
1599
     * @access public
1600
     */
1601
    function desinscriptionProjet( )
1602
    {
1603
        include_once PROJET_CHEMIN_CLASSES.'participe.class.php' ;
1604
        $participant = new participe($this->_db) ;
59 ddelon 1605
 
2 ddelon 1606
        // Le statut 4 désinscrit l'utilisateur, dans la méthode setStatut
1607
        $participant->setStatut(4, $this->_auth->getAuthData (PROJET_CHAMPS_ID), $this->_id_projet) ;
208 neiluj 1608
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1609
        $projet = new projet ($this->_db, $this->_id_projet) ;
1610
        $projet->getListesAssociees() ;
1611
        if ($projet->avoirListe()) {
1612
            include_once PROJET_CHEMIN_CLASSES.'annuaire.class.php' ;
1613
            $annuaire = new annuaire($this->_db, array('identifiant' => PROJET_CHAMPS_ID, 'mail' => PROJET_CHAMPS_MAIL, 'table' => PROJET_ANNUAIRE)) ;
1614
            $annuaire->setId($this->_auth->getAuthData(PROJET_CHAMPS_ID)) ;
1615
            include_once PROJET_CHEMIN_CLASSES.'inscription_liste.class.php' ;
1616
            $desinscription= new inscription_liste($this->_db) ;
1617
            $desinscription->desinscrireUtilisateur($annuaire, $projet->_listes_associes[0]) ;
1618
        }
1619
        if ($this->_presentation != 'arbre') {
122 alexandre_ 1620
            include_once PROJET_CHEMIN_APPLI.'actions/resume.php' ;
1621
            return $retour ;
2 ddelon 1622
        } else {
1623
            $this->_action = PROJET_ACTION_VOIR_RESUME;
1624
        }
1625
    } // end of member function inscriptionProjet
1626
 
1627
    /**
1628
     * Renvoie le formulaire de création d'un wiki
1629
     *
1630
     * @return void
1631
     * @access public
1632
     */
1633
    function formulaireWiki( )
1634
    {
59 ddelon 1635
 
1636
		require_once 'client/integrateur_wikini/bibliotheque/iw_admin_wikini.fonct.php';
1637
 
60 ddelon 1638
 
61 ddelon 1639
  		$url = &$GLOBALS['_GEN_commun']['url'] ;
60 ddelon 1640
		$url->addQueryString ('act', PROJET_ACTION_CREER_WIKI) ;
79 alexandre_ 1641
		$url->addQueryString (PROJET_VARIABLE_ID_PROJET, $this->_id_projet) ;
59 ddelon 1642
		$res =admin_afficherContenuCorps();
79 alexandre_ 1643
		$res .= '<br /><a href="'.$this->_url->getURL().'">'.PROJET_RETOUR_RESUME.'</a>';
59 ddelon 1644
    	return $res;
1645
 
2 ddelon 1646
    } // end of member function formulaireWiki
1647
 
16 ddelon 1648
 
1649
	function associerWiki( )
1650
    {
1651
        $res = '<h1>'.PROJET_ASSOCIER_WIKI.'</h1>'."\n" ;
59 ddelon 1652
 
1653
	 	$db = &$GLOBALS['_GEN_commun']['pear_db'] ;
16 ddelon 1654
    	$res='';
59 ddelon 1655
 
16 ddelon 1656
         // Comportement par défaut
59 ddelon 1657
	    // requete sur la table gen_wikini pour affichage de la liste des Wikini
16 ddelon 1658
	    $requete = "select  gewi_id_wikini, gewi_code_alpha_wikini, gewi_page from gen_wikini" ;
59 ddelon 1659
 
16 ddelon 1660
	    $resultat = $db->query ($requete) ;
1661
	    if (DB::isError ($resultat)) {
1662
	        $GLOBALS['_GEN_commun']['debogage_erreur']->gererErreur(E_USER_WARNING, "Echec de la requete : $requete<br />".$resultat->getMessage(),
1663
	                                                                        __FILE__, __LINE__, 'admin_wikini')   ;
1664
	        return ;
1665
	    }
59 ddelon 1666
 
1667
 
16 ddelon 1668
	    $liste = new HTML_TableFragmenteur () ;
40 ddelon 1669
	    $liste->construireEntete(array (PROJET_NOM_WIKINI,PROJET_PAGE_WIKINI, PROJET_SELECTIONNER_WIKINI)) ;
59 ddelon 1670
 
16 ddelon 1671
	    $tableau_wikini = array() ;
59 ddelon 1672
 
16 ddelon 1673
	    while ($ligne = $resultat->fetchRow()) {
1674
	        $this->_url->addQueryString ('id_wikini', $ligne[0]) ;
208 neiluj 1675
	        array_push ($tableau_wikini, array ($ligne[1]."\n",    // première colonne, le nom de l'application
16 ddelon 1676
										        $ligne[2]."\n",    // Deuxieme colonne, la page par defaut
40 ddelon 1677
	        								  '<a href="'.$this->_url->getURL()."&amp;".PROJET_VARIABLE_ACTION."=".PROJET_ACTION_ASSOCIER_WIKI_V."".'">'.PROJET_CHOISIR_WIKINI.'</a>'."\n",
16 ddelon 1678
	                                            ));
1679
	    }
1680
	    $liste->construireListe($tableau_wikini) ;
1681
	    $res .= $liste->toHTML();
68 alexandre_ 1682
	    $this->_url->removeQueryString(PROJET_VARIABLE_ACTION) ;
16 ddelon 1683
	    return $res ;
59 ddelon 1684
 
1685
 
1686
 
16 ddelon 1687
    } // end of member function formulaireWiki
1688
 
2 ddelon 1689
 
40 ddelon 1690
    /**
1691
     * Associe un wiki au projet courant
1692
     *
1693
     * @return void
1694
     * @access public
1695
     */
2 ddelon 1696
 
40 ddelon 1697
	function associationWiki( )  {
59 ddelon 1698
 
1699
 
40 ddelon 1700
    	if (isset($_GET['id_wikini'])) {
1701
    		$db = &$GLOBALS['_GEN_commun']['pear_db'] ;
1702
		    $requete = "select gewi_code_alpha_wikini from gen_wikini where gewi_id_wikini = ".$_GET['id_wikini'] ;
1703
	    	$resultat = $db->query ($requete) ;
1704
	    	if (DB::isError ($resultat)) {
1705
	        	$GLOBALS['_GEN_commun']['debogage_erreur']->gererErreur(E_USER_WARNING, "Echec de la requete : $requete<br />".$resultat->getMessage(),
1706
	            	                                                            __FILE__, __LINE__, 'admin_wikini')   ;
1707
	        	return ;
1708
	    	}
59 ddelon 1709
 
40 ddelon 1710
	    	$ligne = $resultat->fetchRow();
208 neiluj 1711
	    	include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
40 ddelon 1712
			$projet = new projet($this->_db, $this->_id_projet) ;
1713
        	$projet->majNomWikini($ligne[0]);
1714
    	}
59 ddelon 1715
 
40 ddelon 1716
	}
1717
 
2 ddelon 1718
    /**
1719
     * Supprime le wiki du projet courant
1720
     *
1721
     * @return void
1722
     * @access public
1723
     */
1724
    function supprimerWiki( )
1725
    {
1726
        include_once PROJET_CHEMIN_CLASSES.'gestion_wikini.class.php' ;
1727
        // On crée une nouvelle connexion avec les paramètres spécifiques aux wikinis
1728
        $connexion_bd = DB::connect('mysql://'.PROJET_UTILISATEUR_WIKINI.':'.PROJET_MDP_WIKINI.'@'.PROJET_HOTE_WIKINI.'/'.PROJET_DB_WIKINI) ;
1729
        $gerantWiki = new gestion_wikini($connexion_bd) ;
208 neiluj 1730
        include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
2 ddelon 1731
        $projet = new projet ($this->_db, $this->_id_projet) ;
1732
        $gerantWiki->suppression_tables(strtolower($projet->getWikini())) ;
1733
        $projet->majNomWikini('') ;
1734
    } // end of member function supprimerWiki
1735
 
1736
    /**
1737
     * Permet de lier une ou plusieurs listes de la table agora à un projet.
1738
     *
1739
     * @return string
1740
     * @access public
1741
     */
1742
    function referencerListeExterne( )
1743
    {
158 alexandre_ 1744
        $requete = 'show tables like \'agora\'' ;
1745
        $resultat = $this->_db->query ($requete);
1746
        if ($resultat->numRows() == 0) {
1747
        	return 'Cette fonctionnalité n\'est pas active' ;
1748
        }
2 ddelon 1749
        $res = '<h1>'.PROJET_REFERENCER_LISTE.'</h1>' ;
1750
        include_once PROJET_CHEMIN_CLASSES.'liste_externe.class.php' ;
1751
        $liste_externe = new liste_externe($this->_db) ;
1752
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireListeExterne.class.php' ;
1753
        $this->_url->addQueryString(PROJET_VARIABLE_ID_PROJET, $this->_id_projet) ;
1754
        $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_REFERENCER_LISTE_V) ;
1755
        $HTML_formulaireListeExterne = new HTML_formulaireListeExterne('formulaire_liste_externe', 'post', str_replace('&amp;', '&', $this->_url->getURL())) ;
1756
        $HTML_formulaireListeExterne->construitFormulaire($liste_externe->getListeNom()) ;
1757
        $liste_assoc = $liste_externe->getListesAssociees($this->_id_projet) ;
1758
        $default = array() ;
1759
        foreach ($liste_assoc as $val) $default['liste_'.$val] = 1 ;
1760
 
1761
        $HTML_formulaireListeExterne->setDefaults($default) ;
1762
        return $res.$HTML_formulaireListeExterne->toHTML() ;
1763
    } // end of member function referencerListeExterne
1764
 
1765
    /**
1766
     * Réalise les mises à jours dans la table projet_lien_liste_externe
1767
     *
1768
     * @return void
1769
     * @access public
1770
     */
1771
    function referencerListeExterneValidation( )
1772
    {
1773
        include_once PROJET_CHEMIN_CLASSES.'liste_externe.class.php' ;
1774
        $liste_externe = new liste_externe($this->_db) ;
1775
        include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireListeExterne.class.php' ;
1776
        $HTML_formulaireListeExterne = new HTML_formulaireListeExterne('formulaire_liste_externe', 'post', str_replace('&amp;', '&', $this->_url->getURL())) ;
1777
        $HTML_formulaireListeExterne->construitFormulaire($liste_externe->getListeNom()) ;
59 ddelon 1778
 
2 ddelon 1779
        $liste_externe->enregistrerSQL($HTML_formulaireListeExterne->getSubmitValues(), $this->_id_projet) ;
1780
    } // end of member function referencerListeExterneValidation
1781
 
11 alexandre_ 1782
    /**
1783
     * permet d'exclure un projet de l'affichage
1784
     *
1785
     * @return void
1786
     * @access public
1787
     */
1788
    function exclure($id_projet)
1789
    {
1790
       array_push ($this->_projet_exclu, $id_projet) ;
1791
    } // end of member function exclure
2 ddelon 1792
 
54 alexandre_ 1793
    /**
1794
     * permet d'exclure un projet de l'affichage
1795
     *
1796
     * @return void
1797
     * @access public
1798
     */
1799
    function setPrive()
1800
    {
1801
       $this->_prive = 1 ;
1802
    } // end of member function exclure
2 ddelon 1803
 
11 alexandre_ 1804
 
54 alexandre_ 1805
 
2 ddelon 1806
    /**
1807
     * Renvoie un message d'erreur, en fonction du code de l'erreur.
1808
     *
1809
     * @param int valeur Le code du message d'erreur.
1810
     * @return string
1811
     * @access public
1812
     */
1813
    function messageErreur( $valeur )
1814
    {
1815
        $messageErreur = array (
1816
                    PROJETCONTROLEUR_ACTION_INVALIDE => "Action non valide",
249 alexandre_ 1817
                    PROJETCONTROLEUR_ERREUR_SUPPRESSION_REPERTOIRE => "Impossible de supprimer le r&eacute;pertoire",
1818
                    PROJETCONTROLEUR_PAS_DE_DOCUMENT_SELECTIONNE => 'Pas de fichier s&eacute;lectionn&eacute;',
1819
                    PROJETCONTROLEUR_ERREUR_CREATION_REPERTOIRE => 'Impossible de cr&eacute;er le r&eacute;pertoire'
2 ddelon 1820
        ) ;
1821
        return '<p class="erreur">'.$messageErreur[$valeur].'</p>' ;
1822
    } // end of member function messageErreur
1823
 
1824
 
1825
 
1826
 
1827
} // end of projetControleur
1828
?>