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
@@ -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"]
+35 -6
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'>"