From 541e8d0307af50554cdd030fc35e5cdac30dd355 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Sun, 8 Mar 2009 16:58:54 +0100 Subject: [PATCH] Adds job address to the job interface, makes more uniform address related names. --- bin/cron/clean.php | 4 +- htdocs/javascript/profile.js | 74 ++++---- include/userset.inc.php | 2 +- modules/profile.php | 87 ++++----- modules/profile/addresses.inc.php | 10 +- modules/profile/jobs.inc.php | 207 ++++++++++++--------- modules/profile/mentor.inc.php | 8 +- templates/admin/index.tpl | 4 - templates/geoloc/form.address.tpl | 8 +- templates/include/emails.combobox.tpl | 138 +++++++------- templates/include/emploi.tpl | 6 +- templates/include/minifiche.tpl | 2 +- templates/profile/fiche_referent.tpl | 8 +- templates/profile/jobs.job.tpl | 58 +++--- .../profile/{jobs.secteur.tpl => jobs.sector.tpl} | 10 +- .../{jobs.soussecteur.tpl => jobs.sub_sector.tpl} | 6 +- templates/profile/mentor.tpl | 26 +-- templates/profile/referent.tpl | 14 +- 18 files changed, 339 insertions(+), 333 deletions(-) rename templates/profile/{jobs.secteur.tpl => jobs.sector.tpl} (85%) rename templates/profile/{jobs.soussecteur.tpl => jobs.sub_sector.tpl} (89%) diff --git a/bin/cron/clean.php b/bin/cron/clean.php index 88feaab..6325f63 100755 --- a/bin/cron/clean.php +++ b/bin/cron/clean.php @@ -40,7 +40,9 @@ query("DELETE FROM register_pending WHERE hash = 'INSCRIT'"); query("ALTER TABLE profile_education_enum ORDER BY name"); query("ALTER TABLE binets_def ORDER BY text"); query("ALTER TABLE groupesx_def ORDER BY text"); -query("ALTER TABLE secteur ORDER BY text"); +query("ALTER TABLE profile_job_sector_enum ORDER BY name"); +query("ALTER TABLE profile_job_subsector_enum ORDER BY name"); +query("ALTER TABLE profile_job_subsubsector_enum ORDER BY name"); query("ALTER TABLE sections ORDER BY text"); // Prunes older autocomplete queries. diff --git a/htdocs/javascript/profile.js b/htdocs/javascript/profile.js index 971b5b5..fbf4063 100644 --- a/htdocs/javascript/profile.js +++ b/htdocs/javascript/profile.js @@ -46,8 +46,8 @@ function wizPage_onLoad(id) break; case 'emploi': for (var i = 0 ; $('#job_' + i).length != 0; ++i) { - updateJobSector(i, $('#job_' + i).find("[name*='[ss_secteur]']").val()); - updateJobSubSector(i, $('#job_' + i).find("[name*='[sss_secteur]']").val()); + updateJobSector(i, $('#job_' + i).find("[name='jobs[" + i + "][subSector]']").val()); + updateJobSubSector(i, $('#job_' + i).find("[name='jobs[" + i + "][subSubsector]']").val()); } break; } @@ -295,23 +295,23 @@ function addAddress() Ajax.update_html('addresses_' + i + '_cont', 'profile/ajax/address/' + i, checkCurrentAddress()); } -function addressChanged(id) +function addressChanged(prefid) { - $('#addresses_' + id + '_cont').find('[name*=changed]').val("1"); + $('#' + prefid + '_cont').find('[name*=changed]').val("1"); } -function validGeoloc(id, geoloc) +function validGeoloc(prefid, id, geoloc) { if (geoloc == 1) { - $('#addresses_' + id + '_cont').find('[name*=text]').val($('#addresses_' + id + '_cont').find('[name*=geoloc]').val()); - $('#addresses_' + id + '_cont').find('[name*=postalText]').val($('#addresses_' + id + '_cont').find('[name*=geocodedPostalText]').val()); + $('#' + prefid + '_cont').find('[name*=text]').val($('#' + prefid + '_cont').find('[name*=geoloc]').val()); + $('#' + prefid + '_cont').find('[name*=postalText]').val($('#' + prefid + '_cont').find('[name*=geocodedPostalText]').val()); } if (geoloc > 0) { - $('#addresses_' + id + '_cont').find("[name='addresses[" + id + "][geoloc]']").remove(); + $('#' + prefid + '_cont').find("[name*='[geoloc]']").remove(); } - $('#addresses_' + id + '_cont').find('[name*=text]').removeClass('error'); - $('#addresses_' + id + '_cont').find('[name*=geoloc_choice]').val(geoloc); - $('.addresses_' + id + '_geoloc').remove(); + $('#' + prefid + '_cont').find('[name*=text]').removeClass('error'); + $('#' + prefid + '_cont').find('[name*=geoloc_choice]').val(geoloc); + $('.' + prefid + '_geoloc').remove(); } // {{{1 Phones @@ -458,20 +458,20 @@ function restoreJob(id, pref) function updateJobSector(id, sel) { - var sector = $('#job_' + id).find("[name*='[secteur]']").val(); + var sector = $('#job_' + id).find("[name='jobs[" + id + "][sector]']").val(); if (sector == '') { sector = '-1'; } - Ajax.update_html('job_' + id + '_ss_secteur', 'profile/ajax/secteur/' + id + '/job_' + id + '/jobs[' + id + ']/' + sector + '/' + sel); + Ajax.update_html('job_' + id + '_subSector', 'profile/ajax/sector/' + id + '/job_' + id + '/jobs[' + id + ']/' + sector + '/' + sel); } function updateJobSubSector(id, sel) { - var subSector = $('#job_' + id).find("[name*='[ss_secteur]']").val(); + var subSector = $('#job_' + id).find("[name='jobs[" + id + "][subSector]']").val(); if (subSector == '') { subSector = '-1'; } - Ajax.update_html('job_' + id + '_sss_secteur', 'profile/ajax/ssecteur/' + id + '/' + subSector + '/' + sel); + Ajax.update_html('job_' + id + '_subSubSector', 'profile/ajax/sub_sector/' + id + '/' + subSector + '/' + sel); } function displayAllSector(id) @@ -537,53 +537,53 @@ function addCountry() function updateSubSector() { - var s = $('#secteur_sel').find('[name=secteur_sel]').val(); - var ss = $('#ss_secteur_sel').find("[name='jobs[-1][ss_secteur]']").val(); - if ((s == '' || ss == '') || $('#secteurs_' + s + '_' + ss).length != 0) { - $('#secteurs_add').hide(); + var s = $('#sectorSelection').find('[name=sectorSelection]').val(); + var ss = $('#selectedSubSector').find("[name='jobs[-1][subSector]']").val(); + if ((s == '' || ss == '') || $('#sectors_' + s + '_' + ss).length != 0) { + $('#addSector').hide(); } else { - $('#secteurs_add').show(); + $('#addSector').show(); } } function removeSector(s, ss) { - $('#secteurs_' + s + '_' + ss).remove(); + $('#sectors_' + s + '_' + ss).remove(); updateSubSector(); } function updateSector() { - var secteur = $('#secteur_sel').find('[name=secteur_sel]').val(); - if (secteur == '') { - secteur = '-1'; - $('#ss_secteur_sel').html(''); + var sector = $('#sectorSelection').find('[name=sectorSelection]').val(); + if (sector == '') { + sector = '-1'; + $('#selectedSubSector').html(''); return; } - $.get(platal_baseurl + 'profile/ajax/secteur/-1/0/0/' + secteur, + $.get(platal_baseurl + 'profile/ajax/sector/-1/0/0/' + sector, function(data) { - data = '' + data; - $('#ss_secteur_sel').html(data); - $('#ss_secteur_sel').find("[name='jobs[-1][ss_secteur]']").change(updateSubSector); + $('#selectedSubSector').html(data); + $('#selectedSubSector').find("[name='jobs[-1][subSector]']").change(updateSubSector); }); } function addSector() { - var s = $('#secteur_sel').find('[name=secteur_sel]').val(); - var ss = $('#ss_secteur_sel').find("[name='jobs[-1][ss_secteur]']").val(); - var sst = $('#ss_secteur_sel').find("[name='jobs[-1][ss_secteur]'] :selected").text(); + var s = $('#sectorSelection').find('[name=sectorSelection]').val(); + var ss = $('#selectedSubSector').find("[name='jobs[-1][subSector]']").val(); + var sst = $('#selectedSubSector').find("[name='jobs[-1][subSector]'] :selected").text(); - var html = '
' + var html = '
' + ' ' + ' ' + ' ' - + ' ' + + ' ' + ' ' + sst + '
'; - $('#secteurs').append(html); + $('#sectors').append(html); updateSubSector(); } @@ -604,8 +604,8 @@ function registerEnterpriseAutocomplete(id) $(".sector_name").each( function() { - if (id == -1 || this.name == "jobs[" + id + "][sss_secteur_name]") { - $(this).autocomplete(platal_baseurl + "search/autocomplete/sss_secteur", + if (id == -1 || this.name == "jobs[" + id + "][subSubSector]") { + $(this).autocomplete(platal_baseurl + "search/autocomplete/subSubSector", { selectOnly:1, field:this.name, diff --git a/include/userset.inc.php b/include/userset.inc.php index 32dd544..b824fc7 100644 --- a/include/userset.inc.php +++ b/include/userset.inc.php @@ -180,7 +180,7 @@ class MinificheView extends MultipageView u.perms != 'pending' AS wasinscrit, u.deces != 0 AS dcd, u.deces, u.matricule_ax, FIND_IN_SET('femme', u.flags) AS sexe, - je.name AS entreprise, je.url AS job_web, es.name AS secteur, ef.fonction_fr AS fonction, + je.name AS entreprise, je.url AS job_web, es.name AS sector, ef.fonction_fr AS fonction, IF(n1.nat = '', n1.countryFR, n1.nat) AS nat1, n1.iso_3166_1_a2 AS iso3166_1, IF(n2.nat = '', n2.countryFR, n2.nat) AS nat2, n2.iso_3166_1_a2 AS iso3166_2, IF(n3.nat = '', n3.countryFR, n3.nat) AS nat3, n3.iso_3166_1_a2 AS iso3166_3, diff --git a/modules/profile.php b/modules/profile.php index 60747e5..31677e4 100644 --- a/modules/profile.php +++ b/modules/profile.php @@ -38,8 +38,8 @@ class ProfileModule extends PLModule 'profile/ajax/medal' => $this->make_hook('ajax_medal', AUTH_COOKIE, 'user', NO_AUTH), 'profile/networking' => $this->make_hook('networking', AUTH_PUBLIC), 'profile/ajax/job' => $this->make_hook('ajax_job', AUTH_COOKIE, 'user', NO_AUTH), - 'profile/ajax/secteur' => $this->make_hook('ajax_secteur', AUTH_COOKIE, 'user', NO_AUTH), - 'profile/ajax/ssecteur' => $this->make_hook('ajax_ssecteur', AUTH_COOKIE, 'user', NO_AUTH), + 'profile/ajax/sector' => $this->make_hook('ajax_sector', AUTH_COOKIE, 'user', NO_AUTH), + 'profile/ajax/sub_sector' => $this->make_hook('ajax_sub_sector', AUTH_COOKIE, 'user', NO_AUTH), 'profile/ajax/skill' => $this->make_hook('ajax_skill', AUTH_COOKIE, 'user', NO_AUTH), 'profile/ajax/searchname' => $this->make_hook('ajax_searchname', AUTH_COOKIE, 'user', NO_AUTH), 'profile/ajax/buildnames' => $this->make_hook('ajax_buildnames', AUTH_COOKIE, 'user', NO_AUTH), @@ -65,10 +65,8 @@ class ProfileModule extends PLModule 'admin/education_degree' => $this->make_hook('admin_education_degree', AUTH_MDP, 'admin'), 'admin/education_degree_set' => $this->make_hook('admin_education_degree_set', AUTH_MDP, 'admin'), 'admin/sections' => $this->make_hook('admin_sections', AUTH_MDP, 'admin'), - 'admin/secteurs' => $this->make_hook('admin_secteurs', AUTH_MDP, 'admin'), 'admin/networking' => $this->make_hook('admin_networking', AUTH_MDP, 'admin'), 'admin/trombino' => $this->make_hook('admin_trombino', AUTH_MDP, 'admin'), - 'admin/ss_secteurs' => $this->make_hook('admin_ss_secteurs', AUTH_MDP, 'admin'), 'admin/fonctions' => $this->make_hook('admin_fonctions', AUTH_MDP, 'admin'), 'admin/corps_enum' => $this->make_hook('admin_corps_enum', AUTH_MDP, 'admin'), 'admin/corps_rank' => $this->make_hook('admin_corps_rank', AUTH_MDP, 'admin'), @@ -479,9 +477,9 @@ class ProfileModule extends PLModule $page->assign('i', $id); $page->assign('job', array()); $page->assign('new', true); - $res = XDB::query("SELECT id, name AS label + $res = XDB::query("SELECT id, name FROM profile_job_sector_enum"); - $page->assign('secteurs', $res->fetchAllAssoc()); + $page->assign('sectors', $res->fetchAllAssoc()); $res = XDB::query("SELECT id, fonction_fr, FIND_IN_SET('titre', flags) AS title FROM fonctions_def ORDER BY id"); @@ -490,15 +488,15 @@ class ProfileModule extends PLModule fill_email_combobox($page); } - function handler_ajax_secteur(&$page, $id, $jobid, $jobpref, $sect, $ssect = -1) + function handler_ajax_sector(&$page, $id, $jobid, $jobpref, $sect, $ssect = -1) { header('Content-Type: text/html; charset=utf-8'); - $res = XDB::iterator("SELECT id, name AS label, FIND_IN_SET('optgroup', flags) AS optgroup + $res = XDB::iterator("SELECT id, name, FIND_IN_SET('optgroup', flags) AS optgroup FROM profile_job_subsector_enum WHERE sectorid = {?}", $sect); - $page->changeTpl('profile/jobs.secteur.tpl', NO_SKIN); + $page->changeTpl('profile/jobs.sector.tpl', NO_SKIN); $page->assign('id', $id); - $page->assign('ssecteurs', $res); + $page->assign('subSectors', $res); $page->assign('sel', $ssect); if ($id != -1) { $page->assign('change', 1); @@ -507,15 +505,15 @@ class ProfileModule extends PLModule } } - function handler_ajax_ssecteur(&$page, $id, $ssect, $sssect = -1) + function handler_ajax_sub_sector(&$page, $id, $ssect, $sssect = -1) { header('Content-Type: text/html; charset=utf-8'); - $res = XDB::iterator("SELECT id, name AS label + $res = XDB::iterator("SELECT id, name FROM profile_job_subsubsector_enum WHERE subsectorid = {?}", $ssect); - $page->changeTpl('profile/jobs.soussecteur.tpl', NO_SKIN); + $page->changeTpl('profile/jobs.sub_sector.tpl', NO_SKIN); $page->assign('id', $id); - $page->assign('sssecteurs', $res); + $page->assign('subSubSectors', $res); $page->assign('sel', $sssect); } @@ -635,20 +633,20 @@ class ProfileModule extends PLModule $res = XDB::query("SELECT expertise FROM profile_mentor WHERE uid = {?}", $user->id()); $page->assign('expertise', $res->fetchOneCell()); - //secteurs - $secteurs = $ss_secteurs = Array(); + // Sectors + $sectors = $subSectors = Array(); $res = XDB::iterRow( "SELECT s.name AS label, ss.name AS label FROM profile_mentor_sector AS m LEFT JOIN profile_job_sector_enum AS s ON(m.sectorid = s.id) LEFT JOIN profile_job_subsector_enum AS ss ON(m.sectorid = ss.sectorid AND m.subsectorid = ss.id) WHERE uid = {?}", $user->id()); - while (list($sec, $ssec) = $res->next()) { - $secteurs[] = $sec; - $ss_secteurs[] = $ssec; + while (list($sector, $subSector) = $res->next()) { + $sectors[] = $sector; + $subSectors[] = $subSector; } - $page->assign_by_ref('secteurs', $secteurs); - $page->assign_by_ref('ss_secteurs', $ss_secteurs); + $page->assign_by_ref('sectors', $sectors); + $page->assign_by_ref('subSectors', $subSectors); // Countries. $res = XDB::query( @@ -668,32 +666,33 @@ class ProfileModule extends PLModule $page->setTitle('Conseil Pro'); - //recuperation des noms de secteurs - $res = XDB::iterRow("SELECT id, name AS label FROM profile_job_sector_enum"); - $secteurs[''] = ''; + // Retrieval of sector names + $res = XDB::iterRow("SELECT id, name AS label + FROM profile_job_sector_enum"); + $sectors[''] = ''; while (list($tmp_id, $tmp_label) = $res->next()) { - $secteurs[$tmp_id] = $tmp_label; + $sectors[$tmp_id] = $tmp_label; } - $page->assign_by_ref('secteurs', $secteurs); + $page->assign_by_ref('sectors', $sectors); // nb de mentors $res = XDB::query("SELECT count(*) FROM profile_mentor"); $page->assign('mentors_number', $res->fetchOneCell()); // On vient d'un formulaire - $where = array(); - $pays_sel = XDB::escape(Env::v('pays_sel')); - $secteur_sel = XDB::escape(Env::v('secteur')); - $ss_secteur_sel = XDB::escape(Env::v('ss_secteur')); - $expertise_champ = XDB::escape(Env::v('expertise')); + $where = array(); + $pays_sel = XDB::escape(Env::v('pays_sel')); + $sectorSelection = XDB::escape(Env::v('sector')); + $subSectorSelection = XDB::escape(Env::v('subSector')); + $expertise_champ = XDB::escape(Env::v('expertise')); if ($pays_sel != "''") { $where[] = "mp.country = $pays_sel"; } - if ($secteur_sel != "''") { - $where[] = "ms.sectorid = $secteur_sel"; - if ($ss_secteur_sel != "''") { - $where[] = "ms.subsectorid = $ss_secteur_sel"; + if ($sectorSelection != "''") { + $where[] = "ms.sectorid = " . $sectorSelection; + if ($selectedSubSector != "''") { + $where[] = "ms.subsectorid = " . $subSectorSelection; } } if ($expertise_champ != "''") { @@ -720,9 +719,9 @@ class ProfileModule extends PLModule { header('Content-Type: text/html; charset=utf-8'); $page->changeTpl('include/field.select.tpl', NO_SKIN); - $page->assign('onchange', 'setSSecteurs()'); + $page->assign('onchange', 'setSSectors()'); $page->assign('id', 'ssect_field'); - $page->assign('name', 'ss_secteur'); + $page->assign('name', 'subSector'); $it = XDB::iterator("SELECT id, name AS field FROM profile_job_subsector_enum WHERE sectorid = {?}", $sect); @@ -874,13 +873,6 @@ class ProfileModule extends PLModule $table_editor->describe('text','intitulé',true); $table_editor->apply($page, $action, $id); } - function handler_admin_ss_secteurs(&$page, $action = 'list', $id = null) { - $page->setTitle('Administration - Sous-secteurs'); - $page->assign('title', 'Gestion des sous-secteurs'); - $table_editor = new PLTableEditor('admin/ss_secteurs', 'emploi_ss_secteur', 'id', true); - $table_editor->describe('label', 'intitulé', true); - $table_editor->apply($page, $action, $id); - } function handler_admin_fonctions(&$page, $action = 'list', $id = null) { $page->setTitle('Administration - Fonctions'); $page->assign('title', 'Gestion des fonctions'); @@ -890,13 +882,6 @@ class ProfileModule extends PLModule $table_editor->describe('flags', 'titre', true); $table_editor->apply($page, $action, $id); } - function handler_admin_secteurs(&$page, $action = 'list', $id = null) { - $page->setTitle('Administration - Secteurs'); - $page->assign('title', 'Gestion des secteurs'); - $table_editor = new PLTableEditor('admin/secteurs', 'emploi_secteur', 'id', true); - $table_editor->describe('label', 'intitulé', true); - $table_editor->apply($page, $action, $id); - } function handler_admin_networking(&$page, $action = 'list', $id = null) { $page->assign('xorg_title', 'Polytechnique.org - Administration - Networking'); $page->assign('title', 'Gestion des types de networking'); diff --git a/modules/profile/addresses.inc.php b/modules/profile/addresses.inc.php index d073956..49b7f95 100644 --- a/modules/profile/addresses.inc.php +++ b/modules/profile/addresses.inc.php @@ -93,7 +93,7 @@ class ProfileAddress extends ProfileGeocoding format_phone_number($tel['tel']), $tel['tel'], $tel['pub']); } - private function saveAddress($addrid, array &$address) + public function saveAddress($addrid, array &$address, $type) { require_once "geocoding.inc.php"; @@ -123,9 +123,9 @@ class ProfileAddress extends ProfileGeocoding subAdministrativeAreaId, administrativeAreaId, countryId, latitude, longitude, updateTime, pub, comment, north, south, east, west) - VALUES ({?}, 'home', {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, + VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, FROM_UNIXTIME({?}), {?}, {?}, {?}, {?}, {?}, {?})", - S::i('uid'), $addrid, $flags, $address['accuracy'], + S::i('uid'), $type, $addrid, $flags, $address['accuracy'], $address['text'], $address['postalText'], $address['postalCode'], $address['localityId'], $address['subAdministrativeAreaId'], $address['administrativeAreaId'], $address['countryId'], $address['latitude'], $address['longitude'], @@ -142,7 +142,7 @@ class ProfileAddress extends ProfileGeocoding WHERE uid = {?} AND link_type = 'address'", S::i('uid')); foreach ($value as $addrid => &$address) { - $this->saveAddress($addrid, $address); + $this->saveAddress($addrid, $address, 'home'); $profiletel = new ProfilePhones('address', $addrid); $profiletel->saveTels('tel', $address['tel']); } @@ -162,7 +162,7 @@ class ProfileAddresses extends ProfilePage protected function _fetchData() { - $res = XDB::query("SELECT type, id, accuracy, text, postalText, + $res = XDB::query("SELECT id, accuracy, text, postalText, postalCode, localityId, subAdministrativeAreaId, administrativeAreaId, countryId, latitude, longitude, pub, comment, updateTime, north, south, east, west, diff --git a/modules/profile/jobs.inc.php b/modules/profile/jobs.inc.php index 18dffd8..2d03924 100644 --- a/modules/profile/jobs.inc.php +++ b/modules/profile/jobs.inc.php @@ -22,38 +22,35 @@ class ProfileJob extends ProfileGeocoding { private $pub; - private $mail_new; - private $mail; - private $web; + private $email_new; + private $email; + private $url; private $bool; private $checks; public function __construct() { $this->pub = new ProfilePub(); - $this->mail - = $this->mail_new + $this->email + = $this->email_new = new ProfileEmail(); - $this->web = new ProfileWeb(); + $this->url = new ProfileWeb(); $this->bool = new ProfileBool(); - $this->checks = array('web' => array('w_web'), - 'mail_new' => array('w_email_new'), - 'mail' => array('w_email'), - 'pub' => array('pub', 'w_email_pub')); + $this->checks = array('url' => array('w_url'), + 'email' => array('w_email'), + 'pub' => array('pub', 'w_email_pub'), + ); } private function cleanJob(ProfilePage &$page, $jobid, array &$job, &$success) { $success = true; + if ($job['w_email'] == "new@example.org") { + $job['w_email'] = $job['w_email_new']; + } foreach ($this->checks as $obj=>&$fields) { $chk =& $this->$obj; foreach ($fields as $field) { - if ($field == "w_email_new") { - if ($job['w_email'] == "new@example.org") { - $job['w_email'] = $job[$field]; - } - continue; - } $job[$field] = $chk->value($page, $field, $job[$field], $s); if (!$s) { $success = false; @@ -61,22 +58,22 @@ class ProfileJob extends ProfileGeocoding } } } - if (!$job['sss_secteur_name']) { + if (!$job['subSubSectorName']) { $res = XDB::query("SELECT name FROM profile_job_subsubsector_enum WHERE id = {?}", - $job['sss_secteur']); - $job['sss_secteur_name'] = $res->fetchOneCell(); + $job['subSubSector']); + $job['subSubSectorName'] = $res->fetchOneCell(); } else { $res = XDB::query("SELECT sectorid, subsectorid, id FROM profile_job_subsubsector_enum WHERE name = {?}", - $job['sss_secteur_name']); + $job['subSubSectorName']); if ($res->numRows() != 1) { $success = false; $job['sector_error'] = true; } else { - list($job['secteur'], $job['ss_secteur'], $job['sss_secteur']) = $res->fetchOneRow(); + list($job['sector'], $job['subSector'], $job['subSubSector']) = $res->fetchOneRow(); } } if ($job['name']) { @@ -86,25 +83,21 @@ class ProfileJob extends ProfileGeocoding $job['name']); if ($res->numRows() != 1) { $user = S::user(); - $req = new EntrReq($user, $jobid, $job['name'], $job['acronym'], $job['hq_web'], $job['hq_email'], $job['hq_tel'], $job['hq_fax']); + $req = new EntrReq($user, $jobid, $job['name'], $job['hq_²acronym'], $job['hq_url'], $job['hq_email'], $job['hq_fixed'], $job['hq_fax']); $req->submit(); $job['jobid'] = null; } else { $job['jobid'] = $res->fetchOneCell(); } } - $job['w_adr']['pub'] = $this->pub->value($page, 'adr_pub', @$job['w_adr']['pub'], $s); - $job['w_adr']['checked'] = $this->bool->value($page, 'adr_checked', @$job['w_adr']['checked'], $s); - if (!isset($job['w_tel'])) { - $job['w_tel'] = array(); + $job['w_address']['pub'] = $this->pub->value($page, 'address_pub', $job['w_address']['pub'], $s); + if (!isset($job['w_phone'])) { + $job['w_phone'] = array(); } $profiletel = new ProfilePhones('pro', $jobid); - $job['w_tel'] = $profiletel->value($page, 'tel', $job['w_tel'], $s); + $job['w_phone'] = $profiletel->value($page, 'tel', $job['w_phone'], $s); unset($job['removed']); unset($job['new']); - unset($job['w_adr']['changed']); - unset($job['w_adr']['parsevalid']); - unset($job['w_adr']['display']); } public function value(ProfilePage &$page, $field, $value, &$success) @@ -125,13 +118,13 @@ class ProfileJob extends ProfileGeocoding $job['tmp_name'] = $entreprise[$entr_val]->name; $entr_val ++; } - if (@$job['removed']) { + if (isset($job['removed']) && $job['removed']) { unset($value[$key]); } } foreach ($value as $key=>&$job) { $ls = true; - $this->geocodeAddress($job['w_adr'], $s); + $this->geocodeAddress($job['w_address'], $s); $ls = ($ls && $s); $this->cleanJob($page, $key, $job, $s); $ls = ($ls && $s); @@ -150,28 +143,30 @@ class ProfileJob extends ProfileGeocoding XDB::execute("DELETE FROM profile_job WHERE uid = {?}", S::i('uid')); + XDB::execute("DELETE FROM profile_addresses + WHERE pid = {?} AND type = 'job'", + S::i('uid')); XDB::execute("DELETE FROM profile_phones WHERE uid = {?} AND link_type = 'pro'", S::i('uid')); foreach ($value as $id=>&$job) { - if ($job['w_email'] == "new@example.org") { - $job['w_email'] = $job['w_email_new']; - } if ($job['jobid']) { XDB::execute("INSERT INTO profile_job (uid, id, functionid, description, sectorid, subsectorid, subsubsectorid, email, url, pub, email_pub, jobid) VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})", - S::i('uid'), $id, $job['fonction'], $job['description'], $job['secteur'], $job['ss_secteur'], - $job['sss_secteur'], $job['w_email'], $job['w_web'], $job['pub'], $job['w_email_pub'], $job['jobid']); + S::i('uid'), $id, $job['fonction'], $job['description'], $job['sector'], $job['subSector'], + $job['subSubSector'], $job['w_email'], $job['w_url'], $job['pub'], $job['w_email_pub'], $job['jobid']); } else { XDB::execute("INSERT INTO profile_job (uid, id, functionid, description, sectorid, subsectorid, subsubsectorid, email, url, pub, email_pub) VALUES ({?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?})", - S::i('uid'), $id, $job['fonction'], $job['description'], $job['secteur'], $job['ss_secteur'], - $job['sss_secteur'], $job['w_email'], $job['w_web'], $job['pub'], $job['w_email_pub']); + S::i('uid'), $id, $job['fonction'], $job['description'], $job['sector'], $job['subSector'], + $job['subSubSector'], $job['w_email'], $job['w_url'], $job['pub'], $job['w_email_pub']); } + $address = new ProfileAddress(); + $address->saveAddress($id, $job['w_address'], 'job'); $profiletel = new ProfilePhones('pro', $id); - $profiletel->saveTels('tel', $job['w_tel']); + $profiletel->saveTels('tel', $job['w_phone']); } } } @@ -207,53 +202,89 @@ class ProfileJobs extends ProfilePage $this->values['corps'] = $res->fetchOneAssoc(); // Build the jobs tree - $res = XDB::iterRow("SELECT j.id, je.name, j.functionid, j.sectorid, j.subsectorid, - j.subsubsectorid, j.description, e.adr1, e.adr2, e.adr3, - e.postcode, e.city, e.cityid, e.region, e.regiontxt, - e.country, gc.countryFR, - j.email, j.url, j.pub, - e.adr_pub, j.email_pub, - e.glat, e.glng, s.name + $res = XDB::iterRow("SELECT j.id, j.jobid, je.name, j.functionid, j.sectorid, j.subsectorid, j.subsubsectorid, + s.name, j.description, j.email, j.email_pub, j.url, j.pub, + je.acronym, je.url, je.email, + aw.accuracy, aw.text, aw.postalText, aw.postalCode, aw.localityId, + aw.subAdministrativeAreaId, aw.administrativeAreaId, aw.countryId, + aw.latitude, aw.longitude, aw.pub, aw.updateTime, + aw.north, aw.south, aw.east, aw.west, + ah.accuracy, ah.text, ah.postalText, ah.postalCode, ah.localityId, + ah.subAdministrativeAreaId, ah.administrativeAreaId, ah.countryId, + ah.latitude, ah.longitude, ah.pub, ah.updateTime, + ah.north, ah.south, ah.east, ah.west FROM profile_job AS j LEFT JOIN profile_job_enum AS je ON (j.jobid = je.id) - LEFT JOIN entreprises AS e ON (j.uid = e.uid AND j.id = e.entrid) - LEFT JOIN geoloc_countries AS gc ON (gc.iso_3166_1_a2 = e.country) LEFT JOIN profile_job_subsubsector_enum AS s ON (s.id = j.subsubsectorid) + LEFT JOIN profile_addresses AS aw ON (aw.pid = j.uid AND aw.type = 'job') + LEFT JOIN profile_addresses AS ah ON (ah.jobid = j.jobid AND ah.type = 'hq') WHERE j.uid = {?} - ORDER BY entrid", S::i('uid')); + ORDER BY j.id", + S::i('uid')); $this->values['jobs'] = array(); - while (list($id, $name, $function, $secteur, $ss_secteur, $sss_secteur, $description, - $w_adr1, $w_adr2, $w_adr3, $w_postcode, $w_city, $w_cityid, - $w_region, $w_regiontxt, $w_country, $w_countrytxt, - $w_email, $w_web, - $pub, $w_adr_pub, $w_email_pub, $w_glat, $w_glng, $sss_secteur_name + while (list($id, $jobid, $name, $function, $sector, $subSector, $subSubSector, + $subSubSectorName, $description, $w_email, $w_emailPub, $w_url, $pub, + $hq_acronym, $hq_url, $hq_email, + $w_accuracy, $w_text, $w_postalText, $w_postalCode, $w_localityId, + $w_subAdministrativeAreaId, $w_administrativeAreaId, $w_countryId, + $w_latitude, $w_longitude, $w_pub, $w_updateTime, + $w_north, $w_south, $w_east, $w_west, + $hq_accuracy, $hq_text, $hq_postalText, $hq_postalCode, $hq_localityId, + $hq_subAdministrativeAreaId, $hq_administrativeAreaId, $hq_countryId, + $hq_latitude, $hq_longitude, $hq_pub, $hq_updateTime, + $hq_north, $hq_south, $hq_east, $hq_west, ) = $res->next()) { $this->values['jobs'][] = array('id' => $id, + 'jobid' => $jobid, 'name' => $name, - 'fonction' => $function, - 'secteur' => $secteur, - 'ss_secteur' => $ss_secteur, - 'sss_secteur' => $sss_secteur, - 'sss_secteur_name' => $sss_secteur_name, + 'function' => $function, + 'sector' => $sector, + 'subSector' => $subSector, + 'subSubSector' => $subSubSector, + 'subSubSectorName' => $subSubSectorName, 'description' => $description, - 'w_adr' => array('adr1' => $w_adr1, - 'adr2' => $w_adr2, - 'adr3' => $w_adr3, - 'postcode' => $w_postcode, - 'city' => $w_city, - 'cityid' => $w_cityid, - 'region' => $w_region, - 'regiontxt' => $w_regiontxt, - 'country' => $w_country, - 'countrytxt' => $w_countrytxt, - 'pub' => $w_adr_pub, - 'checked' => (($w_checked == 0)? true : false), - 'precise_lat' => $w_glat, - 'precise_lon' => $w_glng), - 'w_email' => $w_email, - 'w_web' => $w_web, 'pub' => $pub, - 'w_email_pub' => $w_email_pub); + 'w_email' => $w_email, + 'w_email_pub' => $w_email_pub, + 'w_url' => $w_url, + 'hq_acronym' => $hq_acronym, + 'hq_url' => $hq_url, + 'hq_email' => $hq_email, + 'w_address' => array('accuracy' => $w_accuracy, + 'text' => $w_text, + 'postalText' => $w_postalText, + 'postalCode' => $w_postalCode, + 'localityId' => $w_localityId, + 'subAdministrativeAreaId' => $w_subAdministrativeAreaId, + 'administrativeAreaId' => $w_administrativeAreaId, + 'countryId' => $w_countryId, + 'latitude' => $w_latitude, + 'longitude' => $w_longitude, + 'pub' => $w_pub, + 'updateTime' => $w_update, + 'north' => $w_north, + 'south' => $w_south, + 'east' => $w_east, + 'west' => $w_west, + ), + 'hq_address' => array('accuracy' => $hq_accuracy, + 'text' => $hq_text, + 'postalText' => $hq_postalText, + 'postalCode' => $hq_postalCode, + 'localityId' => $hq_localityId, + 'subAdministrativeAreaId' => $hq_subAdministrativeAreaId, + 'administrativeAreaId' => $hq_administrativeAreaId, + 'countryId' => $hq_countryId, + 'latitude' => $hq_latitude, + 'longitude' => $hq_longitude, + 'pub' => $hq_pub, + 'updateTime' => $hq_update, + 'north' => $hq_north, + 'south' => $hq_south, + 'east' => $hq_east, + 'west' => $hq_west, + ), + ); } $res = XDB::iterator("SELECT link_id AS jobid, tel_type AS type, pub, display_tel AS tel, comment @@ -263,9 +294,8 @@ class ProfileJobs extends ProfilePage S::i('uid')); $i = 0; $jobNb = count($this->values['jobs']); - while ($tel = $res->next()) { - $jobid = $tel['jobid']; - unset($tel['jobid']); + while ($phone = $res->next()) { + $jobid = $phone['jobid']; while ($i < $jobNb && $this->values['jobs'][$i]['id'] < $jobid) { $i++; } @@ -273,18 +303,17 @@ class ProfileJobs extends ProfilePage break; } $job =& $this->values['jobs'][$i]; - if (!isset($job['w_tel'])) { - $job['w_tel'] = array(); + if (!isset($job['w_phone'])) { + $job['w_phone'] = array(); } if ($job['id'] == $jobid) { - $job['w_tel'][] = $tel; + $job['w_phone'][] = $phone; } } - foreach ($this->values['jobs'] as $id=>&$job) { - if (!isset($job['w_tel'])) { - $job['w_tel'] = array(); + foreach ($this->values['jobs'] as $id => &$job) { + if (!isset($job['w_phone'])) { + $job['w_phone'] = array(); } - unset($job['id']); } } @@ -314,11 +343,11 @@ class ProfileJobs extends ProfilePage $res = XDB::query("SELECT id, name AS label FROM profile_job_sector_enum"); - $page->assign('secteurs', $res->fetchAllAssoc()); + $page->assign('sectors', $res->fetchAllAssoc()); $res = XDB::query("SELECT id, fonction_fr, FIND_IN_SET('titre', flags) AS title FROM fonctions_def ORDER BY id"); - $page->assign('fonctions', $res->fetchAllAssoc()); + $page->assign('functions', $res->fetchAllAssoc()); $res = XDB::iterator("SELECT id, name FROM profile_corps_enum diff --git a/modules/profile/mentor.inc.php b/modules/profile/mentor.inc.php index 54858b9..4fc7b94 100644 --- a/modules/profile/mentor.inc.php +++ b/modules/profile/mentor.inc.php @@ -19,7 +19,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * ***************************************************************************/ -class ProfileSecteurs implements ProfileSetting +class ProfileSectors implements ProfileSetting { public function value(ProfilePage &$page, $field, $value, &$success) { @@ -118,7 +118,7 @@ class ProfileMentor extends ProfilePage { parent::__construct($wiz); $this->settings['expertise'] = null; - $this->settings['secteurs'] = new ProfileSecteurs(); + $this->settings['sectors'] = new ProfileSectors(); $this->settings['countries'] = new ProfileCountry(); } @@ -151,8 +151,8 @@ class ProfileMentor extends ProfilePage public function _prepare(PlPage &$page, $id) { - $page->assign('secteurs_sel', XDB::iterator("SELECT id, name AS label - FROM profile_job_sector_enum")); + $page->assign('sectors', XDB::iterator("SELECT id, name + FROM profile_job_sector_enum")); $page->assign('countryList', XDB::iterator("SELECT iso_3166_1_a2, countryFR FROM geoloc_countries diff --git a/templates/admin/index.tpl b/templates/admin/index.tpl index 35aab21..f36bd70 100644 --- a/templates/admin/index.tpl +++ b/templates/admin/index.tpl @@ -136,10 +136,6 @@ Emploi - Secteurs -   |   - Sous-secteurs -   |   Fonctions   |   Networking diff --git a/templates/geoloc/form.address.tpl b/templates/geoloc/form.address.tpl index ea8b01a..50ecdf3 100644 --- a/templates/geoloc/form.address.tpl +++ b/templates/geoloc/form.address.tpl @@ -26,9 +26,9 @@
@@ -36,7 +36,7 @@ {/if}
- {if $address.geoloc}