From: hickert Date: Mon, 9 Mar 2009 14:11:03 +0000 (+0000) Subject: Updated conferences X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=98f42be2f746b58d433334ce07719dd0035d6bd2;p=gosa.git Updated conferences -Added transaction to conferences git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13516 594d385d-05f5-0310-b6e9-bd551577e9d8 --- diff --git a/gosa-plugins/gofon/gofon/conference/class_phoneConferenceGeneric.inc b/gosa-plugins/gofon/gofon/conference/class_phoneConferenceGeneric.inc index 32eaed957..cfa94b4d8 100644 --- a/gosa-plugins/gofon/gofon/conference/class_phoneConferenceGeneric.inc +++ b/gosa-plugins/gofon/gofon/conference/class_phoneConferenceGeneric.inc @@ -447,6 +447,7 @@ class conference extends plugin } /* Connect to current database to be able to add new entries */ + $SQL=array(); $cfg_Current = $this->goFonHomeServers[$this->goFonHomeServer] ; $res_cur = @mysql_pconnect($cfg_Current['SERVER'],$cfg_Current['LOGIN'],$cfg_Current['PASSWORD']); $db_cur = @mysql_select_db($cfg_Current['DB'],$res_cur); @@ -455,6 +456,16 @@ class conference extends plugin * Remove entries that could cause trouble ********************/ + + /* Check table definitions + */ + if($save && !phoneAccount::checkRealtimeTables($cfg_Current)){ + msg_dialog::display(_("Warning"), + sprintf(_("GOsa identified problems with your MySQL table definition, please activate debugging for details.")), + WARNING_DIALOG); + } + + /* If the current home server is different to the initial home server, * there may be already some entries with the given telephoneNumber and/or cn. * We must remove those entries to avoid duplicate use of the same extension name. @@ -468,17 +479,9 @@ class conference extends plugin return(msgPool::dbquery("GOfon", @mysql_error($res_cur),$cfg_Current['SERVER'])); } if($save && mysql_affected_rows($res_cur)) { - $SQL = "DELETE FROM ".$cfg_Current['EXT_TABLE']." + $SQL[] = "DELETE FROM ".$cfg_Current['EXT_TABLE']." WHERE (exten='".$this->telephoneNumber."') OR (exten='".$this->cn."')"; - - /* Query and ensure that everything went fine */ - $res = @mysql_query($SQL,$res_cur); - @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$SQL, "Database query"); - if(!$res){ - new log("debug","gofonconference/".get_class($this),"",array(),@mysql_error($res_cur)); - return(msgPool::dbquery("GOfon", @mysql_error($res_cur),$cfg_Current['SERVER'])); - } } } @@ -586,7 +589,6 @@ class conference extends plugin $EXT[$i]['appdata'] =$this->telephoneNumber."|1"; - $SQL=array(); foreach($EXT as $keytop => $valtop){ $s_keys = ""; $s_values = ""; @@ -598,10 +600,38 @@ class conference extends plugin $s_values =preg_replace("/\,$/","",$s_values); $SQL[]="INSERT INTO ".$cfg_Current['EXT_TABLE']." (".$s_keys.") VALUES (".$s_values.");"; } - foreach($SQL as $sqlsyn){ - mysql_query($sqlsyn,$res_cur); - @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,$sqlsyn, "Database query"); + + + + /* Start transaction, to be able to rollback + */ + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,"---Updating/Inserting entries---",""); + + mysql_query("begin;",$res_cur); + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,"begin;","Starting transaction!"); + + foreach($SQL as $query){ + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,"".$query."", ""); + if(!mysql_query($query,$res_cur)){ + $err = mysql_error($res_cur); + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,"\n".$err, "FAILED"); + msg_dialog::display(_("Error"), + msgPool::mysqlerror($err,__CLASS__)." ". + "\n

"._("Please activate debugging for details!")."

", + ERROR_DIALOG); + + mysql_query("rollback;",$res_cur); + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,"rollback;", "ERROR Rollback transaction!"); + @mysql_close($res_cur); + return(false); + } } + + /* Let changes get active, everything was fine; + */ + mysql_query("commit;",$res_cur); + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,"commit;", ""); + @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,"---Transaction sucessful!---", ""); } @mysql_close($res_cur);