Poll Fix + Link (#4655)

Fixes the permissions required for polling / the button not showing up for devs.
Adds the option to display a link in the poll
This commit is contained in:
Werner
2018-04-25 22:01:58 +02:00
committed by Erki
parent d4e9990e82
commit d4c2268c4e
5 changed files with 57 additions and 11 deletions

View File

@@ -99,8 +99,7 @@ var/list/admin_verbs_admin = list(
/client/proc/clear_toxins,
/client/proc/wipe_ai, // allow admins to force-wipe AIs
/client/proc/fix_player_list,
/client/proc/reset_openturf,
/client/proc/create_poll //Allows to create polls
/client/proc/reset_openturf
)
var/list/admin_verbs_ban = list(
/client/proc/unban_panel,
@@ -371,7 +370,8 @@ var/list/admin_verbs_dev = list( //will need to be altered - Ryan784
/client/proc/cmd_dev_bst,
/client/proc/lighting_show_verbs,
/client/proc/cmd_display_del_log,
/client/proc/cmd_display_init_log
/client/proc/cmd_display_init_log,
/client/proc/create_poll //Allows to create polls
)
var/list/admin_verbs_cciaa = list(
/client/proc/cmd_admin_pm_panel, /*admin-pm list*/

View File

@@ -2,7 +2,7 @@
set category = "Special Verbs"
set name = "Create Poll"
if(!check_rights(R_ADMIN|R_DEV))
if(!check_rights(R_DEV))
return
if(!establish_db_connection(dbcon))
to_chat(src,"<span class='danger'>Failed to establish database connection.</span>")
@@ -60,13 +60,20 @@
viewtoken = "'[sanitizeSQL(viewtoken)]'"
else
viewtoken = "NULL"
var/link = null
link = input("Do you want to provide a link to get more information?","Link") as text
if(link)
link = "'[sanitizeSQL(link)]'"
else
link = "NULL"
var/sql_ckey = sanitizeSQL(ckey)
var/question = input("Write your question","Question") as message
if(!question)
return
question = sanitizeSQL(question)
var/DBQuery/query_polladd_question = dbcon.NewQuery("INSERT INTO ss13_poll_question (polltype, starttime, endtime, question, adminonly, multiplechoiceoptions, createdby_ckey, createdby_ip, publicresult, viewtoken) VALUES ('[polltype]', '[starttime]', '[endtime]', '[question]', '[adminonly]', '[choice_amount]', '[sql_ckey]', '[address]', '[publicresult]', [viewtoken])")
var/DBQuery/query_polladd_question = dbcon.NewQuery("INSERT INTO ss13_poll_question (polltype, starttime, endtime, question, adminonly, multiplechoiceoptions, createdby_ckey, createdby_ip, publicresult, viewtoken, link) VALUES ('[polltype]', '[starttime]', '[endtime]', '[question]', '[adminonly]', '[choice_amount]', '[sql_ckey]', '[address]', '[publicresult]', [viewtoken], [link])")
if(!query_polladd_question.Execute())
var/err = query_polladd_question.ErrorMsg()
to_chat(src,"SQL ERROR adding new poll question to table. Error : \[[err]\]\n")

View File

@@ -216,6 +216,10 @@ INITIALIZE_IMMEDIATE(/mob/abstract/new_player)
handle_player_polling()
return
if(href_list["showpolllink"])
show_poll_link(href_list["showpolllink"])
return
if(href_list["pollid"])
var/pollid = href_list["pollid"]

View File

@@ -34,20 +34,35 @@
src << browse(output,"window=playerpolllist;size=500x300")
/mob/abstract/new_player/proc/show_poll_link(var/pollid = -1)
if(pollid == -1) return
establish_db_connection(dbcon)
if(dbcon.IsConnected())
var/DBQuery/select_query = dbcon.NewQuery("SELECT link FROM ss13_poll_question WHERE id = :pollid:")
select_query.Execute(list("pollid"=pollid))
var/link = null
while(select_query.NextRow())
link = select_query.item[1]
if(link && link != "")
usr << link(link)
else
log_debug("Polling: [usr.ckey] tried to open poll [pollid] with a invalid link: [link]")
/mob/abstract/new_player/proc/poll_player(var/pollid = -1)
if(pollid == -1) return
establish_db_connection(dbcon)
if(dbcon.IsConnected())
var/DBQuery/select_query = dbcon.NewQuery("SELECT starttime, endtime, question, polltype, multiplechoiceoptions FROM ss13_poll_question WHERE id = [pollid]")
select_query.Execute()
var/DBQuery/select_query = dbcon.NewQuery("SELECT starttime, endtime, question, polltype, multiplechoiceoptions, link FROM ss13_poll_question WHERE id = :pollid:")
select_query.Execute(list("pollid"=pollid))
var/pollstarttime = ""
var/pollendtime = ""
var/pollquestion = ""
var/polltype = ""
var/haslink = 0
var/found = 0
var/multiplechoiceoptions = 0
@@ -56,6 +71,8 @@
pollendtime = select_query.item[2]
pollquestion = select_query.item[3]
polltype = select_query.item[4]
if(select_query.item[6] && select_query.item[6] != "")
haslink = 1
found = 1
break
@@ -89,7 +106,10 @@
var/output = "<div align='center'><B>Player poll</B>"
output +="<hr>"
output += "<b>Question: [pollquestion]</b><br>"
output += "<font size='2'>Poll runs from <b>[pollstarttime]</b> until <b>[pollendtime]</b></font><p>"
output += "<font size='2'>Poll runs from <b>[pollstarttime]</b> until <b>[pollendtime]</b></font>"
if(haslink)
output += "<br><font size='2'>Additional information <a href='?src=\ref[src];showpolllink=[pollid]'>is available here</a></font>"
output += "<p>"
if(!voted) //Only make this a form if we have not voted yet
output += "<form name='cardcomp' action='?src=\ref[src]' method='get'>"
@@ -133,7 +153,10 @@
var/output = "<div align='center'><B>Player poll</B>"
output +="<hr>"
output += "<b>Question: [pollquestion]</b><br>"
output += "<font size='2'>Feedback gathering runs from <b>[pollstarttime]</b> until <b>[pollendtime]</b></font><p>"
output += "<font size='2'>Feedback gathering runs from <b>[pollstarttime]</b> until <b>[pollendtime]</b></font>"
if(haslink)
output += "<br><font size='2'>Additional information <a href='?src=\ref[src];showpolllink=[pollid]'>is available here</a></font>"
output += "<p>"
if(!voted) //Only make this a form if we have not voted yet
output += "<form name='cardcomp' action='?src=\ref[src]' method='get'>"
@@ -167,7 +190,10 @@
var/output = "<div align='center'><B>Player poll</B>"
output +="<hr>"
output += "<b>Question: [pollquestion]</b><br>"
output += "<font size='2'>Poll runs from <b>[pollstarttime]</b> until <b>[pollendtime]</b></font><p>"
output += "<font size='2'>Poll runs from <b>[pollstarttime]</b> until <b>[pollendtime]</b></font>"
if(haslink)
output += "<br><font size='2'>Additional information <a href='?src=\ref[src];showpolllink=[pollid]'>is available here</a></font>"
output += "<p>"
var/voted = 0
while(voted_query.NextRow())
@@ -262,7 +288,10 @@
var/output = "<div align='center'><B>Player poll</B>"
output +="<hr>"
output += "<b>Question: [pollquestion]</b><br>You can select up to [multiplechoiceoptions] options. If you select more, the first [multiplechoiceoptions] will be saved.<br>"
output += "<font size='2'>Poll runs from <b>[pollstarttime]</b> until <b>[pollendtime]</b></font><p>"
output += "<font size='2'>Poll runs from <b>[pollstarttime]</b> until <b>[pollendtime]</b></font>"
if(haslink)
output += "<br><font size='2'>Additional information <a href='?src=\ref[src];showpolllink=[pollid]'>is available here</a></font>"
output += "<p>"
if(!voted) //Only make this a form if we have not voted yet
output += "<form name='cardcomp' action='?src=\ref[src]' method='get'>"