diff --git a/code/modules/admin/banjob.dm b/code/modules/admin/banjob.dm index 94c09c54eea..955c19d0ecd 100644 --- a/code/modules/admin/banjob.dm +++ b/code/modules/admin/banjob.dm @@ -24,7 +24,7 @@ var/jobban_keylist[0] //to store the keys & ranks return "Whitelisted Job" for (var/s in jobban_keylist) - if( findtext(s,"[M.ckey] - [rank]") ) + if( findtext(s,"[M.ckey] - [rank]") == 1 ) var/startpos = findtext(s, "## ")+3 if(startpos && startposJobbans active in this round." + for(var/t in jobban_keylist) + usr << "[t]" + +/client/proc/print_jobban_old_filter() + set name = "Search Jobban Log" + set desc = "This searches all the active jobban entries for the current round and outputs the results to standard output." + set category = "Debug" + + var/filter = input("Contains what?","Filter") as text|null + if(!filter) + return + + usr << "Jobbans active in this round." + for(var/t in jobban_keylist) + if(findtext(t, filter)) + usr << "[t]" \ No newline at end of file diff --git a/code/modules/admin/verbs/mapping.dm b/code/modules/admin/verbs/mapping.dm index e0f8e007dbe..2523bcc0bff 100644 --- a/code/modules/admin/verbs/mapping.dm +++ b/code/modules/admin/verbs/mapping.dm @@ -150,6 +150,8 @@ var/intercom_range_display_status = 0 src.verbs += /client/proc/cmd_admin_areatest src.verbs += /client/proc/cmd_admin_rejuvenate src.verbs += /datum/admins/proc/show_traitor_panel + src.verbs += /client/proc/print_jobban_old + src.verbs += /client/proc/print_jobban_old_filter //src.verbs += /client/proc/cmd_admin_rejuvenate feedback_add_details("admin_verb","mDV") //If you are copy-pasting this, ensure the 2nd parameter is unique to the new proc! diff --git a/code/modules/mob/new_player/new_player.dm b/code/modules/mob/new_player/new_player.dm index 53e0486d3a0..57826e5e52a 100644 --- a/code/modules/mob/new_player/new_player.dm +++ b/code/modules/mob/new_player/new_player.dm @@ -211,7 +211,7 @@ usr << "The option ID difference is too big. Please contact administration or the database admin." return - for(var/optionid = id_min; optionid<= id_max; optionid++) + for(var/optionid = id_min; optionid <= id_max; optionid++) if(!isnull(href_list["o[optionid]"])) //Test if this optionid was replied to var/rating if(href_list["o[optionid]"] == "abstain") @@ -222,6 +222,20 @@ return vote_on_numval_poll(pollid, optionid, rating) + if("MULTICHOICE") + var/id_min = text2num(href_list["minoptionid"]) + var/id_max = text2num(href_list["maxoptionid"]) + world << "MULTICHOICE" + + if( (id_max - id_min) > 100 ) //Basic exploit prevention + usr << "The option ID difference is too big. Please contact administration or the database admin." + return + + for(var/optionid = id_min; optionid <= id_max; optionid++) + world << "checking [optionid]" + if(!isnull(href_list["option_[optionid]"])) //Test if this optionid was selected + world << "FOUND [optionid]" + vote_on_poll(pollid, optionid, 1) proc/IsJobAvailable(rank) var/datum/job/job = job_master.GetJob(rank) diff --git a/code/modules/mob/new_player/poll.dm b/code/modules/mob/new_player/poll.dm index ed1b53413a2..884b7ffc4ee 100644 --- a/code/modules/mob/new_player/poll.dm +++ b/code/modules/mob/new_player/poll.dm @@ -84,7 +84,7 @@ establish_db_connection() if(dbcon.IsConnected()) - var/DBQuery/select_query = dbcon.NewQuery("SELECT starttime, endtime, question, polltype FROM erro_poll_question WHERE id = [pollid]") + var/DBQuery/select_query = dbcon.NewQuery("SELECT starttime, endtime, question, polltype, multiplechoiceoptions FROM erro_poll_question WHERE id = [pollid]") select_query.Execute() var/pollstarttime = "" @@ -92,6 +92,7 @@ var/pollquestion = "" var/polltype = "" var/found = 0 + var/multiplechoiceoptions = 0 while(select_query.NextRow()) pollstarttime = select_query.item[1] @@ -271,9 +272,71 @@ output += "" src << browse(output,"window=playerpoll;size=500x500") + if("MULTICHOICE") + var/DBQuery/voted_query = dbcon.NewQuery("SELECT optionid FROM erro_poll_vote WHERE pollid = [pollid] AND ckey = '[usr.ckey]'") + voted_query.Execute() + + var/list/votedfor = list() + var/voted = 0 + while(voted_query.NextRow()) + votedfor.Add(text2num(voted_query.item[1])) + voted = 1 + + var/list/datum/polloption/options = list() + var/maxoptionid = 0 + var/minoptionid = 0 + + var/DBQuery/options_query = dbcon.NewQuery("SELECT id, text FROM erro_poll_option WHERE pollid = [pollid]") + options_query.Execute() + while(options_query.NextRow()) + var/datum/polloption/PO = new() + PO.optionid = text2num(options_query.item[1]) + PO.optiontext = options_query.item[2] + if(PO.optionid > maxoptionid) + maxoptionid = PO.optionid + if(PO.optionid < minoptionid || !minoptionid) + minoptionid = PO.optionid + options += PO + + + if(select_query.item[5]) + multiplechoiceoptions = text2num(select_query.item[5]) + + var/output = "
Player poll" + output +="
" + output += "Question: [pollquestion]
You can select up to [multiplechoiceoptions] options. If you select more, the first [multiplechoiceoptions] will be saved.
" + output += "Poll runs from [pollstarttime] until [pollendtime]

