Subversion Repositories Applications.papyrus

Rev

Rev 243 | Blame | Last modification | View Log | RSS feed

<?
/*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 $
/**
* programme principal du module annuaire
*
* programme principal du module 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                                       |
// +------------------------------------------------------------------------------------------------------+


include_once 'client/annuaire/configuration/ann_config.inc.php' ;
include_once ANN_CHEMIN_LIBRAIRIE.'annuaire.fonct.php' ;
if (isset($lang)) {
    include_once ANN_CHEMIN_APPLI."/langues/ann_langue_$lang.inc.php" ;
} else {
    include_once ANN_CHEMIN_APPLI.'/langues/ann_langue_fr.inc.php' ;
}



include_once 'HTML/QuickForm.php' ;


define ("ENVOIE_MAIL", 2) ;

/**
 *  Renvoie le code HTML de l'application
 *
 * @return  string  HTML
 */

function afficherContenuCorps () {
    $res = "<h1 class=\"annuaire_titre1\">".ANN_TITRE."</h1>\n" ;
    if (!$GLOBALS['AUTH']->getAuth())  {
        $res .= AUTH_formulaire_login() ;
    } else {
        // Le code javascript des cases à cocher
        $java =
            "function setCheckboxes(the_form)
            {
            var do_check=document.forms[the_form].elements['selecttotal'].checked;
            var elts            = document.forms[the_form].elements['select[]'];
            var elts_cnt = (typeof(elts.length) != 'undefined')
                                ? elts.length
                                : 0;
            if (elts_cnt) {
                for (var i = 0; i < elts_cnt; i++) {
                    elts[i].checked = do_check;
                } // Fin for
            } else {
                elts.checked = do_check;
            } // Fin if... else
            return true;
        } // Fin de la fonction 'setCheckboxes()'";
        GEN_stockerCodeScript($java) ;

        $res .= "<h2 class=\"annuaire_titre2\">".ANN_CLIQUEZ_LETTRE."</h2>\n";

        global $baseURL ;
        $baseURL = $GLOBALS['ann_url']->getURL() ;
            // S'il y a un mail a envoyé, on l'envoie
        if ($action == ENVOIE_MAIL) $res .= envoie_mail () ;

        $res .= parcourrirAnnu("") ;
    }
    return $res;
}

//==============================================================================
// FUNCTION putFooter ()
//
// Generation of footer.
//==============================================================================

function putFooter () {
  return '&nbsp;';
}



function envoie_mail () {
    global $titre, $corps, $HTTP_POST_VARS, $select, $AUTH, $db ;

    // On vérifie qu'un email aie été sélectionné
    if (!is_array($select)) {
        $res ="<div class=\"annuaire_erreur\">".ANN_VERIF_MAIL_COCHE."</divr>";
        return $res ;
    }
    if ($titre == "" || $corps == "") {
        $res = "<div class=\"annuaire_erreur\">".ANN_VERIF_TITRE."</div>\n" ;
        return $res ;
    }

    // On récupère le mail de l'expéditeur
    $req_exp = "select ".ANN_CHAMPS_MAIL." from ".ANN_ANNUAIRE." where ".ANN_CHAMPS_ID."=".$AUTH->getAuthData(ANN_CHAMPS_ID) ;
    $res_exp = $db->query($req_exp) ;
    if (DB::isError($res_exp)) {
        die ("Echec de la requete sur annuaire_tela <br>".$res_exp->getMessage()) ;
    }
    $ligne_exp = $res_exp->fetchRow(DB_FETCHMODE_ASSOC) ;
    $expediteur = $ligne_exp[ANN_CHAMPS_MAIL] ;

    $corps .= ANN_PIED_MESSAGE ;
    $liste = "" ;
    for ($i = 0; $i < count($select); $i++) {
        $requete = "select ".ANN_CHAMPS_MAIL." from ".ANN_ANUAIRE." where ".ANN_CHAMPS_ID."=".$select[$i] ;
        $resultat = $db->query($requete) ;
        
        if (DB::isError($resultat)) {
            die ("Echec de la requete sur annuaire_tela <br>".$resultat->getMessage()) ;
        }
        $ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;

        // L'envoie du mail proprement dit
        if (!mail($ligne[ANN_CHAMPS_MAIL], stripslashes($titre), stripslashes($corps), "From: $expediteur")) {
            return "<div class=\"annuaire_erreur\">Le mail n'est pas partie</div>\n" ;
        }
        $liste .= $ligne[ANN_CHAMPS_MAIL]."\n" ;
    }
    $corps .= "\n----------------------------------------------------------------------------
                Ce message a été envoyé à :\n $liste" ;
    mail ("ANN_MAIL_ADMIN", stripslashes($titre), stripslashes($corps), "From: $expediteur");
}
/**------------------------------------------------------------------------------
* $Log: not supported by cvs2svn $
* Revision 1.2  2005/01/06 15:17:39  alex
* ajout de commentaires
*
* Revision 1.1.1.1  2005/01/03 17:27:49  alex
* Import initial
*
* Revision 1.1  2005/01/03 17:18:43  alex
* retour vers la liste des participants après un ajout.
*
*
*-- End of source  ------------------------------------------------------------*/
?>