summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4b0eddf)
raw | patch | inline | side by side (parent: 4b0eddf)
author | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 9 Mar 2009 14:11:03 +0000 (14:11 +0000) | ||
committer | hickert <hickert@594d385d-05f5-0310-b6e9-bd551577e9d8> | |
Mon, 9 Mar 2009 14:11:03 +0000 (14:11 +0000) |
-Added transaction to conferences
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13516 594d385d-05f5-0310-b6e9-bd551577e9d8
git-svn-id: https://oss.gonicus.de/repositories/gosa/trunk@13516 594d385d-05f5-0310-b6e9-bd551577e9d8
gosa-plugins/gofon/gofon/conference/class_phoneConferenceGeneric.inc | patch | blob | history |
diff --git a/gosa-plugins/gofon/gofon/conference/class_phoneConferenceGeneric.inc b/gosa-plugins/gofon/gofon/conference/class_phoneConferenceGeneric.inc
index 32eaed95793cdda41bdc5405d9d805ae73ce5e4d..cfa94b4d8b6b969ba73737b8d1fdb4f42f4d6f5a 100644 (file)
}
/* 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);
* 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.
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']));
- }
}
}
$EXT[$i]['appdata'] =$this->telephoneNumber."|1";
- $SQL=array();
foreach($EXT as $keytop => $valtop){
$s_keys = "";
$s_values = "";
$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__,"<b>---Updating/Inserting entries---</b>","");
+
+ mysql_query("begin;",$res_cur);
+ @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,"<b>begin;</b>","<i>Starting transaction!</i>");
+
+ foreach($SQL as $query){
+ @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,"<b>".$query."</b>", "");
+ if(!mysql_query($query,$res_cur)){
+ $err = mysql_error($res_cur);
+ @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,"\n".$err, "<b>FAILED</b>");
+ msg_dialog::display(_("Error"),
+ msgPool::mysqlerror($err,__CLASS__)." ".
+ "\n<p>"._("Please activate debugging for details!")."</p>",
+ ERROR_DIALOG);
+
+ mysql_query("rollback;",$res_cur);
+ @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,"<b>rollback;</b>", "<b>ERROR</b> 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__,"<b>commit;</b>", "");
+ @DEBUG (DEBUG_MYSQL, __LINE__, __FUNCTION__, __FILE__,"<b>---Transaction sucessful!---</b>", "");
}
@mysql_close($res_cur);