Subversion Repositories Applications.papyrus

Rev

Rev 1087 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1087 Rev 1229
Line 1... Line 1...
1
<?php
1
<?php
2
// $Id: ezmlm-msgdisplay.php,v 1.3 2006-04-19 13:50:04 alexandre_tb Exp $
2
// $Id: ezmlm-msgdisplay.php,v 1.3.2.1 2007-02-16 13:38:35 alexandre_tb Exp $
3
//
3
//
4
// ezmlm-msgdisplay.php - ezmlm-php v2.0
4
// ezmlm-msgdisplay.php - ezmlm-php v2.0
5
// --------------------------------------------------------------
5
// --------------------------------------------------------------
6
// Will parse a template (if specified) and display a message.
6
// Will parse a template (if specified) and display a message.
7
// Includes a default template.
7
// Includes a default template.
Line 15... Line 15...
15
	var $msgtmpl;
15
	var $msgtmpl;
16
    var $message_rendu ;
16
    var $message_rendu ;
17
    var $_auth ;
17
    var $_auth ;
18
	// display: parses a message (using ezmlm_parser) and displays it
18
	// display: parses a message (using ezmlm_parser) and displays it
19
	// using a template
19
	// using a template
-
 
20
    var $msgfile;
Line 20... Line 21...
20
    
21
    
21
	function display($msgfile) {
22
    function display($msgfile) {
22
        if (!is_file($msgfile)) {
23
        if (!is_file($msgfile)) {
23
			if (is_file($this->listdir . "/" . $msgfile)) { $msgfile = $this->listdir . "/" . $msgfile; }
24
            if (is_file($this->listdir . "/" . $msgfile)) { $msgfile = $this->listdir . "/" . $msgfile; }
24
			else if (is_file($this->listdir . "/archive/" . $msgfile)) { $msgfile = $this->listdir . "/archive/" . $msgfile; }
25
		else if (is_file($this->listdir . "/archive/" . $msgfile)) { $msgfile = $this->listdir . "/archive/" . $msgfile; }
25
			else { return FALSE; }
26
		else { return FALSE; }
-
 
27
	    }
26
		}
28
	$this->msgfile = $msgfile ;
-
 
29
        $message = file_get_contents($msgfile) ;
-
 
30
	// En cours de codage
-
 
31
	// La fonction display retourne tout simplement le source du mail
-
 
32
	// Il n'y a plus d'analyse à ce niveau
-
 
33
	
27
        $message = file_get_contents($msgfile) ;
34
	return $message;
28
        $mimeDecode = new Mail_mimeDecode($message) ;
35
        $mimeDecode = new Mail_mimeDecode($message) ;
Line 29... Line 36...
29
        $mailDecode = $mimeDecode->decode(array('decode_bodies' => 'true', 'include_bodies' => 'true')) ;
36
        $mailDecode = $mimeDecode->decode(array('decode_bodies' => 'true', 'include_bodies' => 'true')) ;
30
        
37
        
Line 65... Line 72...
65
                $repertoire_precedent = $nom_repertoire - 1 ;
72
                $repertoire_precedent = $nom_repertoire - 1 ;
66
            } else {
73
            } else {
67
                $fichier_precedent = '0'.($nom_fichier - 1) ;
74
                $fichier_precedent = '0'.($nom_fichier - 1) ;
68
            }
75
            }
69
        }
76
        }
70
        
-
 
71
        if (is_file($this->listdir.'/archive/'.$repertoire_precedent.'/'.$fichier_precedent)) {
-
 
72
            print "[" . $this->makelink("action=show_msg&actionargs[]=$a1&actionargs[]=" . $numero_precedent, ' '.PROJET_PRECEDENT.' ') . "] ";
-
 
73
        } else {
-
 
74
            print '['.PROJET_PRECEDENT.']' ;
-
 
75
        }
-
 
