Subversion Repositories Applications.papyrus

Rev

Rev 1289 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1289 Rev 1292
Line 6... Line 6...
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
6
// | Copyright (C) 2004 Tela Botanica (accueil@tela-botanica.org)                                         |
7
// +------------------------------------------------------------------------------------------------------+
7
// +------------------------------------------------------------------------------------------------------+
8
// | This library is free software; you can redistribute it and/or                                        |
8
// | This library is free software; you can redistribute it and/or                                        |
9
// | modify it under the terms of the GNU Lesser General Public                                           |
9
// | modify it under the terms of the GNU Lesser General Public                                           |
10
// | License as published by the Free Software Foundation; either                                         |
10
// | License as published by the Free Software Foundation; either                                         |
11
// | version 2.1 of the License, or (at your option) any later version.                                   |
11
// | version 2.1 of the License, or (at your option) any later veRrsion.                                   |
12
// |                                                                                                      |
12
// |                                                                                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
13
// | This library is distributed in the hope that it will be useful,                                      |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
14
// | but WITHOUT ANY WARRANTY; without even the implied warranty of                                       |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
15
// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                                    |
16
// | Lesser General Public License for more details.                                                      |
16
// | Lesser General Public License for more details.                                                      |
17
// |                                                                                                      |
17
// |                                                                                                      |
18
// | You should have received a copy of the GNU Lesser General Public                                     |
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                                  |
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                            |
20
// | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA                            |
21
// +------------------------------------------------------------------------------------------------------+
21
// +------------------------------------------------------------------------------------------------------+
22
// CVS : $Id: inscription.fonct.php,v 1.25 2007-04-04 15:15:22 neiluj Exp $
22
// CVS : $Id: inscription.fonct.php,v 1.26 2007-04-06 08:35:46 neiluj Exp $
23
// CVS : $Id: inscription.fonct.php,v 1.25 2007-04-04 15:15:22 neiluj Exp $
23
// CVS : $Id: inscription.fonct.php,v 1.26 2007-04-06 08:35:46 neiluj Exp $
24
/**
24
/**
25
* Fonctions du module inscription
25
* Fonctions du module inscription
26
*
26
*
27
* Fonctions du module inscription
27
* Fonctions du module inscription
28
*
28
*
29
*@package inscription
29
*@package inscription
30
//Auteur original :
30
//Auteur original :
31
*@author        Alexandre Granier <alexandre@tela-botanica.org>
31
*@author        Alexandre Granier <alexandre@tela-botanica.org>
32
//Autres auteurs :
32
//Autres auteurs :
33
*@author        Florian Schmitt <florian@ecole-et-nature.org>
33
*@author        Aucun
34
*@copyright     Tela-Botanica 2000-2004
34
*@copyright     Tela-Botanica 2000-2004
35
*@version       $Revision: 1.25 $ $Date: 2007-04-04 15:15:22 $
35
*@version       $Revision: 1.26 $ $Date: 2007-04-06 08:35:46 $
36
*@version       $Revision: 1.25 $ $Date: 2007-04-04 15:15:22 $
36
*@version       $Revision: 1.26 $ $Date: 2007-04-06 08:35:46 $
37
// +------------------------------------------------------------------------------------------------------+
37
// +------------------------------------------------------------------------------------------------------+
38
*/
38
*/
Line 39... Line 39...
39
 
39
 
40
// +------------------------------------------------------------------------------------------------------+
40
// +------------------------------------------------------------------------------------------------------+
41
// |                                            ENTETE du PROGRAMME                                       |
41
// |                                            ENTETE du PROGRAMME                                       |
Line 42... Line 42...
42
// +------------------------------------------------------------------------------------------------------+
42
// +------------------------------------------------------------------------------------------------------+
43
 
-
 
44
include_once 'inscription.fonct.wiki.php' ;
43
 
-
 
44
include_once 'inscription.fonct.wiki.php' ;
-
 
45
if (INS_UTILISE_SPIP) include_once 'inscription.fonct.spip.php' ;
-
 
46
require_once PAP_CHEMIN_RACINE.'api/pear/HTML/QuickForm.php' ;
Line 45... Line 47...
45
include_once 'inscription.class.php' ;
47
require_once PAP_CHEMIN_RACINE.'api/pear/HTML/QuickForm/checkbox.php' ;
46
if (INS_UTILISE_SPIP) include_once 'inscription.fonct.spip.php' ;
48
require_once PAP_CHEMIN_RACINE.'api/pear/HTML/QuickForm/password.php' ;
47
 
49
 
Line 48... Line 50...
48
// +------------------------------------------------------------------------------------------------------+
50
// +------------------------------------------------------------------------------------------------------+
49
// |                                           LISTE de FONCTIONS                                         |
51
// |                                           LISTE de FONCTIONS                                         |
209
    if (INS_UTILISE_SPIP) {
203
    if (INS_UTILISE_SPIP) {
210
        mod_inscription_spip($GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID), $valeur) ;
204
        mod_inscription_spip($GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID), $valeur) ;
211
    }
205
    }
212
}
206
}
Line 213... Line 207...
213
 
207
 
214
/** requete_annuaire () - Renvoie une chaine contenant les champs de l'annuaire avec leur valeur suite à le fonction process de QuickForm
208
/** requete_annuaire () - Renvoie une chaine contenant les champs de l'annuaire avec leur valeur suite à le fonction process de QuickForm
215
*
209
*
216
* @return   string  une requete du type champs="valeur",...
210
* @return   string  une requete du type champs="valeur",...
217
*/
-
 
218
 
-
 
