From 8282802d5e7cfd909e54384f0efc14ea496694b0 Mon Sep 17 00:00:00 2001 From: Cameron Date: Wed, 23 Mar 2016 16:43:41 -0700 Subject: [PATCH] Fixes #1449 - Polls failing in PHP7 and Multiple options voting not functioning. --- e107_handlers/e107_class.php | 2 +- e107_handlers/mysql_class.php | 20 +- e107_handlers/shortcode_handler.php | 3 + e107_plugins/forum/forum_viewtopic.php | 2 +- .../forum/templates/forum_poll_template.php | 10 + e107_plugins/poll/oldpolls.php | 193 ++++----- e107_plugins/poll/poll_class.php | 392 ++++++++++++------ e107_plugins/poll/templates/poll_template.php | 10 +- 8 files changed, 399 insertions(+), 233 deletions(-) diff --git a/e107_handlers/e107_class.php b/e107_handlers/e107_class.php index 860e44d8c..42faec689 100644 --- a/e107_handlers/e107_class.php +++ b/e107_handlers/e107_class.php @@ -2244,7 +2244,7 @@ class e107 if(ADMIN && E107_DBG_INCLUDES) { - e107::getMessage()->addDebug( "template path=".$path ); + e107::getMessage()->addDebug( "Attempting to load Template File: ".$path ); } $id = str_replace('/', '_', $id); diff --git a/e107_handlers/mysql_class.php b/e107_handlers/mysql_class.php index db6f1ba93..b6442f0ac 100644 --- a/e107_handlers/mysql_class.php +++ b/e107_handlers/mysql_class.php @@ -531,11 +531,25 @@ class e_db_mysql { $buglink = is_null($rli) ? $this->mySQLaccess : $rli; - if(is_array($query) && is_object($ex)) + if($this->pdo == true && isset($ex) && is_object($ex)) { - $query = "ERROR: ".$ex->errorInfo[2]."
PREPARE: ".$query['PREPARE']."
BIND:".print_a($query['BIND'],true); // ,true); + if(is_array($query)) + { + $query = "ERROR: ".$ex->errorInfo[2]."
PREPARE: ".$query['PREPARE']."
BIND:".print_a($query['BIND'],true); // ,true); + + } + else + { + $query = $ex->getMessage(); + $query .= print_a( $ex->getTrace(),true); + + + + + } } + $db_debug->Mark_Query($query, $buglink, $sQryRes, $aTrace, $mytime, $pTable); } else @@ -1040,7 +1054,7 @@ class e_db_mysql foreach ($arg['data'] as $fn => $fv) { $new_data .= ($new_data ? ', ' : ''); - $ftype = $fieldTypes[$fn]; + $ftype = isset($fieldTypes[$fn]) ? $fieldTypes[$fn] : 'str'; $new_data .= ($this->pdo == true && $ftype !='cmd') ? "`{$fn}`= :". $fn : "`{$fn}`=".$this->_getFieldValue($fn, $fv, $fieldTypes); diff --git a/e107_handlers/shortcode_handler.php b/e107_handlers/shortcode_handler.php index 25e078e68..fb9ba3f63 100644 --- a/e107_handlers/shortcode_handler.php +++ b/e107_handlers/shortcode_handler.php @@ -1290,6 +1290,9 @@ class e_shortcode */ protected $scVars = null; + /** + * e_shortcode constructor. + */ public function __construct() { $this->scVars = new e_vars(); diff --git a/e107_plugins/forum/forum_viewtopic.php b/e107_plugins/forum/forum_viewtopic.php index 196d2c97c..2112a86a4 100644 --- a/e107_plugins/forum/forum_viewtopic.php +++ b/e107_plugins/forum/forum_viewtopic.php @@ -179,7 +179,7 @@ if($thread->message) //{ if(e107::isInstalled('poll')) { - $_qry = 'SELECT * FROM `#polls` WHERE `poll_datestamp` = ' . $thread->threadId; + $_qry = 'SELECT p.*, u.user_id, u.user_name FROM `#polls` AS p LEFT JOIN `#user` AS u ON p.poll_admin_id = u.user_id WHERE p.poll_datestamp = ' . $thread->threadId; if($sql->gen($_qry)) { if (!defined('POLLCLASS')) diff --git a/e107_plugins/forum/templates/forum_poll_template.php b/e107_plugins/forum/templates/forum_poll_template.php index 87f9286ae..e2513f826 100644 --- a/e107_plugins/forum/templates/forum_poll_template.php +++ b/e107_plugins/forum/templates/forum_poll_template.php @@ -60,6 +60,16 @@ $FORUM_POLL_TEMPLATE['results']['end'] = " "; +/* v2.x template for polls when user HAS been denied the ability to vote (userclass) */ + +$FORUM_POLL_TEMPLATE['denied']['start'] = $FORUM_POLL_TEMPLATE['results']['start']; +$FORUM_POLL_TEMPLATE['denied']['item'] = $FORUM_POLL_TEMPLATE['results']['item']; +$FORUM_POLL_TEMPLATE['denied']['end'] = "
{DISALLOWMESSAGE}
+
{VOTE_TOTAL}
+ {COMMENTS} {OLDPOLLS} + + +"; diff --git a/e107_plugins/poll/oldpolls.php b/e107_plugins/poll/oldpolls.php index 545cb8cd3..bcd578349 100644 --- a/e107_plugins/poll/oldpolls.php +++ b/e107_plugins/poll/oldpolls.php @@ -23,52 +23,46 @@ if (!e107::isInstalled('poll')) require_once(HEADERF); require_once(e_HANDLER."comment_class.php"); $cobj = new comment; -$gen = new convert; -if(!defined("USER_WIDTH")){ define("USER_WIDTH","width:95%"); } + +if(!defined("USER_WIDTH") && !deftrue('BOOTSTRAP')) +{ + define("USER_WIDTH","width:95%"); +} include_lan(e_PLUGIN."poll/languages/".e_LANGUAGE.".php"); if(e_QUERY) { + + require_once('poll_class.php'); + $query = "SELECT p.*, u.user_id, u.user_name FROM #polls AS p LEFT JOIN #user AS u ON p.poll_admin_id = u.user_id WHERE p.poll_type=1 AND p.poll_id=".intval(e_QUERY); - if($sql->db_Select_gen($query)) + if($sql->gen($query)) { + $pl = new poll; + $row = $sql ->fetch(); - $row = $sql -> db_Fetch(); - extract($row); + $start_datestamp = $tp->toDate($row['poll_datestamp'], "long"); + $end_datestamp = $tp->toDate($row['poll_end_datestamp'], "long"); + $uparams = array('id' => $row['user_id'], 'name' => $row['user_name']); + $link = e107::getUrl()->create('user/profile/view', $uparams); + $userlink = "".$row['user_name'].""; - $optionArray = explode(chr(1), $poll_options); - $optionArray = array_slice($optionArray, 0, -1); - $voteArray = explode(chr(1), $poll_votes); - $voteArray = array_slice($voteArray, 0, -1); - $voteTotal = array_sum($voteArray); - $percentage = array(); - foreach($voteArray as $votes) - { - $percentage[] = round(($votes/$voteTotal) * 100, 2); - } + $text = $pl->render_poll($row, 'forum', 'oldpolls',true); - $start_datestamp = $gen->convert_date($poll_datestamp, "long"); - $end_datestamp = $gen->convert_date($poll_end_datestamp, "long"); - //".$user_name." - $uparams = array('id' => $user_id, 'name' => $user_name); - $link = e107::getUrl()->create('user/profile/view', $uparams); - $userlink = "".$user_name.""; - $text = " - - - "; + $text .= " +
+ ".POLLAN_35." ".$userlink."
".POLLAN_37." ".$start_datestamp." ".POLLAN_38." ".$end_datestamp."
+ "; - $count = 0; + + + /* $count = 0; $barl = (file_exists(THEME."images/barl.png") ? THEME."images/barl.png" : e_PLUGIN."poll/images/barl.png"); $barr = (file_exists(THEME."images/barr.png") ? THEME."images/barr.png" : e_PLUGIN."poll/images/barr.png"); @@ -92,79 +86,90 @@ if(e_QUERY) $count++; } - +*/ $query = "SELECT c.*, u.* FROM #comments AS c - LEFT JOIN #user AS u ON FLOOR(SUBSTR(c.comment_author,1,INSTR(c.comment_author,'.')-1))=u.user_id - WHERE comment_item_id=".intval($poll_id)." AND comment_type=4 ORDER BY comment_datestamp"; - if ($comment_total = $sql->db_Select_gen($query) !== FALSE) + LEFT JOIN #user AS u ON c.comment_author_id = u.user_id + WHERE comment_item_id=".intval($row['poll_id'])." AND comment_type='4' ORDER BY comment_datestamp"; + + if ($comment_total = $sql->gen($query)) { - $text .= ""; + $text .= ""; } - $text .= "
- ".$tp -> toHTML($poll_title,TRUE,'TITLE')." -
".POLLAN_35." ".$userlink."
".POLLAN_37." ".$start_datestamp." ".POLLAN_38." ".$end_datestamp.".
".POLLAN_26.": {$voteTotal}
-
-


