Subversion Repositories Applications.papyrus

Compare Revisions

Ignore whitespace Rev 1964 → Rev 1965

/branches/livraison_aha/client/projet/classes/ezmlm-php-2.0/services_vpopmail/messages_thread.php
1,5 → 1,37
<?php
 
/*vim: set expandtab tabstop=4 shiftwidth=4: */
// +------------------------------------------------------------------------------------------------------+
// | PHP version 4.1 |
// +------------------------------------------------------------------------------------------------------+
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org) |
// +------------------------------------------------------------------------------------------------------+
// | This library is free software; you can redistribute it and/or |
// | modify it under the terms of the GNU General Public |
// | License as published by the Free Software Foundation; either |
// | version 2.1 of the License, or (at your option) any later version. |
// | |
// | This library is distributed in the hope that it will be useful, |
// | but WITHOUT ANY WARRANTY; without even the implied warranty of |
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
// | General Public License for more details. |
// | |
// | You should have received a copy of the GNU General Public |
// | License along with this library; if not, write to the Free Software |
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
// +------------------------------------------------------------------------------------------------------+
// CVS : $Id: messages_thread.php,v 1.2.4.1 2008-11-05 09:45:04 aperonnet Exp $
/**
* Application projet
*
* Renvoie les messages d un thread
*
*@package projet
//Auteur original :
*@author Alexandre Granier <alexandre@tela-botanica.org>
*@copyright Tela-Botanica 2000-2008
*@version $Revision: 1.2.4.1 $
// +------------------------------------------------------------------------------------------------------+
*/
include_once 'ezmlm-php-2.0/ezmlm.php' ;
 
 
11,12 → 43,10
$info->listname = $liste;
$info->listdomain = $domaine ;
$info->tempdir = '/home/vpopmail/www/tmp' ;
ob_start() ;
if (!$info->load($actionargs[0])) {
$html = $info->load($actionargs[0]) ;
if (!$html) {
if (!$info) return 'Les fichiers de la liste ne sont pas visible sur le serveur' ;
}
$html = ob_get_contents() ;
ob_end_clean() ;
 
include_once 'XML/Util.php' ;
 
29,4 → 59,16
$xml .= XML_Util::createEndElement('ezmlm_messages_thread') ;
header ('Content-type: text/xml');
echo $xml ;
?>
/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.4 2008-11-04 17:11:10 aperonnet
* correction de bugs dans la liste des derniers messages
*
* Revision 1.3 2008-08-26 09:26:41 alexandre_tb
* ajout commentaire
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>
/branches/livraison_aha/client/projet/classes/ezmlm-php-2.0/ezmlm-listinfo.php
1,5 → 1,5
<?php
// $Id: ezmlm-listinfo.php,v 1.3 2007-04-19 15:34:35 neiluj Exp $
// $Id: ezmlm-listinfo.php,v 1.3.4.1 2008-11-05 09:45:04 aperonnet Exp $
//
// ezmlm-listinfo.php - ezmlm-php v2.0
// --------------------------------------------------------------
50,10 → 50,12
if (!is_dir($this->listdir.'/archive/0')) return false;
$html = '' ;
$parser = new ezmlm_parser();
$parser->listdir = $this->listdir ;
print '<table class="table_cadre">'."\n";
print '<tr><th class="col1">Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
$html .= '<table class="table_cadre">'."\n";
$html .= '<tr><th class="col1">Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
$ctc = 0;
$recent = $parser->recent_msgs();
66,7 → 68,7
$class = array ('ligne_paire', 'ligne_impaire') ;
while (list($key,$val) = each($recent)) {
print '<tr class="'.$class[$ctc].'">'."\n";
$html .= '<tr class="'.$class[$ctc].'">'."\n";
//print '<td>'.$val->nummessage.'</td>' ;
// $key contient le numero du message tel que dans les fichiers d index par ex 216
74,7 → 76,7
$decimal = (string) $key;
if ($key >= 100) {
$fichier_message = substr($decimal, -2) ;
$repertoire_message = substr ($decimal, 0,count ($decimal) -2) ;
$repertoire_message = substr ($decimal, 0, -2) ;
} else {
if ($key < 10) {
$fichier_message = '0'.$key;
84,36 → 86,42
$repertoire_message = '0';
}
print '<td>'.$key.'</td>' ;
print '<td>';
$html .= '<td>'.$key.'</td>' ;
$html .= '<td>';
 
$from = $val[4];
 
print $this->makelink("action=show_author_msgs&actionargs[]=".$val[3],$this->decode_iso($this->protect_email($from,false)));
print "</td>\n";
print '<td><b>';
$html .= $this->makelink("action=show_author_msgs&actionargs[]=".$val[3],$this->decode_iso($this->protect_email($from,false)));
$html .= "</td>\n";
$html .= '<td><b>';
$actionargs = preg_split("/\//", $val->msgfile);
print $this->makelink("action=show_msg&actionargs[]=" . $repertoire_message .
"&actionargs[]=" . $fichier_message ,$this->decode_iso($val[1]));
$html .= $this->makelink("action=show_msg&actionargs[]=".$repertoire_message.
"&actionargs[]=".$fichier_message ,$this->decode_iso($val[1]));
 
print "</b></td>\n";
$html .= "</b></td>\n";
//print '<td>'.$this->date_francaise($val[2]).'</td>'."\n";
print '<td>'.$val[2].'</td>'."\n";
print "</tr>\n";
$html .= '<td>'.$val[2].'</td>'."\n";
$html .= "</tr>\n";
 
$ctc++;
if ($ctc == 2) { $ctc = 0; }
}
print '</table>'."\n";
return true;
$html .= '</table>'."\n";
return $html;
}
function show_month ($month) {
// Le nom du fichier est annéemois ex 200501 pour janvier 2005
// le html est vide au début
$html = '' ;
// on ouvre chaque fichier en lecture
if(!file_exists($this->listdir . '/archive/threads/' . $month)) {
return false ;
}
$fd = file_get_contents($this->listdir . '/archive/threads/' . $month, 'r');
$fichier = explode ("\n", $fd) ;
// on récupère la première ligne
137,8 → 145,8
$numero_premier_mail = $numero_dernier_mail ;
$numero_dernier_mail = $temp;
}
print '<table class="table_cadre">'."\n";
print '<tr><th class="col1">Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
$html .= '<table class="table_cadre">'."\n";
$html .= '<tr><th class="col1">Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
$ctc = 0;
$class = array ('ligne_paire', 'ligne_impaire') ;
158,32 → 166,32
$i = -1;
}
print '<tr class="'.$class[$ctc].'">'."\n";
print '<td>'.($repertoire_premier_mail != 0 ? $repertoire_premier_mail : '').$num_message.'</td><td>';
$html .= '<tr class="'.$class[$ctc].'">'."\n";
$html .= '<td>'.($repertoire_premier_mail != 0 ? $repertoire_premier_mail : '').$num_message.'</td><td>';
$hash = $this->makehash($mailDecode->headers['from']);
print $this->makelink("action=show_author_msgs&actionargs[]=".
$html .= $this->makelink("action=show_author_msgs&actionargs[]=".
$hash,$this->decode_iso($this->protect_email($mailDecode->headers['from'],TRUE)));
print "</td>\n";
print '<td><b>';
$html .= "</td>\n";
$html .= '<td><b>';
$actionargs[0] = $repertoire_premier_mail ;
$actionargs[1] = $num_message ;
if (count ($actionargs) > 1) {
print $this->makelink("action=show_msg&actionargs[]=".
$html .= $this->makelink("action=show_msg&actionargs[]=".
$actionargs[(count($actionargs) - 2)] .
"&actionargs[]=".
$actionargs[(count($actionargs) - 1)] ,$this->decode_iso($mailDecode->headers['subject']));
}
print "</b></td>\n";
print '<td>'.$this->date_francaise($mailDecode->headers['date']).'</td>'."\n";
print "</tr>\n";
$html .= "</b></td>\n";
$html .= '<td>'.$this->date_francaise($mailDecode->headers['date']).'</td>'."\n";
$html .= "</tr>\n";
$ctc++;
if ($ctc == 2) { $ctc = 0; }
}
}
print '</table>'."\n";
return true;
$html .= '</table>'."\n";
return $html;
}
}
 
