Jk-voting-vote subjects

From AOLserver Wiki
Revision as of 19:41, 15 January 2002 by WikiSysop (talk | contribs) (imported from WiKit id 78)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

proc vote_subjects {conn context} {

   set output ""
   foreach {db db2} ns_db gethandle postgres 2 {}
   set userrow user $db $conn
   #force_voting_exist $db
   set rows ns_db select $db "select * from voting_topics;"
   set subject_lines ""
   set bgcolor 0
   while {ns_db getrow $db $rows == 1} {
       set inner_row [[ns_db 0or1row $db2 \
"select sum(votes) from voting_detail where \
topic_identifier = [db_quote [ns_set get $rows topic_identifier]]];"]
       set content_set ns_set create content_set
       ns_set put $content_set bgcolor color_sequence $bgcolor
       incr bgcolor
       ns_set put $content_set total_votes ns_set get $inner_row sum
       ns_set put $content_set subject ns_set get $rows subject
       ns_set put $content_set author ns_set get $rows author
       ns_set put $content_set topic_identifier \
ns_set get $rows topic_identifier
   if {$userrow != ""} {
           #logged in users can vote
            ns_set put $content_set vote_option \
"<input type=button value=\"Vote\" \
onClick=\"parent.main.location='/voting/place_vote?id=ns_set get $rows topic_identifier'\">"
           #users can delete entries that they authored
           if {ns_set get $rows author == ns_set get $userrow name} {
               ns_set put $content_set delete_option \

"<input type=button value=\"Delete\" \ onClick=\"parent.main.location='/voting/delete_subject?id=ns_set get $rows topic_identifier'\">" } else { ns_set put $content_set delete_option "" } } else { ns_set put $content_set vote_option "" ns_set put $content_set delete_option "" } append subject_lines template "voting_subject.html" $content_set unset content_set } if {string length $subject_lines <= 0} { set subject_lines "There are no Voting Booths Open!"

   }
   set content_set ns_set create content_set
   ns_set put $content_set subject_lines $subject_lines
   ns_return 200 text/html \
template "voting_subject_page.html" $content_set
}