Subversion Repositories Applications.projet

Rev

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