Subversion Repositories Sites.tela-botanica.org

Rev

Rev 609 | Blame | Compare with Previous | Last modification | View Log | RSS feed

<?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 Lesser 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                                    |
// | Lesser General Public License for more details.                                                      |
// |                                                                                                      |
// | You should have received a copy of the GNU Lesser 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: annuaire.php,v 1.3 2005/01/06 15:44:33 alex Exp $
/**
* Permet d'envoie un mail à une sélection dans l'annuaire
* 
*
*@package annuaire
//Auteur original :
*@author        Alexandre Granier <alexandre@tela-botanica.org>
//Autres auteurs :
*@author        Aucun
*@copyright     Tela-Botanica 2000-2004
*@version       $Revision: 1.3 $
// +------------------------------------------------------------------------------------------------------+
*/

// +------------------------------------------------------------------------------------------------------+
// |                                            ENTETE du PROGRAMME                                       |
// +------------------------------------------------------------------------------------------------------+

function putFrame() {
    
    // configuration
    global $objet, $corps, $annuaire_LABEL_STATUT, $SERVER_ADMIN ;
    global $action ;
    
    $url = $GLOBALS['ann_url']->getURL() ;
    
    $annu_table = "annuaire_tela" ;
    $champs_mail = "U_MAIL" ;

    // Entete
    
    $corps_debut = "RESEAU TELA BOTANICA - Le ".date("j/m/Y").
                    "\n\nBonjour,\n"."\n\nCordialement,\n-------------------\nTela Botanica le réseau des botanistes francophones\naccueil@tela-botanica.org\nhttp://www.tela-botanica.org\n";  

    $res = "<h1>Envoi d'un mail &agrave; tous les membres</h1>\n" ;
    
    if ($_GET['action'] == ANN_MAIL_TOUS_ENVOIE) $res .= envoie_mail_selection() ;
    $GLOBALS['ann_url']->addQueryString('action', ANN_MAIL_TOUS_ENVOIE);
    // formulaire
    $res .= '<div><form action="'.$GLOBALS['ann_url']->getURL()."\" method=\"post\"><table>\n" ;
    $res .= "<tr><td class=\"insLabel\">" ;
    $res .= "Objet&nbsp;:&nbsp;</td><td><input size=\"91\" name=\"objet\" type=\"text\" class=\"insInputForm\"></td></tr>\n" ;
    $res .= "<tr><td class=\"insLabel\">Corps&nbsp;:&nbsp;</td><td><textarea name=\"corps\" cols=\"90\" rows=\"30\" class=\"insInputForm\">$corps_debut</textarea></td></tr>\n" ;
    $res .= "<tr><td></td><td><input type=\"submit\" class=\"texte_tb\" value=\"envoyer\"" ;
    $res .= " onclick=\"javascript:return confirm('Etes-vous sur de vouloir envoyer ce message !!');\"" ;
    $res .= "></td></tr>\n" ;
    $res .= "</table></form></div>\n" ;
    $res .= $_SESSION['requete_mail_tous'];

return $res ;
}

include_once ("Mail.php");

// envoie le mail à tous
function envoie_mail_selection() 
{
    global $objet, $corps, $annuaire_LABEL_STATUT, $SERVER_ADMIN, $GS_GLOBAL ;
    
    $annuaire = "annuaire_tela" ;
    $champs_mail = "U_MAIL" ;
    
    $headers['From']    = "accueil@tela-botanica.org" ;
    $headers['Subject'] = stripslashes($objet) ;

    $corps = stripslashes($corps) ;
    
    $requete = $_SESSION['requete_mail_tous'] ;
    unset ($_SESSION['requete_mail_tous']) ;

    $resultat = mysql_query($requete) or die ("echec") ;
    
    while ($ligne = mysql_fetch_object($resultat)) {
        if (!mail($ligne->U_MAIL, $headers['Subject'], $corps, "From: ".$headers['From'])) {
        return "<tr><td>Une erreur s'est produite:<br>".$mail_object->getMessage()."</td></tr>\n" ;
        }
    }
    
    return "<div>Le mail est parti !</div>\n";

}
?>