Subversion Repositories Sites.tela-botanica.org

Rev

Rev 366 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
4 david 1
<?php
2
/*vim: set expandtab tabstop=4 shiftwidth=4: */
3
// +------------------------------------------------------------------------------------------------------+
4
// | PHP version 4.1                                                                                      |
5
// +------------------------------------------------------------------------------------------------------+
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
8
// | This library is free software; you can redistribute it and/or                                        |
9
// | modify it under the terms of the GNU Lesser General Public                                           |
10
// | License as published by the Free Software Foundation; either                                         |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
12
// |                                                                                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
16
// | Lesser General Public License for more details.                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
19
// | License along with this library; if not, write to the Free Software                                  |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
22
// CVS : $Id: annuaire.fonct.php,v 1.1 2005/03/24 08:46:07 alex Exp $
23
/**
24
* Fonctions du module annuaire
25
*
26
* Fonctions du module annuaire
27
*
28
*@package annuaire
29
//Auteur original :
30
*@author        Alexandre Granier <alexandre@tela-botanica.org>
31
//Autres auteurs :
32
*@author        Aucun
33
*@copyright     Tela-Botanica 2000-2004
34
*@version       $Revision: 1.1 $
35
// +------------------------------------------------------------------------------------------------------+
36
*/
37
 
38
// +------------------------------------------------------------------------------------------------------+
39
// |                                            ENTETE du PROGRAMME                                       |
40
// +------------------------------------------------------------------------------------------------------+
41
 
42
include_once "HTML/QuickForm.php" ;
43
 
44
// +------------------------------------------------------------------------------------------------------+
45
// |                                           LISTE de FONCTIONS                                         |
46
// +------------------------------------------------------------------------------------------------------+
47
 
48
 
49
function AUTH_formulaire_login() {
50
    $res = '';
51
    $url = preg_replace ('/&amp;/', '&', $GLOBALS['ann_url']->getURL()) ;
52
    $form = new HTML_QuickForm ('inscription', 'post', $url) ;
53
    $form->addElement ('text', 'username', ANN_EMAIL) ;
54
    $form->addElement ('password', 'password', ANN_MOT_DE_PASSE) ;
55
    $form->addElement('submit', 'valider', ANN_VALIDER);
56
 
57
    $res .= $form->toHTML() ;
58
 
59
    $res .= "<div>".ANN_TEXTE_PERDU."</div>\n" ;
60
    return $res;
61
}
62
 
63
/** function parcourrirAnnu ()  Affiche l'annuaire à partir d'une lettre
64
*
65
*
66
*
67
*	@return string HTML
68
*/
69
 
70
function parcourrirAnnu($event) {
71
 
72
    $res = '<div><table><tr>';
73
 
74
    // ecrire toutes les lettres avec un lien
75
    for ($i = 65 ; $i <91 ; $i++) {
76
        $res .= '<td><a style="font-size:15px;" href="'.$GLOBALS['ann_url']->getURL().'&amp;lettre=';
77
        $res .= chr($i) ;
78
        $res .= '">';
79
        $res .= chr($i) ;
80
        $res .= "</a></td>\n";
81
    }
82
    $res .= "</tr></table></div>\n";
83
 
84
    // si une lettre est selectionne
85
    if (!empty($_REQUEST['lettre'])) {
210 jpm 86
        $requete = "SELECT ".ANN_ANNUAIRE.".*, ".ANN_TABLE_PAYS.".* FROM ".ANN_ANNUAIRE.",".ANN_TABLE_PAYS." WHERE ".ANN_CHAMPS_PAYS." = ".ANN_GC_ID." AND ";
4 david 87
        if ($_REQUEST['lettre'] != "tous") $requete .= " ".ANN_CHAMPS_NOM." LIKE \"".$_REQUEST['lettre']."%\"" ;
88
        $requete .= " ORDER BY ".ANN_CHAMPS_NOM ;
89
 
90
        $res .= listes_inscrit ($requete, $GLOBALS['ann_url']->getURL(), $select, '', $GLOBALS['ann_db'], $niveau = 'pays').carto_texte_cocher().
91
                        carto_formulaire($_POST['titre'], $_POST['corps']) ;
92
    }
93
    return $res ;
94
}
95
 