76
        if (is_file($this->listdir.'/archive/'.$repertoire_suivant.'/'.$fichier_suivant)) {
-
 
77
            print "[" . $this->makelink("action=show_msg&actionargs[]=$a1&actionargs[]=" . $numero_suivant, ' '.PROJET_SUIVANT.' ') . "] ";
-
 
78
        } else {
-
 
79
            print '['.PROJET_SUIVANT.']' ;
-
 
80
        }
-
 
81
        // on crée un lien vers la thread avec une ancre vers le message
-
 
82
        $parser = new ezmlm_parser();
-
 
83
        $parser->listdir = $this->listdir ;
-
 
84
        $recent = $parser->recent_msgs(1);
-
 
85
        $actionargs = preg_split("/\//", $recent[0]->msgfile);
-
 
86
		print "[" . $this->makelink('action=show_msg&actionargs[]=' . $actionargs[(count($actionargs) - 2)] . 
-
 
87
                                '&actionargs[]=' .  $actionargs[(count($actionargs) - 1)] , ' '.PROJET_DERNIER_MESSAGE.' ') . '] ';
-
 
88
        if ($this->_auth->getAuth()) {
-
 
89
            print '['.$this->makelink('action=repondre&actionargs[]='.$a1.'&actionargs[]='.$a2, PROJET_REPONDRE).'] ';
-
 
90
        }
-
 
91
		print '<br />'."\n";
-
 
92
        print '<div class="message">' ;
-
 
93
        print $this->parse_entete_mail($mailDecode) ;
77
        print $this->parse_entete_mail($mailDecode) ;
94
		$this->parse_template($mailDecode, $a2, $a1);
78
		$this->parse_template($mailDecode, $a2, $a1);
95
        print $this->message_rendu;
79
        print $this->message_rendu;
96
        print '</div>' ;
80
        //print '</div>' ;
97
	}
81
	}
Line 98... Line 82...
98
    
82
    
-
 
83
    /**
-
 
84
     * Renvoie les infos des messages suivants
-
 
85
     * 
-
 
86
     *
-
 
87
    */
-
 
88
    function getInfoSuivant() {
-
 
89
	$relfile = preg_replace('!' . $this->listdir . '!', '', $this->msgfile);
-
 
90
 	$a1 = preg_replace('!/archive/(.*)/.*$!', '\1', $relfile);  // $a1 contient le nom du répertoire
-
 
91
	$a2 = preg_replace('!/archive/.*/(.*)$!', '\1', $relfile);  // $a2 contient le nom du fichier
-
 
92
       
-
 
93
	if ($a2 <= 10) $numero_precedent = '0'.($a2 - 1) ; else $numero_precedent = ($a2 - 1) ;
-
 
94
        if ($a2 < 9) $numero_suivant = '0'.($a2 + 1) ; else $numero_suivant =  ($a2 + 1);
-
 
95
        // On teste si le message suivant existe
-
 
96
        $decoupe = explode ('/', $this->msgfile) ;
-
 
97
        
-
 
98
        // Les nom de fichiers sont du format :
-
 
99
        // archive/0/01
-
 
100
        // archive/0/02 ... 0/99 archive/1/01 ...
-
 
101
        
-
 
102
        $nom_fichier = $decoupe[count($decoupe)-1] ;
-
 
103
        $nom_repertoire = $decoupe[count($decoupe)-2] ;
-
 
104
        $repertoire_suivant = $nom_repertoire ; $repertoire_precedent = $nom_repertoire ;
-
 
105
        if ($nom_fichier > 8) {
-
 
106
            $fichier_suivant = $nom_fichier + 1 ;
-
 
107
            if ($nom_fichier == 99) {
-
 
108
                $fichier_suivant = '01' ;
-
 
109
                $repertoire_suivant = $nom_repertoire + 1 ;
-
 
110
            }
-
 
111
        } else {
-
 
112
            $fichier_suivant = '0'.($nom_fichier + 1) ;
-
 
113
        }
-
 
114
        if ($nom_fichier > 10) {
-
 
115
            $fichier_precedent = $nom_fichier - 1 ;
-
 
116
        } else {
-
 
117
            if ($nom_fichier == '01') {
-
 
118
                $fichier_precedent = '99' ;
-
 
119
                $repertoire_precedent = $nom_repertoire - 1 ;
-
 
120
            } else {
-
 
121
                $fichier_precedent = '0'.($nom_fichier - 1) ;
-
 
122
            }
-
 
123
	}
-
 
124
	// On vérifie que le message suivant existe bien
-
 
125
	if (!file_exists($this->listdir.'/archive/'.$repertoire_suivant.'/'.$fichier_suivant)) {
-
 
126
	    $fichier_suivant = null ;
-
 
127
	}
-
 
128
	return array ('fichier_suivant' => $fichier_suivant,
-
 
129
		      'repertoire_suivant' => $repertoire_suivant,
-
 
130
		      'fichier_precedent' => $fichier_precedent,
-
 
131
		      'repertoire_precedent' => $repertoire_precedent);
-
 
132
    }
