This repository was archived by the owner on May 22, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 458
Expand file tree
/
Copy pathtopic.dm
More file actions
93 lines (72 loc) · 3.31 KB
/
topic.dm
File metadata and controls
93 lines (72 loc) · 3.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/datum/admins/proc/checkMentorEditList(ckey)
var/datum/DBQuery/query_memoedits = SSdbcore.NewQuery("SELECT edits FROM [format_table_name("mentor_memo")] WHERE (ckey = :key)", list("key" = ckey))
if(!query_memoedits.warn_execute())
qdel(query_memoedits)
return
if(query_memoedits.NextRow())
var/edit_log = "<HTML><HEAD><meta charset='UTF-8'></HEAD><BODY>" + query_memoedits.item[1] + "</BODY></HTML>"
usr << browse(edit_log,"window=mentormemoeditlist")
qdel(query_memoedits)
/datum/admins/proc/makeMentor(ckey, position)
if(!usr.client)
return
if (!check_rights(R_EVERYTHING))
return
if(!ckey)
return
var/client/C = GLOB.directory[ckey]
if(C)
if(check_rights_for(C, R_ADMIN,0))
to_chat(usr, span_danger("The client chosen is an admin! Cannot mentorize."), confidential=TRUE)
return
new /datum/mentors(ckey, position)
if(SSdbcore.Connect())
var/datum/DBQuery/query_get_mentor = SSdbcore.NewQuery("SELECT id FROM `[format_table_name("mentor")]` WHERE `ckey` = :ckey", list("ckey" = ckey))
query_get_mentor.warn_execute()
if(query_get_mentor.NextRow())
to_chat(usr, span_danger("[ckey] is already a mentor."), confidential=TRUE)
qdel(query_get_mentor)
return
qdel(query_get_mentor)
var/datum/DBQuery/query_add_mentor = SSdbcore.NewQuery("INSERT INTO `[format_table_name("mentor")]` (`id`, `ckey`, `position`) VALUES (null, :ckey, :position)", list("ckey" = ckey, "position" = position))
if(!query_add_mentor.warn_execute())
qdel(query_add_mentor)
return
qdel(query_add_mentor)
var/datum/DBQuery/query_add_mentor_log = SSdbcore.NewQuery({"
INSERT INTO [format_table_name("admin_log")] (datetime, round_id, adminckey, adminip, operation, target, log)
VALUES (:time, :round_id, :adminckey, INET_ATON(:adminip), 'add mentor', :target, CONCAT('New mentor added: ', :target))
"}, list("time" = SQLtime(), "round_id" = "[GLOB.round_id]", "adminckey" = usr.ckey, "adminip" = usr.client.address, "target" = ckey))
if(!query_add_mentor_log.warn_execute())
qdel(query_add_mentor_log)
return
qdel(query_add_mentor_log)
webhook_send_mchange(owner.ckey, C.ckey, "add")
else
to_chat(usr, span_danger("Failed to establish database connection. The changes will last only for the current round."), confidential=TRUE)
message_admins("[key_name_admin(usr)] added new [position]: [ckey]")
log_admin("[key_name(usr)] added new [position]: [ckey]")
/datum/admins/proc/removeMentor(ckey)
if(!usr.client)
return
if (!check_rights(R_EVERYTHING))
return
if(!ckey)
return
var/client/C = GLOB.directory[ckey]
if(C)
if(check_rights_for(C, R_ADMIN,0))
to_chat(usr, span_danger("The client chosen is an admin, not a mentor! Cannot de-mentorize."), confidential=TRUE)
return
C.remove_mentor_verbs()
C.mentor_datum = null
GLOB.mentors -= C
if(SSdbcore.Connect())
var/datum/DBQuery/query_remove_mentor = SSdbcore.NewQuery("DELETE FROM `[format_table_name("mentor")]` WHERE `ckey` = :ckey", list("ckey" = ckey))
query_remove_mentor.warn_execute()
qdel(query_remove_mentor)
webhook_send_mchange(owner.ckey, C.ckey, "remove")
else
to_chat(usr, span_danger("Failed to establish database connection. The changes will last only for the current round."), confidential=TRUE)
message_admins("[key_name_admin(usr)] removed mentor: [ckey]")
log_admin("[key_name(usr)] removed mentor: [ckey]")