Subversion Repositories Applications.papyrus

Rev

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