Subversion Repositories Applications.papyrus

Rev

Rev 1217 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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