From 46c1fbacc96e8ec60bbda72bfbf399027c751ab3 Mon Sep 17 00:00:00 2001 From: hickert Date: Tue, 24 Jun 2008 09:54:04 +0000 Subject: [PATCH] Updated phoneAccount. -If the phone number has changed the voicemail table wasn't updated. git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@11411 594d385d-05f5-0310-b6e9-bd551577e9d8 --- .../gofon/phoneaccount/class_phoneAccount.inc | 32 ++++++++++++++++--- 1 file changed, 28 insertions(+), 4 deletions(-) diff --git a/gosa-plugins/gofon/gofon/phoneaccount/class_phoneAccount.inc b/gosa-plugins/gofon/gofon/phoneaccount/class_phoneAccount.inc index e49c967b4..548bc34ad 100644 --- a/gosa-plugins/gofon/gofon/phoneaccount/class_phoneAccount.inc +++ b/gosa-plugins/gofon/gofon/phoneaccount/class_phoneAccount.inc @@ -659,6 +659,17 @@ class phoneAccount extends plugin $customer_id = $newnums[$i_new_key]; + $query = "SELECT id,name,callerid FROM ".$a_New['SIP_TABLE']." WHERE name='".$this->uid."';"; + + $rid = mysql_query($query,$new_connection); + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query"); + $result = mysql_fetch_assoc($rid); + + $old_customer_id = ""; + if($result){ + $old_customer_id = $result['callerid']; + } + $voice_data_array = array( "customer_id" => $customer_id, "mailbox" => $customer_id, @@ -670,7 +681,9 @@ class phoneAccount extends plugin $voice_data_array['pager'] = $this->pager; /* Check if there is already an entry in sip_users for this uid */ - $query_tmp = "SELECT * FROM ".$a_New['VOICE_TABLE']." WHERE customer_id='".$customer_id."';\n"; + $query_tmp = "SELECT * FROM ".$a_New['VOICE_TABLE']." WHERE customer_id='".$old_customer_id."';\n"; + + $rid = mysql_query($query_tmp,$new_connection); @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query_tmp, "Database query"); if(mysql_affected_rows($new_connection)){ @@ -678,6 +691,7 @@ class phoneAccount extends plugin /********************** * Update Voice mail entry **********************/ + $result = mysql_fetch_assoc($rid) ; foreach($voice_data_array as $name => $value){ @@ -686,14 +700,14 @@ class phoneAccount extends plugin } } - /* Only update entry if there is something to uopdate */ + /* Only update entry if there is something to update */ if(count($voice_data_array)){ $query = "UPDATE ".$a_New['VOICE_TABLE']." SET "; foreach($voice_data_array as $key => $val){ $query.= "".$key."='".$val."',"; } $query = preg_replace("/,$/","",$query); - $query.= " WHERE customer_id='".$customer_id."';"; + $query.= " WHERE customer_id='".$old_customer_id."';"; $SQL_query_array[] = $query; } }else{ @@ -1425,7 +1439,17 @@ class phoneAccount extends plugin $SQL[] = "DELETE FROM ".$a_SETUP['EXT_TABLE']." WHERE exten='".$s_telenums."';\n"; } - $SQL[] = "DELETE FROM ".$a_SETUP['VOICE_TABLE']." WHERE customer_id='".$first_num."';"; + + $query = "SELECT id,name,callerid FROM ".$a_SETUP['SIP_TABLE']." WHERE name='".$this->uid."';"; + $rid = mysql_query($query,$r_con); + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$query, "Database query"); + $result = mysql_fetch_assoc($rid); + $callerid = $first_num; + if($result){ + $callerid = $result['callerid']; + } + + $SQL[] = "DELETE FROM ".$a_SETUP['VOICE_TABLE']." WHERE customer_id='".$callerid."';"; $SQL[] = "DELETE FROM ".$a_SETUP['EXT_TABLE']." WHERE exten='".$this->uid."';\n"; $SQL[] = "DELETE FROM ".$a_SETUP['SIP_TABLE']." WHERE name='".$this->uid."';\n"; -- 2.30.2