Subversion Repositories Sites.tela-botanica.org

Rev

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