Subversion Repositories Applications.bazar

Rev

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

Rev 21 Rev 24
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.9 2005-10-10 16:22:52 alexandre_tb Exp $
22
// CVS : $Id: bazar.fonct.php,v 1.10 2005-10-12 15:14:06 florian Exp $
23
/**
23
/**
24
*
24
*
25
* Fonctions du module bazar
25
* Fonctions du module bazar
26
*
26
*
27
*@package bazar
27
*@package bazar
28
//Auteur original :
28
//Auteur original :
29
*@author        Alexandre Granier <alexandre@tela-botanica.org>
29
*@author        Alexandre Granier <alexandre@tela-botanica.org>
30
*@author        Florian Schmitt <florian@ecole-et-nature.org>
30
*@author        Florian Schmitt <florian@ecole-et-nature.org>
31
//Autres auteurs :
31
//Autres auteurs :
32
*@copyright     Tela-Botanica 2000-2004
32
*@copyright     Tela-Botanica 2000-2004
33
*@version       $Revision: 1.9 $ $Date: 2005-10-10 16:22:52 $
33
*@version       $Revision: 1.10 $ $Date: 2005-10-12 15:14:06 $
34
// +------------------------------------------------------------------------------------------------------+
34
// +------------------------------------------------------------------------------------------------------+
35
*/
35
*/
Line 36... Line 36...
36
 
36
 
37
// +------------------------------------------------------------------------------------------------------+
37
// +------------------------------------------------------------------------------------------------------+
Line 50... Line 50...
50
// +------------------------------------------------------------------------------------------------------+
50
// +------------------------------------------------------------------------------------------------------+
Line 51... Line 51...
51
 
51
 
