Subversion Repositories Applications.bazar

Rev

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

Rev 77 Rev 79
Line 17... Line 17...
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: bazar.fonct.php,v 1.35 2006-01-18 11:06:51 florian Exp $
22
// CVS : $Id: bazar.fonct.php,v 1.36 2006-01-19 17:42:11 florian Exp $
23
/**
23
/**
24
*
24
*
25
* Fonctions du module bazar
25
* Fonctions du module bazar
26
* 
26
* 
27
*
27
*
Line 29... Line 29...
29
//Auteur original :
29
//Auteur original :
30
*@author        Alexandre Granier <alexandre@tela-botanica.org>
30
*@author        Alexandre Granier <alexandre@tela-botanica.org>
31
*@author        Florian Schmitt <florian@ecole-et-nature.org>
31
*@author        Florian Schmitt <florian@ecole-et-nature.org>
32
//Autres auteurs :
32
//Autres auteurs :
33
*@copyright     Tela-Botanica 2000-2004
33
*@copyright     Tela-Botanica 2000-2004
34
*@version       $Revision: 1.35 $ $Date: 2006-01-18 11:06:51 $
34
*@version       $Revision: 1.36 $ $Date: 2006-01-19 17:42:11 $
35
// +------------------------------------------------------------------------------------------------------+
35
// +------------------------------------------------------------------------------------------------------+
36
*/
36
*/
Line 37... Line 37...
37
 
37
 
38
// +------------------------------------------------------------------------------------------------------+
38
// +------------------------------------------------------------------------------------------------------+
Line 567... Line 567...
567
		$formtemplate->addRule('accept_condition', BAZ_ACCEPTE_CONDITIONS_REQUIS, 'required', '', 'client') ;
567
		$formtemplate->addRule('accept_condition', BAZ_ACCEPTE_CONDITIONS_REQUIS, 'required', '', 'client') ;
568
		$formtemplate->addElement('submit', 'valider', BAZ_VALIDER);
568
		$formtemplate->addElement('submit', 'valider', BAZ_VALIDER);
569
	}
569
	}
570
	//affichage du formulaire si conditions acceptées
570
	//affichage du formulaire si conditions acceptées
