Adds delete method for phone and address classes.
authorStéphane Jacob <sj@m4x.org>
Wed, 20 Oct 2010 12:50:06 +0000 (14:50 +0200)
committerStéphane Jacob <sj@m4x.org>
Wed, 20 Oct 2010 13:11:59 +0000 (15:11 +0200)
Signed-off-by: Stéphane Jacob <sj@m4x.org>
classes/address.php
classes/phone.php
modules/admin.php
modules/profile/addresses.inc.php
modules/profile/jobs.inc.php

index d1f812c..c3c0dea 100644 (file)
@@ -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)) {
index 2d85beb..948894f 100644 (file)
@@ -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 = '';
index 633a683..bb4f9a6 100644 (file)
@@ -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 = {?}
index 27c2362..846fda8 100644 (file)
@@ -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);
     }
 
index 694f0af..eb7696b 100644 (file)
@@ -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) {