Subversion Repositories Applications.papyrus

Rev

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

Rev Author Line No. Line
448 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
// +------------------------------------------------------------------------------------------------------+
1259 alexandre_ 22
// CVS : $Id: forums.php,v 1.10.2.1 2007-03-13 11:07:33 alexandre_tb Exp $
448 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
1259 alexandre_ 34
*@version       $Revision: 1.10.2.1 $
448 ddelon 35
// +------------------------------------------------------------------------------------------------------+
36
*/
37
 
38
// +------------------------------------------------------------------------------------------------------+
39
// |                                            ENTETE du PROGRAMME                                       |
40
// +------------------------------------------------------------------------------------------------------+
41
 
518 alexandre_ 42
include_once (PROJET_CHEMIN_CLASSES.'HTML_formulaireMail.class.php') ;
43
include_once (PROJET_CHEMIN_CLASSES.'inscription_liste.class.php') ;
821 alexandre_ 44
include_once (PROJET_CHEMIN_CLASSES.'ezmlmAccessObject.class.php') ;
448 ddelon 45
// RAPPEL IMPORTANT
46
// On se situe dans la méthode run() de la classe projetControleur
47
//
48
 
49
 
50
// création de l'objet projet courant
51
$projet = new projet ($this->_db, $this->_id_projet) ;
52
 
53
$liste_ext_res = '' ;
54
$sortie_liste = '' ;
556 ddelon 55
$inscription_laius ='' ;
617 alexandre_ 56
$this->_url->addQueryString (PROJET_VARIABLE_ID_PROJET, $this->_id_projet);
448 ddelon 57
if ($projet->avoirListe()) {
58
    foreach ($projet->_listes_associes as $info_liste) {
59
        ob_start() ;
60
        $id_u = $this->_auth->getAuthData(PROJET_CHAMPS_ID) ;
61
        if ($this->_auth->getAuth()) {
62
            $participant = new participe($this->_db) ;
63
 
64
            $isCoord = $participant->isCoordinateur($id_u, $this->_id_projet, $this->_db) ;
65
            if ($isCoord) $droits = PROJET_DROIT_COORDINATEUR ;
66
            $isAdm = participe::isAdministrateur($this->_auth->getAuthData(PROJET_CHAMPS_ID), $this->_db) ;
67
            if ($isAdm) $droits = PROJET_DROIT_ADMINISTRATEUR ;
68
            if ($isAdm) $isCoord = true ;
69
        } else {
70
            $droits = PROJET_DROIT_AUCUN;
71
        }
72
 
518 alexandre_ 73
        // gestion de l'inscription désinscription à la liste
548 alexandre_ 74
        // TODO : la gestion de linscription au résumé
518 alexandre_ 75
        $inscription_liste = new inscription_liste($this->_db) ;
76
        $statut = $inscription_liste->getStatutInscrit( $info_liste->getId(),  $this->_auth ) ;
617 alexandre_ 77
        if ($this->_auth->getAuth() && isset($GLOBALS['_GEN_commun']['info_application']->seulement_forum)) {
548 alexandre_ 78
	        if ($statut == 2) {
617 alexandre_ 79
	        	$this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_DESINSCRIPTION_LISTE);
548 alexandre_ 80
	        	$inscription_laius ='<h2>'.PROJET_VOUS_ETES_INSCRIT.'</h2>'."\n" ;
81
	        	$inscription_laius .= '<a href="'.$this->_url->getURL().'">'.PROJET_SE_DESINSCRIRE_LISTE.'</a>'."\n" ;
82
	        } else {
617 alexandre_ 83
	        	$this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_INSCRIPTION_LISTE);
548 alexandre_ 84
	        	$inscription_laius ='<h2>'.PROJET_VOUS_N_ETES_PAS_INSCRIT.'</h2>'."\n" ;
85
	        	$inscription_laius .= '<a href="'.$this->_url->getURL().'">'.PROJET_S_INSCRIRE.'</a>'."\n" ;
86
	        }
518 alexandre_ 87
        }
88
 
