Subversion Repositories Sites.gentiana.org

Rev

Rev 48 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
43 jpm 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
 
43
 
44
// +------------------------------------------------------------------------------------------------------+
45
// |                                           LISTE de FONCTIONS                                         |
46
// +------------------------------------------------------------------------------------------------------+
47
 
48
function AUTH_formulaire_login() {
49
    $res = '';
50
 
51
    $url = preg_replace ('/&amp;/', '&', $GLOBALS['ann_url']->getURL()) ;
52
 
53
    $form = new HTML_QuickForm ('inscription', 'post', $url) ;
54
    $form->addElement ('text', 'username', ANN_EMAIL) ;
55
    $form->addElement ('password', 'password', ANN_MOT_DE_PASSE) ;
56
    $form->addElement('submit', 'valider', ANN_VALIDER);
57
    $res .= $form->toHTML() ;
58
 
59
    $res .= '<p>'.ANN_TEXTE_PERDU.'</p>'."\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
function parcourrirAnnu($event) {
70
 
71
    $res = '<p id="annuaire_alphabet">';
72
 
73
    // Alphabet pour la rechercher par lettre du nom des inscrits
74
    for ($i = 65 ; $i <91 ; $i++) {
75
        $GLOBALS['ann_url']->addQueryString('lettre', chr($i));
76
        $url_lettre = $GLOBALS['ann_url']->getURL();
77
        $GLOBALS['ann_url']->removeQueryString('lettre');
78
        $res .= '<a href="'.$url_lettre.'">'.chr($i).'</a>&nbsp;'."\n";
79
    }
80
    $GLOBALS['ann_url']->addQueryString('lettre', 'tous');
81
    $url_lettre = $GLOBALS['ann_url']->getURL();
82
	$GLOBALS['ann_url']->removeQueryString('lettre');
83
    $res .= '<a href="'.$url_lettre.'">'.'Tous'.'</a>'."\n";
84
    $res .= '</p>'."\n";
85
 
86
    // Si une lettre est sélectionnée
87
    if (empty($_REQUEST['lettre'])) {
88
    	$_REQUEST['lettre'] = ANN_LETTRE_DEFAUT;
89
    }
90
    if (!empty($_REQUEST['lettre'])) {
91
        $requete = "SELECT ".ANN_ANNUAIRE.".*, ".ANN_TABLE_PAYS.".* FROM ".ANN_ANNUAIRE.",".ANN_TABLE_PAYS." WHERE ".ANN_CHAMPS_PAYS." = ".ANN_GC_ID." ";
92
        if ($_REQUEST['lettre'] != 'tous') {
93
        	$requete .= " AND ".ANN_CHAMPS_NOM." LIKE \"".$_REQUEST['lettre']."%\"" ;
94
        }
95
        $requete .= " ORDER BY ".ANN_CHAMPS_NOM ;
96
 
97
        $res .= listes_inscrit ($requete, $GLOBALS['ann_url']->getURL(), $select, '', $GLOBALS['ann_db'], $niveau = 'pays').
98
        		carto_texte_cocher().
99
                carto_formulaire($_POST['titre'], $_POST['corps']) ;
100
    }
101
    return $res;
102
}
103
 
104
/**
105
 *  Renvoie le code HTML de la liste des inscrits
106
 *  en fonction de la requete passé en parametre
107
 *
108
 * @return  Renvoie le code HTML de la liste des inscrits
109
 */
110
function listes_inscrit ($requete, $url, $select, $argument, &$db, $niveau = 'pays') {
111
    $resultat = $GLOBALS['ann_db']->query($requete);
112
    (DB::isError($resultat)) ? die($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) : '';
113
 
114
	if ($resultat->numRows() > 0) {
115
	    $res = "<form action=\"$url?mailer=1&amp;lettre=".$_REQUEST['lettre']."\" method=\"post\" name=\"formmail\">\n";
116
	    $res .= '<div id="annuaire" class="conteneur_table">
117
	                <table id="table_inscrit" class="table_cadre">
118
	                    <colgroup>
119
	                        <col />
120
	                        <col />
121
	                        <col />
122
	                        <col />
123
	                        <col />
124
	                        <col />
125
	                        <col />
126
	                    </colgroup>
127
	                        <thead class="entete_fixe">
128
	                        	<tr>
129
	                                <th>&nbsp;</th>
130
	                                <th>'.ANN_NOM.'</th>
131
	                                <th>'.ANN_PRENOM.'</th>
132
	                                <th>'.ANN_DATE_INS.'</th>
133
	                                <th>'.ANN_CP.'</th>
134
	                                <th>'.ANN_VILLE.'</th>
135
									<th>'.ANN_PAYS.'</th>
136
								</tr>
137
	                        </thead>
138
	                        <tbody class="contenu_deroulant">';
139
	    $indic = 0;
140
	    $i = 1;
141
	    while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
142
	        if ($indic==0) {
143
	            $res.="<tr class=\"ligne_impaire\">\n";
144
	            $indic=1;
145
	        } else {
146
	            $res.="<tr class=\"ligne_paire\">\n";
147
	            $indic=0;
148
	        }
149
	        $res.= "<td><input type=\"checkbox\" name=\"select[]\" value=\"".$ligne[ANN_CHAMPS_MAIL]."\" /></td>\n
150
	                        <td>".strtoupper($ligne[ANN_CHAMPS_NOM])."&nbsp;</td>\n
151
	                        <td>".str_replace(' - ', '-', ucwords(strtolower(str_replace('-', ' - ', $ligne[ANN_CHAMPS_PRENOM]))))."&nbsp;</td>\n
152
	                        <td>".date("d m Y", strtotime($ligne[ANN_CHAMPS_DATE_INS]))."&nbsp;</td>\n
153
	                        <td>".$ligne[ANN_CHAMPS_CODE_POSTAL]."&nbsp;</td>\n
154
	                        <td>".strtoupper($ligne[ANN_CHAMPS_VILLE])."&nbsp;</td>\n
155
	                        <td>".str_replace(' - ', '-', ucwords(strtolower(str_replace('-', ' - ', ($ligne[ANN_GC_NOM])))))."&nbsp;</td>\n" ;
156
	        $res .= "</tr>\n";
157
	    }
158
	    $res .= "</tbody></table></div>\n";
159
	} else {
160
		$res = '<p class="information">Aucun inscrit n\'a de nom commençant par '.$_REQUEST['lettre'].'</p>';
161
	}
162
    return $res;
163
}
164
 