-
 
133
	
99
    /**
134
    /**
100
    *   analyse l'entete d'un mail pour en extraire les entêtes
135
    *   analyse l'entete d'un mail pour en extraire les entêtes
101
    *   to, from, subject, date
136
    *   to, from, subject, date
102
    *   met à jour la variable $this->msgtmpl
137
    *   met à jour la variable $this->msgtmpl
103
    *
138
    *
Line 104... Line 139...
104
    */
139
    */
105
    
140
    
106
    function parse_entete_mail (&$mailDecode) {
141
    function parse_entete_mail (&$mailDecode) {
107
        $startpos = strpos(strtolower($this->msgtmpl_entete), '<ezmlm-headers>');
142
        $startpos = strpos(strtolower($this->msgtmpl_entete), '<ezmlm-headers>');
108
		$endpos = strpos(strtolower($this->msgtmpl_entete), '</ezmlm-headers>');
143
        $endpos = strpos(strtolower($this->msgtmpl_entete), '</ezmlm-headers>');
109
		$headers = substr($this->msgtmpl_entete,$startpos + 15,($endpos - $startpos - 15));
144
	$headers = substr($this->msgtmpl_entete,$startpos + 15,($endpos - $startpos - 15));
110
        $headers_replace = '' ;
145
        $headers_replace = '' ;
111
		for ($i = 0; $i < count($this->showheaders); $i++) {
146
	for ($i = 0; $i < count($this->showheaders); $i++) {
112
			$val = $this->showheaders[$i];
147
	    $val = $this->showheaders[$i];
113
			$headers_replace .= $headers;
148
	    $headers_replace .= $headers;
114
			$hnpos = strpos(strtolower($headers_replace), '<ezmlm-header-name>');
149
	    $hnpos = strpos(strtolower($headers_replace), '<ezmlm-header-name>');
-
 
150
	    $headers_replace = substr_replace($headers_replace, $this->header_en_francais[$val], $hnpos, 19);
115
			$headers_replace = substr_replace($headers_replace, $this->header_en_francais[$val], $hnpos, 19);
151
	    $hvpos = strpos(strtolower($headers_replace), '<ezmlm-header-value');
116
			$hvpos = strpos(strtolower($headers_replace), '<ezmlm-header-value');
152
            $headers_replace = $this->decode_iso ($headers_replace) ;
117
            if ($val == 'date') {
153
            if ($val == 'date') {
118
                $headers_replace = substr_replace($headers_replace, $this->date_francaise($mailDecode->headers[strtolower($val)]), $hvpos, 20);
154
                $headers_replace = substr_replace($headers_replace, $this->date_francaise($mailDecode->headers[strtolower($val)]), $hvpos, 20);
119
            } else {
155
            } else {
120
                $headers_replace = substr_replace($headers_replace, $this->protect_email($mailDecode->headers[strtolower($val)]), $hvpos, 20);
-
 
121
            }
156
                $headers_replace = substr_replace($headers_replace, $this->protect_email($this->decode_iso($mailDecode->headers[strtolower($val)])), $hvpos, 20);
122
            $headers_replace = $this->decode_iso ($headers_replace) ;
-
 
123
		}
157
            }
124
        
158
	}
Line 125... Line 159...
125
		return substr_replace($this->msgtmpl_entete, $headers_replace, $startpos, (($endpos + 16) - $startpos));
159
        return substr_replace($this->msgtmpl_entete, $headers_replace, $startpos, (($endpos + 16) - $startpos));
126
    }
160
    }
