diff options
author | Benjamin Kellermann <Benjamin.Kellermann@gmx.de> | 2009-10-14 14:31:01 +0200 |
---|---|---|
committer | Benjamin Kellermann <Benjamin.Kellermann@gmx.de> | 2009-10-14 14:31:01 +0200 |
commit | ba24bf5fbad3cff5bd7b4cf82a089e98ccc87157 (patch) | |
tree | f95df763e8583f42e001456c574bfce378cb5ea5 | |
parent | bce9de6fdaaae6ddfad42d0048d1641807bf0e8b (diff) |
edituser is no longer persistant
-rwxr-xr-x | config_poll.rb | 2 | ||||
-rwxr-xr-x | participate.rb | 9 | ||||
-rw-r--r-- | poll.rb | 25 |
3 files changed, 15 insertions, 21 deletions
diff --git a/config_poll.rb b/config_poll.rb index 65aebb3..6a77c28 100755 --- a/config_poll.rb +++ b/config_poll.rb @@ -135,7 +135,7 @@ HTMLHEAD $htmlout += <<TABLE <h1>#{table.name}</h1> -#{table.to_html(config = true,activecolumn = $cgi["editcolumn"])} +#{table.to_html("",true,$cgi["editcolumn"])} TABLE $htmlout += <<INVITEDELETE diff --git a/participate.rb b/participate.rb index 7d6039b..7d0550a 100755 --- a/participate.rb +++ b/participate.rb @@ -33,8 +33,6 @@ load "charset.rb" load "config.rb" Dir.chdir(olddir) -$edituser = $cgi["edituser"] if $cgi.include?("edituser") - if $cgi.include?("revision") REVISION=$cgi["revision"].to_i table = YAML::load(VCS.cat(REVISION, "data.yaml")) @@ -43,8 +41,7 @@ else if $cgi.include?("add_participant") if $cgi.include?("delete_participant") - table.invite_delete($edituser) - $edituser = nil + table.invite_delete($cgi["olduser"]) else agreed = {} $cgi.params.each{|k,v| @@ -53,7 +50,7 @@ else end } - table.add_participant($cgi["add_participant"],agreed) + table.add_participant($cgi["olduser"],$cgi["add_participant"],agreed) end end @@ -90,7 +87,7 @@ $htmlout += <<TABLE <h1>#{table.name}</h1> <div id='polltable'> <form method='post' action='.'> - #{table.to_html} + #{table.to_html($cgi['edituser'])} </form> </div> TABLE @@ -63,7 +63,7 @@ EDITDELETE ret += "</tr>\n" ret end - def to_html(config = false,activecolumn = nil) + def to_html(edituser = "", config = false,activecolumn = nil) if VCS.revno == 1 && !config return <<HINT <pre @@ -95,7 +95,7 @@ HINT ret += head_to_html(config, activecolumn) sort_data($cgi.include?("sort") ? $cgi.params["sort"] : ["timestamp"]).each{|participant,poll| ret += "<tr class='participantrow'>\n" - ret += "<td class='name' #{$edituser == participant ? "id='active'":""}>" + ret += "<td class='name' #{edituser == participant ? "id='active'":""}>" ret += participant ret += " <sup><a href=\"?edituser=#{CGI.escapeHTML(CGI.escape(participant))}\" style='text-decoration: none' >#{EDIT}</a></sup>" unless config ret += "</td>\n" @@ -119,7 +119,7 @@ HINT } # PARTICIPATE - ret += participate_to_html unless config + ret += participate_to_html(edituser) unless config # SUMMARY ret += "<tr id='summary'><td class='name'>total</td>\n" @@ -161,22 +161,20 @@ HINT ret += "</table>\n" ret end - def participate_to_html + def participate_to_html(edituser) checked = {} - if $edituser && @data.include?($edituser) - participant = $edituser - @head.each_key{|k| checked[k] = @data[participant][k]} + if @data.include?(edituser) + @head.each_key{|k| checked[k] = @data[edituser][k]} else - participant = "" @head.each_key{|k| checked[k] = NOVAL} end ret = "<tr id='add_participant'>\n" ret += "<td class='name'> - <input type='hidden' name='edituser' value=\"#{participant}\" /> + <input type='hidden' name='olduser' value=\"#{edituser}\" /> <input size='16' type='text' name='add_participant' - value=\"#{participant}\" + value=\"#{edituser}\" title='To change a line, add a new person with the same name!' />" ret += "</td>\n" @head.sort.each{|columntitle,columndescription| @@ -198,7 +196,7 @@ HINT ret += "</table></td>" } ret += "<td class='checkboxes'><input type='submit' value='add/edit' />" - ret += "<br /><input type='submit' name='delete_participant' value='delete user' />" if $edituser + ret += "<br /><input type='submit' name='delete_participant' value='delete user' />" if @data.include?(edituser) ret += "</td>\n" ret += "</tr>\n" @@ -268,7 +266,7 @@ ADDCOMMENT ret += " <a href='.' >last</a>" if defined?(REVISION) ret end - def add_participant(name, agreed) + def add_participant(olduser, name, agreed) name.strip! if name == "" maximum = @data.keys.collect{|e| e.scan(/^Anonymous #(\d*)/).flatten[0]}.compact.collect{|i| i.to_i}.max @@ -276,8 +274,7 @@ ADDCOMMENT name = "Anonymous ##{maximum + 1}" end htmlname = CGI.escapeHTML(name) - @data.delete(CGI.escapeHTML($edituser)) if $edituser - $edituser = htmlname + @data.delete(CGI.escapeHTML(olduser)) @data[htmlname] = {"timestamp" => Time.now } @head.each_key{|columntitle| @data[htmlname][columntitle] = agreed[columntitle.to_s] |