Subversion Repositories Applications.projet

Rev

Rev 112 | Rev 249 | 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
// +------------------------------------------------------------------------------------------------------+
208 neiluj 22
// CVS : $Id: forums.php,v 1.11 2007-04-19 15:34:35 neiluj 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
208 neiluj 34
*@version       $Revision: 1.11 $
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' ;
33 alexandre_ 44
include_once (PROJET_CHEMIN_CLASSES.'HTML_formulaireMail.class.php') ;
45
include_once (PROJET_CHEMIN_CLASSES.'inscription_liste.class.php') ;
106 alexandre_ 46
include_once (PROJET_CHEMIN_CLASSES.'ezmlmAccessObject.class.php') ;
2 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 = '' ;
46 ddelon 57
$inscription_laius ='' ;
69 alexandre_ 58
$this->_url->addQueryString (PROJET_VARIABLE_ID_PROJET, $this->_id_projet);
2 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
 
33 alexandre_ 75
        // gestion de l'inscription désinscription à la liste
41 alexandre_ 76
        // TODO : la gestion de linscription au résumé
33 alexandre_ 77
        $inscription_liste = new inscription_liste($this->_db) ;
78
        $statut = $inscription_liste->getStatutInscrit( $info_liste->getId(),  $this->_auth ) ;
69 alexandre_ 79
        if ($this->_auth->getAuth() && isset($GLOBALS['_GEN_commun']['info_application']->seulement_forum)) {
41 alexandre_ 80
	        if ($statut == 2) {
69 alexandre_ 81
	        	$this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_DESINSCRIPTION_LISTE);
41 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 {
69 alexandre_ 85
	        	$this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_INSCRIPTION_LISTE);
41 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
	        }
33 alexandre_ 89
        }
90
 
2 ddelon 91
        if ($info_liste->isPublic() || $droits <= PROJET_DROIT_CONTRIBUTEUR) {
208 neiluj 92
            include_once PROJET_CHEMIN_CLASSES_LISTES.'ezmlm.php' ;
2 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";
39 alexandre_ 114
            $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ENVOYER_UN_MAIL);
69 alexandre_ 115
            if (isset ($GLOBALS['_GEN_commun']['info_application']->seulement_forum))
116
            		print '<a href="'.$this->_url->getURL().'">'.PROJET_ECRIRE_LISTE.'</a><br />';
2 ddelon 117
 
118
            print '<h2>'.PROJET_TOUS_LES_MESSAGES.'</h2>'."\n";
106 alexandre_ 119
            $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_VOIR_FORUM);
2 ddelon 120
 
106 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
 
2 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
                    }
106 alexandre_ 140
 
2 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
106 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();
208 neiluj 156
					$this->_url->addQueryString ('action', 'show_msg');
106 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>]';
112 alexandre_ 174
					if ($isCoord) {
175
						$this->_url->addQueryString ('action', 'supprimer');
176
						print '[<a href="'.$this->_url->getURL().'&amp;actionargs[]='.$liste->actionargs[0].
208 neiluj 177
							'&amp;actionargs[]='.$liste->actionargs[1].'" onclick="javascript:return confirm(\''.PROJET_SUPPRIMER.' ?\');">'.
178
							PROJET_SUPPRIMER.'</a>]';
112 alexandre_ 179
					}
106 alexandre_ 180
					print '<div class="message">' ;
181
                    print $message->parse_entete_mail($mailDecode) ;
182
        	        $message->parse_template($mailDecode, $liste->actionargs[1], $liste->actionargs[0]);
183
       				print $message->message_rendu;
184
       				print '</div>' ;
185
 
2 ddelon 186
                    break;
187
 
188
                case "list_info":
112 alexandre_ 189
 
190
                    print'<h2>'.PROJET_DERNIERS_MESSAGES.'</h2>'."\n" ;
191
                    $xml_parser->reset() ;
192
					$xml_parser->setAction ('derniers_messages');
193
                    $xml_parser->load();
194
                    ob_start ();
195
                    $xml_parser->parse() ;
196
                    $derniers_messages = ob_get_contents() ;
197
                    ob_end_clean();
198
                    echo $derniers_messages ;
2 ddelon 199
 
200
                    break;
201
                case "show_threads":
112 alexandre_ 202
                    $xml_parser->reset() ;
203
					$xml_parser->setAction ('messages_thread');
204
					$xml_parser->setMois($liste->actionargs[0]);
205
                    $xml_parser->load();
206
                    ob_start ();
207
                    $xml_parser->parse() ;
208
                    $messages_thread = ob_get_contents() ;
209
                    ob_end_clean();
210
                    echo $messages_thread ;
2 ddelon 211
                    break;
212
                case "show_author_msgs" :
112 alexandre_ 213
                    $xml_parser->reset() ;
214
					$xml_parser->setAction ('messages_auteur');
215
					$xml_parser->setHashAuteur($liste->actionargs[0]);
216
                    $xml_parser->load();
217
                    ob_start ();
218
                    $xml_parser->parse() ;
219
                    $messages_auteur = ob_get_contents() ;
220
                    ob_end_clean();
221
                    echo $messages_auteur ;
2 ddelon 222
                    break;
223
                case 'show_month' :
112 alexandre_ 224
                	echo '[ '.$liste->makelink(PROJET_VARIABLE_ACTION.'=forums&amp;action=show_threads&amp;actionargs[]='.
225
                			$liste->actionargs[0], 'par fil de discussion').' ]' ;
226
                    $xml_parser->reset() ;
227
					$xml_parser->setAction ('messages_mois');
228
					$xml_parser->setMois($liste->actionargs[0]);
229
                    $xml_parser->load();
230
                    ob_start ();
231
                    $xml_parser->parse() ;