Line 159... Line 193...
159
                                            $mailDecode->parts[$i]->d_parameters['filename'] : $mailDecode->parts[$i]->ctype_parameters['name'] ;
193
                                            $mailDecode->parts[$i]->d_parameters['filename'] : $mailDecode->parts[$i]->ctype_parameters['name'] ;
160
                        $mimeType = new type_fichier_mime($GLOBALS['projet_db'], $mailDecode->parts[$i]->ctype_primary.'/'.
194
                        $mimeType = new type_fichier_mime($GLOBALS['projet_db'], $mailDecode->parts[$i]->ctype_primary.'/'.
161
                                            $mailDecode->parts[$i]->ctype_secondary, PROJET_CHEMIN_ICONES) ;
195
                                            $mailDecode->parts[$i]->ctype_secondary, PROJET_CHEMIN_ICONES) ;
162
                    }
196
                    }
Line 163... Line 197...
163
                    
197
                    
164
                    $corps .= '<a href="'.PROJET_CHEMIN_APPLI.'fichier_attache.php?nom_liste='.$this->listname.
198
                    $corps .= '<a href="'.PROJET_CHEMIN_APPLI.'synchroliste/fichier_attache.php?nom_liste='.$this->listname.
165
                                    '&actionargs[]='.$numero_mois.
199
                                    '&actionargs[]='.$numero_mois.
Line 166... Line 200...
166
                                    '&actionargs[]='.$numero_mail;
200
                                    '&actionargs[]='.$numero_mail;
167
                                    
201
                                    
Line 187... Line 221...
187
        } else if ($mailDecode->ctype_primary == 'application' || $mailDecode->ctype_primary == 'image'){
221
        } else if ($mailDecode->ctype_primary == 'application' || $mailDecode->ctype_primary == 'image'){
188
            if ($mailDecode->ctype_secondary == 'applefile') return ;
222
            if ($mailDecode->ctype_secondary == 'applefile') return ;
189
            $mimeType = new type_fichier_mime($GLOBALS['projet_db'], $mailDecode->ctype_primary.'/'.$mailDecode->ctype_secondary,PROJET_CHEMIN_ICONES) ;
223
            $mimeType = new type_fichier_mime($GLOBALS['projet_db'], $mailDecode->ctype_primary.'/'.$mailDecode->ctype_secondary,PROJET_CHEMIN_ICONES) ;
Line 190... Line 224...
190
            
224
            
191
            if ($mimeType->getIdType() != 12) {
225
            if ($mimeType->getIdType() != 12) {
192
                $corps .= '<a href="'.PROJET_CHEMIN_APPLI.'fichier_attache.php?nom_liste='.$this->listname.'&actionargs[]='.
226
                $corps .= '<a href="'.PROJET_CHEMIN_APPLI.'synchroliste/fichier_attache.php?nom_liste='.$this->listname.'&actionargs[]='.
193
                                    $numero_mois.'&actionargs[]='.
227
                                    $numero_mois.'&actionargs[]='.
194
                                    $numero_mail.'&actionargs[]='.$i.'">'.
228
                                    $numero_mail.'&actionargs[]='.$i.'">'.
195
                                    '<img src="'.$mimeType->getCheminIcone().'" alt="'.$mailDecode->ctype_parameters['name'].'" />&nbsp;' ;
229
                                    '<img src="'.$mimeType->getCheminIcone().'" alt="'.$mailDecode->ctype_parameters['name'].'" />&nbsp;' ;