52
/** niveau_droit() - Retourne le niveau de droit de l'utilisateur
52
/** niveau_droit() - Retourne le niveau de droit de l'utilisateur
53
*
53
*
54
* @param   integer Id de la nature d'offre pour connaitre les droits sur une rubrique
54
* @param   integer Id de la nature d'offre pour connaitre les droits sur une rubrique
55
* @param   integer Id de la personne (par défaut la personne logguée)
55
* @param   integer Id de la personne (par défaut la personne loguée)
56
*
56
*
57
* @return   string Retourne 'redacteur', 'administrateur', 'superadministrateur', ou 'aucun'
57
* @return   string Retourne 'redacteur', 'administrateur', 'superadministrateur', ou 'aucun'
58
*/
58
*/
59
function niveau_droit($id_nature_offre='0', $personne) {
59
function niveau_droit($id_nature_offre='0', $personne) {
Line 153... Line 153...
153
/** mes_fiches () - Renvoie les fiches bazar d'un utilisateur
153
/** mes_fiches () - Renvoie les fiches bazar d'un utilisateur
154
*
154
*
155
* @return   string  HTML
155
* @return   string  HTML
156
*/
156
*/
157
function mes_fiches() {
157
function mes_fiches() {
-
 
158
	if ($GLOBALS['AUTH']->getAuth()) {
158
	$res= '<h2>'.BAZ_VOS_ANNONCES.'</h2>'."\n";
159
		$res= '<h2>'.BAZ_VOS_ANNONCES.'</h2>'."\n";
159
	// requête pour voir si l'utilisateur a des fiches à son nom, classées par date de MAJ et nature d'annonce
160
		// requête pour voir si l'utilisateur a des fiches à son nom, classées par date de MAJ et nature d'annonce
160
	$requete = 'SELECT * FROM bazar_fiche, bazar_nature WHERE bf_ce_utilisateur='. $GLOBALS['id_user'].
161
		$requete = 'SELECT * FROM bazar_fiche, bazar_nature WHERE bf_ce_utilisateur='. $GLOBALS['id_user'].
161
	           ' AND bn_id_nature=bf_ce_nature AND bn_ce_id_menu='.$GLOBALS['_GEN_commun']['info_menu']->gm_id_menu.' or  bn_ce_id_menu=0 ORDER BY bf_date_maj_fiche DESC,bf_ce_nature ASC';  
162
		           ' AND bn_id_nature=bf_ce_nature AND bn_ce_id_menu='.$GLOBALS['_GEN_commun']['info_menu']->gm_id_menu.' or  bn_ce_id_menu=0 ORDER BY bf_date_maj_fiche DESC,bf_ce_nature ASC';
162
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
163
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
163
	if (DB::isError($resultat)) {
164
		if (DB::isError($resultat)) {
164
		die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
165
			die ('Echec de la requete<br />'.$resultat->getMessage().'<br />'.$resultat->getDebugInfo()) ;
165
	}
166
		}
166
	if ($resultat->numRows() != 0) {
167
		if ($resultat->numRows() != 0) {
167
		$tableAttr = array('id' => 'table_bazar') ;
168
			$tableAttr = array('id' => 'table_bazar') ;
168
		$table = new HTML_Table($tableAttr) ;
169
			$table = new HTML_Table($tableAttr) ;
169
		$entete = array (BAZ_TITREANNONCE , BAZ_TYPEANNONCE, BAZ_ETATPUBLICATION, BAZ_MODIFIER, BAZ_SUPPRIMER) ;
170
			$entete = array (BAZ_TITREANNONCE , BAZ_TYPEANNONCE, BAZ_ETATPUBLICATION, BAZ_MODIFIER, BAZ_SUPPRIMER) ;
170
		$table->addRow($entete) ;
171
			$table->addRow($entete) ;
171
		$table->setRowType (0, "th") ;
172
			$table->setRowType (0, "th") ;
172
		
173
					
173
		// On affiche une ligne par proposition
174
		// On affiche une ligne par proposition
174
		while ($ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC)) {
175
		while ($ligne = $resultat->fetchRow (DB_FETCHMODE_ASSOC)) {
175
			if ($ligne['bf_statut_fiche']==1) $publiee=BAZ_PUBLIEE;
176
			if ($ligne['bf_statut_fiche']==1) $publiee=BAZ_PUBLIEE;
176
			elseif ($ligne['bf_statut_fiche']==0) $publiee=BAZ_ENCOURSDEVALIDATION;
177
			elseif ($ligne['bf_statut_fiche']==0) $publiee=BAZ_ENCOURSDEVALIDATION;
177
			else $publiee=BAZ_REJETEE;
178
			else $publiee=BAZ_REJETEE;
Line 206... Line 207...
206
		$table->updateColAttributes(1, array("align" => "center"));
207
		$table->updateColAttributes(1, array("align" => "center"));
207
		$table->updateColAttributes(2, array("align" => "center"));
208
		$table->updateColAttributes(2, array("align" => "center"));
208
		$table->updateColAttributes(3, array("align" => "center"));
209
		$table->updateColAttributes(3, array("align" => "center"));
209
		$table->updateColAttributes(4, array("align" => "center"));
210
		$table->updateColAttributes(4, array("align" => "center"));
210
		$res .= $table->toHTML() ;
211
		$res .= $table->toHTML() ;
-
 
212
		}
-
 
213
	    else {
-
 
214
	    	$res .= BAZ_PAS_DE_FICHE ;
-
 
215
	    }
211
	}
216
	}
212
	else {
-
 
213
		$res .= BAZ_PAS_DE_FICHE ;
217
	else $res=BAZ_IDENTIFIEZ_VOUS_POUR_SAISIR;;
214
	}
-
 
215
	return $res;
218
	return $res;
216
}
219
}
Line 217... Line 220...
217
 
220
 
Line 224... Line 227...
224
	$res= '<h2>'.BAZ_ADMIN_ANNONCES.'</h2>'."\n";
227
	$res= '<h2>'.BAZ_ADMIN_ANNONCES.'</h2>'."\n";
225
	return $res;
228
	return $res;
226
}
229
}
Line 227... Line 230...
227
 
230
 
228
 
231
 
229
/** baz_afficher_formulaire_annonce() - Genère le formulaire de saisie d'une annonce
232
/** baz_afficher_formulaire_annonce() - Génère le formulaire de saisie d'une annonce
230
*
233
*
231
* @param   string type de formulaire: insertion ou modification
234
* @param   string type de formulaire: insertion ou modification
232
* @param   mixed objet quickform du formulaire
235
* @param   mixed objet quickform du formulaire
Line 456... Line 459...
456
* @param   string choix du formulaire à afficher (soit formulaire personnalisé de l'annonce, soit choix du type d'annonce)
459
* @param   string choix du formulaire à afficher (soit formulaire personnalisé de l'annonce, soit choix du type d'annonce)
457
*
460
*
458
* @return   string  HTML
461
* @return   string  HTML
459
*/
462
*/
460
function baz_formulaire($mode = 'inscription') {
463
function baz_formulaire($mode = 'inscription') {
-
 
464
	if ($GLOBALS['AUTH']->getAuth()) {
461
	//Récuperer les éventuelles variables passées en GET ou en POST
465
	//Récupérer les éventuelles variables passées en GET ou en POST
462
	if (isset($_GET['id_fiche'])) $GLOBALS['_BAZAR_']['id_fiche']=$_GET['id_fiche'];
466
	if (isset($_GET['id_fiche'])) $GLOBALS['_BAZAR_']['id_fiche']=$_GET['id_fiche'];
463
	if (isset($_REQUEST['typeannonce'])) {
467
	if (isset($_REQUEST['typeannonce'])) {
464
		$GLOBALS['_BAZAR_']['typeannonce']=$_REQUEST['typeannonce'];
468
		$GLOBALS['_BAZAR_']['typeannonce']=$_REQUEST['typeannonce'];
465
		// Pour éviter qu'un formulaire soit revalidé si l'utilisateur
469
		// Pour éviter qu'un formulaire soit revalidé si l'utilisateur
466
		// Clique sur son bouton précédent
470
		// Clique sur son bouton précédent
Line 505... Line 509...
505
	//------------------------------------------------------------------------------------------------
509
	//------------------------------------------------------------------------------------------------
506
	if ($mode == BAZ_DEPOSER_ANNONCE) {
510
	if ($mode == BAZ_DEPOSER_ANNONCE) {
507
		$res = '';
511
		$res = '';
Line 508... Line 512...
508
		
512
		
509
		//requete pour obtenir le nom et la description des types d'annonce
513
		//requete pour obtenir le nom et la description des types d'annonce
510
		$requete = "SELECT bn_id_nature, bn_label_nature, bn_description, bn_condition FROM bazar_nature WHERE bn_ce_id_menu=".$_REQUEST['menu']." or  bn_ce_id_menu=0 ORDER BY bn_label_nature ASC";
514
		$requete = "SELECT bn_id_nature, bn_label_nature, bn_description, bn_condition FROM bazar_nature WHERE bn_ce_id_menu=".$GLOBALS['_GEN_commun']['info_menu']->gm_id_menu." or  bn_ce_id_menu=0 ORDER BY bn_label_nature ASC";
511
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
515
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
512
		if (DB::isError($resultat)) {
516
		if (DB::isError($resultat)) {
513
			die ($resultat->getMessage().$resultat->getDebugInfo()) ;
517
			die ($resultat->getMessage().$resultat->getDebugInfo()) ;
514
		}
518
		}
Line 583... Line 587...
583
			$personne=$_POST['personnes'];
587
			$personne=$_POST['personnes'];
584
		}
588
		}
585
		else $personne=0;
589
		else $personne=0;
Line 586... Line 590...
586
		
590
		
587
		
591
		
588
		//Cas ou les droits ont étés changés
592
		//Cas ou les droits ont été changés
589
		if (isset($_GET['pers'])) {
593
		if (isset($_GET['pers'])) {
590
			$personne=$_GET['pers'];
594
			$personne=$_GET['pers'];
591
			//CAS DES DROITS POUR UN TYPE D'ANNONCE: On efface tous les droits de la personne pour ce type d'annonce
595
			//CAS DES DROITS POUR UN TYPE D'ANNONCE: On efface tous les droits de la personne pour ce type d'annonce
Line 728... Line 732...
728
				$table->updateColAttributes(3, array('align' => 'left'));
732
				$table->updateColAttributes(3, array('align' => 'left'));
729
				$res.=$table->toHTML() ;
733
				$res.=$table->toHTML() ;
730
			}
734
			}
731
		}
735
		}
732
	}
736
	}
-
 
737
    }
-
 
738
	else $res=BAZ_IDENTIFIEZ_VOUS_POUR_SAISIR;
733
	return $res;
739
	return $res;
734
}
740
}
Line 735... Line 741...
735
 
