mirror of
https://github.com/CHOMPStation2/CHOMPStation2.git
synced 2025-12-11 18:53:06 +00:00
Merge pull request #6369 from ItsSelis/db-mentors
Adding DB Capability for Mentors
This commit is contained in:
@@ -289,6 +289,15 @@ CREATE TABLE IF NOT EXISTS `vr_player_hours` (
|
||||
|
||||
-- Data exporting was unselected.
|
||||
|
||||
-- CHOMPedit Start - Mentors Database Table
|
||||
CREATE TABLE IF NOT EXISTS `erro_mentor` (
|
||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`ckey` varchar(32) NOT NULL,
|
||||
`mentor` int(16) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=latin1 ROW_FORMAT=COMPACT;
|
||||
-- CHOMPedit End
|
||||
|
||||
/*!40101 SET SQL_MODE=IFNULL(@OLD_SQL_MODE, '') */;
|
||||
/*!40014 SET FOREIGN_KEY_CHECKS=IF(@OLD_FOREIGN_KEY_CHECKS IS NULL, 1, @OLD_FOREIGN_KEY_CHECKS) */;
|
||||
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
||||
|
||||
@@ -535,6 +535,24 @@ var/world_topic_spam_protect_time = world.timeofday
|
||||
var/ckey = copytext(line, 1, length(line)+1)
|
||||
var/datum/mentor/M = new /datum/mentor(ckey)
|
||||
M.associate(GLOB.directory[ckey])
|
||||
else // CHOMPedit Start - Implementing loading mentors from database
|
||||
establish_db_connection()
|
||||
if(!SSdbcore.IsConnected())
|
||||
error("Failed to connect to database in load_mentors().")
|
||||
log_misc("Failed to connect to database in load_mentors().")
|
||||
return
|
||||
|
||||
var/DBQuery/query = SSdbcore.NewQuery("SELECT ckey, mentor FROM erro_mentor") //CHOMPEdit TGSQL
|
||||
query.Execute()
|
||||
while(query.NextRow())
|
||||
var/ckey = query.item[1]
|
||||
var/mentor = query.item[2]
|
||||
|
||||
if(mentor)
|
||||
var/datum/mentor/M = new /datum/mentor(ckey)
|
||||
M.associate(GLOB.directory[ckey])
|
||||
qdel(query)
|
||||
// COMPedit End
|
||||
|
||||
/world/proc/update_status()
|
||||
var/s = ""
|
||||
|
||||
@@ -64,6 +64,13 @@ var/list/mentor_verbs_default = list(
|
||||
to_chat(src, "<span class='pm notice'>You have made [C] a mentor.</span>")
|
||||
log_admin("[key_name(src)] made [key_name(C)] a mentor.")
|
||||
feedback_add_details("admin_verb","Make Mentor") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
|
||||
// CHOMPedit Start - Adding to DB Logic
|
||||
var/result = tgui_alert(src, "Do you want to add this person into the mentor database? This will allow them to be a mentor in future rounds too.", "Add to Database", list("Yes", "No"))
|
||||
if(result == "Yes")
|
||||
var/DBQuery/query = SSdbcore.NewQuery("INSERT INTO erro_mentor (ckey, mentor) VALUES (:ckey, :mentor)", list("ckey" = C.ckey, "mentor" = 1))
|
||||
query.Execute()
|
||||
qdel(query)
|
||||
// CHOMPedit End
|
||||
|
||||
/client/proc/unmake_mentor()
|
||||
set category = "Special Verbs"
|
||||
@@ -83,6 +90,11 @@ var/list/mentor_verbs_default = list(
|
||||
to_chat(src, "<span class='pm notice'>You have revoked [C]'s mentorship.</span>")
|
||||
log_admin("[key_name(src)] revoked [key_name(C)]'s mentorship.")
|
||||
feedback_add_details("admin_verb","Unmake Mentor") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc!
|
||||
// CHOMPedit Start - Removing from DB Logic
|
||||
var/DBQuery/query = SSdbcore.NewQuery("DELETE FROM erro_mentor WHERE ckey = :ckey", list("ckey" = C.ckey))
|
||||
query.Execute()
|
||||
qdel(query)
|
||||
// CHOMPedit End
|
||||
|
||||
/client/proc/cmd_mentor_say(msg as text)
|
||||
set category = "Admin"
|
||||
|
||||
Reference in New Issue
Block a user