Subversion Repositories Applications.projet

Rev

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

Rev Author Line No. Line
2 ddelon 1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
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
// +------------------------------------------------------------------------------------------------------+
294 alexandre_ 22
// CVS : $Id: forums.php,v 1.13 2008-08-25 15:02:49 alexandre_tb Exp $
2 ddelon 23
/**
24
* Application projet
25
*
26
* Action forums
27
*
28
*@package projet
29
//Auteur original :
30
*@author        Alexandre Granier <alexandre@tela-botanica.org>
31
//Autres auteurs :
32
*@author        Aucun
33
*@copyright     Tela-Botanica 2000-2005
294 alexandre_ 34
*@version       $Revision: 1.13 $
2 ddelon 35
// +------------------------------------------------------------------------------------------------------+
36
*/
37
 
38
// +------------------------------------------------------------------------------------------------------+
39
// |                                            ENTETE du PROGRAMME                                       |
40
// +------------------------------------------------------------------------------------------------------+
41
 
208 neiluj 42
include_once PROJET_CHEMIN_CLASSES.'projet.class.php' ;
43
include_once PROJET_CHEMIN_CLASSES.'participe.class.php' ;
294 alexandre_ 44
include_once PROJET_CHEMIN_CLASSES.'HTML_formulaireMail.class.php' ;
45
include_once PROJET_CHEMIN_CLASSES.'inscription_liste.class.php' ;
46
include_once PROJET_CHEMIN_CLASSES.'ezmlmAccessObject.class.php' ;
2 ddelon 47
// RAPPEL IMPORTANT
294 alexandre_ 48
// On se situe dans la methode run() de la classe projetControleur
2 ddelon 49
//
50
 
51
 
294 alexandre_ 52
// creation de l'objet projet courant
2 ddelon 53
$projet = new projet ($this->_db, $this->_id_projet) ;
54
 
294 alexandre_ 55
/* contiendra le lien vers la liste yahoo */
2 ddelon 56
$liste_ext_res = '' ;
294 alexandre_ 57
 
58
$url_page_en_cours = $this->_url->getURL();
59
 
46 ddelon 60
$inscription_laius ='' ;
294 alexandre_ 61
$bouton_poster = '';
62
$bouton_desinscription_liste = '';
63
 
64
$loggue = $this->_auth->getAuth();
65
 
66
// Un appel a papyrus pour modifier le titre de la page
67
$GLOBALS['_PAPYRUS_']['rendu']['TITRE_PAGE'] = $projet->getTitre().' - '.PROJET_FORUM;
68
 
69
include_once PROJET_CHEMIN_CLASSES.'liste_externe.class.php' ;
70
$listes_ext = new liste_externe ($this->_db) ;
71
$tableau_liste = $listes_ext->getListesAssociees($this->_id_projet) ;
72
 
73
if (count ($tableau_liste) != 0) {
74
    //$liste_ext_res .= '<h2>'.PROJET_LISTES_ASSOCIEES.'</h2>'."\n" ;
75
    for ($i = 0; $i < count ($tableau_liste); $i++) {
76
        $info_liste = $listes_ext->getInfoListe($tableau_liste[$i]) ;
77
        $liste_ext_res .= '<p><a href="'.$info_liste->AGO_A_URLGRP.'">'.$info_liste->AGO_A_URLGRP.'</a></p>'."\n" ;
78
        $liste_ext_res .= '<br />'."\n" ;
79
    }
80
    $avoir_liste_externe = true;
81
    $adresse_envoie = $info_liste->AGO_A_MAILSEND;
82
} else {
83
	$avoir_liste_externe = false;
84
}
85
 
86
 