219
function requete_annuaire($valeur) {
-
 
220
    $req = INS_CHAMPS_NOM.'="'.addslashes($valeur['nom']).'", ';
211
*/
-
 
212
 
-
 
213
function requete_annuaire($valeur, $maj = FALSE) {
-
 
214
    $req = INS_CHAMPS_NOM.'="'.addslashes($valeur['nom']).'", ';
-
 
215
    if (INS_UTILISE_WIKINI) {
-
 
216
    	$req .= INS_CHAMPS_NOM_WIKINI.'="'.genere_nom_wiki($valeur['nom']).'", ' ;
-
 
217
    }
-
 
218
    
-
 
219
    if($maj)
-
 
220
    {
-
 
221
    	$id = $GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID);
-
 
222
    	
-
 
223
    	if(!$id) die("erreur"); // ne devrai jamais arriver --julien
-
 
224
    	
Line -... Line 225...
-
 
225
    	$requete = 'SELECT * FROM '.INS_ANNUAIRE.' WHERE '.INS_ANNUAIRE.'.'
-
 
226
               .INS_CHAMPS_ID.'="'.$id.'"' ;          
-
 
227
    	$resultat = $GLOBALS['ins_db'] -> query($requete) ; 
-
 
228
    	if (DB::isError($resultat)) {
221
    if (isset($valeur['est_structure']) && $valeur['est_structure'] == 0) 
229
    		die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
-
 
230
    	}
-
 
231
 
-
 
232
    	$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
-
 
233
    } else 
-
 
234
    	$id_utilisateur = nextId(INS_ANNUAIRE, INS_CHAMPS_ID, $GLOBALS['ins_db']) ;
-
 
235
    
-
 
236
    $req .= INS_CHAMPS_MAIL.'="'.addslashes($valeur['email']).'", ' ;
-
 
237
    
-
 
238
    if(is_file($_FILES['image']['tmp_name']))
-
 
239
    {
-
 
240
    	if($maj && is_file($ligne[INS_CHAMPS_AVATAR]))
-
 
241
    		@unlink($ligne[INS_CHAMPS_AVATAR]);
222
    			$req .= INS_CHAMPS_PRENOM.'="'.addslashes($valeur['prenom']).'", ';
242
    	
-
 
243
    	$chemin_destination=INS_CHEMIN_APPLI.'images/'. ($maj ? $id : $id_utilisateur) .'_'.md5($_FILES['image']['name']).'.jpg';
-
 
244
	    move_uploaded_file($_FILES['image']['tmp_name'], $chemin_destination);
223
    // Initialisation de variable pour éviter des notices
245
	    
-
 
246
    } elseif(is_file($ligne[INS_CHAMPS_AVATAR]))
224
    foreach (array ('adresse_1', 'adresse_2', 'ville', 'telephone', 'fax', 'site') as $val) {
247
    	$chemin_destination=$ligne[INS_CHAMPS_AVATAR];
225
    	if (!isset ($valeur[$val])) $valeur[$val] = '' ;   	
248
 
226
    }
249
    $req .= INS_CHAMPS_PASSE.'="'.md5($valeur['mot_de_passe']).'", '.
-
 
250
            'a_description="'.addslashes($valeur['description']).'", '.
227
 
251
            'a_logo="'.$chemin_destination.'", '.
228
    $req .= INS_CHAMPS_MAIL.'="'.addslashes($valeur['email']).'", ' ;
252
            INS_CHAMPS_PAYS.'="'.addslashes($valeur['pays']).'", '.
229
    $req .= INS_CHAMPS_PASSE.'="'.md5($valeur['mot_de_passe']).'", '.
253
    	    'niveauscolaire="'.addslashes($valeur['nom_ref']).'", '.
230
            INS_CHAMPS_PAYS.'="'.addslashes($valeur['pays']).'", '.
254
            INS_CHAMPS_ADRESSE_1.'="'.addslashes($valeur['adresse_1']).'", '.
231
            INS_CHAMPS_ADRESSE_1.'="'.addslashes($valeur['adresse_1']).'", '.
255
            INS_CHAMPS_ADRESSE_2.'="'.addslashes($valeur['adresse_2']).'", '.
232
            INS_CHAMPS_ADRESSE_2.'="'.addslashes($valeur['adresse_2']).'", '.
256
            INS_CHAMPS_DATE_INSCRIPTION.'="'. 
Line 233... Line 257...
233
            INS_CHAMPS_DATE_INSCRIPTION.'=NOW(), '.
257
            	($maj ? $ligne[INS_CHAMPS_DATE_INSCRIPTION] : 'NOW()'). '", '.
234
            INS_CHAMPS_CODE_POSTAL.'="'.addslashes($valeur['cp']).'", '.
258
            INS_CHAMPS_CODE_POSTAL.'="'.addslashes($valeur['cp']).'", '.
Line 265... Line 289...
265
        } else {
289
        } else {
266
            $n_dpt = substr($valeur['cp'], 0, 2) ;
290
            $n_dpt = substr($valeur['cp'], 0, 2) ;
267
        }
291
        }
268
        $req .= ",".INS_CHAMPS_DEPARTEMENT."='$n_dpt'";
292
        $req .= ",".INS_CHAMPS_DEPARTEMENT."='$n_dpt'";
269
    }
293
    }
270
    if (INS_UTILISE_WIKINI && isset ($valeur['nom_wiki'])) $req .= ','.INS_CHAMPS_NOM_WIKINI.'="'.$valeur['nom_wiki'].'"';
-
 
271
    return $req ;
294
    return $req ;
272
}
295
}
Line 289... Line 312...
289
    	die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
312
    	die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
290
    }
313
    }
291
    $ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
314
    $ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
292
    $valeurs_par_defaut = array() ;
315
    $valeurs_par_defaut = array() ;
293
    $valeurs_par_defaut['email'] = $ligne[INS_CHAMPS_MAIL];
316
    $valeurs_par_defaut['email'] = $ligne[INS_CHAMPS_MAIL];
-
 
317
    $valeurs_par_defaut['description'] = $ligne['a_description'];
-
 
318
    $valeurs_par_defaut['image'] = $ligne['a_logo'];
294
    $valeurs_par_defaut['nom'] = $ligne[INS_CHAMPS_NOM];
319
    $valeurs_par_defaut['nom'] = $ligne[INS_CHAMPS_NOM];
295
    $valeurs_par_defaut['prenom'] = $ligne[INS_CHAMPS_PRENOM] ;
320
    $valeurs_par_defaut['prenom'] = $ligne[INS_CHAMPS_PRENOM] ;
