From a710dfd7527b937b0354f5b70751c9be333d8415 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Mon, 20 Sep 2010 09:38:40 +0200 Subject: [PATCH 1/1] Uses Address class more. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- include/reminder/profile_update.inc.php | 7 +------ include/validations/entreprises.inc.php | 1 - modules/admin.php | 30 +++--------------------------- 3 files changed, 4 insertions(+), 34 deletions(-) diff --git a/include/reminder/profile_update.inc.php b/include/reminder/profile_update.inc.php index 4efaffb..7dd5f1b 100644 --- a/include/reminder/profile_update.inc.php +++ b/include/reminder/profile_update.inc.php @@ -53,12 +53,7 @@ class ReminderProfileUpdate extends Reminder $page->assign('profile_incitation', $profile->is_old); $page->assign('profile_last_update', $profile->last_change); $page->assign('photo_incitation', !$profile->has_photo); - - $res = XDB::query('SELECT COUNT(*) - FROM profile_addresses - WHERE pid = {?} AND accuracy = 0', - $profile->id()); - $page->assign('geocoding_incitation', $res->fetchOneCell()); + $page->assign('geocoding_incitation', Geocoder::countNonGeocoded($profile->id())); } public function template() diff --git a/include/validations/entreprises.inc.php b/include/validations/entreprises.inc.php index e7857f2..da2e65e 100644 --- a/include/validations/entreprises.inc.php +++ b/include/validations/entreprises.inc.php @@ -155,7 +155,6 @@ class EntrReq extends ProfileValidate $address = new Address(array('jobid' => $jobid, 'type' => Address::LINK_COMPANY, 'text' => $this->address)); $phone->save(); $fax->save(); - $address->format(); $address->save(); } else { $jobid = $res->fetchOneCell(); diff --git a/modules/admin.php b/modules/admin.php index fe21416..ed71959 100644 --- a/modules/admin.php +++ b/modules/admin.php @@ -1414,16 +1414,11 @@ class AdminModule extends PLModule } if (Env::has('edit')) { - // TODO: use address class to update profile_job_enum once it is done. - S::assert_xsrf_token(); $selectedJob = Env::has('selectedJob'); Phone::deletePhones(0, Phone::LINK_COMPANY, $id); - XDB::execute("DELETE FROM profile_addresses - WHERE jobid = {?} AND type = 'hq'", - $id); - + Address::delete(null, Address::lLINK_COMPANY, $id); if (Env::has('change')) { XDB::execute('UPDATE profile_job SET jobid = {?} @@ -1435,13 +1430,6 @@ class AdminModule extends PLModule $page->trigSuccess("L'entreprise a bien été remplacée."); } else { - $gmapsGeocoder = new GMapsGeocoder(); - $address = array('text' => Env::t('address')); - $address = $gmapsGeocoder->getGeocodedAddress($address); - Geocoder::getAreaId($address, 'administrativeArea'); - Geocoder::getAreaId($address, 'subAdministrativeArea'); - Geocoder::getAreaId($address, 'locality'); - XDB::execute('UPDATE profile_job_enum SET name = {?}, acronym = {?}, url = {?}, email = {?}, NAF_code = {?}, AX_code = {?}, holdingid = {?} @@ -1453,22 +1441,10 @@ class AdminModule extends PLModule 'link_type' => Phone::LINK_COMPANY, 'pub' => 'public')); $fax = new Phone(array('display' => Env::v('fax'), 'link_id' => $id, 'id' => 1, 'type' => 'fax', 'link_type' => Phone::LINK_COMPANY, 'pub' => 'public')); + $address = new Address(array('jobid' => $jobid, 'type' => Address::LINK_COMPANY, 'text' => Env::t('address'))); $phone->save(); $fax->save(); - - XDB::execute("INSERT INTO profile_addresses (jobid, type, id, accuracy, - text, postalText, postalCode, localityId, - subAdministrativeAreaId, administrativeAreaId, - countryId, latitude, longitude, - north, south, east, west) - VALUES ({?}, 'hq', 0, {?}, {?}, {?}, {?}, {?}, {?}, {?}, {?}, - {?}, {?}, {?}, {?}, {?}, {?})", - $id, $address['accuracy'], $address['text'], $address['postalText'], - $address['postalCode'], $address['localityId'], - $address['subAdministrativeAreaId'], $address['administrativeAreaId'], - $address['countryId'], $address['latitude'], $address['longitude'], - $address['north'], $address['south'], - $address['east'], $address['west']); + $address->save(); $page->trigSuccess("L'entreprise a bien été mise à jour."); } -- 2.1.4