69 alexandre_ 87
$this->_url->addQueryString (PROJET_VARIABLE_ID_PROJET, $this->_id_projet);
2 ddelon 88
if ($projet->avoirListe()) {
89
    foreach ($projet->_listes_associes as $info_liste) {
90
        ob_start() ;
91
        $id_u = $this->_auth->getAuthData(PROJET_CHAMPS_ID) ;
92
        if ($this->_auth->getAuth()) {
93
            $participant = new participe($this->_db) ;
294 alexandre_ 94
             $droits = $participant->getStatut($id_u, $this->_id_projet);
2 ddelon 95
        } else {
96
            $droits = PROJET_DROIT_AUCUN;
294 alexandre_ 97
            $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_S_INSCRIRE);
98
    		$lien_inscription = 'javascript:animatedcollapse.toggle(\'projet_bloc_inscription\');';
99
			$label_url_inscription = 'S\'inscrire &agrave; ce projet';
100
			GEN_stockerFichierScript('jquery', 'api/js/jquery/jquery.js');
101
			GEN_stockerFichierScript('animatedcollapse', 'api/js/jquery/animatedcollapse.js');
102
			GEN_stockerCodeScript('animatedcollapse.addDiv(\'projet_bloc_inscription\', \'fade=1, height="100px"\');' ."\n".
103
					'animatedcollapse.init();' ."\n");
2 ddelon 104
        }
294 alexandre_ 105
        switch ($droits) {
106
        	case PROJET_DROIT_AUCUN :
107
	        	$this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_S_INSCRIRE);
108
	    		$lien_inscription = $this->_url->getURL();
109
	    		$label_url_inscription = 'S\'inscrire &agrave; ce projet';
110
				GEN_stockerFichierScript('jquery', 'api/js/jquery/jquery.js');
111
				GEN_stockerFichierScript('animatedcollapse', 'api/js/jquery/animatedcollapse.js');
112
				GEN_stockerCodeScript('animatedcollapse.addDiv(\'projet_bloc_inscription\', \'fade=1, height="100px"\');' ."\n".
113
						'animatedcollapse.init();' ."\n");
114
	    	break;
115
        }
116
        // gestion de l'inscription desinscription a la liste
117
        // TODO : la gestion de linscription au resume
33 alexandre_ 118
        $inscription_liste = new inscription_liste($this->_db) ;
119
        $statut = $inscription_liste->getStatutInscrit( $info_liste->getId(),  $this->_auth ) ;
69 alexandre_ 120
        if ($this->_auth->getAuth() && isset($GLOBALS['_GEN_commun']['info_application']->seulement_forum)) {
41 alexandre_ 121
	        if ($statut == 2) {
69 alexandre_ 122
	        	$this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_DESINSCRIPTION_LISTE);
41 alexandre_ 123
	        	$inscription_laius ='<h2>'.PROJET_VOUS_ETES_INSCRIT.'</h2>'."\n" ;
124
	        	$inscription_laius .= '<a href="'.$this->_url->getURL().'">'.PROJET_SE_DESINSCRIRE_LISTE.'</a>'."\n" ;
125
	        } else {
69 alexandre_ 126
	        	$this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_INSCRIPTION_LISTE);
41 alexandre_ 127
	        	$inscription_laius ='<h2>'.PROJET_VOUS_N_ETES_PAS_INSCRIT.'</h2>'."\n" ;
128
	        	$inscription_laius .= '<a href="'.$this->_url->getURL().'">'.PROJET_S_INSCRIRE.'</a>'."\n" ;
129
	        }
33 alexandre_ 130
        }
294 alexandre_ 131
        if ($inscription_liste->getStatutInscrit($info_liste->getId(),  $this->_auth) == 0) {
132
	        $action_inscription = PROJET_ACTION_INSCRIPTION_LISTE ;
133
	        $label_inscription = 'S\'inscrire &agrave; la liste' ;
134
	    } else {
135
	        // L'action envoyer un mail
136
	        $action_inscription = PROJET_ENVOYER_UN_MAIL ;
137
	        $label_inscription = PROJET_ECRIRE_LISTE ;
138
	        $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_DESINSCRIPTION_LISTE);