"; - while ($row = $sql->db_Fetch()) { - $text .= $cobj->render_comment($row); + $text .= "
"; + + while ($row2 = $sql->fetch()) + { + $text .= e107::getComment()->render_comment($row2, 'poll', 'comment'); } - $text .= "
"; - $ns->tablerender(POLL_ADLAN01." #".$poll_id, $text); + + // $text .= ""; + $ns->tablerender(LAN_PLUGIN_POLL_NAME." #".$row['poll_id'], $text); + echo "
"; } } -$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_type=1 -ORDER BY p.poll_datestamp DESC"; -if(!$sql->db_Select_gen($query)) -{ - $ns->tablerender(POLLAN_28, "
".POLLAN_33."
"); + // Render List of Polls. + + + $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_type=1 + ORDER BY p.poll_datestamp DESC"; + + if(!$array = $sql->retrieve($query,true)) + { + $ns->tablerender(POLLAN_28, "
".POLLAN_33."
"); + require_once(FOOTERF); + exit; + } + + $array = array_slice($array, 1); + + if(empty($array)) + { + $ns->tablerender(POLLAN_28, "
".POLLAN_33."
"); + require_once(FOOTERF); + exit; + } + + $text = " + + + + + + + + + + \n"; + + + foreach($array as $row) + { + + $from = $tp->toDate($row['poll_datestamp'], "short"); + $to = $tp->toDate($row['poll_end_datestamp'], "short"); + + $poll_title = $tp->toHtml($row['poll_title'], true, 'TITLE'); + + $uparams = array('id' => $row['poll_admin_id'], 'name' => $row['user_name']); + + $link = e107::getUrl()->create('user/profile/view', $uparams); + + + $userlink = "".$row['user_name'].""; + $text .= " + + + + \n"; + } + + $text .= "
".LAN_TITLE."".POLLAN_35."".POLLAN_36."
{$poll_title}".$userlink."".$from." ".POLLAN_38." ".$to."
"; + e107::getRender()->tablerender(POLLAN_28, $text); require_once(FOOTERF); - exit; -} - -$array = $sql -> db_getList(); -$oldpollArray = array_slice($array, 1); - -if(!count($oldpollArray)) -{ - $ns->tablerender(POLLAN_28, "
".POLLAN_33."
"); - require_once(FOOTERF); - exit; -} - -$text = " - - - - -\n"; - -if (!is_object($tp->e_bb)) -{ - require_once(e_HANDLER.'bbcode_handler.php'); - $tp->e_bb = new e_bbcode; -} - -foreach($oldpollArray as $oldpoll) -{ - extract($oldpoll); - $from = $gen->convert_date($poll_datestamp, "short"); - $to = $gen->convert_date($poll_end_datestamp, "short"); - - $poll_title = $tp->e_bb->parseBBCodes($poll_title, 0,TRUE,TRUE); // Strip bbcodes -//{$user_name} - $uparams = array('id' => $poll_admin_id, 'name' => $user_name); - $link = e107::getUrl()->create('user/profile/view', $uparams); - $userlink = "".$user_name.""; - $text .= " - - - - \n"; -} - -$text .= "
".POLLAN_34."".POLLAN_35."".POLLAN_36."
{$poll_title}".$userlink."{$from} ".POLLAN_38." {$to}
"; -$ns->tablerender(POLLAN_28, $text); -require_once(FOOTERF); ?> diff --git a/e107_plugins/poll/poll_class.php b/e107_plugins/poll/poll_class.php index bccf8e193..ec4addeb5 100644 --- a/e107_plugins/poll/poll_class.php +++ b/e107_plugins/poll/poll_class.php @@ -43,7 +43,7 @@ class poll $arr_polls_cookies = array(); foreach($_COOKIE as $cookie_name => $cookie_val) { // Collect poll cookies - list($str, $int) = explode('_', $cookie_name); + list($str, $int) = explode('_', $cookie_name, 2); if (($str == 'poll') && is_numeric($int)) { // Yes, its poll's cookie $arr_polls_cookies[] = $int; @@ -310,6 +310,12 @@ class poll } + + + + + + function render_poll($pollArray = "", $type = "menu", $POLLMODE = "", $returnMethod=FALSE) { $ns = e107::getRender(); @@ -321,6 +327,7 @@ class poll switch ($POLLMODE) { case 'query' : // Show poll, register any vote + if ($this->get_poll($pollArray) === FALSE) { return ''; // No display if no poll @@ -328,12 +335,24 @@ class poll $pollArray = $this->pollRow; $POLLMODE = $this->pollmode; break; + case 'results' : if ($sql->gen($pollArray)) { $pollArray = $sql->fetch(); } break; + + case 'oldpolls': + $POLLMODE = 'results'; + break; + + default: + if(ADMIN) + { + return "
No \$POLLMODE set
"; + } + } @@ -385,189 +404,157 @@ class poll } } } - /* get template */ - if (file_exists(THEME.'poll_template.php')) - { - require(THEME.'poll_template.php'); - } - else if (!isset($POLL_NOTVOTED_START)) - { - require(e_PLUGIN.'poll/templates/poll_template.php'); - } - - - + + + + + $template = array(); + if(deftrue('BOOTSTRAP')) { - - if($type == 'forum') + $template = ($type == 'forum') ? e107::getTemplate('forum','forum_poll') : e107::getTemplate('poll'); + } + else + { + /* get template */ + if (file_exists(THEME.'poll_template.php')) { - require_once(e_PLUGIN."forum/templates/forum_poll_template.php"); - - $POLL_FORUM_NOTVOTED_START = $FORUM_POLL_TEMPLATE['form']['start']; - $POLL_FORUM_NOTVOTED_LOOP = $FORUM_POLL_TEMPLATE['form']['item']; - $POLL_FORUM_NOTVOTED_END = $FORUM_POLL_TEMPLATE['form']['end']; - - $POLL_FORUM_VOTED_START = $FORUM_POLL_TEMPLATE['results']['start']; - $POLL_FORUM_VOTED_LOOP = $FORUM_POLL_TEMPLATE['results']['item']; - $POLL_FORUM_VOTED_END = $FORUM_POLL_TEMPLATE['results']['end']; + require(THEME.'poll_template.php'); + } + else if (!isset($POLL_NOTVOTED_START)) + { + require(e_PLUGIN.'poll/templates/poll_template.php'); } - - $POLL_NOTVOTED_START = $POLL_TEMPLATE['form']['start']; - $POLL_NOTVOTED_LOOP = $POLL_TEMPLATE['form']['item']; - $POLL_NOTVOTED_END = $POLL_TEMPLATE['form']['end']; - - $POLL_VOTED_START = $POLL_TEMPLATE['results']['start']; - $POLL_VOTED_LOOP = $POLL_TEMPLATE['results']['item']; - $POLL_VOTED_END = $POLL_TEMPLATE['results']['end']; - - } - - - $preview = FALSE; - if ($type == 'preview') - { - $POLLMODE = 'notvoted'; - } - elseif ($type == 'forum') - { - $preview = TRUE; + $template['form']['start'] = $POLL_NOTVOTED_START ; + $template['form']['item'] = $POLL_NOTVOTED_LOOP; + $template['form']['end'] = $POLL_NOTVOTED_END; + $template['results']['start'] = $POLL_VOTED_START; + $template['results']['item'] = $POLL_VOTED_LOOP; + $template['results']['end'] = $POLL_VOTED_END; + $template['denied']['start'] = $POLL_DISALLOWED_START; + $template['denied']['item'] = $POLL_DISALLOWED_LOOP ; + $template['denied']['end'] = $POLL_DISALLOWED_END ; } - $comment_total = 0; - if ($pollArray['poll_comment']) - { // Only get comments if they're allowed on poll. And we only need the count ATM - $comment_total = $sql->count("comments", "(*)", "WHERE `comment_item_id`='".intval($pollArray['poll_id'])."' AND `comment_type`=4"); - } $sc = e107::getScBatch('poll'); $sc->setVars($pollArray); - - - $QUESTION = $tp->toHTML($pollArray['poll_title'], TRUE, "emotes_off, defs"); - - - $VOTE_TOTAL = POLLAN_31.": ".$voteTotal; - $COMMENTS = ($pollArray['poll_comment'] ? " ".LAN_COMMENTS.": ".$comment_total."" : ""); - - - $poll_count = $sql->count("polls", "(*)", "WHERE poll_id <= '".$pollArray['poll_id']."'"); - $OLDPOLLS = ''; - - if ($poll_count > 1) - { - $OLDPOLLS = ($type == 'menu' ? "".POLLAN_28."" : ""); + if ($pollArray['poll_comment']) // Only get comments if they're allowed on poll. And we only need the count ATM + { + $sc->pollCommentTotal = $sql->count("comments", "(*)", "WHERE `comment_item_id`='".intval($pollArray['poll_id'])."' AND `comment_type`=4"); } - - //"".$pollArray['user_name']."" - $uparams = array('id' => $pollArray['poll_admin_id'], 'name' => $pollArray['user_name']); - $link = e107::getUrl()->create('user/profile/view', $uparams); - $userlink = "".$pollArray['user_name'].""; - $AUTHOR = POLLAN_35." ".($type == 'preview' || $type == 'forum' ? USERNAME : $userlink); - - + $sc->pollCount = $sql->count("polls", "(*)", "WHERE poll_id <= '".$pollArray['poll_id']."'"); + $sc->pollRenderMode = $type; + $sc->pollVoteTotal = $voteTotal; + $sc->pollRenderType = $type; + + + if ($type == 'preview') + { + $POLLMODE = 'notvoted'; + } + elseif ($type == 'forum') + { + $sc->pollPreview = true; + } + + + $text = ''; switch ($POLLMODE) { + case 'notvoted': - $text = "
\n".preg_replace("/\{(.*?)\}/e", '$\1', ($type == "forum" ? $POLL_FORUM_NOTVOTED_START : $POLL_NOTVOTED_START)); + + $text = "\n"; + $text .= $tp->parseTemplate($template['form']['start'],true, $sc); $count = 1; $sc->answerCount = 1; - $alt = 0; // alternate style. - - $template = ($type == "forum") ? $POLL_FORUM_NOTVOTED_LOOP : $POLL_NOTVOTED_LOOP; - - foreach ($optionArray as $option) + + foreach ($optionArray as $option) { $sc->answerOption = $option; - // $MODE = ($mode) ? $mode : ""; /* debug */ - // $OPTIONBUTTON = ($pollArray['poll_allow_multiple'] ? "" : ""); - // $OPTION = $tp->toHTML($option, TRUE); - - // $OPTIONBUTTON = $tp->parseTemplate("{OPTIONBUTTON}",true); - - // $OPTION = $tp->parseTemplate("{OPTION}",true); - - // $OPTION = $tp->parseTemplate("{ANSWER}",true); - - $text .= $tp->parseTemplate($template, true, $sc); + $text .= $tp->parseTemplate($template['form']['item'], true, $sc); $count ++; $sc->answerCount++; } - - $SUBMITBUTTON = ""; - // disable submit when previewing the poll or when NOT viewing the poll in the forum - if (('preview' == $type || $preview == TRUE) && strpos(e_REQUEST_SELF, "forum") === FALSE) - { - $SUBMITBUTTON = ""; - } + $text .= $tp->parseTemplate($template['form']['end'], true, $sc); - $text .= "\n".preg_replace("/\{(.*?)\}/e", '$\1', ($type == "forum" ? $POLL_FORUM_NOTVOTED_END : $POLL_NOTVOTED_END))."\n
"; + $text .= ""; 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)); + + $text = $tp->parseTemplate( $template['results']['start'], true, $sc); $count = 0; + $sc->answerCount = 0; + foreach ($optionArray as $option) { - $OPTION = $tp->toHTML($option, TRUE); - $BAR = $this->generateBar($percentage[$count]); - // $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)); + $sc->pollPercentage = $percentage[$count]; + $sc->answerOption = $option; + $sc->pollVotes = $voteArray[$count]; + + $text .= $tp->parseTemplate($template['results']['item'], true, $sc); + $count ++; + $sc->answerCount++; } - $text .= preg_replace("/\{(.*?)\}/e", '$\1', ($type == "forum" ? $POLL_FORUM_VOTED_END : $POLL_VOTED_END)); + $text .= $tp->parseTemplate($template['results']['end'], true, $sc); } break; + + + + case 'disallowed': - $text = preg_replace("/\{(.*?)\}/e", '$\1', $POLL_DISALLOWED_START); + + $text = $tp->parseTemplate($template['denied']['start'], true, $sc); + $count = 0; + foreach ($optionArray as $option) { - $MODE = $mode; /* debug */ - $OPTION = $tp->toHTML($option, TRUE); - $text .= preg_replace("/\{(.*?)\}/e", '$\1', $POLL_DISALLOWED_LOOP); + $sc->pollPercentage = $percentage[$count]; + $sc->answerOption = $option; + $sc->pollVotes = $voteArray[$count]; + + $text .= $tp->parseTemplate($template['denied']['item'], true, $sc); $count ++; } - if ($pollArray['poll_vote_userclass'] == 253) - { - $DISALLOWMESSAGE = POLLAN_41; - } - elseif ($pollArray['poll_vote_userclass'] == 254) - { - $DISALLOWMESSAGE = POLLAN_42; - } - else - { - $DISALLOWMESSAGE = POLLAN_43; - } - $text .= preg_replace("/\{(.*?)\}/e", '$\1', $POLL_DISALLOWED_END); + + $text .= $tp->parseTemplate($template['denied']['end'], true, $sc); + break; } + if (!defined("POLLRENDERED")) define("POLLRENDERED", TRUE); $caption = (file_exists(THEME."images/poll_menu.png") ? " ".POLLAN_MENU_CAPTION : POLLAN_MENU_CAPTION); if ($type == 'preview') { - $caption = POLLAN_23.SEP."Preview"; // TODO LAN + $caption = POLLAN_23.SEP.LAN_PREVIEW; // "Preview"; // TODO LAN $text = "
\n
".$text."
"; } elseif ($type == 'forum') @@ -682,7 +669,7 @@ class poll $opts = array(1 => LAN_YES, 0=> LAN_NO); // Set to IP address.. Can add a pref to Poll admin for 'default front-end storage method' if demand is there for it. - + $text .= "
@@ -898,34 +885,173 @@ class poll class poll_shortcodes extends e_shortcode { - var $answerOption = array(); - var $answerCount; + public $answerOption = array(); + public $answerCount = 0; + public $pollRenderType = null; // type + public $pollPreview = false; + public $pollVoteTotal = 0; + public $pollCommentTotal = 0; + public $pollPercentage = 0; + public $pollVotes = 0; + public $pollCount = 0; // total polls in the system + + private $barl = null; + private $barr = null; + private $bar = null; + + public function __construct() + { + $this->barl = (file_exists(THEME.'images/barl.png') ? THEME_ABS.'images/barl.png' : e_PLUGIN_ABS.'poll/images/barl.png'); + $this->barr = (file_exists(THEME.'images/barr.png') ? THEME_ABS.'images/barr.png' : e_PLUGIN_ABS.'poll/images/barr.png'); + $this->bar = (file_exists(THEME.'images/bar.png') ? THEME_ABS.'images/bar.png' : e_PLUGIN_ABS.'poll/images/bar.png'); + } function sc_option($parm='') { - return $this->answerOption; + if(!empty($this->answerOption)) + { + return $this->answerOption; + } + + } + + + function sc_percentage($parm=null) + { + return $this->pollPercentage."%"; + } + + + function sc_author($parm=null) + { + $uparams = array('id' => $this->var['poll_admin_id'], 'name' => $this->var['user_name']); + $link = e107::getUrl()->create('user/profile/view', $uparams); + $userlink = "".$this->var['user_name'].""; + + // return print_a($this->var,true); + return POLLAN_35." ".(($this->pollType == 'preview' || $this->pollType == 'forum') ? USERNAME : $userlink); + } + + + function sc_oldpolls($parm=null) + { + // return 'type: '.$this->pollCount; + + if (intval($this->pollCount) > 1 && ($this->pollRenderType == 'menu')) + { + return "".POLLAN_28."" ; + } + + } + + + function sc_disallowmessage($parm=null) + { + if ($this->var['poll_vote_userclass'] == 253) + { + return POLLAN_41; + } + elseif ($this->var['poll_vote_userclass'] == 254) + { + return POLLAN_42; + } + else + { + return POLLAN_43; + } + + } + + + function sc_votes($parm=null) + { + return POLLAN_31.": ".$this->pollVotes; + } + + + function sc_bar($parm=null) + { + + $perc = $this->pollPercentage; + + if(deftrue('BOOTSTRAP',false)) + { + + // return "".$perc.""; + $val = intval($perc); + return ' +
+
+ '.$val.'% +
+
'; + + } + else + { + $barl = $this->barl; + $barr = $this->barr; + $bar = $this->bar; + return ($perc ? "
" : ""); + } } function sc_optionbutton($parm='') { - return ($this->var['poll_allow_multiple'] ? "" : ""); + return ($this->var['poll_allow_multiple'] ? "" : ""); } + function sc_question($parm = "") { $tp = e107::getParser(); - return $tp->toHTML($this->var['poll_title'], TRUE, "emotes_off, defs"); + return $tp->toHTML($this->var['poll_title'], true, "TITLE"); } - + + function sc_answer($parm='') { $frm = e107::getForm(); $opt = array('label'=> $this->answerOption); - return $frm->radio('votea', $this->answerCount,false, $opt); - // $this->answerOption + + if(empty($this->var['poll_allow_multiple'])) + { + return $frm->radio('votea', $this->answerCount,false, $opt); + } + else + { + return $frm->checkbox('votea[]', $this->answerCount,false, $opt); + } + + } + + + function sc_submitbutton($parm=null) + { + + if (('preview' == $this->pollType || $this->pollPreview == true) && strpos(e_REQUEST_SELF, "forum") === false) + { + return ""; + } + + return ""; + // disable submit when previewing the poll or when NOT viewing the poll in the forum + } + + + function sc_vote_total($parm=null) + { + + return POLLAN_31.": ".intval($this->pollVoteTotal); + } + + + function sc_comments($parm=null) + { + return ($this->var['poll_comment'] ? " ".LAN_COMMENTS.": ".$this->pollCommentTotal."" : ""); + } - } diff --git a/e107_plugins/poll/templates/poll_template.php b/e107_plugins/poll/templates/poll_template.php index f0e049243..40f33dc15 100644 --- a/e107_plugins/poll/templates/poll_template.php +++ b/e107_plugins/poll/templates/poll_template.php @@ -233,8 +233,16 @@ $POLL_TEMPLATE['results']['end'] = "
"; +/* v2.x template for polls when user HAS been denied the ability to vote (userclass) */ - +$POLL_TEMPLATE['denied']['start'] = $POLL_TEMPLATE['results']['start']; +$POLL_TEMPLATE['denied']['item'] = $POLL_TEMPLATE['results']['item']; +$POLL_TEMPLATE['denied']['end'] = "
{DISALLOWMESSAGE}
+
{VOTE_TOTAL}
+ {COMMENTS} {OLDPOLLS} + + +"; ?> \ No newline at end of file