X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fuser.func.inc.php;h=09cc874fe84802838f6c8230da38e6297b4617e3;hb=2700a4f5b414f91183460b2dbba33624b5bfd9b7;hp=38b17ad5e2c0dbd60cae196491106e885a68ff3e;hpb=4b239f6e6cb26cdd814b42f3efcbcae40fa862a4;p=platal.git diff --git a/include/user.func.inc.php b/include/user.func.inc.php index 38b17ad..09cc874 100644 --- a/include/user.func.inc.php +++ b/include/user.func.inc.php @@ -257,7 +257,7 @@ function get_user_details_adr($uid, $view = 'private') { function &get_user_details($login, $from_uid = '', $view = 'private') { - $reqsql = "SELECT u.user_id, d.promo_display, u.prenom, u.nom, u.nom_usage, u.date, u.cv, + $reqsql = "SELECT u.user_id, d.promo, u.prenom, u.nom, u.nom_usage, u.date, u.cv, u.perms IN ('admin','user','disabled') AS inscrit, FIND_IN_SET('femme', u.flags) AS sexe, u.deces != 0 AS dcd, u.deces, q.profile_nick AS nickname, q.profile_from_ax, q.profile_freetext AS freetext, q.profile_freetext_pub AS freetext_pub, @@ -286,7 +286,7 @@ function &get_user_details($login, $from_uid = '', $view = 'private') LEFT JOIN profile_mentor AS m ON (m.uid = u.user_id) LEFT JOIN emails AS e ON (e.uid = u.user_id AND e.flags='active') INNER JOIN profile_names_display AS nd ON (nd.user_id = u.user_id) - INNER JOIN profile_display AS d ON (d.uid = u.user_id) + INNER JOIN profile_display AS d ON (d.pid = u.user_id) WHERE a.alias = {?} GROUP BY u.user_id"; $res = XDB::query($reqsql, $from_uid, $login); @@ -357,7 +357,7 @@ function &get_user_details($login, $from_uid = '', $view = 'private') LEFT JOIN profile_education_enum AS en ON (en.id = ed.eduid) LEFT JOIN profile_education_degree_enum AS d ON (d.id = ed.degreeid) LEFT JOIN profile_education_field_enum AS f ON (f.id = ed.fieldid) - WHERE uid={?} + WHERE uid = {?} AND NOT FIND_IN_SET('primary', flags) ORDER BY ed.grad_year", $uid); if (list($name, $url, $degree, $grad_year, $field, $program) = $res->next()) { @@ -591,18 +591,17 @@ function remove_user_pro($uid, $entrid) { // }}} // {{{ function set_user_details_addresses() function set_user_details_addresses($uid, $adrs) { - $res = XDB::query("SELECT adrid FROM adresses WHERE uid = {?} AND adrid >= 1 ORDER BY adrid", $uid); - $adrids = $res->fetchColumn(); + $req = XDB::query('SELECT MAX(adrid) + 1 + FROM adresses + WHERE uid = {?}', $uid); + $adrid = $req->fetchOneCell(); + if (is_null($adrid)) { + $adrid = 0; + } foreach ($adrs as $adr) { - if (isset($adr['adrid']) && isset($adr['remove']) && $adr['remove']) { - remove_user_address($uid, $adr['adrid']); - if (isset($adrids[$adr['adrid']])) unset($adrids[$adr['adrid']]); - } else if (isset($adr['adrid'])) { - update_user_address($uid, $adr['adrid'], $adr); - } else { - for ($adrid = 1; isset($adrids[$adrid-1]) && ($adrids[$adrid-1] == $adrid); $adrid++); + if (!@$adr['remove']) { add_user_address($uid, $adrid, $adr); - $adrids[$adrid-1] = $adrid; + ++$adrid; } } require_once 'geoloc.inc.php'; @@ -613,17 +612,17 @@ function set_user_details_addresses($uid, $adrs) { function set_user_details_pro($uid, $pros) { - $res = XDB::query("SELECT entrid FROM entreprises WHERE uid = {?} ORDER BY entrid", $uid); - $entrids = $res->fetchColumn(); + $req = XDB::query('SELECT MAX(entrid) + 1 + FROM entreprises + WHERE uid = {?}', $uid); + $entrid = $req->fetchOneCell(); + if (is_null($entrid)) { + $entrid = 0; + } foreach ($pros as $pro) { - if (isset($pro['entrid']) && isset($pro['remove']) && $pro['remove']) { - remove_user_pro($uid, $pro['entrid']); - if (isset($entrids[$pro['entrid']])) unset($entrids[$pro['entrid']]); - } else if (isset($pro['entrid'])) { - update_user_pro($uid, $pro['entrid'], $pro); - } else { - for ($entrid = 0; isset($entrids[$entrid]) && ($entrids[$entrid] == $entrid); $entrid++); + if (!@$pro['remove']) { add_user_pro($uid, $entrid, $pro); + ++$entrid; } } }