296
    $valeurs_par_defaut['pays'] = $ligne[INS_CHAMPS_PAYS] ;
321
    $valeurs_par_defaut['pays'] = $ligne[INS_CHAMPS_PAYS] ;
-
 
322
    $valeurs_par_defaut['niveauscolaire'] = $ligne['niveauscolaire'];
297
    if (INS_UTILISE_WIKINI) {$valeurs_par_defaut['nomwiki'] = $ligne[INS_CHAMPS_NOM_WIKINI] ;}
323
    if (INS_UTILISE_WIKINI) {$valeurs_par_defaut['nomwiki'] = $ligne[INS_CHAMPS_NOM_WIKINI] ;}
298
    $valeurs_par_defaut['cp'] = $ligne[INS_CHAMPS_CODE_POSTAL] ;
324
    $valeurs_par_defaut['cp'] = $ligne[INS_CHAMPS_CODE_POSTAL] ;
299
    $valeurs_par_defaut['ville'] = $ligne[INS_CHAMPS_VILLE] ;
325
    $valeurs_par_defaut['ville'] = $ligne[INS_CHAMPS_VILLE] ;
300
    $valeurs_par_defaut['adresse_1'] = $ligne[INS_CHAMPS_ADRESSE_1] ;
326
    $valeurs_par_defaut['adresse_1'] = $ligne[INS_CHAMPS_ADRESSE_1] ;
301
    $valeurs_par_defaut['adresse_2'] = $ligne[INS_CHAMPS_ADRESSE_2] ;
327
    $valeurs_par_defaut['adresse_2'] = $ligne[INS_CHAMPS_ADRESSE_2] ;
302
    $valeurs_par_defaut['telephone'] = $ligne[INS_CHAMPS_TELEPHONE] ;
328
    $valeurs_par_defaut['telephone'] = $ligne[INS_CHAMPS_TELEPHONE] ;
303
    $valeurs_par_defaut['fax'] = $ligne[INS_CHAMPS_FAX] ;
-
 
304
    if (INS_CHAMPS_STRUCTURE != '' && isset($ligne[INS_CHAMPS_STRUCTURE])) {
-
 
305
    	$valeurs_par_defaut['structure'] = $ligne[INS_CHAMPS_STRUCTURE] ;
-
 
306
    	//$valeurs_par_defaut['type_structure'] = $ligne['a_type_structure'];	
-
 
307
    }
-
 
308
    $valeurs_par_defaut['site'] = $ligne[INS_CHAMPS_SITE_INTERNET] ;
329
    $valeurs_par_defaut['site'] = $ligne[INS_CHAMPS_SITE_INTERNET] ;
309
    $valeurs_par_defaut['lettre'] = $ligne[INS_CHAMPS_LETTRE] ;
330
    $valeurs_par_defaut['lettre'] = $ligne[INS_CHAMPS_LETTRE] ;
310
    $valeurs_par_defaut['visible'] = $ligne[INS_CHAMPS_VISIBLE] ;
331
    $valeurs_par_defaut['visible'] = $ligne[INS_CHAMPS_VISIBLE] ;
311
    $valeurs_par_defaut['sigle_structure'] = $ligne[INS_CHAMPS_SIGLE_STRUCTURE] ;
332
    $valeurs_par_defaut['sigle_structure'] = $ligne[INS_CHAMPS_SIGLE_STRUCTURE] ;
312
    if (INS_CHAMPS_NUM_AGREMENT != '') $valeurs_par_defaut['num_agrement'] = $ligne[INS_CHAMPS_NUM_AGREMENT] ;
-
 
313
    return $valeurs_par_defaut ;
333
    return $valeurs_par_defaut ;
314
}
334
}
315
 
335
 
316
 
336
 
317
/** info() - Renvoie une fiche d'information sur la personne ou la structure
337
/** info() - Renvoie une fiche d'information sur la personne ou la structure
318
* 
338
*
319
* @param  integer  identifiant de la fiche a afficher, mettre -1 pour voir sa propre fiche
-
 
320
* @param  text     nom de l'onglet de la fiche
-
 
321
*
-
 
322
* @return   text   Code HTML de la fiche
339
* @return   text   Code HTML de la fiche
323
*/
340
*/
324
function info($id=-1, $type_info='fiche') {
341
function info($id=-1) {
325
	if ($id==-1) $id=$GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID);
342
	if ($id==-1) $id=$GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID);
326
    $requete = 'SELECT * FROM '.INS_ANNUAIRE.' WHERE '.INS_ANNUAIRE.'.'
343
    	$requete = 'SELECT * FROM '.INS_ANNUAIRE.' WHERE '.INS_ANNUAIRE.'.'
327
               .INS_CHAMPS_ID.'="'.$id.'"' ;          
344
               .INS_CHAMPS_ID.'="'.$id.'"' ;          
328
    $resultat = $GLOBALS['ins_db'] -> query($requete) ; 
345
    $resultat = $GLOBALS['ins_db'] -> query($requete) ; 
329
    if (DB::isError($resultat)) {
346
    if (DB::isError($resultat)) {
330
    	die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
347
    	die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
331
    }
348
    }
332
 
349
 
333
    $ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
350
    $ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
334
    
-
 
335
    //voir la présentation de la fiche
-
 
