Subversion Repositories Applications.projet

Rev

Rev 76 | Rev 112 | 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
// +------------------------------------------------------------------------------------------------------+
106 alexandre_ 22
// CVS : $Id: forums.php,v 1.9 2006-04-19 13:49:31 alexandre_tb 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
106 alexandre_ 34
*@version       $Revision: 1.9 $
2 ddelon 35
// +------------------------------------------------------------------------------------------------------+
36
*/
37
 
38
// +------------------------------------------------------------------------------------------------------+
39
// |                                            ENTETE du PROGRAMME                                       |
40
// +------------------------------------------------------------------------------------------------------+
41
 
33 alexandre_ 42
include_once (PROJET_CHEMIN_CLASSES.'HTML_formulaireMail.class.php') ;
43
include_once (PROJET_CHEMIN_CLASSES.'inscription_liste.class.php') ;
106 alexandre_ 44
include_once (PROJET_CHEMIN_CLASSES.'ezmlmAccessObject.class.php') ;
2 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 = '' ;
46 ddelon 55
$inscription_laius ='' ;
69 alexandre_ 56
$this->_url->addQueryString (PROJET_VARIABLE_ID_PROJET, $this->_id_projet);
2 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
 
33 alexandre_ 73
        // gestion de l'inscription désinscription à la liste
41 alexandre_ 74
        // TODO : la gestion de linscription au résumé
33 alexandre_ 75
        $inscription_liste = new inscription_liste($this->_db) ;
76
        $statut = $inscription_liste->getStatutInscrit( $info_liste->getId(),  $this->_auth ) ;
69 alexandre_ 77
        if ($this->_auth->getAuth() && isset($GLOBALS['_GEN_commun']['info_application']->seulement_forum)) {
41 alexandre_ 78
	        if ($statut == 2) {
69 alexandre_ 79
	        	$this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_DESINSCRIPTION_LISTE);
41 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 {
69 alexandre_ 83
	        	$this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_INSCRIPTION_LISTE);
41 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
	        }
33 alexandre_ 87
        }
88
 
2 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";
39 alexandre_ 111
            $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ENVOYER_UN_MAIL);
69 alexandre_ 112
            if (isset ($GLOBALS['_GEN_commun']['info_application']->seulement_forum))
113
            		print '<a href="'.$this->_url->getURL().'">'.PROJET_ECRIRE_LISTE.'</a><br />';
2 ddelon 114
 
115
            print '<h2>'.PROJET_TOUS_LES_MESSAGES.'</h2>'."\n";
106 alexandre_ 116
            $this->_url->addQueryString(PROJET_VARIABLE_ACTION, PROJET_ACTION_VOIR_FORUM);
2 ddelon 117
 
106 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
 
2 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
                    }
106 alexandre_ 137
 
2 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
106 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();
153
					if ($xml_parser->getNumeroFichierPrecedent() != '') {
154
						$this->_url->addQueryString ('action', 'show_msg');
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>]';
171
 
172
					print '<div class="message">' ;
173
                    print $message->parse_entete_mail($mailDecode) ;
174
        	        $message->parse_template($mailDecode, $liste->actionargs[1], $liste->actionargs[0]);
175
       				print $message->message_rendu;
176
       				print '</div>' ;
177
 
2 ddelon 178
                    break;
179
 
180
                case "list_info":
181
                    $info = new ezmlm_listinfo();
182
 
183
                    if (!$info) print 'Les fichiers de la liste ne sont pas visible sur le serveur' ;
184
                    $info->forcehref = $this->_url->getURL();
185
                    $info->listdir = $liste->listdir ;
186
                    $info->listname = $info_liste->getNom();
187
                    $info->listdomain = $info_liste->getDomaine() ;
188
                    print'<h2>'.PROJET_DERNIERS_MESSAGES.'</h2>'."\n" ;
189
                    if (!$info->show_recentmsgs()) {
190
                        echo 'Pas de message dans cette liste' ;
191
                    }
192
                    break;
193
                case "show_threads":
194
                    $threads = new ezmlm_threads();
195
                    $this->_url->addQueryString(PROJET_VARIABLE_ACTION, $this->_action) ;
196
                    $threads->forcehref = $this->_url->getURL() ;
197
                    $threads->listdir = $liste->listdir ;
198
                    $threads->listname = $info_liste->getNom() ;
