From c3896020976e9ba8ec791b3630e93da48b2ef238 Mon Sep 17 00:00:00 2001 From: Pascal Corpet Date: Sun, 9 Jan 2005 14:20:49 +0000 Subject: [PATCH] Nouvelle API (db -> xdb, -> Session::) pour les include/profil git-archimport-id: opensource@polytechnique.org--2005/platal--mainline--0.9--patch-251 --- include/profil/get_adresses.inc.php | 25 ++++++----- include/profil/get_emploi.inc.php | 20 ++++----- include/profil/get_general.inc.php | 23 +++++----- include/profil/get_mentor.inc.php | 74 ++++++++++++++++----------------- include/profil/get_poly.inc.php | 26 ++++++------ include/profil/get_skill.inc.php | 48 ++++++++++----------- include/profil/update_adresses.inc.php | 76 ++++++++++++++++++++++------------ include/profil/update_emploi.inc.php | 43 ++++++++++++------- include/profil/update_general.inc.php | 12 +++--- include/profil/update_mentor.inc.php | 2 +- include/profil/update_poly.inc.php | 4 +- include/profil/verif_adresses.inc.php | 20 +++++---- include/profil/verif_emploi.inc.php | 5 ++- include/profil/verif_mentor.inc.php | 4 +- 14 files changed, 208 insertions(+), 174 deletions(-) diff --git a/include/profil/get_adresses.inc.php b/include/profil/get_adresses.inc.php index 4af53cc..0d47580 100644 --- a/include/profil/get_adresses.inc.php +++ b/include/profil/get_adresses.inc.php @@ -37,7 +37,7 @@ function is_adr_empty($adrid){ function delete_address($adrid, $in_request_array = false){ global $globals; - $globals->db->query("DELETE FROM adresses WHERE uid = ".$_SESSION["uid"]." AND adrid = '$adrid'"); + $globals->xdb->execute("DELETE FROM adresses WHERE uid = {?} AND adrid = {?}",Session::getInt('uid', -1), $adrid); if($in_request_array == true){ unset($_REQUEST['adrid'][$adrid]); } @@ -47,8 +47,9 @@ function delete_address($adrid, $in_request_array = false){ } //on verifie si on nous a demande une suppression +$req_adrid_del = Env::getMixed('adrid_del', Array()); for($i = 1; $i <= $nb_adr_max; $i++){ - if( isset( $_REQUEST['adrid_del'][$i] ) ) { + if( isset( $req_adrid_del[$i] ) ) { delete_address($i,true); } } @@ -57,15 +58,11 @@ for($i = 1; $i <= $nb_adr_max; $i++){ $sql_order = ''; //recuperation des adrid -$res = $globals->db->query("SELECT adrid FROM adresses WHERE uid = {$_SESSION['uid']} AND NOT FIND_IN_SET('pro',statut) ".$sql_order); -$i = 1; -while(list($adrids[$i]) = mysql_fetch_row($res)){ - $adresses[$adrids[$i]]['adrid'] = $adrids[$i]; - $i++; -} +$res = $globals->xdb->query("SELECT adrid FROM adresses WHERE uid = {?} AND NOT FIND_IN_SET('pro', statut) ".$sql_order, Session::getInt('uid', -1)); +$adrids = $res->fetchColumn(); //recuperation des donnees de la bd -$res = $globals->db->query( +$res = $globals->xdb->iterRow( "SELECT FIND_IN_SET('res-secondaire', statut), FIND_IN_SET('courrier', statut), FIND_IN_SET('active', statut), FIND_IN_SET('temporaire', statut), @@ -74,20 +71,22 @@ $res = $globals->db->query( FIND_IN_SET('adr_public', visibilite), FIND_IN_SET('adr_ax', visibilite), FIND_IN_SET('tel_public', visibilite), FIND_IN_SET('tel_ax', visibilite) FROM adresses - WHERE uid = {$_SESSION['uid']} AND NOT FIND_IN_SET('pro',statut) ".$sql_order + WHERE uid = {?} AND NOT FIND_IN_SET('pro',statut) ".$sql_order +, Session::getInt('uid', -1) ); -$nb_adr = mysql_num_rows($res); +$nb_adr = $res->total(); -for ($i = 1; $i <= $nb_adr; $i++) { +for ($i = 0; $i < $nb_adr; $i++) { $adrid = $adrids[$i]; + $adresses[$adrid]['adrid'] = $adrid; list( $adresses[$adrid]['secondaire'], $adresses[$adrid]['courrier'], $adresses[$adrid]['active'], $adresses[$adrid]['temporaire'], $adresses[$adrid]['adr1'], $adresses[$adrid]['adr2'], $adresses[$adrid]['adr3'], $adresses[$adrid]['cp'], $adresses[$adrid]['ville'], $adresses[$adrid]['pays'], $adresses[$adrid]['region'], $adresses[$adrid]['tel'], $adresses[$adrid]['fax'], $adresses[$adrid]['adr_public'], $adresses[$adrid]['adr_ax'], - $adresses[$adrid]['tel_public'], $adresses[$adrid]['tel_ax']) = mysql_fetch_row($res); + $adresses[$adrid]['tel_public'], $adresses[$adrid]['tel_ax']) = $res->next(); $adresses[$adrid]['nouvelle'] = 'modif'; $adresses[$adrid]['numero_formulaire'] = -1; } diff --git a/include/profil/get_emploi.inc.php b/include/profil/get_emploi.inc.php index f08bf1c..bd775ee 100644 --- a/include/profil/get_emploi.inc.php +++ b/include/profil/get_emploi.inc.php @@ -23,19 +23,19 @@ require_once('geoloc.inc.php'); require_once('secteur.emploi.inc.php'); require_once('fonction.emploi.inc.php'); -$res = $globals->db->query("SELECT entrid, entreprise, secteur, ss_secteur, poste, fonction, +$res = $globals->xdb->iterRow("SELECT entrid, entreprise, secteur, ss_secteur, poste, fonction, adr1, adr2, adr3, cp, ville, pays, region, tel, fax, FIND_IN_SET('entreprise_public',visibilite),FIND_IN_SET('entreprise_ax',visibilite),FIND_IN_SET('adr_public',visibilite), FIND_IN_SET('adr_ax',visibilite),FIND_IN_SET('tel_public',visibilite),FIND_IN_SET('tel_ax',visibilite) FROM entreprises - WHERE uid = '{$_SESSION['uid']}' ORDER BY entrid"); + WHERE uid = {?} ORDER BY entrid",Session::getInt('uid', -1)); -$nb_res = mysql_num_rows($res); +$nb_res = $res->total(); for($i = 0; $i < $nb_res ; $i++){ list($endrid[$i], $entreprise[$i], $secteur[$i], $ss_secteur[$i], $poste[$i], $fonction[$i], $adrpro1[$i], $adrpro2[$i], $adrpro3[$i], $cppro[$i], $villepro[$i], $payspro[$i], $regionpro[$i], $telpro[$i], $faxpro[$i], $entreprise_public[$i], $entreprise_ax[$i], $adrpro_public[$i], $adrpro_ax[$i], - $telpro_public[$i], $telpro_ax[$i]) = mysql_fetch_row($res); + $telpro_public[$i], $telpro_ax[$i]) = $res->next(); } //limite dure a 2 for($i = $nb_res; $i < 2 ; $i++){ @@ -64,22 +64,22 @@ for($i = $nb_res; $i < 2 ; $i++){ //recuperation des donnees sur les secteurs : -$res = $globals->db->query("SELECT id, label from emploi_secteur"); +$res = $globals->xdb->iterRow("SELECT id, label FROM emploi_secteur"); -while(list($tmp_secteur_id, $tmp_secteur_label) = mysql_fetch_row($res)){ +while(list($tmp_secteur_id, $tmp_secteur_label) = $res->next()){ $secteurs[$tmp_secteur_id] = $tmp_secteur_label; } //recuperation des donnees sur les fonctions : -$res = $globals->db->query("SELECT id, fonction_fr, FIND_IN_SET('titre', flags) from fonctions_def ORDER BY id"); +$res = $globals->xdb->iterRow("SELECT id, fonction_fr, FIND_IN_SET('titre', flags) FROM fonctions_def ORDER BY id"); -while(list($tmp_fonction_id, $tmp_fonction_label, $tmp_fonction_titre) = mysql_fetch_row($res)){ +while(list($tmp_fonction_id, $tmp_fonction_label, $tmp_fonction_titre) = $res->next()){ $fonctions[$tmp_fonction_id] = $tmp_fonction_label; $fonctions_titre[$tmp_fonction_id] = $tmp_fonction_titre; } //recuperation du CV -$res = $globals->db->query("SELECT cv from auth_user_md5 where user_id = '{$_SESSION['uid']}'"); -list($cv) = mysql_fetch_row($res); +$res = $globals->xdb->query("SELECT cv FROM auth_user_md5 WHERE user_id = {?}", Session::getInt('uid', -1)); +$cv = $res->fetchOneCell(); ?> diff --git a/include/profil/get_general.inc.php b/include/profil/get_general.inc.php index 938ddee..8a88374 100644 --- a/include/profil/get_general.inc.php +++ b/include/profil/get_general.inc.php @@ -30,16 +30,14 @@ $sql = "SELECT u.nom, u.prenom". " FROM auth_user_md5 AS u". " LEFT JOIN applis_ins AS a1 ON(a1.uid = u.user_id and a1.ordre = 0)". " LEFT JOIN applis_ins AS a2 ON(a2.uid = u.user_id and a2.ordre = 1)". - " WHERE user_id=".$_SESSION['uid']; + " WHERE user_id = {?}"; -$result = $globals->db->query($sql); +$result = $globals->xdb->query($sql, Session::getInt('uid', -1)); list($nom, $prenom, $promo, $epouse, $femme, $nationalite, $mobile, $web, $libre, $appli_id1,$appli_type1, - $appli_id2,$appli_type2) = mysql_fetch_row($result); - -mysql_free_result($result); + $appli_id2,$appli_type2) = $result->fetchOneRow(); replace_ifset($nationalite,'nationalite'); replace_ifset($mobile,'mobile'); @@ -50,15 +48,14 @@ replace_ifset($appli_id2,"appli_id2"); replace_ifset($appli_type1,"appli_type1"); replace_ifset($appli_type2,"appli_type2"); -if(isset($_REQUEST['modifier']) || isset($_REQUEST['suivant'])) { - $mobile_public = (isset($_REQUEST['mobile_public'])); - $mobile_ax = (isset($_REQUEST['mobile_ax'])); - $libre_public = (isset($_REQUEST['libre_public'])); - $web_public = (isset($_REQUEST['web_public'])); +if(Env::has('modifier') || Env::has('suivant')) { + $mobile_public = Env::has('mobile_public'); + $mobile_ax = Env::has('mobile_ax'); + $libre_public = Env::has('libre_public'); + $web_public = Env::has('web_public'); } // Y a-t-il une photo en attente de confirmation ? -$sql = $globals->db->query('SELECT COUNT(*) FROM requests WHERE type="photo" AND user_id='.$_SESSION['uid']); -list($nouvellephoto)=mysql_fetch_row($sql); -mysql_free_result($sql); +$sql = $globals->xdb->query("SELECT COUNT(*) FROM requests WHERE type='photo' AND user_id = {?}", Session::getInt('uid', -1)); +$nouvellephoto=$sql->fetchOneCell(); ?> diff --git a/include/profil/get_mentor.inc.php b/include/profil/get_mentor.inc.php index c445d44..b4ff84d 100644 --- a/include/profil/get_mentor.inc.php +++ b/include/profil/get_mentor.inc.php @@ -26,81 +26,77 @@ $max_mentor_pays = 10; $max_mentor_secteurs = 10; //recuperation de l'expertise -$res = $globals->db->query("SELECT expertise FROM mentor WHERE uid = {$_SESSION['uid']}"); +$res = $globals->xdb->query("SELECT expertise FROM mentor WHERE uid = {?}", Session::getInt('uid',-1)); -if(mysql_num_rows($res) > 0) { - list($mentor_expertise) = mysql_fetch_row($res); -} else { - $mentor_expertise = ''; -} +$mentor_expertise = $res->fetchOneCell(); $mentor_expertise_bd = $mentor_expertise; //suppression eventuelle d'un pays -if(isset($_POST['mentor_pays_op']) && ($_POST['mentor_pays_op'] == 'retirer')) { - if(isset($_POST['mentor_pays_id'])) { - $id_supprimee = $_POST['mentor_pays_id']; - $globals->db->query("DELETE FROM mentor_pays WHERE uid = {$_SESSION['uid']} AND pid = '$id_supprimee' LIMIT 1"); +if(Post::get('mentor_pays_op', '') == 'retirer') { + if(Post::has('mentor_pays_id')) { + $id_supprimee = Post::get('mentor_pays_id', '00'); + $globals->xdb->execute("DELETE FROM mentor_pays WHERE uid = {?} AND pid = {?} LIMIT 1", Session::getInt('uid', -1), $id_supprimee); } } //recuperation des pays -$res = $globals->db->query("SELECT m.pid, p.pays +$res = $globals->xdb->iterRow("SELECT m.pid, p.pays FROM mentor_pays AS m - LEFT JOIN geoloc_pays AS p ON(m.pid = p.a2) WHERE m.uid = {$_SESSION['uid']} LIMIT $max_mentor_pays"); -$nb_mentor_pays = mysql_num_rows($res); + LEFT JOIN geoloc_pays AS p ON(m.pid = p.a2) WHERE m.uid = {?} LIMIT {?}", Session::getInt('uid', -1), $max_mentor_pays); +$nb_mentor_pays = $res->total(); $mentor_pid = $mentor_pays = Array(); -for($i = 1; $i <= $nb_mentor_pays ; $i++) list($mentor_pid[$i], $mentor_pays[$i]) = mysql_fetch_row($res); +for($i = 1; $i <= $nb_mentor_pays ; $i++) list($mentor_pid[$i], $mentor_pays[$i]) = $res->next(); //ajout eventuel d'un pays -if(isset($_POST['mentor_pays_op']) && ($_POST['mentor_pays_op'] == 'ajouter') && ($nb_mentor_pays < $max_mentor_pays)) { - if(isset($_POST['mentor_pays_id']) && ($_POST['mentor_pays_id'] != '00')) { - $id_ajoutee = $_POST['mentor_pays_id']; - $globals->db->query("INSERT INTO mentor_pays(uid, pid) VALUES('{$_SESSION['uid']}', '$id_ajoutee')"); +if((Post::get('mentor_pays_op', '') == 'ajouter') && ($nb_mentor_pays < $max_mentor_pays)) { + if(Post::get('mentor_pays_id', '00') != '00') { + $id_ajoutee = Post::get('mentor_pays_id', '00'); + $globals->xdb->execute("INSERT INTO mentor_pays(uid, pid) VALUES({?}, {?})", Session::getInt('uid', -1), $id_ajoutee); $nb_mentor_pays++; $mentor_pid[$nb_mentor_pays] = $id_ajoutee; - $mentor_pays[$nb_mentor_pays] = $_POST['mentor_pays_name']; + $mentor_pays[$nb_mentor_pays] = Post::get('mentor_pays_name', ''); } } //suppression d'un secteur / ss-secteur -if(isset($_POST['mentor_secteur_op']) && ($_POST['mentor_secteur_op'] == 'retirer')) { - if(isset($_POST['mentor_secteur_id'])) { - $id_supprimee = $_POST['mentor_secteur_id']; - $globals->db->query("DELETE FROM mentor_secteurs WHERE uid = {$_SESSION['uid']} AND secteur = '$id_supprimee' LIMIT 1"); +if(Post::get('mentor_secteur_op', '') == 'retirer') { + if(Post::has('mentor_secteur_id')) { + $id_supprimee = Post::get('mentor_secteur_id', ''); + $globals->xdb->execute("DELETE FROM mentor_secteurs WHERE uid = {?} AND secteur = {?} LIMIT 1", Session::getInt('uid', -1), $id_supprimee); } } //recuperation des secteurs -$res = $globals->db->query("SELECT m.secteur, s.label, m.ss_secteur, ss.label +$res = $globals->xdb->iterRow("SELECT m.secteur, s.label, m.ss_secteur, ss.label FROM mentor_secteurs AS m LEFT JOIN emploi_secteur AS s ON(m.secteur = s.id) LEFT JOIN emploi_ss_secteur AS ss ON(s.id = ss.secteur AND m.ss_secteur = ss.id) - WHERE m.uid = {$_SESSION['uid']} - LIMIT $max_mentor_pays"); -$nb_mentor_secteurs = mysql_num_rows($res); + WHERE m.uid = {?} + LIMIT {?}", Session::getInt('uid', -1), $max_mentor_pays); +$nb_mentor_secteurs = $res->total(); $mentor_sid = $mentor_secteur = $mentor_ssid = $mentor_ss_secteur = Array(); for($i = 1; $i <= $nb_mentor_secteurs ; $i++) - list($mentor_sid[$i], $mentor_secteur[$i], $mentor_ssid[$i], $mentor_ss_secteur[$i]) = mysql_fetch_row($res); + list($mentor_sid[$i], $mentor_secteur[$i], $mentor_ssid[$i], $mentor_ss_secteur[$i]) = $res->next(); //ajout d'un secteur $mentor_secteur_id_new = ''; -if(isset($_POST['mentor_secteur_op']) && ($_POST['mentor_secteur_op'] == 'ajouter') && ($nb_mentor_secteurs < $max_mentor_secteurs)) { - if(isset($_POST['mentor_secteur_id']) && ($_POST['mentor_secteur_id'] != '')) +if((Post::get('mentor_secteur_op', '')== 'ajouter') && ($nb_mentor_secteurs < $max_mentor_secteurs)) { + if(Post::get('mentor_secteur_id', '') != '') { - $sid_ajoutee = $_POST['mentor_secteur_id']; - if(isset($_POST['mentor_ss_secteur_id'])) - $ssid_ajoutee = $_POST['mentor_ss_secteur_id']; - $globals->db->query("INSERT INTO mentor_secteurs (uid, secteur, ss_secteur) - VALUES('{$_SESSION['uid']}', '$sid_ajoutee',".( ($ssid_ajoutee == '')?'NULL':"'$ssid_ajoutee'" ).")"); + $sid_ajoutee = Post::get('mentor_secteur_id', ''); + if(Post::has('mentor_ss_secteur_id')) + $ssid_ajoutee = Post::get('mentor_ss_secteur_id', ''); + $globals->xdb->execute("INSERT INTO mentor_secteurs (uid, secteur, ss_secteur) + VALUES({?}, {?}, {?})", Session::getInt('uid', -1), $sid_ajoutee, ($ssid_ajoutee == '')?null:$ssid_ajoutee); $nb_mentor_secteurs++; $mentor_sid[$nb_mentor_secteurs] = $sid_ajoutee; - $mentor_secteur[$nb_mentor_secteurs] = $_POST['mentor_secteur_name']; + $mentor_secteur[$nb_mentor_secteurs] = Post::get('mentor_secteur_name', ''); $mentor_ssid[$nb_mentor_secteurs] = $ssid_ajoutee; - $mentor_ss_secteur[$nb_mentor_secteurs] = $_POST['mentor_ss_secteur_name']; + $mentor_ss_secteur[$nb_mentor_secteurs] = Post::get('mentor_ss_secteur_name', ''); } -} elseif(isset($_POST['mentor_secteur_id_new'])){ - $mentor_secteur_id_new = $_POST['mentor_secteur_id_new']; +} elseif(Post::has('mentor_secteur_id_new')){ + $mentor_secteur_id_new = Post::get('mentor_secteur_id_new', ''); } ?> diff --git a/include/profil/get_poly.inc.php b/include/profil/get_poly.inc.php index 771a2fd..c38e662 100644 --- a/include/profil/get_poly.inc.php +++ b/include/profil/get_poly.inc.php @@ -25,33 +25,33 @@ $sql = "SELECT u.nom, u.prenom". ", u.promo, epouse, u.flags, section". " FROM auth_user_md5 AS u". - " WHERE user_id=".$_SESSION['uid']; + " WHERE user_id = {?}"; -$result = $globals->db->query($sql); -list($nom, $prenom, $promo, $epouse, $flags, $section) = mysql_fetch_row($result); +$result = $globals->xdb->query($sql, Session::getInt('uid', -1)); +list($nom, $prenom, $promo, $epouse, $flags, $section) = $result->fetchOneRow(); replace_ifset($section,'section'); /************* gestion des binets ************/ -if (isset($_REQUEST['binet_op'])) { +if (Env::has('binet_op')) { // retrait binet - if($_REQUEST['binet_op']=="retirer" && !empty($_REQUEST['binet_id'])) { - $globals->db->query("delete from binets_ins where user_id='{$_SESSION['uid']}' and binet_id='{$_REQUEST['binet_id']}'"); + if( (Env::get('binet_op', '')=='retirer')&&(Env::getInt('binet_id', 0) != 0)) { + $globals->xdb->execute("DELETE FROM binets_ins WHERE user_id = {?} AND binet_id = {?}", Session::getInt('uid', -1), Env::getInt('binet_id', -1)); } // ajout binet - if ($_REQUEST['binet_op']=="ajouter" && !empty($_REQUEST['binet_id'])) { - $globals->db->query("insert into binets_ins (user_id,binet_id) VALUES('{$_SESSION['uid']}','{$_REQUEST['binet_id']}')"); + if (Env::get('binet_op')=="ajouter" && (Env::getInt('binet_id', 0) != 0)) { + $globals->xdb->execute("INSERT INTO binets_ins (user_id,binet_id) VALUES({?}, {?})", Session::getInt('uid', -1), Env::getInt('binet_id', -1)); } } /************* gestion des groupes X ************/ -if (isset($_REQUEST['groupex_op'])) { +if (Env::has('groupex_op')) { // retrait groupe X - if ($_REQUEST['groupex_op']=="retirer" && !empty($_REQUEST['groupex_id'])) { - $globals->db->query("delete from groupesx_ins where guid='{$_SESSION['uid']}' and gid='{$_REQUEST['groupex_id']}'"); + if (Env::get('groupex_op')=="retirer" && (Env::getInt('groupex_id', 0) != 0)) { + $globals->xdb->execute("DELETE FROM groupesx_ins WHERE guid = {?} AND gid = {?}", Session::getInt('uid', -1), Env::getInt('groupex_id', -1)); } // ajout groupe X - if ($_REQUEST['groupex_op']=="ajouter" && !empty($_REQUEST['groupex_id'])) { - $globals->db->query("insert into groupesx_ins (guid,gid) VALUES('{$_SESSION['uid']}','{$_REQUEST['groupex_id']}')"); + if (Env::get('groupex_op')=="ajouter" && (Env::getInt('groupex_id', 0) != 0)) { + $globals->xdb->execute("INSERT INTO groupesx_ins (guid, gid) VALUES ({?}, {?})", Session::getInt('uid', -1), Env::getInt('groupex_id', -1)); } } diff --git a/include/profil/get_skill.inc.php b/include/profil/get_skill.inc.php index 4346116..d9d703a 100644 --- a/include/profil/get_skill.inc.php +++ b/include/profil/get_skill.inc.php @@ -20,21 +20,21 @@ ***************************************************************************/ -if(isset($_REQUEST['langue_op'])){ - if($_REQUEST['langue_op']=='retirer'){ - $globals->db->query("delete from langues_ins where uid='{$_SESSION['uid']}' and lid='{$_REQUEST['langue_id']}'"); - } elseif($_REQUEST['langue_op'] == 'ajouter'){ - if(isset($_REQUEST['langue_id']) && ($_REQUEST['langue_id'] != '')) - $globals->db->query("insert into langues_ins (uid,lid,level) VALUES('{$_SESSION['uid']}','{$_REQUEST['langue_id']}','{$_REQUEST['langue_level']}')"); +if(Env::has('langue_op')){ + if(Env::get('langue_op', '')=='retirer'){ + $globals->xdb->execute("DELETE FROM langues_ins WHERE uid = {?} AND lid = {?}", Session::getInt('uid', -1), Env::get('langue_id', '')); + } elseif(Env::get('langue_op', '') == 'ajouter'){ + if(Env::get('langue_id', '') != '') + $globals->xdb->execute("INSERT INTO langues_ins (uid,lid,level) VALUES ({?}, {?}, {?})", Session::getInt('uid', -1), Env::get('langue_id', ''), Env::get('langue_level', '')); } } -if(isset($_REQUEST['comppros_op'])){ - if($_REQUEST['comppros_op']=='retirer'){ - $globals->db->query("delete from competences_ins where uid='{$_SESSION['uid']}' and cid='{$_REQUEST['comppros_id']}'"); - } elseif($_REQUEST['comppros_op'] == 'ajouter') { - if(isset($_REQUEST['comppros_id']) && ($_REQUEST['comppros_id'] != '')) - $globals->db->query("insert into competences_ins (uid,cid,level) VALUES('{$_SESSION['uid']}','{$_REQUEST['comppros_id']}','{$_REQUEST['comppros_level']}')"); +if(Env::has('comppros_op')){ + if(Env::get('comppros_op', '')=='retirer'){ + $globals->xdb->execute("DELETE FROM competences_ins WHERE uid = {?} AND cid = {?}", Session::getInt('uid', -1), Env::get('comppros_id', '')); + } elseif(Env::get('comppros_op', '') == 'ajouter') { + if(Env::get('comppros_id', '') != '') + $globals->xdb->execute("INSERT INTO competences_ins (uid,cid,level) VALUES({?}, {?}, {?})", Session::getInt('uid', -1), Env::get('comppros_id', ''), Env::get('comppros_level', '')); } } @@ -43,22 +43,22 @@ $nb_lg_max = 10; // nombre maximum autorisé de compétences professionnelles $nb_cpro_max = 20; -$res = $globals->db->query("SELECT ld.id, ld.langue_fr, li.level from langues_ins AS li, langues_def AS ld " - ."where (li.lid=ld.id and li.uid='{$_SESSION['uid']}') LIMIT $nb_lg_max"); +$res = $globals->xdb->iterRow("SELECT ld.id, ld.langue_fr, li.level FROM langues_ins AS li, langues_def AS ld " + ."WHERE (li.lid=ld.id AND li.uid= {?}) LIMIT $nb_lg_max", Session::getInt('uid', -1)); -$nb_lg = mysql_num_rows($res); +$nb_lg = $res->total(); for ($i = 1; $i <= $nb_lg; $i++) { - list($langue_id[$i], $langue_name[$i], $langue_level[$i]) = mysql_fetch_row($res); + list($langue_id[$i], $langue_name[$i], $langue_level[$i]) = $res->next(); } -$res = $globals->db->query("SELECT cd.id, cd.text_fr, ci.level from competences_ins AS ci, competences_def AS cd " - ."where (ci.cid=cd.id and ci.uid='{$_SESSION['uid']}') LIMIT $nb_cpro_max"); +$res = $globals->xdb->iterRow("SELECT cd.id, cd.text_fr, ci.level FROM competences_ins AS ci, competences_def AS cd " + ."WHERE (ci.cid=cd.id AND ci.uid={?}) LIMIT $nb_cpro_max", Session::getInt('uid', -1)); -$nb_cpro = mysql_num_rows($res); +$nb_cpro = $res->total(); for ($i = 1; $i <= $nb_cpro; $i++) { - list($cpro_id[$i], $cpro_name[$i], $cpro_level[$i]) = mysql_fetch_row($res); + list($cpro_id[$i], $cpro_name[$i], $cpro_level[$i]) = $res->next(); } //Definitions des tables de correspondances id => nom @@ -71,9 +71,9 @@ $langues_levels = Array( 6 => "6" ); -$res = $globals->db->query("SELECT id, langue_fr FROM langues_def"); +$res = $globals->xdb->iterRow("SELECT id, langue_fr FROM langues_def"); -while(list($tmp_lid, $tmp_lg_fr) = mysql_fetch_row($res)){ +while(list($tmp_lid, $tmp_lg_fr) = $res->next()){ $langues_def[$tmp_lid] = $tmp_lg_fr; } @@ -83,9 +83,9 @@ $comppros_levels = Array( 'expert' => 'expert' ); -$res = $globals->db->query("SELECT id, text_fr, FIND_IN_SET('titre',flags) FROM competences_def"); +$res = $globals->xdb->iterRow("SELECT id, text_fr, FIND_IN_SET('titre',flags) FROM competences_def"); -while(list($tmp_id, $tmp_text_fr, $tmp_title) = mysql_fetch_row($res)){ +while(list($tmp_id, $tmp_text_fr, $tmp_title) = $res->next()){ $comppros_def[$tmp_id] = $tmp_text_fr; $comppros_title[$tmp_id] = $tmp_title; } diff --git a/include/profil/update_adresses.inc.php b/include/profil/update_adresses.inc.php index 4ff84fe..95809af 100644 --- a/include/profil/update_adresses.inc.php +++ b/include/profil/update_adresses.inc.php @@ -44,39 +44,63 @@ foreach($adresses as $adrid => $adr){ if ($adr["nouvelle"] == 'ajout') { //nouvelle adresse - $globals->db->query("INSERT INTO adresses SET - adr1 = '".put_in_db($adr['adr1'])."', - adr2 = '".put_in_db($adr['adr2'])."', - adr3 = '".put_in_db($adr['adr3'])."', - cp = '".put_in_db($adr['cp'])."', - ville = '".put_in_db($adr['ville'])."', - pays = '".$adr['pays']."', - region = '".$adr['region']."', - tel = '".put_in_db($adr['tel'])."', - fax = '".put_in_db($adr['fax'])."', - visibilite = '$visibilite', + $globals->xdb->execute("INSERT INTO adresses SET + adr1 = {?}, + adr2 = {?}, + adr3 = {?}, + cp = {?}, + ville = {?}, + pays = {?}, + region = {?}, + tel = {?}, + fax = {?}, + visibilite = {?}, datemaj = NOW(), - statut = '$statut', - uid = '{$_SESSION['uid']}', adrid = '$adrid'"); + statut = {?}, + uid = {?}, adrid = {?}", + $adr['adr1'], + $adr['adr2'], + $adr['adr3'], + $adr['cp'], + $adr['ville'], + $adr['pays'], + $adr['region'], + $adr['tel'], + $adr['fax'], + $visibilite, + $statut, + Session::getInt('uid', -1), $adrid); } else{ //c'est une mise à jour - $globals->db->query( + $globals->xdb->execute( "UPDATE adresses SET - adr1 = '".put_in_db($adr['adr1'])."', - adr2 = '".put_in_db($adr['adr2'])."', - adr3 = '".put_in_db($adr['adr3'])."', - cp = '".put_in_db($adr['cp'])."', - ville = '".put_in_db($adr['ville'])."', - pays = '".$adr['pays']."', - region = '".$adr['region']."', - tel = '".put_in_db($adr['tel'])."', - fax = '".put_in_db($adr['fax'])."', - visibilite = '$visibilite', + adr1 = {?}, + adr2 = {?}, + adr3 = {?}, + cp = {?}, + ville = {?}, + pays = {?}, + region = {?}, + tel = {?}, + fax = {?}, + visibilite = {?}, datemaj = NOW(), - statut = '$statut' - WHERE uid = '".$_SESSION["uid"]."' AND adrid = '$adrid'" + statut = {?} + WHERE uid = {?} AND adrid = {?}", + $adr['adr1'], + $adr['adr2'], + $adr['adr3'], + $adr['cp'], + $adr['ville'], + $adr['pays'], + $adr['region'], + $adr['tel'], + $adr['fax'], + $visibilite, + $statut, + Session::getInt('uid', -1), $adrid ); }// fin nouvelle / ancienne adresse }//fin if nouvellement crée diff --git a/include/profil/update_emploi.inc.php b/include/profil/update_emploi.inc.php index cbde045..78e04f8 100644 --- a/include/profil/update_emploi.inc.php +++ b/include/profil/update_emploi.inc.php @@ -21,22 +21,35 @@ for($i = 0; $i < 2; $i++){ $visibilite = ""; - if (! empty($_REQUEST["entreprise_public"][$i])) $visibilite .= 'entreprise_public,'; - if (! empty($_REQUEST["entreprise_ax"][$i])) $visibilite .= 'entreprise_ax,'; - if (! empty($_REQUEST["adrpro_public"][$i])) $visibilite .= 'adr_public,'; - if (! empty($_REQUEST["adrpro_ax"][$i])) $visibilite .= 'adr_ax,'; - if (! empty($_REQUEST["telpro_public"][$i])) $visibilite .= 'tel_public,'; - if (! empty($_REQUEST["telpro_ax"][$i])) $visibilite .= 'tel_ax,'; + $tab = Env::getMixed("entreprise_public", Array()); + if (! empty($tab[$i])) $visibilite .= 'entreprise_public,'; + $tab = Env::getMixed("entreprise_ax", Array()); + if (! empty($tab[$i])) $visibilite .= 'entreprise_ax,'; + $tab = Env::getMixed("adrpro_public", Array()); + if (! empty($tab[$i])) $visibilite .= 'adr_public,'; + $tab = Env::getMixed("adrpro_ax", Array()); + if (! empty($tab[$i])) $visibilite .= 'adr_ax,'; + $tab = Env::getMixed("telpro_public", Array()); + if (! empty($tab[$i])) $visibilite .= 'tel_public,'; + $tab = Env::getMixed("telpro_ax", Array()); + if (! empty($tab[$i])) $visibilite .= 'tel_ax,'; if (! empty($visibilite)) $visibilite = substr($visibilite, 0, -1); - $globals->db->query("REPLACE INTO entreprises(uid,entrid,entreprise,secteur,ss_secteur,poste,fonction,adr1,adr2,adr3,cp,ville,pays,region,tel,fax,visibilite) ". - "VALUES ('{$_SESSION['uid']}','$i','".put_in_db($entreprise[$i])."',". - ( ($secteur[$i] == "") ? "NULL ," : "'{$secteur[$i]}',") . //sinon un faux 0 est rentre dans la base - ( ($ss_secteur[$i] == "") ? "NULL " : "'{$ss_secteur[$i]}'") . - ",'".put_in_db($poste[$i])."','{$fonction[$i]}',". - "'".put_in_db($adrpro1[$i])."','".put_in_db($adrpro2[$i])."', '".put_in_db($adrpro3[$i])."','".put_in_db($cppro[$i])."',". - "'".put_in_db($villepro[$i])."','".put_in_db($payspro[$i])."','" - .put_in_db($regionpro[$i])."','".put_in_db($telpro[$i])."','".put_in_db($faxpro[$i])."', '$visibilite')"); + $globals->xdb->execute("REPLACE INTO entreprises(uid,entrid,entreprise,secteur,ss_secteur,poste,fonction,adr1,adr2,adr3,cp,ville,pays,region,tel,fax,visibilite) ". + "VALUES ({?}, {?}, {?}, ". + "{?},". + "{?}". + ", {?}, {?}, ". + "{?}, {?}, {?}, {?}, ". + "{?}, {?}, ". + "{?}, {?}, {?}, {?})", + Session::getInt('uid', -1) , $i , $entreprise[$i] , + ( ($secteur[$i] == "") ? null : $secteur[$i]), //sinon un faux 0 est rentre dans la base + ( ($ss_secteur[$i] == "") ? null : $ss_secteur[$i]), + $poste[$i], $fonction[$i], + $adrpro1[$i], $adrpro2[$i], $adrpro3[$i], $cppro[$i], + $villepro[$i], $payspro[$i], + $regionpro[$i], $telpro[$i], $faxpro[$i], $visibilite); } -$globals->db->query("UPDATE auth_user_md5 set cv='".put_in_db($cv)."' where user_id='{$_SESSION['uid']}'"); +$globals->xdb->execute("UPDATE auth_user_md5 set cv= {?} WHERE user_id = {?}", $cv, Session::getInt('uid', -1)); ?> diff --git a/include/profil/update_general.inc.php b/include/profil/update_general.inc.php index 4845451..dd20297 100644 --- a/include/profil/update_general.inc.php +++ b/include/profil/update_general.inc.php @@ -20,19 +20,19 @@ ***************************************************************************/ if ($appli_id1>0) - $globals->db->query("replace into applis_ins set uid={$_SESSION['uid']},aid=$appli_id1,type='$appli_type1',ordre=0"); + $globals->xdb->execute("REPLACE INTO applis_ins SET uid= {?}, aid = {?}, type = {?}, ordre = 0", Session::getInt('uid', -1), $appli_id1, $appli_type1); else - $globals->db->query("delete from applis_ins where uid={$_SESSION['uid']} and ordre=0"); + $globals->xdb->execute("DELETE FROM applis_ins WHERE uid= {?} AND ordre=0", Session::getInt('uid', -1)); if ($appli_id2>0) - $globals->db->query("replace into applis_ins set uid={$_SESSION['uid']},aid=$appli_id2,type='$appli_type2',ordre=1"); + $globals->xdb->execute("REPLACE INTO applis_ins SET uid= {?}, aid = {?}, type = {?}, ordre = 1", Session::getInt('uid', -1), $appli_id2, $appli_type2); else - $globals->db->query("delete from applis_ins where uid={$_SESSION['uid']} and ordre=1"); + $globals->xdb->execute("DELETE FROM applis_ins WHERE uid= {?} AND ordre=1", Session::getInt('uid', -1)); $sql = "UPDATE auth_user_md5 - SET nationalite='$nationalite',web='$web',mobile='$mobile',libre='".put_in_db($libre)."' WHERE user_id={$_SESSION['uid']}"; + SET nationalite= {?}, web= {?}, mobile= {?}, libre= {?} WHERE user_id= {?}"; -$globals->db->query($sql); +$globals->xdb->execute($sql, $nationalite, $web, $mobile, $libre, Session::getInt('uid', -1)); ?> diff --git a/include/profil/update_mentor.inc.php b/include/profil/update_mentor.inc.php index 5a4782a..b34577e 100644 --- a/include/profil/update_mentor.inc.php +++ b/include/profil/update_mentor.inc.php @@ -22,7 +22,7 @@ //mise a jour d'expertise si nécessaire if($mentor_expertise != $mentor_expertise_bd) { - $globals->db->query("REPLACE INTO mentor(uid, expertise) VALUES('{$_SESSION['uid']}', '".put_in_db($mentor_expertise)."')"); + $globals->xdb->execute("REPLACE INTO mentor(uid, expertise) VALUES({?}, {?})", Session::getInt('uid', -1), $mentor_expertise); } diff --git a/include/profil/update_poly.inc.php b/include/profil/update_poly.inc.php index fb5160b..96555f0 100644 --- a/include/profil/update_poly.inc.php +++ b/include/profil/update_poly.inc.php @@ -19,8 +19,8 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ -$sql = "UPDATE auth_user_md5 set section=$section WHERE user_id={$_SESSION['uid']}"; +$sql = "UPDATE auth_user_md5 set section= {?} WHERE user_id= {?}"; -$globals->db->query($sql); +$globals->xdb->execute($sql, $section, Session::getInt('uid', -1)); ?> diff --git a/include/profil/verif_adresses.inc.php b/include/profil/verif_adresses.inc.php index fb69f92..b6edb28 100644 --- a/include/profil/verif_adresses.inc.php +++ b/include/profil/verif_adresses.inc.php @@ -43,12 +43,14 @@ function generate_new_adrid(){ } function replace_ifset_adr($varname, $i){ - if (isset($_REQUEST[$varname][$i])) - $GLOBALS['adresses'][$i][$varname] = $_REQUEST[$varname][$i]; + $tab = Env::getMixed($varname, Array()); + if (isset($tab[$i])) + $GLOBALS['adresses'][$i][$varname] = $tab[$i]; } function set_flag_adr($varname,$i){ - if(isset($_REQUEST[$varname][$i])){ + $tab = Env::getMixed($varname, Array()); + if (isset($tab[$i])){ $GLOBALS['adresses'][$i][$varname] = 1; } else @@ -65,7 +67,7 @@ function replace_address($i){ replace_ifset_adr('secondaire', $i); set_flag_adr('courrier', $i); replace_ifset_adr('temporaire', $i); - if(isset($_REQUEST['adrid_active']) && ($_REQUEST['adrid_active'] == $i)) + if(Env::getInt('adrid_active', $i+1) == $i) $GLOBALS['adresses'][$i]['active'] = 1; else $GLOBALS['adresses'][$i]['active'] = 0; @@ -82,8 +84,9 @@ function replace_address($i){ set_flag_adr('adr_ax', $i); set_flag_adr('tel_public', $i); set_flag_adr('tel_ax', $i); - if($_REQUEST['numero_formulaire'][$i]) - $GLOBALS['adresses'][$i]['numero_formulaire'] = $_REQUEST['numero_formulaire'][$i]; + $tab = Env::getMixed('numero_formulaire', Array()); + if($tab[$i]) + $GLOBALS['adresses'][$i]['numero_formulaire'] = $tab[$i]; else $GLOBALS['adresses'][$i]['numero_formulaire'] = -1; } @@ -91,12 +94,13 @@ function replace_address($i){ //remplace par les eventuelles nouvelles valeurs : for ($adrid = 1; $adrid <= $nb_adr_max; $adrid++) { - if(isset($_REQUEST['adrid'][$adrid])){ //cet adrid etait donc present dans le formulaire + $tab = Env::getMixed('adrid', Array()); + if(isset($tab[$adrid])){ //cet adrid etait donc present dans le formulaire replace_address($adrid); } } -if(($_REQUEST['old_tab'] == 'adresses') && isset($_REQUEST['modifier'])){ // on ne valide que qd on vient du formulaire +if(Env::get('old_tab', '') == 'adresses' && Env::has('modifier')){ // on ne valide que qd on vient du formulaire $adresses_principales = 0; reset($adresses); foreach($adresses as $adrid => $adr) { diff --git a/include/profil/verif_emploi.inc.php b/include/profil/verif_emploi.inc.php index f1a46c2..f54defb 100644 --- a/include/profil/verif_emploi.inc.php +++ b/include/profil/verif_emploi.inc.php @@ -21,7 +21,8 @@ function set_flag_i(&$var,$var_name,$i){ - if(isset($_REQUEST[$var_name][$i])){ + $tab = Env::getMixed($var_name, Array()); + if(isset($tab[$i])){ $var[$i] = 1; } else @@ -45,7 +46,7 @@ replace_ifset_i($regionpro,"regionpro",$i); replace_ifset_i($telpro,"telpro",$i); replace_ifset_i($faxpro,"faxpro",$i); -if(isset($_REQUEST['adresse_flag'])){ +if(Env::has('adresse_flag')){ set_flag_i($entreprise_public,"entreprise_public",$i); set_flag_i($entreprise_ax,"entreprise_ax",$i); set_flag_i($adrpro_public,"adrpro_public",$i); diff --git a/include/profil/verif_mentor.inc.php b/include/profil/verif_mentor.inc.php index 09ce531..f0f4720 100644 --- a/include/profil/verif_mentor.inc.php +++ b/include/profil/verif_mentor.inc.php @@ -21,8 +21,8 @@ //au cas ou le submit du formulaire vient d'un changement du nouveau secteur -if(isset($_POST['mentor_expertise'])){ - $mentor_expertise = $_POST['mentor_expertise']; +if(Post::has('mentor_expertise')){ + $mentor_expertise = Post::get('mentor_expertise'); if(!empty($mentor_expertise)){ if (strlen(strtok($mentor_expertise,"<>{}~§`|%$^")) < strlen($mentor_expertise)){//TODO: affiner la liste $page->trig("L'expertise contient un caractère interdit."); -- 2.1.4