Code

Voicemail entries are now deleted, if phonenumber changes
authorhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 10 Aug 2005 07:15:47 +0000 (07:15 +0000)
committerhickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8>
Wed, 10 Aug 2005 07:15:47 +0000 (07:15 +0000)
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@1095 594d385d-05f5-0310-b6e9-bd551577e9d8

plugins/gofon/phoneaccount/class_phoneAccount.inc

index 188dab5c6af3259056d58f8faed4b8ebf2ba39a0..3675bef6ad7dee39db1c9387b7ddefcba48d54f3 100644 (file)
@@ -332,7 +332,6 @@ class phoneAccount extends plugin
     $sip_entry = $sip_data_array;
 
     reset($this->phoneNumbers);
-
     $key = key($this->phoneNumbers);
     $sip_entry['callerid']  =$this->phoneNumbers[$key];
     $sip_entry['mailbox']   =$this->phoneNumbers[$key];
@@ -350,11 +349,7 @@ class phoneAccount extends plugin
       }
 
 
-      $SQL[]= "DELETE FROM ".$a_SETUP['VOICE_TABLE']." WHERE customer_id='".$this->phoneNumbers[$key]."';"; 
-      $SQL[]= "INSERT INTO ".$a_SETUP['VOICE_TABLE']." 
-        (`customer_id`,`context`,`mailbox`,`password`,`fullname`,`email`,`pager`) 
-        VALUES 
-        ('".$this->phoneNumbers[$key]."','default','".$this->phoneNumbers[$key]."','".$this->goFonPIN."','".$this->sn."','".$mail."','');";
+      $SQL[]= "DELETE FROM ".$a_SETUP['VOICE_TABLE']." WHERE customer_id=".$this->phoneNumbers[$key].";"; 
 
       // Generate Strings with keys and values 
       $values = "";
@@ -372,10 +367,23 @@ class phoneAccount extends plugin
       $SQL[] ="INSERT INTO ".$a_SETUP['SIP_TABLE']." (".$keys.") VALUES (".$values.");";
 
       // Delete old entries
+      $first_deleted  =false;
       foreach($this->a_old_telenums as $s_telenums){
         $SQL[] = "DELETE FROM ".$a_SETUP['EXT_TABLE']." WHERE exten='".$s_telenums."';\n";
+        if(!$first_deleted){
+          $first_deleted=true;
+          $SQL[] = "DELETE FROM ".$a_SETUP['VOICE_TABLE']." WHERE customer_id=".$s_telenums.";";
+        }
       }
 
+      reset($this->phoneNumbers);
+      $key = key($this->phoneNumbers);
+
+      $SQL[]= "INSERT INTO ".$a_SETUP['VOICE_TABLE']."
+        (`customer_id`,`context`,`mailbox`,`password`,`fullname`,`email`,`pager`)
+        VALUES
+        ('".$this->phoneNumbers[$key]."','default','".$this->phoneNumbers[$key]."','".$this->goFonPIN."','".$this->sn."','".$mail."','');";
+
       $i_is_accounted=false;
 
       // Entension entries  Hint / Dial / Goto