Subversion Repositories Applications.projet

Rev

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

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