Moves some stuff that belongs in dbcore to dbcore (#24145)

* Moves some stuff that belongs in dbcore to dbcore

* Wew garbage

* Ree

* Fixed
This commit is contained in:
Cyberboss
2017-02-18 20:21:53 -05:00
committed by oranges
parent 9fbd95320a
commit 2d424cf6be
15 changed files with 64 additions and 105 deletions
+4 -8
View File
@@ -6,8 +6,7 @@
if(!check_rights(R_BAN))
return
establish_db_connection()
if(!dbcon.IsConnected())
if(!dbcon.Connect())
src << "<span class='danger'>Failed to establish database connection.</span>"
return
@@ -183,8 +182,7 @@
if(job)
sql += " AND job = '[job]'"
establish_db_connection()
if(!dbcon.IsConnected())
if(!dbcon.Connect())
return
var/ban_id
@@ -280,8 +278,7 @@
var/sql = "SELECT ckey FROM [format_table_name("ban")] WHERE id = [id]"
establish_db_connection()
if(!dbcon.IsConnected())
if(!dbcon.Connect())
return
var/ban_number = 0 //failsafe
@@ -333,8 +330,7 @@
if(!check_rights(R_BAN))
return
establish_db_connection()
if(!dbcon.IsConnected())
if(!dbcon.Connect())
usr << "<span class='danger'>Failed to establish database connection.</span>"
return
+1 -1
View File
@@ -61,7 +61,7 @@
var/ckeytext = ckey(key)
if(!establish_db_connection())
if(!dbcon.Connect())
log_world("Ban database connection failure. Key [ckeytext] not checked")
diary << "Ban database connection failure. Key [ckeytext] not checked"
return
+3 -6
View File
@@ -127,8 +127,7 @@ var/list/admin_ranks = list() //list of all admin_rank datums
previous_rights = R.rights
else
establish_db_connection()
if(!dbcon.IsConnected())
if(!dbcon.Connect())
log_world("Failed to connect to database in load_admin_ranks(). Reverting to legacy system.")
diary << "Failed to connect to database in load_admin_ranks(). Reverting to legacy system."
config.admin_legacy_system = 1
@@ -202,8 +201,7 @@ var/list/admin_ranks = list() //list of all admin_rank datums
world.SetConfig("APP/admin", ckey, "role=admin")
D.associate(directory[ckey]) //find the client for a ckey if they are connected and associate them with the new admin datum
else
establish_db_connection()
if(!dbcon.IsConnected())
if(!dbcon.Connect())
log_world("Failed to connect to database in load_admins(). Reverting to legacy system.")
diary << "Failed to connect to database in load_admins(). Reverting to legacy system."
config.admin_legacy_system = 1
@@ -375,8 +373,7 @@ var/list/admin_ranks = list() //list of all admin_rank datums
edit_admin_permissions()
/datum/admins/proc/updateranktodb(ckey,newrank)
establish_db_connection()
if (!dbcon.IsConnected())
if(!dbcon.Connect())
return
var/sql_ckey = sanitizeSQL(ckey)
var/sql_admin_rank = sanitizeSQL(newrank)
+2 -2
View File
@@ -33,7 +33,7 @@
cachedintel.cache = TRUE
return cachedintel
if (establish_db_connection())
if(dbcon.Connect())
var/DBQuery/query = dbcon.NewQuery({"
SELECT date, intel, TIMESTAMPDIFF(MINUTE,date,NOW())
FROM [format_table_name("ipintel")]
@@ -61,7 +61,7 @@
res.intel = ip_intel_query(ip)
if (updatecache && res.intel >= 0)
SSipintel.cache[ip] = res
if (establish_db_connection())
if(dbcon.Connect())
var/DBQuery/query = dbcon.NewQuery("INSERT INTO [format_table_name("ipintel")] (ip, intel) VALUES (INET_ATON('[ip]'), [res.intel]) ON DUPLICATE KEY UPDATE intel = VALUES(intel), date = NOW()")
query.Execute()
return
@@ -60,9 +60,7 @@
if (!check_rights(R_PERMISSIONS))
return
establish_db_connection()
if(!dbcon.IsConnected())
if(!dbcon.Connect())
usr << "<span class='danger'>Failed to establish database connection.</span>"
return
@@ -109,8 +107,7 @@
if(check_rights(R_PERMISSIONS))
return
establish_db_connection()
if(!dbcon.IsConnected())
if(!dbcon.Connect())
usr << "<span class='danger'>Failed to establish database connection.</span>"
return
@@ -15,7 +15,6 @@
return
dbcon.Disconnect()
failed_db_connections = 0
log_admin("[key_name(usr)] has forced the database to disconnect")
message_admins("[key_name_admin(usr)] has <b>forced</b> the database to disconnect!")
feedback_add_details("admin_verb","FRDB") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
@@ -24,8 +23,8 @@
message_admins("[key_name_admin(usr)] is attempting to re-established the DB Connection")
feedback_add_details("admin_verb","RDB") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
failed_db_connections = 0
if (!establish_db_connection())
dbcon.failed_connections = 0
if(!dbcon.Connect())
message_admins("Database connection failed: " + dbcon.ErrorMsg())
else
message_admins("Database connection re-established")