Subversion Repositories Applications.papyrus

Rev

Go to most recent revision | Blame | 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.fonct.php,v 1.1 2005-09-22 14:02:49 ddelon Exp $
/**
* Fonctions du module annuaire
*
* Fonctions 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.1 $
// +------------------------------------------------------------------------------------------------------+
*/

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

include_once "HTML/QuickForm.php" ;

// +------------------------------------------------------------------------------------------------------+
// |                                           LISTE de FONCTIONS                                         |
// +------------------------------------------------------------------------------------------------------+

/** function parcourirAnnu ()  Affiche l'annuaire à partir d'une lettre
*
*
*
*       @return string HTML
*/

function parcourirAnnu() {

    $res = '<div><table><tr>';

    // ecrire toutes les lettres avec un lien
    for ($i = 65 ; $i <91 ; $i++) {
        $res .= '<td><a style="font-size:15px;" href="'.$GLOBALS['ins_url']->getURL().'&amp;lettre=';
        $res .= chr($i) ;
        $res .= '">';
        $res .= chr($i) ;
        $res .= '</a></td>'."\n";
    }
    $res .= '</tr></table></div>'."\n";

    // si une lettre est selectionne
    if (!empty($_REQUEST['lettre'])) {
        $requete = 'SELECT '.INS_CHAMPS_ID;
        foreach($GLOBALS['annuaire_champs_visibles']['champs_db'] as $i) {
                $requete .= ', '.$i;
        }
        $requete .= ' FROM '.INS_ANNUAIRE.' WHERE ';
        if ($_REQUEST['lettre'] != 'tous') {
                $requete .= INS_CHAMPS_NOM.' LIKE "'.$_REQUEST['lettre'].'%"';
        } else {
                $requete .= '1';
        }
        $requete .= ' ORDER BY '.INS_CHAMPS_NOM ;
        $resultat = $GLOBALS['ins_db']->query($requete);
        if ($resultat->numRows()>0) {
                $i=0;
                while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
                        $donnees_membres[$i++]=$ligne;
                }
                $res .= listes_inscrit($donnees_membres, $GLOBALS['annuaire_champs_visibles']['label_champs']);
        } else {$res .= ANN_PAS_D_INSCRITS;}
    }
    return $res ;
}

/**
 *  Renvoie le code HTML de la liste des inscrits
 *  en fonction de la requete passé en parametre
 *
 * @return  Renvoie le code HTML de la liste des inscrits
 */

function listes_inscrit(& $donnees_membres, & $entete , $case_a_cocher=true) {
    $res = '<div>'."\n";
    if ($case_a_cocher) {$res .= '<form action="'.$GLOBALS['ins_url']->getURL().'"&amp;lettre='.$_REQUEST['lettre'].'" method="post" name="formmail">'."\n";}
    $res .= '<table id="table_inscrit">'."\n".'<colgroup>'."\n";
    if ($case_a_cocher) {$res .= '<col />';}
    foreach($entete as $i) {$res .= '<col />'; }
    $res .= '</colgroup>'."\n".'<thead>'."\n";
    if ($case_a_cocher) {$res .= '<th>&nbsp;</th>'."\n";}
    foreach($entete as $i) {
        $res .= '<th>'.$i.'</th>'."\n";
    }
    $res .= '</thead>'."\n";
   
    $indic=0;
    $i=1;
    foreach($entete as $i) {
        if ($indic==0) {
            $res.='<tr class="ligne_impaire">'."\n";
            $indic=1;
        }
        else {
            $res.='<tr class="ligne_paire">'."\n";
            $indic=0;
        } 
    }
    for ($i=0;$i<count($donnees_membres);$i++) {
        $id = array_shift($donnees_membres[$i]);
        if ($case_a_cocher) {$res.='<td><input type="checkbox" name="select[]" value="'.$id.'"></td>'."\n";}
        foreach($donnees_membres[$i] as $valeur) $res .= '<td>'.$valeur.'</td>'."\n" ;
        $res .= '</tr>'."\n";
    }
   
    $res .= '</table></div>'."\n";
    if ($case_a_cocher) {
        $res .= '<div class="texte">'.ANN_CHECK_UNCHECK ;
        $res .= '&nbsp;<input type="checkbox" name="selecttotal" onclick="javascript:setCheckboxes(\'formmail\');"></div>';
        $res .= '<h3>'.ANN_ENVOYER_MAIL.'</h3>'."\n";
        $res .= '<div>'."\n".'<table border="0">'."\n"
                .'<tr><td class="texte">'.ANN_SUJET.' :</td>'."\n"
                .'<td><input class="forml" type="text" name="titre_mail" size="60"></td>'."\n"
                .'</tr><tr><td class="texte" valign="top">'.ANN_MESSAGE.'&nbsp;:&nbsp;</td>'."\n"
                .'<td><textarea class="forml" name="corps" rows="5" cols="60"></textarea></td>'."\n"
                .'</tr><tr><td></td><td align="center">';
        $res.='<input type="submit" value="'.ANN_ENVOYER.'">';
        $res.='</td>'."\n".'</tr>'."\n".'</table>'."\n".'</div>'."\n".'</form>'."\n";
    }
    return $res ;
}



/** envoie_mail_depuis_annuaire()
 *
 *
 * @return  envoie l'email
 */

function envoie_mail_depuis_annuaire() {
    $requete = "select ".ANN_CHAMPS_MAIL." from ".ANN_ANNUAIRE.
            " where ".ANN_CHAMPS_ID."='".$GLOBALS['AUTH']->getAuthData (ANN_CHAMPS_ID)."'";
    $resultat = $GLOBALS['ann_db']->query($requete);
    if (DB::isError($resultat)) {
        die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo());
    }
    $ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
    $entete = "From: <".$ligne[ANN_CHAMPS_MAIL].">\n";
    
    $_POST['corps'] .= ANN_PIED_MESSAGE;
    $_POST['corps'] = stripslashes($_POST['corps']) ;
    $liste = "" ;
    foreach ($_POST['select'] as $key => $value) {
        mail ($value, stripslashes($_POST['titre_mail']), $_POST['corps'] , $entete) ;
        $liste .= $value."\n" ;
    }
    
    $_POST['corps'] .= "\n----------------------------------------------------------------------------";
    $_POST['corps'] .= "\n".ANN_MESSAGE_ENVOYE_A." :\n $liste" ;
    
    mail (CAR_MAIL_ADMIN, stripslashes($_POST['titre_mail']), $_POST['corps'], $entete);
    $_POST['corps'] = '';
    $_POST['titre_mail'] = '';
    return '<div>'.ANN_MAIL_ENVOYER.'</div>' ;
}

/* +--Fin du code ----------------------------------------------------------------------------------------+
*
* $Log: not supported by cvs2svn $
* Revision 1.4  2005/09/22 13:30:49  florian
* modifs pour compatibilité XHTML Strict + corrections de bugs (mais ya encore du boulot!!)
*
* Revision 1.3  2005/03/24 08:24:29  alex
* --
*
* Revision 1.2  2005/01/06 15:18:31  alex
* modification de la fonction de formulaire d'authentification
*
* Revision 1.1.1.1  2005/01/03 17:27:49  alex
* Import initial
*
* Revision 1.1  2005/01/03 17:18:49  alex
* retour vers la liste des participants après un ajout.
*
*
*
* +-- Fin du code ----------------------------------------------------------------------------------------+
*/
?>