571
	else {		
571
	else {		
572
	//Parcours du fichier de templates, pour mettre les champs specifiques
572
	//Parcours du fichier de templates, pour mettre les champs specifiques	
573
	
-
 
574
	$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
573
	$tableau=baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
-
 
574
	if ($mode=='modification') {
-
 
575
		//Ajout des valeurs par defaut
-
 
576
		$valeurs_par_defaut = baz_valeurs_fiche($GLOBALS['_BAZAR_']['id_fiche']) ;
575
	for ($i=0; $i<count($tableau); $i++) {
577
		for ($i=0; $i<count($tableau); $i++) {
-
 
578
			if (($tableau[$i]['type']=='liste')or($tableau[$i]['type']=='checkbox')) {
-
 
579
				$def=$tableau[$i]['type'].$tableau[$i]['nom_bdd'];
-
 
580
			}
-
 
581
			else {
-
 
582
				$def=$tableau[$i]['nom_bdd'];
-
 
583
			}
-
 
584
			$tableau[$i]['type']($formtemplate, $tableau[$i]['nom_bdd'], $tableau[$i]['label'], $tableau[$i]['limite1'],
-
 
585
		                         $tableau[$i]['limite2'], $valeurs_par_defaut[$def], $tableau[$i]['table_source'], $tableau[$i]['obligatoire']) ;		           
-
 
586
		 }
-
 
587
	}
-
 
588
	else {
-
 
589
		for ($i=0; $i<count($tableau); $i++) {
576
		$tableau[$i]['type']($formtemplate, $tableau[$i]['nom_bdd'], $tableau[$i]['label'], $tableau[$i]['limite1'],
590
			$tableau[$i]['type']($formtemplate, $tableau[$i]['nom_bdd'], $tableau[$i]['label'], $tableau[$i]['limite1'],
577
		                     $tableau[$i]['limite2'], $tableau[$i]['defaut'], $tableau[$i]['table_source'], $tableau[$i]['obligatoire']) ;		
591
		                         $tableau[$i]['limite2'], $tableau[$i]['defaut'], $tableau[$i]['table_source'], $tableau[$i]['obligatoire']) ;
-
 
592
		 }
578
	}
593
	}
579
	
-
 
580
	$formtemplate->addElement('hidden', 'typeannonce', $GLOBALS['_BAZAR_']['id_typeannonce']);
594
	$formtemplate->addElement('hidden', 'typeannonce', $GLOBALS['_BAZAR_']['id_typeannonce']);
581
	$formtemplate->addElement('submit', 'valider', BAZ_VALIDER);
595
	$formtemplate->addElement('submit', 'valider', BAZ_VALIDER);
Line 582... Line 596...
582
	
596
	
583
	if ($mode=='modification') {
597
	if ($mode=='modification') {
584
		//initialisation de la variable globale id_fiche
598
		//initialisation de la variable globale id_fiche
585
		$GLOBALS['_BAZAR_']['id_fiche'] = $_REQUEST['id_fiche'];
-
 
586
		
-
 
587
		//Ajout des valeurs par defaut
-
 
588
		$formtemplate->setDefaults(baz_valeurs_fiche($GLOBALS['_BAZAR_']['id_fiche'])) ;
-
 
589
				
599
		$GLOBALS['_BAZAR_']['id_fiche'] = $_REQUEST['id_fiche'];								
590
		//preparation des formulaires supplementaires
600
		//preparation des formulaires supplementaires
591
		//AJOUTER UNE IMAGE
601
		//AJOUTER UNE IMAGE
592
		$lien_formulaire=$GLOBALS['_BAZAR_']['url'];
602
		$lien_formulaire=$GLOBALS['_BAZAR_']['url'];
593
		$lien_formulaire->addQueryString('action', BAZ_ACTION_MODIFIER);
603
		$lien_formulaire->addQueryString('action', BAZ_ACTION_MODIFIER);
Line 1192... Line 1202...
1192
	$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
1202
	$ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC) ;
1193
	$valeurs_fiche = array() ;
1203
	$valeurs_fiche = array() ;
1194
	$tableau = baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
1204
	$tableau = baz_valeurs_template($GLOBALS['_BAZAR_']['template']);
1195
	for ($i=0; $i<count($tableau); $i++) {
1205
	for ($i=0; $i<count($tableau); $i++) {
1196
	     if ($tableau[$i]['type']!='labelhtml') {
1206
	     if ($tableau[$i]['type']!='labelhtml') {
-
 
1207
	     	if (($tableau[$i]['type']=='liste')or($tableau[$i]['type']=='checkbox')) {
-
 
1208
	     		$requete = 'SELECT bfvl_valeur FROM bazar_fiche_valeur_liste WHERE bfvl_ce_fiche='.$idfiche.
-
 
1209
				' AND  bfvl_ce_liste='.$tableau[$i]['nom_bdd'];
-
 
1210
				$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
-
 
1211
				if (DB::isError ($resultat)) {
-
 
1212
					die ($resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
-
 
1213
				}
-
 
1214
				$nb=0;$val='';
-
 
1215
                while ($result = $resultat->fetchRow()) {
-
 
1216
                	if ($nb>0) $val .= ', ';
-
 
1217
                	$val .= $result[0];
-
 
1218
                	$nb++;
-
 
1219
                }
-
 
1220
	     		$valeurs_fiche[$tableau[$i]['type'].$tableau[$i]['nom_bdd']] = $val;
-
 
1221
	     	}
-
 
1222
	     	else {
1197
		 $valeurs_fiche[$tableau[$i]['nom_bdd']] = stripslashes($ligne[$tableau[$i]['nom_bdd']]);
1223
	     		$valeurs_fiche[$tableau[$i]['nom_bdd']] = stripslashes($ligne[$tableau[$i]['nom_bdd']]);
-
 
1224
	     	}
1198
	     }
1225
	     }	 
1199
	}
1226
	}
1200
	return $valeurs_fiche;
1227
	return $valeurs_fiche;
1201
}
1228
}
Line 1202... Line -...
1202
 
-
 
1203
 
-
 
1204
/** baz_rechercher() affiche le formulaire de recherche d'annonces
-
 
1205
*
-
 
1206
*   @return  string    le code HTML à afficher
-
 
1207
*/
-
 
1208
//function baz_rechercher() {
-
 
1209
//	$res= '<h2>'.BAZ_RECHERCHER_DES_ANNONCES.'</h2>'."\n";
-
 
1210
//	
-
 
1211
//	$GLOBALS['_BAZAR_']['url']->addQueryString('action', BAZ_RECHERCHER_ANNONCE);
-
 
1212
//	$lien_formulaire=preg_replace ('/&amp;/', '&', $GLOBALS['_BAZAR_']['url']->getURL()) ;
-
 
1213
//	$formtemplate = new HTML_QuickForm('formulaire', 'post', $lien_formulaire) ;
-
 
1214
//	
-
 
1215
//	//requete pour obtenir l'id et le label des types d'annonces
-
 
1216
//	$requete = 'SELECT bn_label_nature '.
-
 
1217
//	           'FROM bazar_nature WHERE bn_ce_id_menu='.$GLOBALS['_GEN_commun']['info_menu']->gm_id_menu.
-
 
1218
//		   '  or  bn_ce_id_menu=0 ORDER BY bn_label_nature ASC';
-
 
1219
//	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
-
 
1220
//	if (DB::isError($resultat)) {
-
 
1221
//		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
-
 
1222
//	}
-
 
1223
//	$type_annonce_select['toutes']=BAZ_TOUTES;
-
 
1224
//	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
-
 
1225
//		$type_annonce_select[$ligne['bn_label_nature']] = $ligne['bn_label_nature'];
-
 
1226
//	}
-
 
1227
//	$option=array('style'=>'width: 195px;', 'onchange'=>'this.form.submit();');
-
 
1228
//	$formtemplate->addElement ('select', 'type_annonce', BAZ_TYPEANNONCE, $type_annonce_select, $option) ;
-
 
1229
//	
-
 
1230
//	//requete pour obtenir l'id, le nom et prénom de toutes les personnes ayant une fiche publiée actuellement
-
 
1231
//	$requete = 'SELECT '.BAZ_CHAMPS_ID.', '.BAZ_CHAMPS_NOM.', '.BAZ_CHAMPS_PRENOM.' '.
-
 
1232
//	           'FROM bazar_fiche,'.BAZ_ANNUAIRE.' '.
-
 
1233
//		   'WHERE bf_statut_fiche=1 AND bf_date_debut_validite_fiche<=NOW() AND bf_date_fin_validite_fiche>=NOW() AND bf_ce_utilisateur='.BAZ_CHAMPS_ID.' '.
-
 
1234
//		   'ORDER BY '.BAZ_CHAMPS_NOM.' ASC';
-
 
1235
//	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
-
 
1236
//	if (DB::isError($resultat)) {
-
 
1237
//		die ($resultat->getMessage().$resultat->getDebugInfo()) ;
-
 
1238
//	}
-
 
1239
//	$personnes_select['tous']=BAZ_TOUS;
-
 
1240
//	while ($ligne = $resultat->fetchRow(DB_FETCHMODE_ASSOC)) {
-
 
1241
//		$personnes_select[$ligne[BAZ_CHAMPS_ID]] = $ligne[BAZ_CHAMPS_NOM]." ".$ligne[BAZ_CHAMPS_PRENOM] ;
-
 
1242
//	}
-
 
1243
//	$option=array('style'=>'width: 195px;', 'onchange'=>'this.form.submit();');
-
 
1244
//	$formtemplate->addElement ('select', 'personnes', BAZ_EMETTEUR, $personnes_select, $option) ;
-
 
1245
//	
-
 
1246
//	//champs texte pour entrer les mots clés
-
 
1247
//	$option=array('size'=>30,'maxlength'=>40);
-
 
1248
//	$formtemplate->addElement('text', 'recherche_mots_cles', BAZ_MOT_CLE, $option) ;
-
 
1249
//	//Bouton de validation du formulaire
-
 
1250
//	$bouton[] = &HTML_QuickForm::createElement('submit', 'valider', BAZ_VALIDER);
-
 
1251
//	$formtemplate->addGroup($bouton, null, null, '');
-
 
1252
//	
-
 
1253
//	$requeteSQL='';
-
 
1254
//	//affichage des résultats de la recherche si le formulaire a été envoyé
-
 
1255
//	if (isset($_POST['type_annonce'])) {
-
 
1256
//		//ajout des champs pour la recherche personnalisée
-
 
1257
//		if ($_POST['type_annonce']!='toutes') {
-
 
1258
//			$tableau=baz_valeurs_template($_POST['type_annonce'].'.tpl');
-
 
1259
//			$nbvaleurs=count($tableau);
-
 
1260
//			$html='<h3>'.BAZ_RECHERCHE_AVANCEE.'</h3>'."\n";
-
 
1261
//			$formtemplate->addElement('html', $html) ;
-
 
1262
//			for ($i=0; $i<$nbvaleurs; $i++) {
-
 
1263
//				if (($tableau[$i]['type']=='liste')or($tableau[$i]['type']=='listedatedeb')or($tableau[$i]['type']=='listedatefin')) {
-
 
1264
//					$tableau[$i]['type']($formtemplate, $tableau[$i]['nom_bdd'], $tableau[$i]['label'], $tableau[$i]['limite1'],
-
 
1265
//					$tableau[$i]['limite2'], $tableau[$i]['defaut'], $tableau[$i]['table_source'], 0) ;
-
 
1266
//				}
-
 
1267
//			}
-
 
1268
//		}
-
 
1269
//		$res.= $formtemplate->toHTML() ;
-
 
1270
//		
-
 
1271
//		//préparation de la requête pour trouver les mots clés
-
 
1272
//		if ($_POST['recherche_mots_cles']!='') {
-
 
1273
//			//découpage des mots clés
-
 
1274
//			$recherche = split(' ', $_POST['recherche_mots_cles']) ;
-
 
1275
//			$nbmots=count($recherche); 
-
 
1276
//			for ($i=0; $i<$nbmots; $i++) {
-
 
1277
//				if ($i>0) $requeteSQL.=' OR ';
-
 
1278
//				$requeteSQL.='bf_titre LIKE "%'.$recherche[$i].'%" OR bf_description LIKE "%'.$recherche[$i].'%" ';
-
 
1279
//			}
-
 
1280
//		}
-
 
1281
//		
-
 
1282
//		//génération de l'affichage
-
 
1283
//		$res.=RSSversHTML(gen_RSS($_POST['type_annonce'], '', $_POST['personnes'], 1, $requeteSQL), 1, 'jm') ;
-
 
1284
//	}
-
 
1285
//	else {
-
 
1286
//		//Bouton de validation du formulaire
-
 
1287
//		$res.=$formtemplate->toHTML()."\n".BAZ_DESCRIPTION_RECHERCHE;
-
 
1288
//	}
-
 
1289
//	
-
 
1290
//	return $res;
-
 
1291
//}
-
 
1292
 
1229
 
1293
 
1230
 
1294
function baz_envoie_mail() {
1231
function baz_envoie_mail() {
1295
	$headers['From']    = $_SERVER['SERVER_ADMIN'] ;
1232
	$headers['From']    = $_SERVER['SERVER_ADMIN'] ;
Line 1326... Line 1263...
1326
	}
1263
	}
1327
	return;
1264
	return;
1328
}
1265
}
Line 1329... Line 1266...
1329
 
