Subversion Repositories Applications.projet

Rev

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