741
 
Line 1064... Line 1070...
1064
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
1070
		$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
1065
		if (DB::isError($resultat)) {
1071
		if (DB::isError($resultat)) {
1066
			die ($resultat->getMessage().$resultat->getDebugInfo()) ;
1072
			die ($resultat->getMessage().$resultat->getDebugInfo()) ;
1067
		}
1073
		}
1068
	}
1074
	}
1069
	$res= '<h2>'.BAZ_S_INSCRIRE_AUX_ANNONCES.'</h2>'."\n";
-
 
1070
	
-
 
Line -... Line 1075...
-
 
1075
	
-
 
1076
	if ($GLOBALS['AUTH']->getAuth()) {
-
 
1077
	$res= '<h2>'.BAZ_S_ABONNER.'</h2>'."\n";
1071
	
1078
	$res= BAZ_LAIUS_S_ABONNER."\n";
1072
	//requete pour obtenir l'id et le label des types d'annonces
1079
	//requete pour obtenir l'id et le label des types d'annonces
1073
	$requete = 'SELECT bn_id_nature, bn_label_nature '.
1080
	$requete = 'SELECT bn_id_nature, bn_label_nature '.
1074
	           'FROM bazar_nature WHERE bn_ce_id_menu='.$GLOBALS['_GEN_commun']['info_menu']->gm_id_menu .' or  bn_ce_id_menu=0';
1081
	           'FROM bazar_nature WHERE bn_ce_id_menu='.$GLOBALS['_GEN_commun']['info_menu']->gm_id_menu .' or  bn_ce_id_menu=0';
1075
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
1082
	$resultat = $GLOBALS['_BAZAR_']['db']->query($requete) ;
Line 1124... Line 1131...
1124
					     '<a href='.$lien_RSS->getURL().'><img src="client/bazar/images/BAZ_rss.png" alt="'.BAZ_RSS.'" /></a>'));