199
                    $threads->listdomain = $info_liste->getDomaine() ;
200
                    $threads->tempdir = PROJET_CHEMIN_APPLI.'/tmp' ;
201
                    $threads->load($liste->actionargs[0]);
202
                    break;
203
                case "show_author_msgs" :
204
                    $author = new ezmlm_author();
205
                    $author->listdir = $liste->listdir ;
206
                    $author->listname = $info_liste->getNom() ;
207
                    $author->listdomain = $info_liste->getDomaine() ;
208
                    $author->forcehref = $this->_url->getURL() ;
209
                    $author->display($liste->actionargs[0]);
210
                    break;
211
                case 'show_month' :
212
                    $info = new ezmlm_listinfo();
213
                    if (!$info) return 'Les fichiers de la liste ne sont pas visible sur le serveur' ;
214
                    $info->forcehref = $this->_url->getURL();
215
                    $info->listdir = $liste->listdir ;
216
                    $info->listname = $info_liste->getNom();
217
                    $info->listdomain = $info_liste->getDomaine() ;
218
                    echo '[ '.$info->makelink('action=show_threads&amp;actionargs[]='.$liste->actionargs[0], 'par fil de discussion').' ]' ;
46 ddelon 219
               //     print'<h2>'.PROJET_MESSAGE_DU_MOIS.$GLOBALS['mois'][((int)substr($liste->actionargs[0],4,2) / 1)-1] .', ' .
2 ddelon 220
                                                                substr($liste->actionargs[0],0,4). '</h2>'."\n" ;
221
                    if (!$info->show_month($liste->actionargs[0])) {
222
                        echo 'Pas de message dans cette liste' ;
223
                    }
224
                break;
225
                case 'repondre' :
226
                    if (count($liste->actionargs) < 2) {
227
                        $liste->error(EZMLM_INVALID_SYNTAX,TRUE);
228
                    }
229
                    $repondre = new ezmlm_repondre();
230
                    $repondre->listdir = $liste->listdir ;
231
                    $this->_url->removeQueryString (PROJET_VARIABLE_ACTION) ;
232
                    $repondre->forcehref = $this->_url->getURL();
233
                    $repondre->listname = $info_liste->getNom() ;
234
                    // actionargs[0] contient le nom du répertoire et actionargs[1] le nom du fichier
235
                    // On appelle la fonction qui affiche un fichier
236
                    print'<h2>'.PROJET_REDIGER_REPONSE.'</h2>'."\n" ;
237
                    $repondre->repondre($liste->actionargs[0] . "/" . $liste->actionargs[1]);
238
                    break;
239
            }
240
 
241
        } else {
242
            print PROJET_MESSAGE_LISTE_PRIVEE ;
243
        }
244
        $sortie_liste = ob_get_contents() ;
245
        ob_end_clean() ;
246
    }
247
}
248
 
249
include_once PROJET_CHEMIN_CLASSES.'liste_externe.class.php' ;
250
$listes_ext = new liste_externe ($this->_db) ;
251
$tableau_liste = $listes_ext->getListesAssociees($this->_id_projet) ;
252
 
253
if (count ($tableau_liste) != 0) {
254
    //$liste_ext_res .= '<h2>'.PROJET_LISTES_ASSOCIEES.'</h2>'."\n" ;
255
    for ($i = 0; $i < count ($tableau_liste); $i++) {
256
        $info_liste = $listes_ext->getInfoListe($tableau_liste[$i]) ;
257
        $liste_ext_res .= '<p><a href="'.$info_liste->AGO_A_URLGRP.'">'.$info_liste->AGO_A_URLGRP.'</a></p>'."\n" ;
258
        $liste_ext_res .= '<br />'."\n" ;
259
    }
260
}
261
 
76 alexandre_ 262
$retour .= '<h1>' ;
263
if (!isset($GLOBALS['_GEN_commun']['info_application']->seulement_forum)) $retour .= PROJET_PROJET.' : ';
264
$retour .= $projet->getTitre()."</h1>" ;
33 alexandre_ 265
$retour .= $inscription_laius ;
2 ddelon 266
$retour .= '<h2>'.PROJET_ADRESSE_ECRIRE.'</h2>'."\n" ;
33 alexandre_ 267
 
2 ddelon 268
$retour .= $sortie_liste ;
269
$retour .= $liste_ext_res ;
270
?>