448 ddelon 89
        if ($info_liste->isPublic() || $droits <= PROJET_DROIT_CONTRIBUTEUR) {
90
            $liste = new ezmlm_php() ;
91
            // Paramétrage de la liste
92
 
93
            $liste->listdir = PROJET_CHEMIN_LISTES.$info_liste->getDomaine().'/'.$info_liste->getNom();
94
            $liste->listname = $info_liste->getNom() ;
95
            $liste->listdomain = $info_liste->getDomaine();
96
 
97
            if (isset ($GLOBALS['action']) && $GLOBALS['action'] != '') {
98
                $liste->set_action($GLOBALS['action']) ;
99
                $liste->set_actionargs($GLOBALS['actionargs']) ;
100
            } else {
101
                $liste->set_action('list_info') ;
102
            }
103
            $liste->sendheaders	= false;
104
            $liste->sendbody        = false;
105
            $liste->sendfooters    = false;
106
            $liste->forcehref = $this->_url->getURL() ;
107
 
108
 
109
            print '<a href="mailto:'.$info_liste->getAdresseEnvoi().'">' . $info_liste->getAdresseEnvoi() ;
110
            print "</a><br />\n";
539 alexandre_ 111
            $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ENVOYER_UN_MAIL);
617 alexandre_ 112
            if (isset ($GLOBALS['_GEN_commun']['info_application']->seulement_forum))
113
            		print '<a href="'.$this->_url->getURL().'">'.PROJET_ECRIRE_LISTE.'</a><br />';
448 ddelon 114
 
115
            print '<h2>'.PROJET_TOUS_LES_MESSAGES.'</h2>'."\n";
821 alexandre_ 116
            $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_VOIR_FORUM);
448 ddelon 117
 
821 alexandre_ 118
            $xml_parser = &new ezmlmAccessObject('calendrier_messages', $info_liste->getDomaine(),
119
            									$info_liste->getNom(), $GLOBALS['lang'],
120
            									$this->_url->getURL()) ;
121
			$xml_parser->load();
122
			$resultat = $xml_parser->parse() ;
123
			$xml_parser->reset();
124
 
125
            //$this->_url->addQueryString(PROJET_VARIABLE_ACTION, $this->_action) ;
126
 
448 ddelon 127
            // On teste si l'on vient d'une réponse à un email, si oui
128
            // on modifie $liste->action pour renvoyer le message auquelon vient de répondre
129
            if (isset($_POST['messageid'])) {
130
                $liste->action = 'show_msg' ;
131
            }