1131
					     '<a href='.$lien_RSS->getURL().'><img src="client/bazar/images/BAZ_rss.png" alt="'.BAZ_RSS.'" /></a>'));
1125
			$lien_RSS->removeQueryString('annonce');
1132
			$lien_RSS->removeQueryString('annonce');
1126
		}
1133
		}
1127
	}
1134
	}
1128
	$table->altRowAttributes(1, array('class' => 'ligne_impaire'), array('class' => 'ligne_paire'));
1135
	$table->altRowAttributes(1, array('class' => 'ligne_impaire'), array('class' => 'ligne_paire'));
1129
	$table->updateColAttributes(0, array('align' => 'left'));
1136
	$table->updateColAttributes(0, array('style' => 'text-align:left;'));
1130
	$table->updateColAttributes(1, array('align' => 'center'));
1137
	$table->updateColAttributes(1, array('align' => 'center'));
1131
	$table->updateColAttributes(2, array('align' => 'center'));
1138
	$table->updateColAttributes(2, array('align' => 'center'));
1132
	$table->updateColAttributes(3, array('align' => 'center'));
1139
	$table->updateColAttributes(3, array('style' => 'text-align:center;'));
1133
	$res.=$table->toHTML() ;
1140
	$res.=$table->toHTML() ;
-
 
1141
	}
-
 
1142
	else $res=BAZ_IDENTIFIEZ_VOUS_POUR_SAISIR;
Line 1134... Line 1143...
1134
	
1143
	
1135
	return $res;
1144
	return $res;
Line 1225... Line 1234...
1225
				}
1234
				}
1226
			}
1235
			}
1227
		}
1236
		}
1228
		$res.= $formtemplate->toHTML() ;
1237
		$res.= $formtemplate->toHTML() ;
Line 1229... Line 1238...
1229
		
1238
		
1230
		//préparation de la requète pour trouver les mots clés
1239
		//préparation de la requête pour trouver les mots clés