232
                    $messages_mois = ob_get_contents() ;
233
                    ob_end_clean();
234
                    echo $messages_mois ;
2 ddelon 235
                break;
236
                case 'repondre' :
237
                    if (count($liste->actionargs) < 2) {
238
                        $liste->error(EZMLM_INVALID_SYNTAX,TRUE);
239
                    }
112 alexandre_ 240
                    $xml_parser->setAction ('message');
241
                    $xml_parser->setIdMessage($liste->actionargs[0], $liste->actionargs[1]) ;
242
                    $xml_parser->load();
243
                    ob_start ();
244
                    $xml_parser->parse() ;
245
                    $message = ob_get_contents() ;
246
                    ob_end_clean();
247
        			$mimeDecode = new Mail_mimeDecode($message) ;
248
        			$mailDecode = $mimeDecode->decode(array('decode_bodies' => 'true', 'include_bodies' => 'true')) ;
249
 
250
					if (isset($_SESSION['formulaire_mail'])) {
251
            			unset ($_SESSION['formulaire_mail']) ;
252
        			}
253
 
254
			        $formulaireReponse = new HTML_formulaireMail('formulaire_reponse', 'post',
255
										str_replace('&amp;', '&', $this->_url->getURL()).
256
										'&action='.PROJET_ENVOYER_UN_MAIL_V.
257
                                        '&actionargs[]='.$liste->actionargs[0].
258
										'&actionargs[]='.$liste->actionargs[1].
259
										'&'.PROJET_VARIABLE_ACTION.'='.PROJET_ENVOYER_UN_MAIL_V) ;
260
			        $formulaireReponse->construitFormulaire() ;
261
 
262
					$repondre = new ezmlm_repondre();
2 ddelon 263
                    $repondre->listdir = $liste->listdir ;
264
                    $this->_url->removeQueryString (PROJET_VARIABLE_ACTION) ;
265
                    $repondre->forcehref = $this->_url->getURL();
266
                    $repondre->listname = $info_liste->getNom() ;
267
                    // actionargs[0] contient le nom du répertoire et actionargs[1] le nom du fichier
268
                    // On appelle la fonction qui affiche un fichier
269
                    print'<h2>'.PROJET_REDIGER_REPONSE.'</h2>'."\n" ;
270
                    $repondre->repondre($liste->actionargs[0] . "/" . $liste->actionargs[1]);
112 alexandre_ 271
 
272
                    $repondre->parse_template($mailDecode, $liste->actionargs[0], $liste->actionargs[1]);
273
			        $formulaireReponse->addElement ('hidden', 'messageid', $mailDecode->headers['message-id']) ;
274
			        // Ajout de > au début de chaque ligne du message
275
			        $tableau = explode ("\n", $repondre->message_rendu) ;
276
			        $repondre->message_rendu = "> ".implode ("\n> ", $tableau) ;
277
 
278
			        $formulaireReponse->setDefaults(array('mail_corps' => $repondre->message_rendu,
279
			                                              'mail_titre' => 'Re : '.$repondre->decode_iso ($mailDecode->headers['subject']))) ;
280
 
281
			        print $formulaireReponse->toHTML() ;
282
 
2 ddelon 283
                    break;
112 alexandre_ 284
                case 'supprimer' :
285
                    $xml_parser->reset() ;
286
					$xml_parser->setAction ('supprimer');
287
					$xml_parser->setIdMessage($liste->actionargs[0], $liste->actionargs[1]) ;
288
                    $xml_parser->load();
208 neiluj 289
                    print'<h2>'.PROJET_DERNIERS_MESSAGES.'</h2>'."\n" ;
290
                    $xml_parser->reset() ;
291
					$xml_parser->setAction ('derniers_messages');
292
                    $xml_parser->load();
293
                    ob_start ();
294
                    $xml_parser->parse() ;
295
                    $derniers_messages = ob_get_contents() ;
296
                    ob_end_clean();
297
                    echo $derniers_messages ;
112 alexandre_ 298
                break;
2 ddelon 299
            }
300
 
301
        } else {
302
            print PROJET_MESSAGE_LISTE_PRIVEE ;
303
        }
304
        $sortie_liste = ob_get_contents() ;
305
        ob_end_clean() ;
306
    }
307
}
308
 
309
include_once PROJET_CHEMIN_CLASSES.'liste_externe.class.php' ;
310
$listes_ext = new liste_externe ($this->_db) ;
311
$tableau_liste = $listes_ext->getListesAssociees($this->_id_projet) ;
312
 
313
if (count ($tableau_liste) != 0) {
314
    //$liste_ext_res .= '<h2>'.PROJET_LISTES_ASSOCIEES.'</h2>'."\n" ;
315
    for ($i = 0; $i < count ($tableau_liste); $i++) {
316
        $info_liste = $listes_ext->getInfoListe($tableau_liste[$i]) ;
317
        $liste_ext_res .= '<p><a href="'.$info_liste->AGO_A_URLGRP.'">'.$info_liste->AGO_A_URLGRP.'</a></p>'."\n" ;
318
        $liste_ext_res .= '<br />'."\n" ;
319
    }
320
}
321
 
76 alexandre_ 322
$retour .= '<h1>' ;
323
if (!isset($GLOBALS['_GEN_commun']['info_application']->seulement_forum)) $retour .= PROJET_PROJET.' : ';
324
$retour .= $projet->getTitre()."</h1>" ;
33 alexandre_ 325
$retour .= $inscription_laius ;
2 ddelon 326
$retour .= '<h2>'.PROJET_ADRESSE_ECRIRE.'</h2>'."\n" ;
33 alexandre_ 327
 
2 ddelon 328
$retour .= $sortie_liste ;
329
$retour .= $liste_ext_res ;
330
?>