X-Git-Url: http://git.polytechnique.org/?a=blobdiff_plain;f=modules%2Fprofile%2Fgeneral.inc.php;h=488d180745f3424cca3e66f95c8ae3c18204cb94;hb=257ae4081d1b5da12c4458f0642b9d2b7843abee;hp=9856dc83d588ec0c9487e42931f87d74fcf80b0d;hpb=3f95a7bd17cd6cd7b218f12787276a485f496f1d;p=platal.git diff --git a/modules/profile/general.inc.php b/modules/profile/general.inc.php index 9856dc8..488d180 100644 --- a/modules/profile/general.inc.php +++ b/modules/profile/general.inc.php @@ -1,6 +1,6 @@ next(); } } else { - $value[] = array('typeid' => $sn_type['id'], - 'type' => $sn_type['type'], - 'type_name' => $sn_type['name'], - 'pub' => 1, + $value[] = array('name' => '', + 'particle' => '', + 'typeid' => $sn_type['id'], + 'type' => $sn_type['type'], + 'type_name' => $sn_type['name'], 'has_particle' => $sn_type['has_particle'], - 'always_displayed' => 1); + 'always_displayed' => 1, + 'pub' => 1); } } if ($sn) { @@ -162,6 +165,7 @@ class ProfileSearchNames implements ProfileSetting Platal::page()->assign('public_name', $public_name); Platal::page()->assign('private_name', $private_name); } + return $value; } @@ -180,7 +184,7 @@ class ProfileSearchNames implements ProfileSetting if ($has_new) { $new_names = new NamesReq(S::user(), $this->search_names, $this->private_name_end); $new_names->submit(); - Platal::page()->trigWarning("La demande de modification de tes noms a bien été prises en compte." . + Platal::page()->trigWarning("La demande de modification de tes noms a bien été prise en compte." . " Tu recevras un email dès que ces changements auront été effectués."); } else { $display_names = array(); @@ -211,7 +215,7 @@ class ProfileEdu implements ProfileSetting $value = array(); $value = XDB::fetchAllAssoc("SELECT eduid, degreeid, fieldid, grad_year, program FROM profile_education - WHERE uid = {?} AND !FIND_IN_SET('primary', flags) + WHERE pid = {?} AND !FIND_IN_SET('primary', flags) ORDER BY id", $page->pid()); } else { @@ -236,12 +240,12 @@ class ProfileEdu implements ProfileSetting public function save(ProfilePage &$page, $field, $value) { XDB::execute("DELETE FROM profile_education - WHERE uid = {?} AND !FIND_IN_SET('primary', flags)", + WHERE pid = {?} AND !FIND_IN_SET('primary', flags)", $page->pid()); foreach ($value as $eduid=>&$edu) { if ($edu['eduid'] != '') { XDB::execute("INSERT INTO profile_education - SET id = {?}, uid = {?}, eduid = {?}, degreeid = {?}, + SET id = {?}, pid = {?}, eduid = {?}, degreeid = {?}, fieldid = {?}, grad_year = {?}, program = {?}", $eduid, $page->pid(), $edu['eduid'], $edu['degreeid'], $edu['fieldid'], $edu['grad_year'], $edu['program']); @@ -296,7 +300,7 @@ class ProfileNetworking implements ProfileSetting $value = XDB::fetchAllAssoc("SELECT n.address, n.network_type AS type, n.pub, m.name FROM profile_networking AS n INNER JOIN profile_networking_enum AS m ON (n.network_type = m.network_type) - WHERE n.uid = {?}", + WHERE n.pid = {?}", $page->pid()); } if (!is_array($value)) { @@ -334,14 +338,14 @@ class ProfileNetworking implements ProfileSetting public function save(ProfilePage &$page, $field, $value) { XDB::execute("DELETE FROM profile_networking - WHERE uid = {?}", + WHERE pid = {?}", $page->pid()); if (!count($value)) { return; } $insert = array(); foreach ($value as $id=>$network) { - XDB::execute("INSERT INTO profile_networking (uid, nwid, network_type, address, pub) + XDB::execute("INSERT INTO profile_networking (pid, nwid, network_type, address, pub) VALUES ({?}, {?}, {?}, {?}, {?})", $page->pid(), $id, $network['type'], $network['address'], $network['pub']); } @@ -368,8 +372,6 @@ class ProfileGeneral extends ProfilePage = $this->settings['yourself'] = $this->settings['promo'] = null; - $this->settings['synchro_ax'] - = new ProfileBool(); $this->settings['email_directory'] = new ProfileEmail(); $this->settings['email_directory_new'] @@ -389,13 +391,12 @@ class ProfileGeneral extends ProfilePage $res = XDB::query("SELECT p.promo, e.entry_year AS entry_year, e.grad_year AS grad_year, pr.nationality1, pr.nationality2, pr.nationality3, pr.birthdate, t.display_tel as mobile, t.pub as mobile_pub, - d.email_directory as email_directory, - pr.freetext, pr.freetext_pub as freetext_pub + pr.email_directory as email_directory, + pr.freetext, pr.freetext_pub, pr.ax_id AS matricule_ax, p.yourself FROM profiles AS pr INNER JOIN profile_display AS p ON (p.pid = pr.pid) - INNER JOIN profile_education AS e ON (e.uid = pr.pid AND FIND_IN_SET('primary', e.flags)) - LEFT JOIN profile_phones AS t ON (t.uid = pr.pid AND link_type = 'user') - LEFT JOIN profile_directory AS d ON (d.uid = pr.pid) + INNER JOIN profile_education AS e ON (e.pid = pr.pid AND FIND_IN_SET('primary', e.flags)) + LEFT JOIN profile_phones AS t ON (t.pid = pr.pid AND link_type = 'user') WHERE pr.pid = {?}", $this->pid()); $this->values = $res->fetchOneAssoc(); if ($this->owner) { @@ -404,14 +405,14 @@ class ProfileGeneral extends ProfilePage // Retreive photo informations $res = XDB::query("SELECT pub - FROM photo - WHERE uid = {?}", $this->pid()); + FROM profile_photos + WHERE pid = {?}", $this->pid()); $this->values['photo_pub'] = $res->fetchOneCell(); if ($this->owner) { $res = XDB::query("SELECT COUNT(*) FROM requests - WHERE type='photo' AND user_id = {?}", + WHERE type = 'photo' AND uid = {?}", $this->owner->id()); $this->values['nouvellephoto'] = $res->fetchOneCell(); } else { @@ -429,7 +430,8 @@ class ProfileGeneral extends ProfilePage protected function _saveData() { if ($this->changed['nationality1'] || $this->changed['nationality2'] || $this->changed['nationality3'] - || $this->changed['birthdate'] || $this->changed['freetext'] || $this->changed['freetext_pub']) { + || $this->changed['birthdate'] || $this->changed['freetext'] || $this->changed['freetext_pub'] + || $this->changed['email_directory']) { if ($this->values['nationality3'] == "") { $this->values['nationality3'] = NULL; } @@ -442,30 +444,24 @@ class ProfileGeneral extends ProfilePage $this->values['nationality2'] = $this->values['nationality3']; $this->values['nationality3'] = NULL; } - - XDB::execute("UPDATE profiles - SET nationality1 = {?}, nationality2 = {?}, nationality3 = {?}, birthdate = {?}, - freetext = {?}, freetext_pub = {?} - WHERE user_id = {?}", - $this->values['nationality1'], $this->values['nationality2'], $this->values['nationality3'], - preg_replace('@(\d{2})/(\d{2})/(\d{4})@', '\3-\2-\1', $this->values['birthdate']), - $this->values['freetext'], $this->values['freetext_pub'], - $this->pid()); - } - if ($this->changed['email_directory']) { $new_email = ($this->values['email_directory'] == "new@example.org") ? $this->values['email_directory_new'] : $this->values['email_directory']; if ($new_email == "") { $new_email = NULL; } - XDB::execute("REPLACE INTO profile_directory (uid, email_directory) - VALUES ({?}, {?})", - $this->pid(), $new_email); + + XDB::execute("UPDATE profiles + SET nationality1 = {?}, nationality2 = {?}, nationality3 = {?}, birthdate = {?}, + freetext = {?}, freetext_pub = {?}, email_directory = {?} + WHERE pid = {?}", + $this->values['nationality1'], $this->values['nationality2'], $this->values['nationality3'], + preg_replace('@(\d{2})/(\d{2})/(\d{4})@', '\3-\2-\1', $this->values['birthdate']), + $this->values['freetext'], $this->values['freetext_pub'], $new_email, $this->pid()); } if ($this->changed['photo_pub']) { - XDB::execute("UPDATE photo + XDB::execute("UPDATE profile_photos SET pub = {?} - WHERE uid = {?}", + WHERE pid = {?}", $this->values['photo_pub'], $this->pid()); } if ($this->changed['yourself']) {