/branches/livraison_aha/client/projet/classes/ezmlm-php-2.0/ezmlm-threads.php
1,5 → 1,5
<?php
// $Id: ezmlm-threads.php,v 1.5 2007-04-19 15:34:35 neiluj Exp $
// $Id: ezmlm-threads.php,v 1.5.4.1 2008-11-05 09:45:04 aperonnet Exp $
//
// ezmlm-threads.php - ezmlm-php v2.0
// --------------------------------------------------------------
37,7 → 37,7
$this->build($month);
}
}
$this->display($month);
return $this->display($month);
}
 
// display: this loads each cache file sequentially and displays the messages in them
51,21 → 51,22
$cache = $this->tempdir . "/ezmlm-php-" . $this->listname . "/" . $month;
}
// Le lien par date et par thread
echo '[ '.$this->makelink('action=show_month&amp;actionargs[]='.$month, 'par date').' ]' ;
$months = array(1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');
$html = '[ '.$this->makelink('action=show_month&amp;actionargs[]='.$month, 'par date').' ]' ;
$months = array(1 => 'January', 2 => 'February', 3 => 'March', 4 => 'April', 5 => 'May', 6 => 'June', 7 => 'July', 8 => 'August',
9 => 'September', 10 => 'October', 11 => 'November', 12 => 'December');
// remplacé par le tableau globals $mois dans ezmlm.php
print '<h2>'.FIL_DE_DISCUSSION.' pour '.$GLOBALS['mois'][((int)substr($month,4,2) / 1)] .', ' . substr($month,0,4) . '</h2>'."\n";
$html = '<h2>'.FIL_DE_DISCUSSION.' pour '.$GLOBALS['mois'][((int)substr($month,4,2) / 1)] .', ' . substr($month,0,4) . '</h2>'."\n";
print '<table class="table_cadre">'."\n";
print '<tr><th>Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
print '<tr><td colspan="3"><hr /></td></tr>'."\n";
$html = '<table class="table_cadre">'."\n";
$html = '<tr><th>Num</th><th>De</th><th>Sujet</th><th>Date</th></tr>'."\n";
$html = '<tr><td colspan="3"><hr /></td></tr>'."\n";
$ctc = 0;
 
if (is_file($cache)) {
include($cache);
}
print '<tr><td colspan="3"></td></tr>'."\n";
print '</table>'."\n";
$html = '<tr><td colspan="3"></td></tr>'."\n";
$html = '</table>'."\n";
}
 
 
252,18 → 253,28
 