96
/**
97
 *  Renvoie le code HTML de la liste des inscrits
98
 *  en fonction de la requete passé en parametre
99
 *
100
 * @return  Renvoie le code HTML de la liste des inscrits
101
 */
102
 
103
function listes_inscrit ($requete, $url, $select, $argument, &$db, $niveau = 'pays') {
104
    $res = "<div>";
365 jpm 105
    $res .= "<form action=\"$url?mailer=1&amp;lettre=".$_REQUEST['lettre']."\" method=\"post\" name=\"formmail\">\n
4 david 106
                <table id=\"table_inscrit\" class=\"table_cadre\">\n
107
                    <colgroup>
108
                        <col />
109
                        <col />
110
                        <col />
111
                        <col />
112
                        <col />
113
                        <col />
210 jpm 114
                        <col />
4 david 115
                    </colgroup>
116
                        <thead>\n
117
                                <th>&nbsp;</th>
118
                                <th>".ANN_NOM."</th>
119
                                <th>".ANN_PRENOM."</th>
120
                                <th>".ANN_DATE_INS."</th>
209 jpm 121
                                <th>".ANN_CP."</th>
4 david 122
                                <th>".ANN_VILLE."</th>
210 jpm 123
								<th>".ANN_PAYS."</th>
4 david 124
                        </thead>";
125
 
126
    $resultat= $GLOBALS['ann_db']->query($requete);
127
    if (DB::isError($resultat)) {
128
        die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
129
    }
130
    $indic=0;
131
    $i=1;
132
    while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
133
        if ($indic==0) {
134
            $res.="<tr class=\"ligne_impaire\">\n";
135
            $indic=1;
136
        }
137
        else {
138
            $res.="<tr class=\"ligne_paire\">\n";
139
            $indic=0;
140
        }
141
        $res.="<td><input type=\"checkbox\" name=\"select[]\" value=\"".$ligne[ANN_CHAMPS_MAIL]."\"></td>\n
187 jpm 142
                        <td>".strtoupper($ligne[ANN_CHAMPS_NOM])."&nbsp;</td>\n
143
                        <td>".str_replace(' - ', '-', ucwords(strtolower(str_replace('-', ' - ', $ligne[ANN_CHAMPS_PRENOM]))))."&nbsp;</td>\n
4 david 144
                        <td>".date("d m Y", strtotime($ligne[ANN_CHAMPS_DATE_INS]))."&nbsp;</td>\n
209 jpm 145
                        <td>".$ligne[ANN_CHAMPS_CODE_POSTAL]."&nbsp;</td>\n
210 jpm 146
                        <td>".strtoupper($ligne[ANN_CHAMPS_VILLE])."&nbsp;</td>\n
147
                        <td>".str_replace(' - ', '-', ucwords(strtolower(str_replace('-', ' - ', ($ligne[ANN_GC_NOM])))))."&nbsp;</td>\n" ;
4 david 148
        $res .= "</tr>\n";
149
    }
150
    $res .= "</table></div>\n";
151
    return $res ;
152
}
153
 
154
 