1231
		if ($_POST['recherche_mots_cles']!='') {
1240
		if ($_POST['recherche_mots_cles']!='') {
1232
			//découpage des mots clés
1241
			//découpage des mots clés
1233
			$recherche = split(' ', $_POST['recherche_mots_cles']) ;
1242
			$recherche = split(' ', $_POST['recherche_mots_cles']) ;
1234
			$nbmots=count($recherche); 
1243
			$nbmots=count($recherche); 
Line 1326... Line 1335...
1326
           '?' => '&#8230;',
1335
           '?' => '&#8230;',
1327
           '?' => '&#8224;',
1336
           '?' => '&#8224;',
1328
           '?' => '&#8225;',
1337
           '?' => '&#8225;',
1329
           '?' => '&#710;',
1338
           '?' => '&#710;',
1330
           '?' => '&#8240;',
1339
           '?' => '&#8240;',
1331
           '¦' => '&#352;',
1340
           'à' => '&#352;',
1332
           '?' => '&#8249;',
1341
           '?' => '&#8249;',
1333
           '¼' => '&#338;',
1342
           'à' => '&#338;',
1334
           '?' => '&#8216;',
1343
           '?' => '&#8216;',
1335
           '?' => '&#8217;',
1344
           '?' => '&#8217;',
1336
           '?' => '&#8220;',
1345
           '?' => '&#8220;',
1337
           '?' => '&#8221;',
1346
           '?' => '&#8221;',
1338
           '?' => '&#8226;',
1347
           '?' => '&#8226;',
1339
           '?' => '&#8211;',
1348
           '?' => '&#8211;',
1340
           '?' => '&#8212;',
1349
           '?' => '&#8212;',
1341
           '?' => '&#732;',
1350
           '?' => '&#732;',
1342
           '?' => '&#8482;',
1351
           '?' => '&#8482;',
1343
           '¨' => '&#353;',
1352
           'à' => '&#353;',
1344
           '?' => '&#8250;',
1353
           '?' => '&#8250;',
1345
           '½' => '&#339;',
1354
           'à' => '&#339;',
1346
           '¾' => '&#376;',
1355
           'à' => '&#376;',
1347
           '¤' => '&#8364;');
1356
           'à' => '&#8364;');
1348
       return str_replace(array_keys($entites),
1357
       return str_replace(array_keys($entites),
1349
                                array_values($entites),
1358
                                array_values($entites),
1350
                                $chaine);
1359
                                $chaine);
1351
}
1360
}
Line 1352... Line 1361...
1352
 
1361
 
1353
/* +--Fin du code ----------------------------------------------------------------------------------------+
1362
/* +--Fin du code ----------------------------------------------------------------------------------------+
1354
*
1363
*
-
 
1364
* $Log: not supported by cvs2svn $
-
 
1365
* Revision 1.9  2005/10/10 16:22:52  alexandre_tb
-
 
1366
* Correction de bug. Lorsqu'on revient en arrière après avoir validé un formulaire.
1355
* $Log: not supported by cvs2svn $
1367
*
1356
* Revision 1.8  2005/09/30 13:50:07  alexandre_tb
1368
* Revision 1.8  2005/09/30 13:50:07  alexandre_tb
1357
* correction bug date parution ressource
1369
* correction bug date parution ressource
1358
*
1370
*
1359
* Revision 1.7  2005/09/30 13:15:58  ddelon
1371
* Revision 1.7  2005/09/30 13:15:58  ddelon
Line 1379... Line 1391...
1379
*
1391
*
1380
* Revision 1.10  2004/07/08 17:25:25  florian
1392
* Revision 1.10  2004/07/08 17:25:25  florian
1381
* ajout commentaires + petits debuggages
1393
* ajout commentaires + petits debuggages
1382
*
1394
*
1383
* Revision 1.8  2004/07/07 14:30:19  florian
1395
* Revision 1.8  2004/07/07 14:30:19  florian
1384
* débuggage RSS
1396
* débogage RSS
1385
*
1397
*
1386
* Revision 1.7  2004/07/06 16:22:01  florian
1398
* Revision 1.7  2004/07/06 16:22:01  florian
1387
* débuggage modification + MAJ flux RSS
1399
* débogage modification + MAJ flux RSS
1388
*
1400
*
1389
* Revision 1.6  2004/07/06 09:28:26  florian
1401
* Revision 1.6  2004/07/06 09:28:26  florian
1390
* changement interface de modification
1402
* changement interface de modification
1391
*
1403
*
1392
* Revision 1.5  2004/07/05 15:10:23  florian
1404
* Revision 1.5  2004/07/05 15:10:23  florian