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