139
	        $bouton_desinscription_liste = bouton::toHTML($this->_url->getURL(), 'Se d&eacute;sinscrire de la liste','cross');
140
	    }
33 alexandre_ 141
 
2 ddelon 142
        if ($info_liste->isPublic() || $droits <= PROJET_DROIT_CONTRIBUTEUR) {
208 neiluj 143
            include_once PROJET_CHEMIN_CLASSES_LISTES.'ezmlm.php' ;
2 ddelon 144
            $liste = new ezmlm_php() ;
294 alexandre_ 145
            // Parametrage de la liste
2 ddelon 146
 
147
            $liste->listdir = PROJET_CHEMIN_LISTES.$info_liste->getDomaine().'/'.$info_liste->getNom();
148
            $liste->listname = $info_liste->getNom() ;
149
            $liste->listdomain = $info_liste->getDomaine();
150
 
151
            if (isset ($GLOBALS['action']) && $GLOBALS['action'] != '') {
152
                $liste->set_action($GLOBALS['action']) ;
153
                $liste->set_actionargs($GLOBALS['actionargs']) ;
154
            } else {
155
                $liste->set_action('list_info') ;
156
            }
157
            $liste->sendheaders	= false;
158
            $liste->sendbody        = false;
159
            $liste->sendfooters    = false;
160
            $liste->forcehref = $this->_url->getURL() ;
161
 
294 alexandre_ 162
            if (!$avoir_liste_externe) {
163
            	$adresse_envoie = $info_liste->getAdresseEnvoi();
164
            }
165
            print '<a href="mailto:'.$adresse_envoie.'">' . $adresse_envoie ;
2 ddelon 166
            print "</a><br />\n";
294 alexandre_ 167
            $this->_url->addQueryString(PROJET_VARIABLE_ACTION, $action_inscription);
168
            $bouton_poster = bouton::toHTML($this->_url->getURL(), $label_inscription,'ecrire');
69 alexandre_ 169
            if (isset ($GLOBALS['_GEN_commun']['info_application']->seulement_forum))
170
            		print '<a href="'.$this->_url->getURL().'">'.PROJET_ECRIRE_LISTE.'</a><br />';
2 ddelon 171
 
172
            print '<h2>'.PROJET_TOUS_LES_MESSAGES.'</h2>'."\n";
106 alexandre_ 173
            $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_VOIR_FORUM);
2 ddelon 174
 
294 alexandre_ 175
            if ($liste->action != 'show_message') {
176
	            $xml_parser = &new ezmlmAccessObject('calendrier_messages', $info_liste->getDomaine(),
177
	            									$info_liste->getNom(), $GLOBALS['lang'],
178
	            									$this->_url->getURL()) ;
179
				$xml_parser->load();
180
				ob_start();
181
				$resultat = $xml_parser->parse() ;
182
				$calendrier = ob_get_contents();
183
				ob_end_clean();
184
				$xml_parser->reset();
185
            }
106 alexandre_ 186
            //$this->_url->addQueryString(PROJET_VARIABLE_ACTION, $this->_action) ;
187
 
294 alexandre_ 188
            // On teste si l'on vient d'une reponse a un email, si oui
189
            // on modifie $liste->action pour renvoyer le message auquelon vient de repondre
2 ddelon 190
            if (isset($_POST['messageid'])) {
191
                $liste->action = 'show_msg' ;
192
            }