132
            switch ($liste->action) {
133
                case "show_msg":
134
                    if (count($liste->actionargs) < 2) {
135
                        $liste->error(EZMLM_INVALID_SYNTAX,TRUE);
136
                    }
821 alexandre_ 137
 
448 ddelon 138
                    // actionargs[0] contient le nom du répertoire et actionargs[1] le nom du fichier
139
                    // On appelle la fonction qui affiche un fichier
821 alexandre_ 140
					$xml_parser->setAction ('message');
141
                    $xml_parser->setIdMessage($liste->actionargs[0], $liste->actionargs[1]) ;
142
                    $xml_parser->load();
143
                    ob_start ();
144
                    $xml_parser->parse() ;
145
                    $mail = ob_get_contents() ;
146
                    ob_end_clean();
147
 
148
                    $mimeDecode = new Mail_mimeDecode($mail) ;
149
        			$mailDecode = $mimeDecode->decode(array('decode_bodies' => 'true',
150
												'include_bodies' => 'true')) ;
151
					$message = new ezmlm_msgdisplay() ;
152
					$message->listname = $info_liste->getNom();
1259 alexandre_ 153
					$this->_url->addQueryString ('action', 'show_msg');
821 alexandre_ 154
					if ($xml_parser->getNumeroFichierPrecedent() != '') {
155
			            print '[<a href="' . $this->_url->getURL(). '&amp;actionargs[]='.
156
			            		$xml_parser->getNumeroRepertoirePrecedent().'&amp;actionargs[]='.
157
			            		$xml_parser->getNumeroFichierPrecedent().
158
								'">'.PROJET_PRECEDENT.'</a>]';
159
			        } else {
160
			            print '['.PROJET_PRECEDENT.']' ;
161
			        }
162
			        if ($xml_parser->getNumeroFichierSuivant() != '') {
163
			            print '[<a href="' .$this->_url->getURL().'&amp;actionargs[]='.$xml_parser->getNumeroRepertoireSuivant()
164
			            		.'&amp;actionargs[]='.$xml_parser->getNumeroFichierSuivant().'">'.PROJET_SUIVANT. '</a>]';
165
			        } else {
166
			            print '['.PROJET_SUIVANT.']' ;
167
        			}
168
        			$this->_url->addQueryString ('action', 'repondre');
169
					print '[<a href="'.$this->_url->getURL().'&amp;actionargs[]='.$liste->actionargs[0].
170
							'&amp;actionargs[]='.$liste->actionargs[1].'">'.PROJET_REPONDRE.'</a>]';
863 alexandre_ 171
					if ($isCoord) {
172
						$this->_url->addQueryString ('action', 'supprimer');
173
						print '[<a href="'.$this->_url->getURL().'&amp;actionargs[]='.$liste->actionargs[0].
1259 alexandre_ 174
							'&amp;actionargs[]='.$liste->actionargs[1].'" onclick="javascript:return confirm(\''.PROJET_SUPPRIMER.' ?\');">'.
175
							PROJET_SUPPRIMER.'</a>]';
863 alexandre_ 176
					}
821 alexandre_ 177
					print '<div class="message">' ;
178
                    print $message->parse_entete_mail($mailDecode) ;
1259 alexandre_ 179
                    //var_dump($mailDecode);
821 alexandre_ 180
        	        $message->parse_template($mailDecode, $liste->actionargs[1], $liste->actionargs[0]);
181
       				print $message->message_rendu;
182
       				print '</div>' ;
183
 
448 ddelon 184
                    break;
185
 
186
                case "list_info":
863 alexandre_ 187
 
188
                    print'<h2>'.PROJET_DERNIERS_MESSAGES.'</h2>'."\n" ;
189
                    $xml_parser->reset() ;
190
					$xml_parser->setAction ('derniers_messages');
191
                    $xml_parser->load();
192
                    ob_start ();
193
                    $xml_parser->parse() ;
194
                    $derniers_messages = ob_get_contents() ;
195
                    ob_end_clean();
196
                    echo $derniers_messages ;
448 ddelon 197
 
198
                    break;
199
                case "show_threads":
863 alexandre_ 200
                    $xml_parser->reset() ;
201
					$xml_parser->setAction ('messages_thread');
202
					$xml_parser->setMois($liste->actionargs[0]);
203
                    $xml_parser->load();
204
                    ob_start ();
205
                    $xml_parser->parse() ;
206
                    $messages_thread = ob_get_contents() ;
207
                    ob_end_clean();
208
                    echo $messages_thread ;
448 ddelon 209
                    break;
210
                case "show_author_msgs" :
863 alexandre_ 211
                    $xml_parser->reset() ;
212
					$xml_parser->setAction ('messages_auteur');
213
					$xml_parser->setHashAuteur($liste->actionargs[0]);
214
                    $xml_parser->load();
215
                    ob_start ();
216
                    $xml_parser->parse() ;
217
                    $messages_auteur = ob_get_contents() ;
218
                    ob_end_clean();
219
                    echo $messages_auteur ;
448 ddelon 220
                    break;
221
                case 'show_month' :
863 alexandre_ 222
                	echo '[ '.$liste->makelink(PROJET_VARIABLE_ACTION.'=forums&amp;action=show_threads&amp;actionargs[]='.
223
                			$liste->actionargs[0], 'par fil de discussion').' ]' ;
224
                    $xml_parser->reset() ;
225
					$xml_parser->setAction ('messages_mois');
226
					$xml_parser->setMois($liste->actionargs[0]);
227
                    $xml_parser->load();
228
                    ob_start ();
229
                    $xml_parser->parse() ;
230
                    $messages_mois = ob_get_contents() ;
231
                    ob_end_clean();
232
                    echo $messages_mois ;
448 ddelon 233
                break;
234
                case 'repondre' :
235
                    if (count($liste->actionargs) < 2) {
236
                        $liste->error(EZMLM_INVALID_SYNTAX,TRUE);
237
                    }
863 alexandre_ 238
                    $xml_parser->setAction ('message');
239
                    $xml_parser->setIdMessage($liste->actionargs[0], $liste->actionargs[1]) ;
240
                    $xml_parser->load();
241
                    ob_start ();
242
                    $xml_parser->parse() ;
243
                    $message = ob_get_contents() ;
244
                    ob_end_clean();
245
        			$mimeDecode = new Mail_mimeDecode($message) ;
246
        			$mailDecode = $mimeDecode->decode(array('decode_bodies' => 'true', 'include_bodies' => 'true')) ;
247
 
248
					if (isset($_SESSION['formulaire_mail'])) {
249
            			unset ($_SESSION['formulaire_mail']) ;
250
        			}
251
 
252
			        $formulaireReponse = new HTML_formulaireMail('formulaire_reponse', 'post',
253
										str_replace('&amp;', '&', $this->_url->getURL()).
254
										'&action='.PROJET_ENVOYER_UN_MAIL_V.
255
                                        '&actionargs[]='.$liste->actionargs[0].
256
										'&actionargs[]='.$liste->actionargs[1].
257
										'&'.PROJET_VARIABLE_ACTION.'='.PROJET_ENVOYER_UN_MAIL_V) ;
258
			        $formulaireReponse->construitFormulaire() ;
259
 
260
					$repondre = new ezmlm_repondre();
448 ddelon 261
                    $repondre->listdir = $liste->listdir ;
262
                    $this->_url->removeQueryString (PROJET_VARIABLE_ACTION) ;
263
                    $repondre->forcehref = $this->_url->getURL();
264
                    $repondre->listname = $info_liste->getNom() ;
265
                    // actionargs[0] contient le nom du répertoire et actionargs[1] le nom du fichier
266
                    // On appelle la fonction qui affiche un fichier
267
                    print'<h2>'.PROJET_REDIGER_REPONSE.'</h2>'."\n" ;
268
                    $repondre->repondre($liste->actionargs[0] . "/" . $liste->actionargs[1]);
863 alexandre_ 269
 
270
                    $repondre->parse_template($mailDecode, $liste->actionargs[0], $liste->actionargs[1]);
271
			        $formulaireReponse->addElement ('hidden', 'messageid', $mailDecode->headers['message-id']) ;
272
			        // Ajout de > au début de chaque ligne du message
273
			        $tableau = explode ("\n", $repondre->message_rendu) ;
274
			        $repondre->message_rendu = "> ".implode ("\n> ", $tableau) ;
275
 
276
			        $formulaireReponse->setDefaults(array('mail_corps' => $repondre->message_rendu,
277
			                                              'mail_titre' => 'Re : '.$repondre->decode_iso ($mailDecode->headers['subject']))) ;
278
 
279
			        print $formulaireReponse->toHTML() ;
280
 
448 ddelon 281
                    break;
863 alexandre_ 282
                case 'supprimer' :
283
                    $xml_parser->reset() ;
284
					$xml_parser->setAction ('supprimer');
285
					$xml_parser->setIdMessage($liste->actionargs[0], $liste->actionargs[1]) ;
286
                    $xml_parser->load();
1259 alexandre_ 287
                    print'<h2>'.PROJET_DERNIERS_MESSAGES.'</h2>'."\n" ;
288
                    $xml_parser->reset() ;
289
					$xml_parser->setAction ('derniers_messages');
290
                    $xml_parser->load();
291
                    ob_start ();
292
                    $xml_parser->parse() ;
293
                    $derniers_messages = ob_get_contents() ;
294
                    ob_end_clean();
295
                    echo $derniers_messages ;
863 alexandre_ 296
                break;
448 ddelon 297
            }