155
function carto_formulaire ($titre_mail="", $corps = "") {
156
    global $HTTP_USER_AGENT ;
181 jpm 157
    $res = "<h2 class=\"chapo\">".ANN_ENVOYER_MAIL."</h2>\n";
158
    $res .= '<p class="attention surveillance">'.ANN_SURVEILLANCE.'</p>' ;
159
    $res .= '<p class="information message_a_tous">'.sprintf(ANN_MESSAGE_A_TOUS, '<a href="'.ANN_URL_ACTUALITE.'">'.ANN_ACTUALITE.'</a>').'</p>' ;
160
    $res .= '<table>'."\n"
4 david 161
            .'<tr><td class="texte">'.ANN_SUJET.' :</td>'."\n"
162
            .'<td><input class="forml" type="text" name="titre_mail" size="60" value="'.$GLOBALS['titre_mail'].'"></td>'."\n"
163
            .'</tr><tr><td class="texte" valign="top">'.ANN_MESSAGE.'&nbsp;:&nbsp;</td>'."\n"
164
            .'<td><textarea class="forml" name="corps" rows="5" cols="60">'.$GLOBALS['corps'].'</textarea></td>'."\n"
165
            .'</tr><tr><td></td><td align="center">';
166
    if (ereg ("Gecko",$HTTP_USER_AGENT)) {
181 jpm 167
        $res.='<input class="spip_bouton" type="submit" value="'.ANN_ENVOYER.'" />';
4 david 168
    } else {
181 jpm 169
        $res.='<input class="spip_bouton" type="submit" onclick="javascript:confirmer();" value="'.ANN_ENVOYER.'" />';
4 david 170
    }
181 jpm 171
    $res.="</td>\n</tr>\n</table>\n</form>\n";
4 david 172
    return $res ;
173
}
174
 
175
 
176
/** function carto_texte_cocher ()
177
*
178
*
179
*	@return string  HTML
180
*/
181
 
182
function carto_texte_cocher () {
183
    $res .= '<div class="texte">'.ANN_CHECK_UNCHECK ;
184
    $res .= "&nbsp;<input type=\"checkbox\" name=\"selecttotal\" onclick=\"javascript:setCheckboxes('formmail');\"></div>";
185
    return $res ;
186
}
187
 
188
 
189
/** envoie_mail()
190
 *
191
 *
192
 * @return  envoie l'email
193
 */
194
 
195
function envoie_mail () {
196
    $requete = "select ".ANN_CHAMPS_MAIL." from ".ANN_ANNUAIRE.
197
            " where ".ANN_CHAMPS_ID."='".$GLOBALS['AUTH']->getAuthData (ANN_CHAMPS_ID)."'";
198
    $resultat = $GLOBALS['ann_db']->query($requete);
199
    if (DB::isError($resultat)) {
200
        die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo());
201
    }
202
    $ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
203
    $entete = "From: <".$ligne[ANN_CHAMPS_MAIL].">\n";
204
 
205
    $_POST['corps'] .= ANN_PIED_MESSAGE;
206
    $_POST['corps'] = stripslashes($_POST['corps']) ;
207
    $liste = "" ;
208
    foreach ($_POST['select'] as $key => $value) {
209
        mail ($value, stripslashes($_POST['titre_mail']), $_POST['corps'] , $entete) ;
210
        $liste .= $value."\n" ;
211
    }
212
 
213
    $_POST['corps'] .= "\n----------------------------------------------------------------------------";
368 jpm 214
    $_POST['corps'] .= "\n".ANN_MESSAGE_APPLI."\n" ;
4 david 215
    $_POST['corps'] .= "\n".ANN_MESSAGE_ENVOYE_A." :\n $liste" ;
216
 
365 jpm 217
    mail (ANN_MAIL_ADMIN, stripslashes($_POST['titre_mail']), $_POST['corps'], $entete);
4 david 218
    $_POST['corps'] = '';
219
    $_POST['titre_mail'] = '';
365 jpm 220
    return '<div class="information">'.ANN_MAIL_ENVOYER.'</div>' ;
4 david 221
}
222
 
223
/* +--Fin du code ----------------------------------------------------------------------------------------+
224
*
225
* $Log: annuaire.fonct.php,v $
226
* Revision 1.1  2005/03/24 08:46:07  alex
227
* version initiale
228
*
229
* Revision 1.2  2005/01/06 15:18:31  alex
230
* modification de la fonction de formulaire d'authentification
231
*
232
* Revision 1.1.1.1  2005/01/03 17:27:49  alex
233
* Import initial
234
*
235
* Revision 1.1  2005/01/03 17:18:49  alex
236
* retour vers la liste des participants après un ajout.
237
*
238
*
239
*
240
* +-- Fin du code ----------------------------------------------------------------------------------------+
241
*/
242
?>