1266
 
1330
 
1267
 
1331
/** function baz_nextId () Renvoie le prochain identifiant numérique libre d'une table
1268
/** function baz_nextId () Renvoie le prochain identifiant numerique libre d'une table
1332
*
1269
*
1333
*   @param  string  Nom de la table
1270
*   @param  string  Nom de la table
1334
*   @param  string  Nom du champs identifiant
1271
*   @param  string  Nom du champs identifiant
1335
*   @param  mixed   Objet DB de PEAR pour la connexion à la base de donnée
1272
*   @param  mixed   Objet DB de PEAR pour la connexion a la base de donnees
1336
*
1273
*
1337
*   return  integer Le prochain numéro d'identifiant disponible
1274
*   return  integer Le prochain numero d'identifiant disponible
1338
*/
1275
*/
1339
function baz_nextId($table, $colonne_identifiant, $bdd) {
1276
function baz_nextId($table, $colonne_identifiant, $bdd) {
1340
	$requete = 'SELECT MAX('.$colonne_identifiant.') AS maxi FROM '.$table;
1277
	$requete = 'SELECT MAX('.$colonne_identifiant.') AS maxi FROM '.$table;
Line 1352... Line 1289...
1352
}
1289
}
Line 1353... Line 1290...
1353
 
1290
 
1354
/* +--Fin du code ----------------------------------------------------------------------------------------+
1291
/* +--Fin du code ----------------------------------------------------------------------------------------+
1355
*
1292
*
-
 
1293
* $Log: not supported by cvs2svn $
-
 
1294
* Revision 1.35  2006/01/18 11:06:51  florian
-
 
1295
* correction erreur saisie date
1356
* $Log: not supported by cvs2svn $
1296
*
1357
* Revision 1.34  2006/01/18 10:53:28  florian
1297
* Revision 1.34  2006/01/18 10:53:28  florian
1358
* corrections bugs affichage fiche
1298
* corrections bugs affichage fiche
1359
*
1299
*
1360
* Revision 1.33  2006/01/18 10:07:34  florian
1300
* Revision 1.33  2006/01/18 10:07:34  florian