298
 
299
        } else {
300
            print PROJET_MESSAGE_LISTE_PRIVEE ;
301
        }
302
        $sortie_liste = ob_get_contents() ;
303
        ob_end_clean() ;
304
    }
305
}
306
 
307
include_once PROJET_CHEMIN_CLASSES.'liste_externe.class.php' ;
308
$listes_ext = new liste_externe ($this->_db) ;
309
$tableau_liste = $listes_ext->getListesAssociees($this->_id_projet) ;
310
 
311
if (count ($tableau_liste) != 0) {
312
    //$liste_ext_res .= '<h2>'.PROJET_LISTES_ASSOCIEES.'</h2>'."\n" ;
313
    for ($i = 0; $i < count ($tableau_liste); $i++) {
314
        $info_liste = $listes_ext->getInfoListe($tableau_liste[$i]) ;
315
        $liste_ext_res .= '<p><a href="'.$info_liste->AGO_A_URLGRP.'">'.$info_liste->AGO_A_URLGRP.'</a></p>'."\n" ;
316
        $liste_ext_res .= '<br />'."\n" ;
317
    }
318
}
319
 
624 alexandre_ 320
$retour .= '<h1>' ;
321
if (!isset($GLOBALS['_GEN_commun']['info_application']->seulement_forum)) $retour .= PROJET_PROJET.' : ';
322
$retour .= $projet->getTitre()."</h1>" ;
518 alexandre_ 323
$retour .= $inscription_laius ;
448 ddelon 324
$retour .= '<h2>'.PROJET_ADRESSE_ECRIRE.'</h2>'."\n" ;
518 alexandre_ 325
 
448 ddelon 326
$retour .= $sortie_liste ;
327
$retour .= $liste_ext_res ;
328
?>