Subversion Repositories Sites.gentiana.org

Rev

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