X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=include%2Fuser.func.inc.php;h=c41919739d38d51495abadfef48159b2b4bab9a2;hb=35a224884f65700df59890012f66849d94a3aff7;hp=7da7ada2c8e3b0dce0aeacd7df3bc1a180468c97;hpb=805f3d1679a53bb04fff34619c171a1381068612;p=platal.git diff --git a/include/user.func.inc.php b/include/user.func.inc.php index 7da7ada..c419197 100644 --- a/include/user.func.inc.php +++ b/include/user.func.inc.php @@ -1,6 +1,6 @@ array('requests', 'user_changes')); if ($really_del) { - array_push($tables_to_clear['uid'], 'emails', 'groupex.membres', 'contacts', 'adresses', 'tels', - 'photo', 'perte_pass', 'langues_ins', 'forums.abos', 'forums.profils'); + array_push($tables_to_clear['uid'], 'emails', '#groupex#.membres', 'contacts', 'adresses', 'tels', + 'photo', 'perte_pass', 'langues_ins', '#forums#.abos', '#forums#.profils'); array_push($tables_to_clear['user_id'], 'newsletter_ins', 'auth_user_quick', 'binets_ins'); $tables_to_clear['id'] = array('aliases'); $tables_to_clear['contact'] = array('contacts'); @@ -103,8 +103,10 @@ function get_not_registered_user($login, $iterator = false) return null; } @list($prenom, $nom, $promo) = explode('.', $login); - $where = 'REPLACE(REPLACE(REPLACE(nom, " ", ""), "-", ""), "\'", "") LIKE CONCAT("%", {?}, "%") - AND REPLACE(REPLACE(REPLACE(prenom, " ", ""), "-", ""), "\'", "") LIKE CONCAT("%", {?}, "%")'; + $where = 'REPLACE(REPLACE(REPLACE(nom, " ", ""), "-", ""), "\'", "") + LIKE CONCAT("%", REPLACE(REPLACE(REPLACE({?}, " ", ""), "-", ""), "\'", ""), "%") + AND REPLACE(REPLACE(REPLACE(prenom, " ", ""), "-", ""), "\'", "") + LIKE CONCAT("%", REPLACE(REPLACE(REPLACE({?}, " ", ""), "-", ""), "\'", ""), "%")'; if ($promo) { if (preg_match('/^[0-9]{2}$/', $promo)) { $where .= 'AND MOD(promo, 100) = {?}'; @@ -325,8 +327,8 @@ function &get_user_details($login, $from_uid = '', $view = 'private') $user['binets_join'] = join(', ', $user['binets']); $res = XDB::iterRow("SELECT a.diminutif, a.nom, a.site - FROM groupex.asso AS a - LEFT JOIN groupex.membres AS m ON (m.asso_id = a.id) + FROM #groupex#.asso AS a + LEFT JOIN #groupex#.membres AS m ON (m.asso_id = a.id) WHERE m.uid = {?} AND (a.cat = 'GroupesX' OR a.cat = 'Institutions') AND pub = 'public'", $uid); $user['gpxs'] = Array(); @@ -426,9 +428,11 @@ function remove_user_address($uid, $adrid) { // }}} // {{{ function add_user_tel() function add_user_tel($uid, $adrid, $telid, $tel) { - XDB::execute( - "INSERT INTO tels SET uid = {?}, adrid = {?}, telid = {?}, tel = {?}, tel_type = {?}, tel_pub = {?}", - $uid, $adrid, $telid, $tel['tel'], $tel['tel_type'], $tel['tel_pub']); + $tel['tel_type'] = ($tel['tel_type'] ? $tel['tel_type'] : ''); + XDB::execute('INSERT INTO tels + SET uid = {?}, adrid = {?}, telid = {?}, tel = {?}, + tel_type = {?}, tel_pub = {?}', + $uid, $adrid, $telid, $tel['tel'], $tel['tel_type'], $tel['tel_pub']); } // }}} // {{{ function update_user_tel() @@ -528,18 +532,17 @@ function remove_user_pro($uid, $entrid) { // }}} // {{{ function set_user_details() 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'; @@ -550,17 +553,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; } } } @@ -569,7 +572,7 @@ function set_user_details_pro($uid, $pros) // {{{ function set_user_details() function set_user_details($uid, $details) { if (isset($details['nom_usage'])) { - XDB::execute("UPDATE auth_user_md5 SET nom_usage = {?} WHERE user_id = {?}", strtoupper($details['nom_usage']), $uid); + XDB::execute("UPDATE auth_user_md5 SET nom_usage = {?} WHERE user_id = {?}", mb_strtoupper($details['nom_usage']), $uid); } if (isset($details['mobile'])) { XDB::execute("UPDATE auth_user_quick SET profile_mobile = {?} WHERE user_id = {?}", $details['mobile'], $uid);