336
    if ($type_info=='fiche') {
-
 
337
	    if ($ligne[INS_CHAMPS_EST_STRUCTURE] == 1) {
351
    if ($ligne[INS_CHAMPS_EST_STRUCTURE] == 1) {
338
	    	$res = '<h1>'.$ligne[INS_CHAMPS_NOM].'</h1>'."\n";
352
    	$res = '<h1>'.INS_FICHE_STRUCTURE.'</h1>'."\n" ;
339
	    	$res .= '<h2>'.INS_FICHE_STRUCTURE.'</h2>'."\n" ;		    
353
	    $res .= '<h2>'.$ligne[INS_CHAMPS_NOM].'</h2>'."\n";
340
		    $res .= '<ul class="affiche_infos">'."\n";
354
	    $res .= '<dl class="affiche_infos">'."\n";
341
		    $res .= ligne_inscription(INS_SIGLE_DE_LA_STRUCTURE, $ligne[INS_CHAMPS_SIGLE_STRUCTURE]) ;
355
	    $res .= ligne_inscription(INS_SIGLE_DE_LA_STRUCTURE, $ligne[INS_CHAMPS_SIGLE_STRUCTURE]) ;
342
		    if (INS_CHAMPS_NUM_AGREMENT != '') $res .= ligne_inscription(INS_NUM_AGREMENT, $ligne[INS_CHAMPS_NUM_AGREMENT]) ;
356
	    $res .= ligne_inscription(INS_NUM_AGREMENT, $ligne[INS_CHAMPS_NUM_AGREMENT]) ;
343
	    } else {
357
    } else {
344
	    	$res = '<h1>'.$ligne[INS_CHAMPS_PRENOM].' '.$ligne[INS_CHAMPS_NOM].'</h1>'."\n";
-
 
345
	    	$res .= '<h2>'.INS_FICHE_PERSONNELLE.'</h2>'."\n" ;	    	
358
    	$res = '<h1>'.INS_FICHE_PERSONNELLE.'</h1>'."\n" ;
346
	    	$res .= '<ul class="affiche_infos">'."\n";
-
 
347
	    }
-
 
348
	    
-
 
349
	    $res .= ligne_inscription(INS_ADRESSE_1, $ligne[INS_CHAMPS_ADRESSE_1]) ;
-
 
350
	    $res .= ligne_inscription(INS_ADRESSE_2, $ligne[INS_CHAMPS_ADRESSE_2]) ;
-
 
351
	    $res .= ligne_inscription(INS_CODE_POSTAL, $ligne[INS_CHAMPS_CODE_POSTAL]) ;
-
 
352
	    $res .= ligne_inscription(INS_VILLE, $ligne[INS_CHAMPS_VILLE]) ;
-
 
353
	    $pays = new ListeDePays($GLOBALS['ins_db']) ;
-
 
354
	    $res .= ligne_inscription(INS_PAYS, $pays->getNomPays($ligne[INS_CHAMPS_PAYS], INS_LANGUE_DEFAUT)) ;
-
 
355
	    $res .= ligne_inscription(INS_TELEPHONE, $ligne[INS_CHAMPS_TELEPHONE]) ;
-
 
356
	    $res .= ligne_inscription(INS_FAX, $ligne[INS_CHAMPS_FAX]) ;
-
 
357
	    if (INS_UTILISE_WIKINI) {
-
 
358
			$res .= ligne_inscription (INS_NOM_WIKI, $ligne[INS_CHAMPS_NOM_WIKINI]) ;
-
 
359
		}
-
 
360
	    if ($ligne[INS_CHAMPS_SITE_INTERNET]!='') {
-
 
361
	    	$res .= ligne_inscription(INS_SITE_INTERNET, '<a href="'.$ligne[INS_CHAMPS_SITE_INTERNET].'" onclick="javascript:window.open(this.href);return false;">'.$ligne[INS_CHAMPS_SITE_INTERNET].'</a>');
-
 
362
	    }
-
 
363
	    if ($GLOBALS['AUTH']->getAuth()) $res .= ligne_inscription(INS_EMAIL, '<a href="mailto:'.$ligne[INS_CHAMPS_MAIL].'">'.$ligne[INS_CHAMPS_MAIL].'</a>');
-
 
364
	    else $res .= '<br /><p class="zone_info">'.INS_PAS_IDENTIFIE.'</p>'."\n";
-
 
365
	    $res .= '</ul>'."\n";
-
 
366
	    if ($id==$GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID)) {
-
 
367
		    $res .= '<br />'."\n";
-
 
368
		    $res .= '<ul>'."\n";
-
 
369
		    if ($ligne[INS_CHAMPS_VISIBLE] == 1) {
-
 
370
		    	$res .= '<li>'.INS_VOUS_APPARAISSEZ.'</li>'."\n";
-
 
371
		    } else $res .= '<li>'.INS_VOUS_APPARAISSEZ_PAS.'</li>'."\n";
-
 
372
		    if (INS_CHAMPS_LETTRE != '') {
-
 
373
		    		if ($ligne[INS_CHAMPS_LETTRE] == 1) {
-
 
374
		    			$res .= '<li>'.INS_VOUS_RECEVEZ_LETTRE.'</li>'."\n";
-
 
375
		    		} else $res .= '<li>'.INS_VOUS_RECEVEZ_PAS_LETTRE.'</li>'."\n";
-
 
376
		    }
-
 
377
		    $res .= '</ul>'."\n";
-
 
378
		    $res .= '<br />'."\n";
-
 
379
		    $res .= '<ul>'."\n";;
-
 
380
		    $res .= '<li><a href="'.$GLOBALS['ins_url']->getURL().'&amp;action=modifier&amp;form_structure='.$ligne[INS_CHAMPS_EST_STRUCTURE].'">'.INS_MODIFIER_INSCRIPTION.'</a></li>'."\n" ;
-
 
381
		    $res .= '<li><a href="'.$GLOBALS['ins_url']->getURL().'&amp;action=supprimer&amp;form_structure='.$ligne[INS_CHAMPS_EST_STRUCTURE].'" onclick="javascript:return confirm(\''.INS_SUPPRIMER_INSCRIPTION.'?\');">'.INS_SUPPRIMER_INSCRIPTION.'</a></li>'."\n" ;
359
    	if(!empty($ligne[INS_CHAMPS_AVATAR]) && is_file($ligne[INS_CHAMPS_AVATAR]))
382
		    $res .= '<li><a href="'.$GLOBALS['ins_url']->getURL().'&amp;action=deconnexion">'.INS_DECONNEXION.'</a></li>'."\n" ;
-
 
383
		    $res .= '</ul>'."\n";
-
 
384
	    } 
-
 
385
	    
-
 
386
	//voir les abonnements presents dans les applis clientes    
-
 
387
    } elseif ($type_info=='abonnement') {
-
 
388
    	$res = '<h1>'.$ligne[INS_CHAMPS_PRENOM].' '.$ligne[INS_CHAMPS_NOM].'</h1>'."\n";
360
    		$res = '<img src="'. INS_URL_IMAGES . $ligne[INS_CHAMPS_AVATAR] .'" style="float:right;" alt="avatar de '.$ligne[INS_CHAMPS_NOM_WIKINI].'" />'."\n" ;
389
    	$res .= '<h2>'.INS_GESTION_DES_ABONNEMENTS.'</h2>'."\n" ;
-
 
Line 390... Line 361...
390
    	
361
    	
391
    	// Appel des actions d'abonnement des applications clientes
362
    	$res .= '<h2>'.$ligne[INS_CHAMPS_PRENOM].' '.$ligne[INS_CHAMPS_NOM].'</h2>'."\n";
392
        $d = dir(GEN_CHEMIN_CLIENT);
363
    	$res .= '<dl class="affiche_infos">'."\n";
393
        $abonnement='';
-
 
394
        $abonnements='';
364
    }