" + + if(!voted) //Only make this a form if we have not voted yet + output += "

" + output += "" + output += "" + output += "" + output += "" + output += "" + + output += "
" + for(var/datum/polloption/O in options) + if(O.optionid && O.optiontext) + if(voted) + if(O.optionid in votedfor) + output += "[O.optiontext]
" + else + output += "[O.optiontext]
" + else + output += " [O.optiontext]
" + output += "
" + + if(!voted) //Only make this a form if we have not voted yet + output += "

" + output += "

" + + output += "
" + + src << browse(output,"window=playerpoll;size=500x250") return -/mob/new_player/proc/vote_on_poll(var/pollid = -1, var/optionid = -1) +/mob/new_player/proc/vote_on_poll(var/pollid = -1, var/optionid = -1, var/multichoice = 0) if(pollid == -1 || optionid == -1) return @@ -282,15 +345,18 @@ establish_db_connection() if(dbcon.IsConnected()) - var/DBQuery/select_query = dbcon.NewQuery("SELECT starttime, endtime, question, polltype FROM erro_poll_question WHERE id = [pollid] AND Now() BETWEEN starttime AND endtime") + var/DBQuery/select_query = dbcon.NewQuery("SELECT starttime, endtime, question, polltype, multiplechoiceoptions FROM erro_poll_question WHERE id = [pollid] AND Now() BETWEEN starttime AND endtime") select_query.Execute() var/validpoll = 0 + var/multiplechoiceoptions = 0 while(select_query.NextRow()) - if(select_query.item[4] != "OPTION") + if(select_query.item[4] != "OPTION" && select_query.item[4] != "MULTICHOICE") return validpoll = 1 + if(select_query.item[5]) + multiplechoiceoptions = text2num(select_query.item[5]) break if(!validpoll) @@ -316,13 +382,18 @@ voted_query.Execute() while(voted_query.NextRow()) - alreadyvoted = 1 - break + alreadyvoted += 1 + if(!multichoice) + break - if(alreadyvoted) + if(!multichoice && alreadyvoted) usr << "\red You already voted in this poll." return + if(multichoice && (alreadyvoted >= multiplechoiceoptions)) + usr << "\red You already have more than [multiplechoiceoptions] logged votes on this poll. Enough is enough. Contact the database admin if this is an error." + return + var/adminrank = "Player" if(usr && usr.client && usr.client.holder) adminrank = usr.client.holder.rank