Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
133 lines (131 loc) · 5.34 KB

File metadata and controls

133 lines (131 loc) · 5.34 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/client/proc/create_poll()
set name = "Create Poll"
set category = "Server"
if(!check_rights(R_POLL))
return
if(!SSdbcore.Connect())
to_chat(src, span_danger("Failed to establish database connection."), confidential=TRUE)
return
var/polltype = input("Choose poll type.","Poll Type") as null|anything in list("Single Option","Text Reply","Rating","Multiple Choice", "Instant Runoff Voting")
var/choice_amount = 0
switch(polltype)
if("Single Option")
polltype = POLLTYPE_OPTION
if("Text Reply")
polltype = POLLTYPE_TEXT
if("Rating")
polltype = POLLTYPE_RATING
if("Multiple Choice")
polltype = POLLTYPE_MULTI
choice_amount = input("How many choices should be allowed?","Select choice amount") as num|null
switch(choice_amount)
if(0)
to_chat(src, "Multiple choice poll must have at least one choice allowed.", confidential=TRUE)
return
if(1)
polltype = POLLTYPE_OPTION
if(null)
return
if ("Instant Runoff Voting")
polltype = POLLTYPE_IRV
else
return 0
var/starttime = SQLtime()
var/endtime = input("Set end time for poll as format YYYY-MM-DD HH:MM:SS. All times in server time. HH:MM:SS is optional and 24-hour. Must be later than starting time for obvious reasons.", "Set end time", SQLtime()) as text
if(!endtime)
return
var/datum/DBQuery/query_validate_time = SSdbcore.NewQuery("SELECT IF(STR_TO_DATE(:endtime,'%Y-%c-%d %T') > NOW(), STR_TO_DATE(:endtime,'%Y-%c-%d %T'), 0)", list("endtime" = endtime))
if(!query_validate_time.warn_execute() || QDELETED(usr) || !src)
qdel(query_validate_time)
return
if(query_validate_time.NextRow())
var/checktime = text2num(query_validate_time.item[1])
if(!checktime)
to_chat(src, "Datetime entered is improperly formatted or not later than current server time.", confidential=TRUE)
qdel(query_validate_time)
return
endtime = query_validate_time.item[1]
qdel(query_validate_time)
var/adminonly
switch(alert("Admin only poll?",,"Yes","No","Cancel"))
if("Yes")
adminonly = 1
if("No")
adminonly = 0
else
return
var/dontshow
switch(alert("Hide poll results from tracking until completed?",,"Yes","No","Cancel"))
if("Yes")
dontshow = 1
if("No")
dontshow = 0
else
return
var/question = input("Write your question","Question") as message|null
if(!question)
return
var/list/sql_option_list = list()
if(polltype != POLLTYPE_TEXT)
var/add_option = 1
while(add_option)
var/option = input("Write your option","Option") as message|null
if(!option)
return
var/default_percentage_calc = 0
if(polltype != POLLTYPE_IRV)
switch(alert("Should this option be included by default when poll result percentages are generated?",,"Yes","No","Cancel"))
if("Yes")
default_percentage_calc = 1
if("No")
default_percentage_calc = 0
else
return
var/minval = 0
var/maxval = 0
var/descmin = ""
var/descmid = ""
var/descmax = ""
if(polltype == POLLTYPE_RATING)
minval = input("Set minimum rating value.","Minimum rating") as num|null
if(minval == null)
return
maxval = input("Set maximum rating value.","Maximum rating") as num|null
if(minval >= maxval)
to_chat(src, "Maximum rating value can't be less than or equal to minimum rating value", confidential=TRUE)
continue
else if(maxval == null)
return
descmin = input("Optional: Set description for minimum rating","Minimum rating description") as message|null
if(descmin == null)
return
descmid = input("Optional: Set description for median rating","Median rating description") as message|null
if(descmid == null)
return
descmax = input("Optional: Set description for maximum rating","Maximum rating description") as message|null
if(descmax == null)
return
sql_option_list += list(list("text" = "[option]", "minval" = "[minval]", "maxval" = "[maxval]", "descmin" = "[descmin]", "descmid" = "[descmid]", "descmax" = "[descmax]", "default_percentage_calc" = "[default_percentage_calc]"))
switch(alert(" ",,"Add option","Finish", "Cancel"))
if("Add option")
add_option = 1
if("Finish")
add_option = 0
else
return 0
var/m1 = "[key_name(usr)] has created a new server poll. Poll type: [polltype] - Admin Only: [adminonly ? "Yes" : "No"] - Question: [question]"
var/m2 = "[key_name_admin(usr)] has created a new server poll. Poll type: [polltype] - Admin Only: [adminonly ? "Yes" : "No"]<br>Question: [question]"
var/datum/DBQuery/query_polladd_question = SSdbcore.NewQuery({"INSERT INTO [format_table_name("poll_question")] (polltype, starttime, endtime, question, adminonly, multiplechoiceoptions, createdby_ckey, createdby_ip, dontshow)
VALUES (:polltype, :starttime, :endtime, :question, :adminonly, :choice_amount, :sql_ckey, INET_ATON(:address), :dontshow)"},
list("polltype" = polltype, "starttime" = starttime, "endtime" = endtime, "question" = question, "adminonly" = adminonly, "choice_amount" = choice_amount, "sql_ckey" = ckey, "address" = address, "dontshow" = dontshow))
if(!query_polladd_question.warn_execute())
qdel(query_polladd_question)
return
var/questionid = query_polladd_question.last_insert_id
qdel(query_polladd_question)
if(polltype != POLLTYPE_TEXT)
for(var/list/i in sql_option_list)
i |= list("pollid" = questionid)
SSdbcore.MassInsert(format_table_name("poll_option"), sql_option_list, warn = 1)
log_admin(m1)
message_admins(m2)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.