395
		while (false !== ($repertoire = $d->read())) {
365
    $res .= ligne_inscription(INS_ADRESSE_1, $ligne[INS_CHAMPS_ADRESSE_1]) ;
396
			if (file_exists(GEN_CHEMIN_CLIENT.$repertoire.GEN_SEP.'bibliotheque'.GEN_SEP.$repertoire.'.abonnement.inc.php')) {
366
    $res .= ligne_inscription(INS_ADRESSE_2, $ligne[INS_CHAMPS_ADRESSE_2]) ;
397
				require_once GEN_CHEMIN_CLIENT.$repertoire.GEN_SEP.'bibliotheque'.GEN_SEP.$repertoire.'.abonnement.inc.php' ;
367
    $res .= ligne_inscription(INS_CODE_POSTAL, $ligne[INS_CHAMPS_CODE_POSTAL]) ;
398
				$abonnements .= $abonnement;   
-
 
399
			}
-
 
400
		}
-
 
401
		$d->close();
368
    $res .= ligne_inscription(INS_VILLE, $ligne[INS_CHAMPS_VILLE]) ;
402
		$res .= $abonnements;
369
    $pays = new ListeDePays($GLOBALS['ins_db']) ;
403
		
-
 
404
    //voir les actus			
-
 
405
    } elseif ($type_info=='actus') {
370
    
406
    	$res = '<h1>'.$ligne[INS_CHAMPS_PRENOM].' '.$ligne[INS_CHAMPS_NOM].'</h1>'."\n";
371
    $res .= ligne_inscription(INS_PAYS, $pays->getNomPays($ligne[INS_CHAMPS_PAYS], INS_LANGUE_DEFAUT)) ;
407
    	$res .= '<h2>'.INS_ACTUALITES_DEPOSEES.'</h2>'."\n" ;
372
    $res .= ligne_inscription(INS_TELEPHONE, $ligne[INS_CHAMPS_TELEPHONE]) ;
408
    	require_once GEN_CHEMIN_CLIENT.'bazar'.GEN_SEP.'configuration'.GEN_SEP.'baz_config.inc.php';
373
    $res .= ligne_inscription(INS_FAX, $ligne[INS_CHAMPS_FAX]) ;
409
    	require_once GEN_CHEMIN_CLIENT.'bazar'.GEN_SEP.'bibliotheque'.GEN_SEP.'bazar.fonct.rss.php';
374
    $res .= ligne_inscription('&nbsp;', '&nbsp;') ;
410
    	$_GET['action']=1;
375
    if (INS_UTILISE_WIKINI) {
411
    	$res .= RSSversHTML(gen_RSS('', '', $id, 1, ''), 0, 'jma', 0);
376
		$res .= ligne_inscription (INS_NOM_WIKI, $ligne[INS_CHAMPS_NOM_WIKINI]) ;
412
    	
-
 
413
	//voir les ressources	
-
 
414
    } elseif ($type_info=='ressources') {
377
	}
415
    	$res = '<h1>'.$ligne[INS_CHAMPS_PRENOM].' '.$ligne[INS_CHAMPS_NOM].'</h1>'."\n";
378
    $res .= ligne_inscription(INS_EMAIL, $ligne[INS_CHAMPS_MAIL]);
416
    	$res .= '<h2>'.INS_RESSOURCES_ASSOCIEES.'</h2>'."\n" ;
379
    if ($ligne[INS_CHAMPS_SITE_INTERNET]!='') {
-
 
380
    	$res .= ligne_inscription(INS_SITE_INTERNET, '<a href="'.$ligne[INS_CHAMPS_SITE_INTERNET].'" onclick="javascript:window.open(this.href);return false;">'.$ligne[INS_CHAMPS_SITE_INTERNET].'</a>');
417
    	$requete = 'SELECT bf_id_fiche, bf_titre FROM bazar_fiche, bazar_appropriation WHERE  ba_ce_id_fiche=bf_id_fiche AND ba_ce_id_structure='.$id ;
381
    }
418
    	$resultat = $GLOBALS['ins_db'] -> query($requete) ;
382
    $res .= '</dl>'."\n";
419
    	$res .= '<ul>'."\n";
383
    $res .= '<br />'."\n";
420
    	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
-
 
421
			$res .= '<li><a href="'.INS_URL_BAZAR.'&amp;action=8&amp;id_fiche='.$ligne['bf_id_fiche'].'" onclick="window.open(this.href,\'_blank\');return false;">'.$ligne['bf_titre'].'</a></li>'."\n";
-
 
422
		}
384
    if ($id==$GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID)) {
423
		$res .= '</ul><br />'."\n";
-
 
424
    
385
	    $res .= '<br />'."\n";
425
    //voir les competences		    
386
	    $res .= '<ul>'."\n";
426
    } elseif ($type_info=='competences') {
387
	    if ($ligne[INS_CHAMPS_VISIBLE] == 1) {
427
    	$res = '<h1>'.$ligne[INS_CHAMPS_PRENOM].' '.$ligne[INS_CHAMPS_NOM].'</h1>'."\n";
388
	    	$res .= '<li>'.INS_VOUS_APPARAISSEZ.'</li>'."\n";
428
    	$res .= '<h2>'.INS_COMPETENCES_ASSOCIEES.'</h2>'."\n" ;
-
 
429
    }
389
	    } else $res .= '<li>'.INS_VOUS_APPARAISSEZ_PAS.'</li>'."\n";