165
 
166
function carto_formulaire ($titre_mail="", $corps = "") {
167
    $res = '<h2 class="chapo">'.ANN_ENVOYER_MAIL.'</h2>'."\n";
168
    $res .= '<p class="attention surveillance">'.ANN_SURVEILLANCE.'</p>' ;
169
    $res .= '<p class="information message_a_tous">'.sprintf(ANN_MESSAGE_A_TOUS, '<a href="'.ANN_URL_ACTUALITE.'">'.ANN_ACTUALITE.'</a>').'</p>' ;
170
    $res .= '<table>'."\n"
171
            .'<tr><td class="texte">'.ANN_SUJET.' :</td>'."\n"
172
            .'<td><input class="forml" type="text" name="titre_mail" size="60" value="'.$GLOBALS['titre_mail'].'"/></td>'."\n"
173
            .'</tr><tr><td class="texte" valign="top">'.ANN_MESSAGE.'&nbsp;:&nbsp;</td>'."\n"
174
            .'<td><textarea class="forml" name="corps" rows="5" cols="60">'.$GLOBALS['corps'].'</textarea></td>'."\n"
175
            .'</tr><tr><td></td><td align="center">';
176
    $res.='<input class="spip_bouton" type="submit" value="'.ANN_ENVOYER.'" />';
177
    $res .= '</td>'."\n";
178
	$res .= '</tr>'."\n";
179
	$res .= '</table>'."\n";
180
	$res .= '</form>'."\n";
181
    return $res ;
182
}
183
 
184
 
185
/** function carto_texte_cocher ()
186
*
187
*
188
*	@return string  HTML
189
*/
190
 
191
function carto_texte_cocher () {
192
    $res .= '<div class="texte">'.ANN_CHECK_UNCHECK ;
193
    $res .= "&nbsp;<input type=\"checkbox\" name=\"selecttotal\" onclick=\"javascript:setCheckboxes('formmail');\"/></div>";
194
    return $res ;
195
}
196
 
197
 
198
/** envoie_mail()
199
 *
200
 *
201
 * @return  envoie l'email
202
 */
203
 
204
function envoie_mail () {
205
    $requete = 	"select ".ANN_CHAMPS_MAIL." from ".ANN_ANNUAIRE.
206
            	" where ".ANN_CHAMPS_ID."='".$GLOBALS['AUTH']->getAuthData (ANN_CHAMPS_ID)."'";
207
    $resultat = $GLOBALS['ann_db']->query($requete);
208
    if (DB::isError($resultat)) {
209
        die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo());
210
    }
211
    $ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC);
212
    $entete = "From: <".$ligne[ANN_CHAMPS_MAIL].">\n";
213
 
214
    $_POST['corps'] .= ANN_PIED_MESSAGE;
215
    $_POST['corps'] = stripslashes($_POST['corps']) ;
216
    $liste = "" ;
217
    foreach ($_POST['select'] as $key => $value) {
218
        mail ($value, stripslashes($_POST['titre_mail']), $_POST['corps'] , $entete) ;
219
        $liste .= $value."\n" ;
220
    }
221
 
222
    $_POST['corps'] .= "\n----------------------------------------------------------------------------";
223
    $_POST['corps'] .= "\n".ANN_MESSAGE_APPLI."\n" ;
224
    $_POST['corps'] .= "\n".ANN_MESSAGE_ENVOYE_A." :\n $liste" ;
225
 
226
    mail (ANN_MAIL_ADMIN, stripslashes($_POST['titre_mail']), $_POST['corps'], $entete);
227
    $_POST['corps'] = '';
228
    $_POST['titre_mail'] = '';
229
    return '<div class="information">'.ANN_MAIL_ENVOYER.'</div>' ;
230
}
231
?>