From 781a24bce24b7060f11e583565ad615ed0c497a3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?St=C3=A9phane=20Jacob?= Date: Wed, 20 Oct 2010 14:50:06 +0200 Subject: [PATCH] Adds delete method for phone and address classes. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Stéphane Jacob --- classes/address.php | 9 ++++++++- classes/phone.php | 7 +++++++ modules/admin.php | 2 +- modules/profile/addresses.inc.php | 2 +- modules/profile/jobs.inc.php | 2 +- 5 files changed, 18 insertions(+), 4 deletions(-) diff --git a/classes/address.php b/classes/address.php index d1f812c..c3c0dea 100644 --- a/classes/address.php +++ b/classes/address.php @@ -286,7 +286,14 @@ class Address } } - static public function delete($pid, $type, $jobid = null) + public function delete() + { + XDB::execute('DELETE FROM profile_addresses + WHERE pid = {?} AND jobid = {?} AND type = {?} AND id = {?}', + $this->pid, $this->jobid, $this->type, $this->id); + } + + static public function deleteAddresses($pid, $type, $jobid = null) { $where = ''; if (!is_null($pid)) { diff --git a/classes/phone.php b/classes/phone.php index 2d85beb..948894f 100644 --- a/classes/phone.php +++ b/classes/phone.php @@ -307,6 +307,13 @@ class Phone } } + public function delete() + { + XDB::execute('DELETE FROM profile_phones + WHERE pid = {?} AND link_type = {?} AND link_id = {?} AND tel_id = {?}', + $this->pid, $this->link_type, $this->link_id, $this->id); + } + static public function deletePhones($pid, $link_type, $link_id = null) { $where = ''; diff --git a/modules/admin.php b/modules/admin.php index 633a683..bb4f9a6 100644 --- a/modules/admin.php +++ b/modules/admin.php @@ -1474,7 +1474,7 @@ class AdminModule extends PLModule $selectedJob = Env::has('selectedJob'); Phone::deletePhones(0, Phone::LINK_COMPANY, $id); - Address::delete(null, Address::LINK_COMPANY, $id); + Address::deleteAddresses(null, Address::LINK_COMPANY, $id); if (Env::has('change')) { XDB::execute('UPDATE profile_job SET jobid = {?} diff --git a/modules/profile/addresses.inc.php b/modules/profile/addresses.inc.php index 27c2362..846fda8 100644 --- a/modules/profile/addresses.inc.php +++ b/modules/profile/addresses.inc.php @@ -44,7 +44,7 @@ class ProfileSettingAddresses implements ProfileSetting public function save(ProfilePage &$page, $field, $value) { Phone::deletePhones($page->pid(), Phone::LINK_ADDRESS); - Address::delete($page->pid(), Address::LINK_PROFILE); + Address::deleteAddresses($page->pid(), Address::LINK_PROFILE); Address::saveFromArray($value, $page->pid(), Address::LINK_PROFILE); } diff --git a/modules/profile/jobs.inc.php b/modules/profile/jobs.inc.php index 694f0af..eb7696b 100644 --- a/modules/profile/jobs.inc.php +++ b/modules/profile/jobs.inc.php @@ -251,7 +251,7 @@ class ProfileSettingJob implements ProfileSetting XDB::execute("DELETE FROM profile_job_term WHERE pid = {?}", $page->pid()); - Address::delete($page->pid(), Address::LINK_JOB); + Address::deleteAddresses($page->pid(), Address::LINK_JOB); Phone::deletePhones($page->pid(), Phone::LINK_JOB); $terms_values = array(); foreach ($value as $id => &$job) { -- 2.1.4