430
    return $res ;
-
 
431
}
-
 
432
 
-
 
433
 
390
	    if ($ligne[INS_CHAMPS_LETTRE] == 1) {
434
/**	ligne_inscription() - Renvoie une ligne avec label et valeur
-
 
435
 *
-
 
436
 * @param string label Le label
-
 
437
 * @param string valeur
-
 
438
 * @return	string HTML
-
 
439
 */
391
	    	$res .= '<li>'.INS_VOUS_RECEVEZ_LETTRE.'</li>'."\n";
440
function ligne_inscription($label, $valeur) {
392
	    } else $res .= '<li>'.INS_VOUS_RECEVEZ_PAS_LETTRE.'</li>'."\n";
441
    if ($valeur == '') {
393
	    $res .= '</ul>'."\n";
442
        return;
-
 
443
    }
394
	    $res .= '<br />'."\n";
444
    if (($label == '')or($label == '&nbsp;')) {
395
	    $res .= '<ul>'."\n";;
445
    	return '<li>'."\n".$valeur."\n".'</li>'."\n" ;
396
	    $res .= '<li><a href="'.$GLOBALS['ins_url']->getURL().'&amp;action=modifier&amp;form_structure='.$ligne[INS_CHAMPS_EST_STRUCTURE].'">'.INS_MODIFIER_INSCRIPTION.'</a></li>'."\n" ;
446
    } else {
397
	    $res .= '<li><a href="'.$GLOBALS['ins_url']->getURL().'&amp;action=supprimer&amp;form_structure='.$ligne[INS_CHAMPS_EST_STRUCTURE].'" onclick="javascript:return confirm(\''.INS_SUPPRIMER_INSCRIPTION.'?\');">'.INS_SUPPRIMER_INSCRIPTION.'</a></li>'."\n" ;
-
 
398
	    $res .= '<li><a href="'.$GLOBALS['ins_url']->getURL().'&amp;action=deconnexion">'.INS_DECONNEXION.'</a></li>'."\n" ;
447
    	return '<li>'."\n".'<strong>'.$label.' : </strong>'."\n".$valeur."\n".'</li>'."\n" ;    	
399
	    $res .= '</ul>'."\n";
-
 
400
    }
-
 
401
    $res .=  '{{Syndication titre="Les fiches associ&eacute;es &agrave; ce participant" url="http://ekotribu.localhost/papyrus.php?menu=48&action=18&emetteur='. $ligne[INS_CHAMPS_ID].'" nb=0 nouvellefenetre=0 formatdate="jma"}}';
-
 
402
    
448
    }
403
    return $res ;
-
 
404
}
-
 
405
 
-
 
406
 
-
 
407
/**	ligne_inscription() - Renvoie une ligne avec label et valeur
-
 
408
 *
-
 
409
 * @param string label Le label
-
 
410
 * @param string valeur
-
 
411
 * @return	string HTML
-
 
412
 */
-
 
413
function ligne_inscription($label, $valeur) {
-
 
414
    if ($valeur == '') {
-
 
415
        return;
-
 
416
    }
-
 
417
    if (($label == '')or($label == '&nbsp;')) {
-
 
418
    	return '<dt>&nbsp;</dt>'."\n".'<dd>'.$valeur.'</dd>'."\n" ;
-
 
419
    } else {
-
 
420
    	return '<dt>'.$label.' : </dt>'."\n".'<dd>'.$valeur.'</dd>'."\n" ;    	
-
 
421
    }
449
}
422
}
450
 
423
 
451
 
424
 