// listmessages: prints out a nice little calendar and displays the message
// totals for each month. The link jumps to the thread listing.
// On lit le répertoire archive/threads/ qui contient un fichier par moi avec tous les thread, par sujet
// Présentés comme suit
// On lit le repetoire archive/threads/ qui contient un fichier par moi avec tous les thread, par sujet
// Presentes comme suit
// num_thread:hash [taille_du_thread] Sujet du thread (le dernier)
// les messages sont rangés par leur numéro
// les messages sont ranges par leur numero
function listmessages() {
if (!is_dir($this->listdir . "/archive/threads/")) {
return false ;
}
$res = '<table id="petit_calendrier">'."\n";
$res .= " <tr>\n";
$res .= " <td></td>" ;
foreach ($GLOBALS['mois'] as $valeur) $res .= '<th>'.$valeur.'</th>' ;
$res .=" </tr>\n";
$res .= $this->calendrierMessage();
$res .= "</table>\n";
return $res;
/*
$threadcount = array();
 
$repertoire_archive = opendir($this->listdir . "/archive/");
 
$tableau_annee = array();
while (false !== ($item = readdir($repertoire_archive))) {
// $item contient les noms des repertoires
// on ne garde que ceux qui sont des chiffres
280,39 → 291,137
$temp = fgets($fichier_index, 4096);
preg_match('/\t([0-9]+) ([a-zA-Z][a-zA-Z][a-zA-Z]) ([0-9][0-9][0-9][0-9])/', $temp, $match) ;
if ($match[0] != '') {
$threadmonth = date('n', strtotime($match[0])) ;
$threadyear = date('Y', strtotime($match[0])) ;
$threadcount[$threadyear][$threadmonth]++;
if (!in_array($threadyear, $tableau_annee)) array_push ($tableau_annee, $threadyear);
}
}
fclose ($fichier_index);
}
}
// La partie qui suit, simple, crée la table avec le nombre de message échangé chaque mois
if (count($threadcount) == 0) return 'Il n\y a pas de messages dans les archives';
// La partie qui suit, simple, cree la table avec le nombre de message echange chaque mois
$res = '<table id="petit_calendrier">'."\n";
$res .= " <tr>\n";
$res .= " <td></td>" ;
foreach ($GLOBALS['mois'] as $valeur) $res .= '<td>'.$valeur.'</td>' ;
foreach ($GLOBALS['mois'] as $valeur) $res .= '<th>'.$valeur.'</th>' ;
$res .=" </tr>\n";
 
while (list($key,$val) = each($threadcount)) {
arsort($tableau_annee);
foreach ($tableau_annee as $annee) {
$res .= " <tr>\n";
$res .= " <td>$key</td>";
$res .= ' <td class="col_annee">'.$annee.'</td>';
for ($i = 1; $i <= 12; $i++) {
if (isset($threadcount[$key][$i]) && $threadcount[$key][$i] > 0) {
$res .= "<td bgcolor=\"" . $this->tablecolours[0] . "\" valign=\"middle\">";
$res .= $this->makelink('action=show_month&amp;actionargs[]='.$key.($i < 10 ? '0'.$i:$i),$threadcount[$key][$i]);
$res .= "</td>";
} else {
$res .= "<td bgcolor=\"" . $this->tablecolours[0] . "\"></td>";
}
$res .= '<td class="mois">';
if (isset($threadcount[$annee][$i]) && $threadcount[$annee][$i] > 0) {
$res .= $this->makelink('action=show_month&amp;actionargs[]='.$annee.($i < 10 ? '0'.$i:$i),$threadcount[$annee][$i]);
}
$res .= '</td>';
}
$res .= "</tr>\n";
$res .= '</tr>'."\n";
}
$res .= "</table>\n";
echo $res ;
return $res ;
*/
}
/*
* Cree un fichier liste.calendrierPermanent qui contient
* le nombre de message par mois pour toutes les annees
* depuis le debut de la liste sauf la derniere
*
*/
function calculeCalendrierPermanent($Annnee = '') {
$numArchive = $this->getNumArchive();
$dernierRepertoire = floor($numArchive / 100);
$threadcount = array();
$tableau_annee = array();
for ($rep_courant = $dernierRepertoire; $rep_courant >= 0; $rep_courant--) {
$fichier_index = file ($this->listdir.'/archive/'.$rep_courant.'/index', FILE_IGNORE_NEW_LINES);
 
// On parcours le fichier a l envers
for ($j = count($fichier_index)-1; $j >= 0; $j-=2) {
preg_match('/\t([0-9]+) ([a-zA-Z][a-zA-Z][a-zA-Z]) ([0-9][0-9][0-9][0-9])/', $fichier_index[$j], $match) ;
if ($match[0] != '') {
$threadmonth = date('n', strtotime($match[0])) ;
$threadyear = date('Y', strtotime($match[0])) ;
if ($Annnee != '') {
if ($threadyear < date('Y')) {
$sortir = true;
break;
}
} else {
if ($threadyear == date('Y')) continue;
}
$threadcount[$threadyear][$threadmonth]++;
if (!in_array($threadyear, $tableau_annee)) array_push ($tableau_annee, $threadyear);
}
}
if ($sortir) break;
}
$res = '';
arsort($tableau_annee);
foreach ($tableau_annee as $annee) {
$res .= " <tr>\n";
$res .= ' <td class="col_annee">'.$annee.'</td>';
for ($i = 1; $i <= 12; $i++) {
$res .= '<td class="mois">';
if (isset($threadcount[$annee][$i]) && $threadcount[$annee][$i] > 0) {
$res .= $this->makelink('action=show_month&amp;actionargs[]='.$annee.($i < 10 ? '0'.$i:$i),$threadcount[$annee][$i]);
}
$res .= '</td>';
}
$res .= '</tr>'."\n";
}
return $res;
}
function ecrireFichierCalendrier() {
$html = $this->calculeCalendrierPermanent();
$f = fopen ('tmp/'.$this->listname.'.calendrier', 'w') ;
fwrite ($f, $html);
fclose($f);
return $html;
}
function calendrierMessage() {
$html = '';
// On ajoute la derniere annee
$html .= $this->calculeCalendrierPermanent(date ('Y'));
if ($this->isFichierCalendrierExiste()) {
// S il existe mais qu il est trop vieux, il faut le recalculer
if ($this->isDoitRecalculerCalendrier()) {
$annees = $this->getAnneesARecalculer();
$html .= $this->calculeCalendrierPermanent($annees);
}
$html .= file_get_contents('tmp/'.$this->listname.'.calendrier');
} else {
$html .= $this->ecrireFichierCalendrier();
}
return $html;
}
function isFichierCalendrierExiste() {
if (file_exists('tmp/'.$this->listname.'.calendrier')) {
return true;
}
return false;
}
function isDoitRecalculerCalendrier() {
 
if (date ('Y', fileatime('tmp/'.$this->listname.'.calendrier')) != date('Y')) return true;
return false;
}
function getAnneesARecalculer() {
// On suppose que l index de ezmlm est correct
$anneeFichierCalendrier = date ('Y', fileatime('tmp/'.$this->listname.'.calendrier'));
return $anneeFichierCalendrier + 1;
}
}
 
// CLASS: ezmlm-thread is a quick little class to allow us to define