function light_poll_display($tid, $msg_count, $folder_fid, $in_list = true, $closed = false, $limit_text = true, $is_preview = false) { $webtag = get_webtag(); forum_check_webtag_available($webtag); $total_votes = 0; $user_votes = 0; $guest_votes = 0; $poll_data = poll_get($tid); $poll_results = poll_get_votes($tid); $user_poll_votes_array = poll_get_user_votes($tid); poll_get_total_votes($tid, $total_votes, $user_votes, $guest_votes); $request_uri = get_request_uri(); $poll_display = "<div class=\"poll\">\n"; $poll_display .= "<form accept-charset=\"utf-8\" method=\"post\" action=\"{$request_uri}\" target=\"_self\">\n"; $poll_display .= form_csrf_token_field(); $poll_display .= form_input_hidden('webtag', htmlentities_array($webtag)); $poll_display .= form_input_hidden('msg', htmlentities_array("{$tid}.1")); if ((!is_array($user_poll_votes_array) || $poll_data['CHANGEVOTE'] == POLL_VOTE_MULTI) && ($_SESSION['UID'] > 0 || $poll_data['ALLOWGUESTS'] == POLL_GUEST_ALLOWED && forum_get_setting('poll_allow_guests', 'Y')) && ($poll_data['CLOSES'] == 0 || $poll_data['CLOSES'] > time()) && !$is_preview) { foreach ($poll_results as $question_id => $poll_question) { $poll_display .= "<h3>" . word_filter_add_ob_tags($poll_question['QUESTION'], true) . "</h3>\n"; if ($poll_data['OPTIONTYPE'] == POLL_OPTIONS_DROPDOWN) { $dropdown_options_array = array_map('poll_dropdown_options_callback', $poll_question['OPTIONS_ARRAY']); $poll_display .= light_form_dropdown_array("poll_vote[{$question_id}]", $dropdown_options_array); } else { foreach ($poll_question['OPTIONS_ARRAY'] as $option_id => $option) { if (sizeof($poll_question['OPTIONS_ARRAY']) == 1 || $poll_question['ALLOW_MULTI'] == 'Y') { $poll_display .= light_form_checkbox("poll_vote[{$question_id}][{$option_id}]", 'Y', word_filter_add_ob_tags($option['OPTION_NAME'])); } else { $poll_display .= light_form_radio("poll_vote[{$question_id}]", $option_id, word_filter_add_ob_tags($option['OPTION_NAME'])); } } } } } else { if ($poll_data['SHOWRESULTS'] == POLL_SHOW_RESULTS || $poll_data['CLOSES'] > 0 && $poll_data['CLOSES'] < time()) { $poll_display .= "<div class=\"poll_results\">\n"; foreach ($poll_results as $poll_question) { $poll_display .= "<h3>" . word_filter_add_ob_tags($poll_question['QUESTION'], true) . "</h3>\n"; $poll_display .= light_poll_graph_display($poll_question['OPTIONS_ARRAY']); } $poll_display .= "</div>\n"; } else { $poll_display .= "<div class=\"poll_results\">\n"; foreach ($poll_results as $poll_question) { $poll_display .= "<h3>" . word_filter_add_ob_tags($poll_question['QUESTION'], true) . "</h3>\n"; foreach ($poll_question['OPTIONS_ARRAY'] as $option) { $poll_display .= word_filter_add_ob_tags($option['OPTION_NAME']); } } $poll_display .= "</div>\n"; } } if (!$is_preview) { $poll_display .= "<div class=\"poll_vote_counts\">" . poll_format_vote_counts($poll_data, $user_votes, $guest_votes) . "</div>\n"; if ($poll_data['CLOSES'] <= time() && $poll_data['CLOSES'] != 0) { $poll_display .= "<div class=\"poll_vote_closed\">" . gettext("Poll has ended") . "</div>\n"; if (is_array($user_poll_votes_array) && sizeof($user_poll_votes_array) > 0) { $poll_display .= poll_display_user_votes($user_poll_votes_array); } } else { if (is_array($user_poll_votes_array) && sizeof($user_poll_votes_array) > 0) { $poll_display .= poll_display_user_votes($user_poll_votes_array); if ($poll_data['CHANGEVOTE'] == POLL_VOTE_MULTI) { $poll_display .= "<div class=\"poll_buttons\">" . light_form_submit('poll_submit', gettext("Vote")) . "</div>"; } if ($poll_data['CHANGEVOTE'] != POLL_VOTE_CANNOT_CHANGE) { $poll_display .= "<div class=\"poll_buttons\">" . light_form_submit('poll_change_vote', gettext("Change vote")) . "</div>\n"; } if ($poll_data['VOTETYPE'] == POLL_VOTE_PUBLIC && $poll_data['CHANGEVOTE'] < POLL_VOTE_MULTI && $poll_data['POLLTYPE'] != POLL_TABLE_GRAPH) { $poll_display .= "<div class=\"poll_type_warning\">" . gettext("<b>Warning</b>: This is a public ballot. Your name will be visible next to the option you vote for.") . "</div>\n"; } } else { if ($_SESSION['UID'] > 0 || $poll_data['ALLOWGUESTS'] == POLL_GUEST_ALLOWED && forum_get_setting('poll_allow_guests', 'Y')) { $poll_display .= "<div class=\"poll_buttons\">" . light_form_submit('poll_submit', gettext("Vote")) . "</div>"; if ($poll_data['VOTETYPE'] == POLL_VOTE_PUBLIC && $poll_data['CHANGEVOTE'] < POLL_VOTE_MULTI && $poll_data['POLLTYPE'] != POLL_TABLE_GRAPH) { $poll_display .= "<div class=\"poll_type_warning\">" . gettext("<b>Warning</b>: This is a public ballot. Your name will be visible next to the option you vote for.") . "</div>\n"; } } } } } $poll_display .= "</form>\n"; $poll_display .= "</div>\n"; $poll_data['CONTENT'] = $poll_display; light_message_display($tid, $poll_data, $msg_count, 1, $folder_fid, $in_list, $closed, $limit_text, true, $is_preview); }
function poll_display($tid, $msg_count, $first_msg, $folder_fid, $in_list = true, $closed = false, $limit_text = true, $show_sigs = true, $is_preview = false, $highlight_array = array()) { $webtag = get_webtag(); $total_votes = 0; $user_votes = 0; $guest_votes = 0; $poll_data = poll_get($tid); $poll_results = poll_get_votes($tid); $user_poll_votes_array = poll_get_user_votes($tid); poll_get_total_votes($tid, $total_votes, $user_votes, $guest_votes); $request_uri = get_request_uri(); $poll_display = "<br />\n"; $poll_display .= "<div align=\"center\">\n"; $poll_display .= " <table class=\"box\" cellpadding=\"0\" cellspacing=\"0\" width=\"580\">\n"; $poll_display .= " <tr>\n"; $poll_display .= " <td align=\"center\">\n"; $poll_display .= " <form accept-charset=\"utf-8\" method=\"post\" action=\"{$request_uri}\" target=\"_self\">\n"; $poll_display .= " " . form_input_hidden("webtag", htmlentities_array($webtag)) . "\n"; $poll_display .= " " . form_input_hidden('tid', htmlentities_array($tid)) . "\n"; $poll_display .= " <table width=\"560\">\n"; if ((!is_array($user_poll_votes_array) || $poll_data['CHANGEVOTE'] == POLL_VOTE_MULTI) && (session::get_value('UID') > 0 || $poll_data['ALLOWGUESTS'] == POLL_GUEST_ALLOWED && forum_get_setting('poll_allow_guests', 'Y')) && ($poll_data['CLOSES'] == 0 || $poll_data['CLOSES'] > time()) && !$is_preview) { foreach ($poll_results as $question_id => $poll_question) { $poll_display .= " <tr>\n"; $poll_display .= " <td align=\"left\"><h2>" . word_filter_add_ob_tags($poll_question['QUESTION'], true) . "</h2></td>\n"; $poll_display .= " </tr>\n"; $poll_display .= " <tr>\n"; $poll_display .= " <td align=\"left\">\n"; $poll_display .= " <table width=\"100%\">\n"; if ($poll_data['OPTIONTYPE'] == POLL_OPTIONS_DROPDOWN) { $dropdown_options_array = array_map('poll_dropdown_options_callback', $poll_question['OPTIONS_ARRAY']); $poll_display .= " <tr>\n"; $poll_display .= " <td align=\"left\" class=\"postbody\" valign=\"top\">" . form_dropdown_array("pollvote[{$question_id}]", $dropdown_options_array) . "</td>\n"; $poll_display .= " </tr>\n"; } else { foreach ($poll_question['OPTIONS_ARRAY'] as $option_id => $option) { if (sizeof($poll_question['OPTIONS_ARRAY']) == 1 || $poll_question['ALLOW_MULTI'] == 'Y') { $poll_display .= " <tr>\n"; $poll_display .= " <td align=\"left\" class=\"postbody\" valign=\"top\" width=\"1%\">" . form_checkbox("pollvote[{$question_id}][{$option_id}]", 'Y', word_filter_add_ob_tags($option['OPTION_NAME']), false) . "</td>\n"; $poll_display .= " </tr>\n"; } else { $poll_display .= " <tr>\n"; $poll_display .= " <td align=\"left\" class=\"postbody\" valign=\"top\" width=\"1%\">" . form_radio("pollvote[{$question_id}]", $option_id, word_filter_add_ob_tags($option['OPTION_NAME']), false) . "</td>\n"; $poll_display .= " </tr>\n"; } } } $poll_display .= " </table>\n"; $poll_display .= " </td>\n"; $poll_display .= " </tr>\n"; } } else { if ($poll_data['SHOWRESULTS'] == POLL_SHOW_RESULTS || $poll_data['CLOSES'] > 0 && $poll_data['CLOSES'] < time()) { if ($poll_data['POLLTYPE'] == POLL_TABLE_GRAPH && $poll_data['VOTETYPE'] != POLL_VOTE_PUBLIC) { $poll_display .= " <tr>\n"; $poll_display .= " <td align=\"left\" colspan=\"2\">" . poll_table_graph($poll_results, $total_votes) . "</td>\n"; $poll_display .= " </tr>\n"; } else { foreach ($poll_results as $question_id => $poll_question) { $poll_display .= " <tr>\n"; $poll_display .= " <td align=\"left\"><h2>" . word_filter_add_ob_tags($poll_question['QUESTION'], true) . "</h2></td>\n"; $poll_display .= " </tr>\n"; $poll_display .= " <tr>\n"; $poll_display .= " <td align=\"left\">\n"; $poll_display .= " <table width=\"100%\">\n"; if ($poll_data['POLLTYPE'] == POLL_HORIZONTAL_GRAPH || $poll_data['VOTETYPE'] == POLL_VOTE_PUBLIC) { $poll_display .= " <tr>\n"; $poll_display .= " <td align=\"left\" colspan=\"2\">" . poll_horizontal_graph($poll_question['OPTIONS_ARRAY'], $poll_data, $total_votes) . "</td>\n"; $poll_display .= " </tr>\n"; } else { $poll_display .= " <tr>\n"; $poll_display .= " <td align=\"left\" colspan=\"2\">" . poll_vertical_graph($poll_question['OPTIONS_ARRAY'], $total_votes) . "</td>\n"; $poll_display .= " </tr>\n"; } $poll_display .= " </table>\n"; $poll_display .= " </td>\n"; $poll_display .= " </tr>\n"; } } } else { foreach ($poll_results as $question_id => $poll_question) { $poll_display .= " <tr>\n"; $poll_display .= " <td align=\"left\"><h2>" . word_filter_add_ob_tags($poll_question['QUESTION'], true) . "</h2></td>\n"; $poll_display .= " </tr>\n"; $poll_display .= " <tr>\n"; $poll_display .= " <td align=\"left\">\n"; $poll_display .= " <table width=\"100%\">\n"; foreach ($poll_question['OPTIONS_ARRAY'] as $option_id => $option) { $poll_display .= " <tr>\n"; $poll_display .= " <td align=\"left\" class=\"postbody\">" . word_filter_add_ob_tags($option['OPTION_NAME']) . "</td>\n"; $poll_display .= " </tr>\n"; } $poll_display .= " </table>\n"; $poll_display .= " </td>\n"; $poll_display .= " </tr>\n"; } } } if (!$is_preview) { $poll_display .= " <tr>\n"; $poll_display .= " <td align=\"left\" colspan=\"2\"> </td>\n"; $poll_display .= " </tr>\n"; $poll_display .= " <tr>\n"; $poll_display .= " <td align=\"left\" colspan=\"2\" class=\"postbody\">" . poll_format_vote_counts($poll_data, $user_votes, $guest_votes) . "</td>\n"; $poll_display .= " </tr>\n"; $poll_display .= " <tr>\n"; $poll_display .= " <td align=\"left\" colspan=\"2\"> </td>\n"; $poll_display .= " </tr>\n"; if ($poll_data['CLOSES'] <= time() && $poll_data['CLOSES'] != 0) { $poll_display .= " <tr>\n"; $poll_display .= " <td align=\"left\" colspan=\"2\" class=\"postbody\">" . gettext("Poll has ended.") . "</td>\n"; $poll_display .= " </tr>\n"; if ($poll_data['VOTETYPE'] == POLL_VOTE_PUBLIC && $poll_data['CHANGEVOTE'] < POLL_VOTE_MULTI && $poll_data['POLLTYPE'] != POLL_TABLE_GRAPH) { $poll_display .= " <tr>\n"; $poll_display .= " <td align=\"left\" colspan=\"2\"> </td>"; $poll_display .= " </tr>\n"; $poll_display .= " <tr>\n"; $poll_display .= " <td colspan=\"2\" align=\"center\"><a href=\"poll_results.php?webtag={$webtag}&tid={$tid}\" class=\"button popup 800x600\"><span>" . gettext("Results") . "</span></a></td>\n"; $poll_display .= " </tr>\n"; $poll_display .= " <tr>\n"; $poll_display .= " <td align=\"left\" colspan=\"2\"> </td>"; $poll_display .= " </tr>\n"; } if (is_array($user_poll_votes_array) && sizeof($user_poll_votes_array) > 0) { $poll_display .= poll_display_user_votes($user_poll_votes_array); } } else { if (is_array($user_poll_votes_array) && sizeof($user_poll_votes_array) > 0) { $poll_display .= poll_display_user_votes($user_poll_votes_array); $poll_display .= " <tr>\n"; $poll_display .= " <td align=\"left\" colspan=\"2\"> </td>\n"; $poll_display .= " </tr>\n"; if ($poll_data['CHANGEVOTE'] == POLL_VOTE_MULTI) { $poll_display .= " <tr>\n"; $poll_display .= " <td colspan=\"2\" align=\"center\">" . form_submit('pollsubmit', gettext("Vote")) . "</td>\n"; $poll_display .= " </tr>\n"; } $poll_display .= " <tr>\n"; $poll_display .= " <td colspan=\"2\" align=\"center\">"; if ($poll_data['SHOWRESULTS'] == POLL_SHOW_RESULTS && $total_votes > 0 || session::get_value('UID') == $poll_data['FROM_UID'] || session::check_perm(USER_PERM_FOLDER_MODERATE, $folder_fid)) { $poll_display .= "<a href=\"poll_results.php?webtag={$webtag}&tid={$tid}\" class=\"button popup 800x600\"><span>" . gettext("Results") . "</span></a>"; } if (session::get_value('UID') == $poll_data['FROM_UID'] || session::check_perm(USER_PERM_FOLDER_MODERATE, $folder_fid)) { $poll_display .= " <a href=\"close_poll.php?webtag={$webtag}&msg={$tid}.1\" class=\"button\" target=\"_parent\">" . gettext("End Poll") . "</a>"; } $poll_display .= " </td>\n"; $poll_display .= " </tr>\n"; if ($poll_data['CHANGEVOTE'] != POLL_VOTE_CANNOT_CHANGE) { $poll_display .= " <tr>\n"; $poll_display .= " <td colspan=\"2\" align=\"center\">" . form_submit('pollchangevote', gettext("Change vote")) . "</td>\n"; $poll_display .= " </tr>\n"; $poll_display .= " <tr>\n"; $poll_display .= " <td colspan=\"2\" align=\"center\"> </td>\n"; $poll_display .= " </tr>\n"; } if ($poll_data['VOTETYPE'] == POLL_VOTE_PUBLIC && $poll_data['CHANGEVOTE'] < POLL_VOTE_MULTI && $poll_data['POLLTYPE'] != POLL_TABLE_GRAPH) { $poll_display .= " <tr>\n"; $poll_display .= " <td colspan=\"2\" align=\"center\" class=\"postbody\">" . gettext("<b>Warning</b>: This is a public ballot. Your name will be visible next to the option you vote for.") . "</td>\n"; $poll_display .= " </tr>\n"; $poll_display .= " <tr>\n"; $poll_display .= " <td colspan=\"2\" align=\"center\"> </td>\n"; $poll_display .= " </tr>\n"; } } else { if (session::get_value('UID') > 0 || $poll_data['ALLOWGUESTS'] == POLL_GUEST_ALLOWED && forum_get_setting('poll_allow_guests', 'Y')) { $poll_display .= " <tr>\n"; $poll_display .= " <td colspan=\"2\" align=\"center\">" . form_submit('pollsubmit', gettext("Vote")) . "</td>\n"; $poll_display .= " </tr>\n"; $poll_display .= " <tr>\n"; $poll_display .= " <td colspan=\"2\" align=\"center\">"; if ($poll_data['SHOWRESULTS'] == POLL_SHOW_RESULTS && $total_votes > 0 || session::get_value('UID') == $poll_data['FROM_UID'] || session::check_perm(USER_PERM_FOLDER_MODERATE, $folder_fid)) { $poll_display .= "<a href=\"poll_results.php?webtag={$webtag}&tid={$tid}\" class=\"button popup 800x600\"><span>" . gettext("Results") . "</span></a>"; } if (session::get_value('UID') == $poll_data['FROM_UID'] || session::check_perm(USER_PERM_FOLDER_MODERATE, $folder_fid)) { $poll_display .= " <a href=\"close_poll.php?webtag={$webtag}&msg={$tid}.1\" class=\"button\" target=\"_parent\">" . gettext("End Poll") . "</a>"; } $poll_display .= " </td>\n"; $poll_display .= " </tr>\n"; $poll_display .= " <tr>\n"; $poll_display .= " <td align=\"left\" colspan=\"2\"> </td>"; $poll_display .= " </tr>\n"; if ($poll_data['VOTETYPE'] == POLL_VOTE_PUBLIC && $poll_data['CHANGEVOTE'] < POLL_VOTE_MULTI && $poll_data['POLLTYPE'] != POLL_TABLE_GRAPH) { $poll_display .= " <tr>\n"; $poll_display .= " <td colspan=\"2\" align=\"center\" class=\"postbody\">" . gettext("<b>Warning</b>: This is a public ballot. Your name will be visible next to the option you vote for.") . "</td>\n"; $poll_display .= " </tr>\n"; $poll_display .= " <tr>\n"; $poll_display .= " <td colspan=\"2\" align=\"center\"> </td>\n"; $poll_display .= " </tr>\n"; } } } } } else { if (is_array($user_poll_votes_array) && sizeof($user_poll_votes_array) > 0) { $poll_display .= " <tr>\n"; $poll_display .= " <td align=\"left\" colspan=\"2\"> </td>\n"; $poll_display .= " </tr>\n"; $poll_display .= " <tr>\n"; $poll_display .= " <td align=\"left\" colspan=\"2\" class=\"postbody\">" . poll_format_vote_counts($poll_data, $user_votes, $guest_votes) . "</td>\n"; $poll_display .= " </tr>\n"; $poll_display .= " <tr>\n"; $poll_display .= " <td align=\"left\" colspan=\"2\"> </td>\n"; $poll_display .= " </tr>\n"; $poll_display .= poll_display_user_votes($user_poll_votes_array); $poll_display .= " <tr>\n"; $poll_display .= " <td align=\"left\" colspan=\"2\"> </td>\n"; $poll_display .= " </tr>\n"; } } $poll_display .= " </table>\n"; $poll_display .= " </form>\n"; $poll_display .= " </td>\n"; $poll_display .= " </tr>\n"; $poll_display .= " </table>\n"; $poll_display .= "</div>\n"; $poll_display .= "<br />\n"; $poll_data['CONTENT'] = $poll_display; $poll_data['FROM_RELATIONSHIP'] = user_get_relationship(session::get_value('UID'), $poll_data['FROM_UID']); message_display($tid, $poll_data, $msg_count, $first_msg, $folder_fid, $in_list, $closed, $limit_text, true, $show_sigs, $is_preview, $highlight_array); }