193
            switch ($liste->action) {
194
                case "show_msg":
195
                    if (count($liste->actionargs) < 2) {
196
                        $liste->error(EZMLM_INVALID_SYNTAX,TRUE);
197
                    }
106 alexandre_ 198
 
294 alexandre_ 199
 
200
                    // actionargs[0] contient le nom du repertoire et actionargs[1] le nom du fichier
2 ddelon 201
                    // On appelle la fonction qui affiche un fichier
106 alexandre_ 202
					$xml_parser->setAction ('message');
203
                    $xml_parser->setIdMessage($liste->actionargs[0], $liste->actionargs[1]) ;
204
                    $xml_parser->load();
205
                    ob_start ();
206
                    $xml_parser->parse() ;
207
                    $mail = ob_get_contents() ;
208
                    ob_end_clean();
209
 
210
                    $mimeDecode = new Mail_mimeDecode($mail) ;
211
        			$mailDecode = $mimeDecode->decode(array('decode_bodies' => 'true',
212
												'include_bodies' => 'true')) ;
213
					$message = new ezmlm_msgdisplay() ;
214
					$message->listname = $info_liste->getNom();
294 alexandre_ 215
 
216
					$numero_message = $xml_parser->getNumeroMessage();
217
        			$total_message = $xml_parser->getNombreTotalMessage();
218
 
208 neiluj 219
					$this->_url->addQueryString ('action', 'show_msg');
294 alexandre_ 220
 
221
					ob_start();
222
					if ($xml_parser->getNumeroFichierPrecedent() != 0) {
223
			            $lien_precedent = $this->_url->getURL(). '&amp;actionargs[]='.
106 alexandre_ 224
			            		$xml_parser->getNumeroRepertoirePrecedent().'&amp;actionargs[]='.
294 alexandre_ 225
			            		$xml_parser->getNumeroFichierPrecedent();
226
			            $bouton_precedent = bouton::toHTML($lien_precedent, PROJET_PRECEDENT, 'gauche', 'projet_bouton_inline');
227
			            $navigation = $bouton_precedent;
106 alexandre_ 228
			        }
294 alexandre_ 229
 
230
			        if ($xml_parser->getNumeroFichierSuivant() != '' && (int) $numero_message < (int) $total_message) {
231
			            $lien_suivant = $this->_url->getURL(). '&amp;actionargs[]='.
232
			            		$xml_parser->getNumeroRepertoireSuivant().'&amp;actionargs[]='.
233
			            		$xml_parser->getNumeroFichierSuivant();
234
			            $bouton_suivant = bouton::toHTML($lien_suivant ,PROJET_SUIVANT, 'droite', 'projet_bouton_inline');
235
			            $navigation .= $bouton_suivant;
236
			        }
106 alexandre_ 237
        			$this->_url->addQueryString ('action', 'repondre');
294 alexandre_ 238
        			$bouton_repondre = bouton::toHTML($this->_url->getURL().'&amp;actionargs[]='.$liste->actionargs[0].
239
							'&amp;actionargs[]='.$liste->actionargs[1], PROJET_REPONDRE, 'repondre', 'projet_bouton_inline');
240
        			$this->_url->removeQueryString('action');
241
        			/*
242
						Un bouton pour revenir a la liste des messages
243
					*/
244
 
245
					$navigation .= bouton::toHTML($this->_url->getURL() ,'retour', 'haut', 'projet_bouton_inline');
246
					if (!$avoir_liste_externe && $droits <= PROJET_DROIT_CONTRIBUTEUR) $navigation .= $bouton_repondre;
247
					if ($droits == PROJET_DROIT_COORDINATEUR || $droits == PROJET_DROIT_ADMINISTRATEUR) {
112 alexandre_ 248
						$this->_url->addQueryString ('action', 'supprimer');
294 alexandre_ 249
 
250
						$bouton_suppression_message = bouton::toHTML($this->_url->getURL().'&amp;actionargs[]='.$liste->actionargs[0].
251
							'&amp;actionargs[]='.$liste->actionargs[1], 'Supprimer', 'cross', 'projet_bouton_inline');
252
						$navigation .= $bouton_suppression_message;
112 alexandre_ 253
					}
294 alexandre_ 254
					$this->_url->removeQueryString ('action');
106 alexandre_ 255
					print '<div class="message">' ;
256
                    print $message->parse_entete_mail($mailDecode) ;
257
        	        $message->parse_template($mailDecode, $liste->actionargs[1], $liste->actionargs[0]);
258
       				print $message->message_rendu;
259
       				print '</div>' ;
294 alexandre_ 260
       				$message = ob_get_contents();
261
       				ob_end_clean();
106 alexandre_ 262
 
2 ddelon 263
                    break;
264
 
265
                case "list_info":
112 alexandre_ 266
                    $xml_parser->reset() ;
267
					$xml_parser->setAction ('derniers_messages');
268
                    $xml_parser->load();
269
                    ob_start ();
270
                    $xml_parser->parse() ;
271
                    $derniers_messages = ob_get_contents() ;
272
                    ob_end_clean();
294 alexandre_ 273
 
2 ddelon 274
 
275
                    break;
276
                case "show_threads":
112 alexandre_ 277
                    $xml_parser->reset() ;
278
					$xml_parser->setAction ('messages_thread');
279
					$xml_parser->setMois($liste->actionargs[0]);
280
                    $xml_parser->load();
281
                    ob_start ();
282
                    $xml_parser->parse() ;
283
                    $messages_thread = ob_get_contents() ;
284
                    ob_end_clean();
294 alexandre_ 285
                    $message = $messages_thread ;
2 ddelon 286
                    break;
287
                case "show_author_msgs" :
112 alexandre_ 288
                    $xml_parser->reset() ;
289
					$xml_parser->setAction ('messages_auteur');
290
					$xml_parser->setHashAuteur($liste->actionargs[0]);
291
                    $xml_parser->load();
292
                    ob_start ();
293
                    $xml_parser->parse() ;
294
                    $messages_auteur = ob_get_contents() ;
295
                    ob_end_clean();
294 alexandre_ 296
                    $message = $messages_auteur ;
2 ddelon 297
                    break;
298
                case 'show_month' :
294 alexandre_ 299
                	$this->_url->addQueryString(PROJET_VARIABLE_ACTION, 'forums');
300
                	$this->_url->addQueryString('action', 'show_threads');
301
                	$this->_url->addQueryString('actionargs[]', $liste->actionargs[0]);
302
                	$message = '[<a href="'.$this->_url->getURL().'">par fil de discussion</a>]';
303
 
112 alexandre_ 304
                    $xml_parser->reset() ;
305
					$xml_parser->setAction ('messages_mois');
306
					$xml_parser->setMois($liste->actionargs[0]);
307
                    $xml_parser->load();
308
                    ob_start ();
309
                    $xml_parser->parse() ;
310
                    $messages_mois = ob_get_contents() ;
311
                    ob_end_clean();
294 alexandre_ 312
                    $message .= $messages_mois ;
2 ddelon 313
                break;
314
                case 'repondre' :
315
                    if (count($liste->actionargs) < 2) {
316
                        $liste->error(EZMLM_INVALID_SYNTAX,TRUE);
317
                    }
112 alexandre_ 318
                    $xml_parser->setAction ('message');
319
                    $xml_parser->setIdMessage($liste->actionargs[0], $liste->actionargs[1]) ;
320
                    $xml_parser->load();
321
                    ob_start ();
322
                    $xml_parser->parse() ;
323
                    $message = ob_get_contents() ;
324
                    ob_end_clean();
325
        			$mimeDecode = new Mail_mimeDecode($message) ;
326
        			$mailDecode = $mimeDecode->decode(array('decode_bodies' => 'true', 'include_bodies' => 'true')) ;
327
 
328
					if (isset($_SESSION['formulaire_mail'])) {
329
            			unset ($_SESSION['formulaire_mail']) ;
330
        			}
331
 
332
			        $formulaireReponse = new HTML_formulaireMail('formulaire_reponse', 'post',
333
										str_replace('&amp;', '&', $this->_url->getURL()).
334
										'&action='.PROJET_ENVOYER_UN_MAIL_V.
335
                                        '&actionargs[]='.$liste->actionargs[0].
336
										'&actionargs[]='.$liste->actionargs[1].
337
										'&'.PROJET_VARIABLE_ACTION.'='.PROJET_ENVOYER_UN_MAIL_V) ;
338
			        $formulaireReponse->construitFormulaire() ;
339
 
340
					$repondre = new ezmlm_repondre();
2 ddelon 341
                    $repondre->listdir = $liste->listdir ;
342
                    $this->_url->removeQueryString (PROJET_VARIABLE_ACTION) ;
343
                    $repondre->forcehref = $this->_url->getURL();
344
                    $repondre->listname = $info_liste->getNom() ;
345
                    // actionargs[0] contient le nom du répertoire et actionargs[1] le nom du fichier
346
                    // On appelle la fonction qui affiche un fichier
294 alexandre_ 347
                    $message = '<h2>'.PROJET_REDIGER_REPONSE.'</h2>'."\n" ;
2 ddelon 348
                    $repondre->repondre($liste->actionargs[0] . "/" . $liste->actionargs[1]);
112 alexandre_ 349
 
350
                    $repondre->parse_template($mailDecode, $liste->actionargs[0], $liste->actionargs[1]);
351
			        $formulaireReponse->addElement ('hidden', 'messageid', $mailDecode->headers['message-id']) ;
352
			        // Ajout de > au début de chaque ligne du message
353
			        $tableau = explode ("\n", $repondre->message_rendu) ;
354
			        $repondre->message_rendu = "> ".implode ("\n> ", $tableau) ;
355
 
356
			        $formulaireReponse->setDefaults(array('mail_corps' => $repondre->message_rendu,
357
			                                              'mail_titre' => 'Re : '.$repondre->decode_iso ($mailDecode->headers['subject']))) ;
358
 
294 alexandre_ 359
			        $message .= $formulaireReponse->toHTML() ;
112 alexandre_ 360
 
2 ddelon 361
                    break;
112 alexandre_ 362
                case 'supprimer' :
363
                    $xml_parser->reset() ;
364
					$xml_parser->setAction ('supprimer');
365
					$xml_parser->setIdMessage($liste->actionargs[0], $liste->actionargs[1]) ;
366
                    $xml_parser->load();
294 alexandre_ 367
                    $message = '<h2>'.PROJET_DERNIERS_MESSAGES.'</h2>'."\n" ;
208 neiluj 368
                    $xml_parser->reset() ;
369
					$xml_parser->setAction ('derniers_messages');
370
                    $xml_parser->load();
371
                    ob_start ();
372
                    $xml_parser->parse() ;
294 alexandre_ 373
                    $message .= ob_get_contents() ;
208 neiluj 374
                    ob_end_clean();
294 alexandre_ 375
 
112 alexandre_ 376
                break;
2 ddelon 377
            }
378
 
379
        } else {
294 alexandre_ 380
            $message = PROJET_MESSAGE_LISTE_PRIVEE ;
2 ddelon 381
        }
382
        ob_end_clean() ;
383
    }
384
}
385
 
386
 
294 alexandre_ 387
if ($liste->action == 'show_msg') $squelette = 'message'; else $squelette = 'forum';
388
ob_start();
389
include_once PROJET_CHEMIN_APPLI.'/squelettes/'.$squelette.'.tpl.html';
390
$retour .= ob_get_contents();
391
ob_end_clean();
2 ddelon 392
 
33 alexandre_ 393
 
294 alexandre_ 394
$this->_url->removeQueryString ('actionargs');
395
$this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_VOIR_FORUM);
396
/* +--Fin du code ----------------------------------------------------------------------------------------+
397
*
398
* $Log: not supported by cvs2svn $
399
*
400
* +-- Fin du code ----------------------------------------------------------------------------------------+
401
*/
2 ddelon 402
?>