452
/** Renvoie vrai si l'email passé en paramètre n'est pas déjà dans l'annuaire
425
/** Renvoie vrai si l'email passé en paramètre n'est pas déjà dans l'annuaire
453
*   ou si, en cas de modification d'inscription, l'inscrit ne modifie pas son email
426
*   ou si, en cas de modification d'inscription, l'inscrit ne modifie pas son email
454
*
427
*
455
*   @return boolean 
428
*   @return boolean 
456
*/
429
*/
457
function verif_doublonMail($mail, $id = '') {
430
function verif_doublonMail($mail, $id = '') {
458
	if ($id == '') {
431
	if ($id == '') {
459
		if (isset ($GLOBALS['AUTH'])) {
432
		if (isset ($GLOBALS['AUTH'])) {
460
			$id = $GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID) ;
433
			$id = $GLOBALS['AUTH']->getAuthData(INS_CHAMPS_ID) ;
461
		}
434
		}
543
    return true ;
607
    return $nom_wiki ;
Line 544... Line 608...
544
}
608
}
-
 
609
 
545
 
610
/**
546
/**
611
 *	Cette fonction supprime les caractères autres que asccii et les chiffres
547
 *
-
 
548
 * @global  ins_db  Un pointeur vers un objet PEAR::DB connecté
612
 *
Line 549... Line -...
549
 * @return
-
 
550
 */
-
 
551
 
-
 
552
function envoie_mail() //A COMPLETER!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-
 
553
{
-
 
554
    include_once PAP_CHEMIN_RACINE.'api/pear/Mail/mime.php' ;
-
 
555
    include_once PAP_CHEMIN_RACINE.'api/pear/Mail.php' ;
-
 
556
    $crlf="\n";
613
 * @return	string la chaine épurée
557
    
-
 
558
    $headers ['From'] = INS_MAIL_ADMIN_APRES_INSCRIPTION ;
-
 
559
    $headers ['Subject'] = INS_MAIL_COORD_SUJET ;
614
 */
560
    $headers ['Reply-To'] = INS_MAIL_ADMIN_APRES_INSCRIPTION ;
-
 
561
    
-
 
562
    $mime = new Mail_mime($crlf);
-
 
563
    
615
 
564
    $requete = "select *, ".INS_CHAMPS_LABEL_PAYS." from ".INS_ANNUAIRE.",".INS_TABLE_PAYS.
-
 
565
            " where ".INS_CHAMPS_MAIL."=\"".$GLOBALS['AUTH']->getUsername()."\"".
616
function trim_non_ascii ($nom) {
566
            " and ".INS_CHAMPS_ID_PAYS."=".INS_CHAMPS_PAYS;
617
    $premiere_lettre = true ;
567
 
-
 
568
    $resultat = $GLOBALS['ins_db']->query($requete) ;
618
    for ($i = 0; $i <= strlen ($nom); $i++) {
569
    if (DB::isError ($resultat)) {
-
 
570
        die ("Echec de la requete : $requete<br />".$resultat->getMessage()) ;
619
        if (!preg_match ('/[a-zA-Z0-9]/', $nom[$i])) {
571
    }
-
 
572
    $ligne  = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
-
 
573
    $body_entete = INS_MAIL_COORD_CORPS."\n" ;
-
 
574
    $body = "mail : ".$ligne[INS_CHAMPS_MAIL]."\n" ;
620
            $nom[$i] = '_' ;
575
    $body .= "------------------------------------------\n";
-
 
576
    $body .= INS_NOM.": ".unhtmlentities($ligne[INS_CHAMPS_NOM])." \n" ;
-
 
577
    $body .= INS_PRENOM.' : '.unhtmlentities($ligne[INS_CHAMPS_PRENOM])." \n" ;
-
 
578
    $body .= INS_PAYS." : ".unhtmlentities($ligne[INS_CHAMPS_LABEL_PAYS])." \n" ;
621
        }
579
    $body .= "-------------------------------------------\n" ;
622
    // remplacement de la première lettre en majuscule
580
    
-
 
581
    $mime->setTXTBody($body);
623
        if (preg_match ('/[a-zA-Z]/', $nom[$i]) && $premiere_lettre) {
582
    $mime->setHTMLBody(info()) ;
-
 
583
    
-
 
584
    $body = $mime->get();
-
 
585
    $headers = $mime->headers($headers);
-
 
586
    
-
 
587
    $mail = & Mail::factory('mail') ;
-
 
588
    
624
            $nom[$i] = strtoupper ($nom[$i]) ;
589
    $mail -> send ($ligne[INS_CHAMPS_MAIL], $headers, $body) ;
-
 
590
    
625
            $premiere_lettre = false ;
591
        // Envoi du mail aux administrateur du site
626
        } else {
592
    foreach ($GLOBALS['mail_admin'] as $administrateur) {
-
 
593
        $mail -> send ($administrateur, $headers, $body) ;
-
 
594
    }
627
            if (preg_match ('/[a-zA-Z]/', $nom[$i])) {
595
    if (PEAR::isError($mail)) {
628
                $nom[$i] = strtolower ($nom[$i]) ;
-
 
629
            }
596
        echo 'erreur d\'envoi' ;
630
        }
597
        return false ;
631
    }
Line -... Line 632...
-
 
632
    $nom = preg_replace ('/_/', '', $nom) ;
-
 
633
    return $nom ;
-
 
634
}
-
 
635
 
-
 
636
//function get_wiki_name($nom)
-
 
637
//{
-
 
638
//	$temp = explode('', $nom);
-
 
639
//	$count = 0;
-
 
640
//	$final = NULL;
-
 
641
//	foreach($temp as $letter)
-
 
642
//	{
-
 
643
//		if(preg_match ('/[a-zA-Z0-9]/', $letter)) {
-
 
644
//            $final .= (($count == 0 || $count == (strlen($nom) - 1)) ? strtoupper($letter) : strtolower($letter));
Line 598... Line -...
598
    }
-
 
599
    return true ;
-
 
600
}
-
 
601
 
-
 
602
 
-
 
603
/**
645
//        }
604
 *  Génère un nom wiki valide à partir des données saisies par l'utilisateur
-
 
605
 *  fait une requete dans la base
-
 
606
 *
646
//	}
607
 * UPDATE: modification de la fonction pour propretée du titre / nom --julien
647
//	return($final);
608
 * @return  string un nom wiki valide
648
//}
609
 */
649
 
610
 
650
// fonction révisée de get_wiki_name() --julien
611
function genere_nom_wiki($nom, $spaces = TRUE)
651
function get_wiki_name($nom)
612
{
652
{
613
	// traitement des accents
653
	// traitement des accents
614
	$nom = str_replace(array('é','è','ë','ê','É','È','Ë','Ê','&','£'), 'e', $nom);
654
	$nom = str_replace(array('é','è','ë','ê','É','È','Ë','Ê','&','£'), 'e', $nom);
615
	$nom = str_replace(array('à','ä','â','Â','Ä','À','@'), 'a', $nom);
655
	$nom = str_replace(array('à','ä','â','Â','Ä','À','@'), 'a', $nom);
Line 616... Line 656...
616
	$nom = str_replace(array('ç','Ç'), 'c', $nom);
656
	$nom = str_replace(array('ç','Ç'), 'c', $nom);
Line 617... Line 657...
617
	$nom = str_replace(array('ÿ','¾'), 'y', $nom);
657
	$nom = str_replace(array('ÿ','¾'), 'y', $nom);
618
	$nom = str_replace(array('ô','ö','ò','Ô','Ò','Ö'), 'o', $nom);
658
	$nom = str_replace(array('ô','ö','ò','Ô','Ò','Ö'), 'o', $nom);
619
	$nom = str_replace(array('ï','î','ì','Î','Ï','Ì'), 'i', $nom);
659
	$nom = str_replace(array('ï','î','ì','Î','Ï','Ì'), 'i', $nom);
620
	$nom = str_replace('$', 's', $nom);
660
	$nom = str_replace('$', 's', $nom);
621
    
661
    
622
	$temp = str_split($nom);
662
	$temp = mb_str_split($nom);
623
	
663
	
624
	$count = 0;
664
	$count = 0;
625
	$final = NULL;
665
	$final = NULL;
626
	foreach($temp as $letter)
666
	foreach($temp as $letter)
627
	{
667
	{
628
		if(preg_match('/([[:space:]]|[[:punct:]])/', $letter))
668
		if(preg_match('/([[:space:]]|[[:punct:]])/', $letter))
Line 640... Line 680...
640
 	// sinon retour du nom formaté
680
 	// sinon retour du nom formaté
641
	return($final);
681
	return($final);
642
}
682
}
Line 643... Line -...
643
 
-
 
644
 
-
 
645
/**
-
 
646
 *	Cette fonction supprime les caractères autres que asccii et les chiffres
-
 
647
 *
-
 
648
 * @return	string la chaine épurée
-
 
649
 */
-
 
650
 
-
 
651
function trim_non_ascii ($nom) {
-
 
652
    $premiere_lettre = true ;
-
 
653
    for ($i = 0; $i < strlen ($nom); $i++) {
-
 
654
        if (!preg_match ('/[a-zA-Z0-9]/', $nom[$i])) {
-
 
655
            $nom[$i] = '_' ;
-
 
656
        }
-
 
657
    // remplacement de la première lettre en majuscule
-
 
658
        if (preg_match ('/[a-zA-Z]/', $nom[$i]) && $premiere_lettre) {
-
 
659
            $nom[$i] = strtoupper ($nom[$i]) ;
-
 
660
            $premiere_lettre = false ;
-
 
661
        } else {
-
 
662
            if (preg_match ('/[a-zA-Z]/', $nom[$i])) {
-
 
663
                $nom[$i] = strtolower ($nom[$i]) ;
-
 
664
            }
-
 
665
        }
-
 
666
    }
-
 
667
    $nom = preg_replace ('/_/', '', $nom) ;
-
 
668
    return $nom ;
-
 
669
}
683
 
670
 
684
 
671
// For users prior to PHP 4.3.0 you may do this:
685
// For users prior to PHP 4.3.0 you may do this:
672
function unhtmlentities($string)
686
function unhtmlentities($string)
673
{
687
{
Line 734... Line 748...
734
}
748
}
Line 735... Line 749...
735
 
749
 
736
/* +--Fin du code ----------------------------------------------------------------------------------------+
750
/* +--Fin du code ----------------------------------------------------------------------------------------+
737
*
751
*
738
* $Log: not supported by cvs2svn $
-
 
739
* Revision 1.24  2007/01/04 16:37:27  alexandre_tb
-
 
740
* ajout d'un test pour savoir si la fonction inscription_validee existe déjà (peut être inutile à vérifier)
-
 
741
*
-
 
742
* Revision 1.23  2006/12/01 13:23:15  florian
-
 
743
* integration annuaire backoffice
-
 
744
*
-
 
745
* Revision 1.22  2006/10/05 13:53:53  florian
-
 
746
* amélioration des fichiers sql
-
 
747
*
-
 
748
* Revision 1.21  2006/09/20 13:10:01  alexandre_tb
-
 
749
* Ajout d'un test sur la lettre d'actualité
-
 
750
*
-
 
751
* Revision 1.20  2006/07/06 10:33:58  alexandre_tb
-
 
752
* Suppression d'un warning
-
 
753
*
-
 
754
* Revision 1.19  2006/07/04 09:39:27  alexandre_tb
-
 
755
* correction d'un bug mineur
-
 
756
*
-
 
757
* Revision 1.18  2006/06/01 14:42:20  alexandre_tb
-
 
758
* suppression d'un commentaire inutile
-
 
759
*
-
 
760
* Revision 1.17  2006/04/28 12:44:05  florian
-
 
761
* integration bazar
-
 
762
*
-
 
763
* Revision 1.16  2006/04/11 08:41:41  alexandre_tb
-
 
764
* Ajout du champs nom wiki dans le formulaire si la constante INS_GENERE_NOM_WIKI n'est pas activé
-
 
765
*
-
 
766
* Revision 1.15  2006/04/10 14:01:36  florian
-
 
767
* uniformisation de l'appli bottin: plus qu'un fichier de fonctions
-
 
768
*
-
 
769
* Revision 1.14  2006/04/04 12:23:05  florian
-
 
770
* modifs affichage fiches, généricité de la carto, modification totale de l'appli annuaire
-
 
771
*
-
 
772
* Revision 1.13  2006/03/21 10:25:33  alexandre_tb
-
 
773
* ajout d'un template pour le mail de confirmation
-
 
774
*
-
 
775
* Revision 1.12  2006/03/15 11:02:35  alexandre_tb
-
 
776
* ajout de l'insertion du prénom qui avait disparu
-
 
777
*
-
 
778
* Revision 1.11  2006/03/02 16:57:31  alexandre_tb
-
 
779
* correction appel au générateur de nom wiki
-
 
780
*
-
 
781
* Revision 1.10  2006/02/28 14:02:20  alexandre_tb
-
 
782
* suppression des insertion dans les tables du bazar
-
 
783
*
-
 
784
* Revision 1.9  2006/02/14 10:19:10  alexandre_tb
-
 
785
* Mise en place des templates
-
 
786
* CREATE TABLE `inscription_template` (
-
 
787
*   `it_id_template` smallint(5) unsigned NOT NULL default '0',
-
 
788
*   `it_i18n` varchar(5) NOT NULL default '',
-
 
789
*   `it_template` text NOT NULL,
-
 
790
*   PRIMARY KEY  (`it_id_template`)
-
 
791
* ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
-
 
792
*
752
* $Log: not supported by cvs2svn $
793
* Revision 1.8  2006/01/02 09:51:38  alexandre_tb
753
* Revision 1.8  2006/01/02 09:51:38  alexandre_tb
794
* généralisation du code et intégration au bottin
754
* généralisation du code et intégration au bottin
795
*
755
*
796
* Revision 1.7  2005/12/19 13:19:07  alexandre_tb
756
* Revision 1.7  2005/12/19 13:19:07  alexandre_tb