From 996d0322f3d3066dd925286dad48a5ac0b7c0c8b Mon Sep 17 00:00:00 2001 From: e107steved Date: Tue, 3 Jun 2008 21:31:31 +0000 Subject: [PATCH] On old polls, display right poll with the comments --- comment.php | 6 ++--- e107_plugins/poll/poll_class.php | 39 +++++++++++++++++++------------- e107_plugins/poll/poll_menu.php | 23 +++++++++++++++---- 3 files changed, 44 insertions(+), 24 deletions(-) diff --git a/comment.php b/comment.php index 5170862f2..131425dbc 100644 --- a/comment.php +++ b/comment.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/comment.php,v $ -| $Revision: 1.5 $ -| $Date: 2008-05-25 08:26:11 $ +| $Revision: 1.6 $ +| $Date: 2008-06-03 21:31:31 $ | $Author: e107steved $ +----------------------------------------------------------------------------+ */ @@ -288,6 +288,7 @@ else $comments_poll = $row['poll_comment']; $subject = $row['poll_title']; define("e_PAGETITLE", COMLAN_101." / ".COMLAN_99." / ".$subject.""); + $poll_to_show = $id; // Need to pass poll number through to display routine require_once(HEADERF); require(e_PLUGIN."poll/poll_menu.php"); $field = $row['poll_id']; @@ -296,7 +297,6 @@ else require_once(FOOTERF); exit; } - require_once(HEADERF); } break; case 'download' : diff --git a/e107_plugins/poll/poll_class.php b/e107_plugins/poll/poll_class.php index 31cae34bd..ed2b28cef 100644 --- a/e107_plugins/poll/poll_class.php +++ b/e107_plugins/poll/poll_class.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/poll/poll_class.php,v $ -| $Revision: 1.7 $ -| $Date: 2007-11-01 22:47:25 $ +| $Revision: 1.8 $ +| $Date: 2008-06-03 21:31:31 $ | $Author: e107steved $ +----------------------------------------------------------------------------+ */ @@ -233,11 +233,19 @@ class poll function render_poll($pollArray = "", $type = "menu", $POLLMODE = "", $returnMethod=FALSE) { global $POLLSTYLE, $sql, $tp, $ns; - if($POLLMODE == "query") + switch ($POLLMODE) { + case "query" : // Show poll, register any vote $this->get_poll($pollArray); $pollArray = $this->pollRow; $POLLMODE = $this->pollmode; + break; + case 'results' : + if ($sql->db_Select_gen($pollArray)) + { + $pollArray = $sql -> db_Fetch(); + } + break; } $barl = (file_exists(THEME."images/barl.png") ? THEME_ABS."images/barl.png" : e_PLUGIN."poll/images/barl.png"); @@ -272,7 +280,7 @@ class poll // $voteArray = array_slice($voteArray, 0, -1); } else - { + { // Get existing results $optionArray = explode(chr(1), $pollArray['poll_options']); $optionArray = array_slice($optionArray, 0, -1); $voteArray = explode(chr(1), $pollArray['poll_votes']); @@ -313,7 +321,8 @@ class poll { $POLLMODE = "notvoted"; } - else if($type == "forum") { + elseif($type == "forum") + { $preview = TRUE; } @@ -331,14 +340,18 @@ class poll $text = "
\n".preg_replace("/\{(.*?)\}/e", '$\1', ($type == "forum" ? $POLL_FORUM_NOTVOTED_START : $POLL_NOTVOTED_START)); $count = 1; $alt = 0; // alternate style. - foreach($optionArray as $option) { + foreach($optionArray as $option) + { // $MODE = ($mode) ? $mode : ""; /* debug */ $OPTIONBUTTON = ($pollArray['poll_allow_multiple'] ? "" : ""); $OPTION = $tp->toHTML($option, TRUE); - if(isset($POLL_NOTVOTED_LOOP_ALT) && $POLL_NOTVOTED_LOOP_ALT && $type != "forum"){ // alternating style + if(isset($POLL_NOTVOTED_LOOP_ALT) && $POLL_NOTVOTED_LOOP_ALT && $type != "forum") + { // alternating style $text .= preg_replace("/\{(.*?)\}/e", '$\1', ($alt == 0 ? $POLL_NOTVOTED_LOOP : $POLL_NOTVOTED_LOOP_ALT)); $alt = ($alt ==0) ? 1 : 0; - }else{ + } + else + { $text .= preg_replace("/\{(.*?)\}/e", '$\1', ($type == "forum" ? $POLL_FORUM_NOTVOTED_LOOP : $POLL_NOTVOTED_LOOP)); } $count ++; @@ -353,24 +366,19 @@ class poll break; case "voted": - + case 'results' : if($pollArray['poll_result_type'] && !strstr(e_SELF, "comment.php")) { $text = "


".POLLAN_39."

".POLLAN_40."


"; - } else { - - $text = preg_replace("/\{(.*?)\}/e", '$\1', ($type == "forum" ? $POLL_FORUM_VOTED_START : $POLL_VOTED_START)); $count = 0; foreach($optionArray as $option) { $OPTION = $tp->toHTML($option, TRUE); - $BAR = ($percentage[$count] ? "
" : ""); - $PERCENTAGE = $percentage[$count]."%"; $VOTES = POLLAN_31.": ".$voteArray[$count]; $text .= preg_replace("/\{(.*?)\}/e", '$\1', ($type == "forum" ? $POLL_FORUM_VOTED_LOOP : $POLL_VOTED_LOOP)); @@ -378,7 +386,6 @@ class poll } } $text .= preg_replace("/\{(.*?)\}/e", '$\1', ($type == "forum" ? $POLL_FORUM_VOTED_END : $POLL_VOTED_END)); - break; case "disallowed": @@ -394,7 +401,7 @@ class poll { $DISALLOWMESSAGE = POLLAN_41; } - else if($pollArray['poll_vote_userclass'] == 254) + elseif($pollArray['poll_vote_userclass'] == 254) { $DISALLOWMESSAGE = POLLAN_42; } diff --git a/e107_plugins/poll/poll_menu.php b/e107_plugins/poll/poll_menu.php index aa509123c..e4af55ff3 100644 --- a/e107_plugins/poll/poll_menu.php +++ b/e107_plugins/poll/poll_menu.php @@ -11,9 +11,9 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_plugins/poll/poll_menu.php,v $ -| $Revision: 1.1.1.1 $ -| $Date: 2006-12-02 04:35:40 $ -| $Author: mcfly_e107 $ +| $Revision: 1.2 $ +| $Date: 2008-06-03 21:31:31 $ +| $Author: e107steved $ +----------------------------------------------------------------------------+ */ @@ -41,12 +41,25 @@ if(!defined("POLL_1")) @include_once(e_PLUGIN."poll/languages/English.php"); } +if (empty($poll_to_show)) +{ + $poll_to_show = ' AND p.`poll_vote_userclass`!=255'; + $pollType = 'menu'; + $pollMode = 'query'; +} +else +{ + $poll_to_show = ' AND p.`poll_id`='.$poll_to_show; + $pollType = 'menu'; + $pollMode = 'results'; +} + $query = "SELECT p.*, u.user_name FROM #polls AS p LEFT JOIN #user AS u ON p.poll_admin_id = u.user_id -WHERE p.poll_vote_userclass!=255 AND p.poll_type=1 +WHERE p.poll_type=1{$poll_to_show} ORDER BY p.poll_datestamp DESC LIMIT 0,1 "; -$poll->render_poll($query, "menu", "query"); +$poll->render_poll($query, $pollType, $pollMode); ?> \ No newline at end of file