mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 20:57:26 +02:00
Fixes #1449 - Polls failing in PHP7 and Multiple options voting not functioning.
This commit is contained in:
@@ -2244,7 +2244,7 @@ class e107
|
|||||||
|
|
||||||
if(ADMIN && E107_DBG_INCLUDES)
|
if(ADMIN && E107_DBG_INCLUDES)
|
||||||
{
|
{
|
||||||
e107::getMessage()->addDebug( "template path=".$path );
|
e107::getMessage()->addDebug( "Attempting to load Template File: ".$path );
|
||||||
}
|
}
|
||||||
|
|
||||||
$id = str_replace('/', '_', $id);
|
$id = str_replace('/', '_', $id);
|
||||||
|
@@ -531,10 +531,24 @@ class e_db_mysql
|
|||||||
{
|
{
|
||||||
$buglink = is_null($rli) ? $this->mySQLaccess : $rli;
|
$buglink = is_null($rli) ? $this->mySQLaccess : $rli;
|
||||||
|
|
||||||
if(is_array($query) && is_object($ex))
|
if($this->pdo == true && isset($ex) && is_object($ex))
|
||||||
|
{
|
||||||
|
if(is_array($query))
|
||||||
{
|
{
|
||||||
$query = "ERROR: ".$ex->errorInfo[2]."<br />PREPARE: ".$query['PREPARE']."<br />BIND:".print_a($query['BIND'],true); // ,true);
|
$query = "ERROR: ".$ex->errorInfo[2]."<br />PREPARE: ".$query['PREPARE']."<br />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);
|
$db_debug->Mark_Query($query, $buglink, $sQryRes, $aTrace, $mytime, $pTable);
|
||||||
}
|
}
|
||||||
@@ -1040,7 +1054,7 @@ class e_db_mysql
|
|||||||
foreach ($arg['data'] as $fn => $fv)
|
foreach ($arg['data'] as $fn => $fv)
|
||||||
{
|
{
|
||||||
$new_data .= ($new_data ? ', ' : '');
|
$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);
|
$new_data .= ($this->pdo == true && $ftype !='cmd') ? "`{$fn}`= :". $fn : "`{$fn}`=".$this->_getFieldValue($fn, $fv, $fieldTypes);
|
||||||
|
|
||||||
|
@@ -1290,6 +1290,9 @@ class e_shortcode
|
|||||||
*/
|
*/
|
||||||
protected $scVars = null;
|
protected $scVars = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* e_shortcode constructor.
|
||||||
|
*/
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->scVars = new e_vars();
|
$this->scVars = new e_vars();
|
||||||
|
@@ -179,7 +179,7 @@ if($thread->message)
|
|||||||
//{
|
//{
|
||||||
if(e107::isInstalled('poll'))
|
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($sql->gen($_qry))
|
||||||
{
|
{
|
||||||
if (!defined('POLLCLASS'))
|
if (!defined('POLLCLASS'))
|
||||||
|
@@ -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'] = "<div class='alert text-warning text-center'>{DISALLOWMESSAGE}</div>
|
||||||
|
<div class='text-center'><small>{VOTE_TOTAL}</small></div>
|
||||||
|
{COMMENTS} {OLDPOLLS}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -23,52 +23,46 @@ if (!e107::isInstalled('poll'))
|
|||||||
require_once(HEADERF);
|
require_once(HEADERF);
|
||||||
require_once(e_HANDLER."comment_class.php");
|
require_once(e_HANDLER."comment_class.php");
|
||||||
$cobj = new comment;
|
$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");
|
include_lan(e_PLUGIN."poll/languages/".e_LANGUAGE.".php");
|
||||||
|
|
||||||
if(e_QUERY)
|
if(e_QUERY)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
require_once('poll_class.php');
|
||||||
|
|
||||||
$query = "SELECT p.*, u.user_id, u.user_name FROM #polls AS p
|
$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
|
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);
|
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();
|
$start_datestamp = $tp->toDate($row['poll_datestamp'], "long");
|
||||||
extract($row);
|
$end_datestamp = $tp->toDate($row['poll_end_datestamp'], "long");
|
||||||
|
$uparams = array('id' => $row['user_id'], 'name' => $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);
|
|
||||||
}
|
|
||||||
|
|
||||||
$start_datestamp = $gen->convert_date($poll_datestamp, "long");
|
|
||||||
$end_datestamp = $gen->convert_date($poll_end_datestamp, "long");
|
|
||||||
//<a href='".e_BASE."user.php?id.{$user_id}'>".$user_name."</a>
|
|
||||||
$uparams = array('id' => $user_id, 'name' => $user_name);
|
|
||||||
$link = e107::getUrl()->create('user/profile/view', $uparams);
|
$link = e107::getUrl()->create('user/profile/view', $uparams);
|
||||||
$userlink = "<a href='".$link."'>".$user_name."</a>";
|
$userlink = "<a href='".$link."'>".$row['user_name']."</a>";
|
||||||
$text = "<table style='".USER_WIDTH."'>
|
|
||||||
<tr>
|
|
||||||
<td colspan='2' class='mediumtext' style='text-align:center'>
|
|
||||||
<b>".$tp -> toHTML($poll_title,TRUE,'TITLE')."</b>
|
|
||||||
<div class='smalltext'>".POLLAN_35." ".$userlink."<br /> ".POLLAN_37." ".$start_datestamp." ".POLLAN_38." ".$end_datestamp.".<br />".POLLAN_26.": {$voteTotal}</div>
|
|
||||||
<br />
|
|
||||||
|
|
||||||
</td>
|
|
||||||
</tr>";
|
|
||||||
|
|
||||||
$count = 0;
|
$text = $pl->render_poll($row, 'forum', 'oldpolls',true);
|
||||||
|
|
||||||
|
|
||||||
|
$text .= "
|
||||||
|
<div class='smalltext text-right'>
|
||||||
|
<small>".POLLAN_35." ".$userlink."<br /> ".POLLAN_37." ".$start_datestamp." ".POLLAN_38." ".$end_datestamp."</small></div>
|
||||||
|
";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* $count = 0;
|
||||||
|
|
||||||
$barl = (file_exists(THEME."images/barl.png") ? THEME."images/barl.png" : e_PLUGIN."poll/images/barl.png");
|
$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");
|
$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++;
|
$count++;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
$query = "SELECT c.*, u.* FROM #comments AS c
|
$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
|
LEFT JOIN #user AS u ON c.comment_author_id = u.user_id
|
||||||
WHERE comment_item_id=".intval($poll_id)." AND comment_type=4 ORDER BY comment_datestamp";
|
WHERE comment_item_id=".intval($row['poll_id'])." AND comment_type='4' ORDER BY comment_datestamp";
|
||||||
if ($comment_total = $sql->db_Select_gen($query) !== FALSE)
|
|
||||||
|
if ($comment_total = $sql->gen($query))
|
||||||
{
|
{
|
||||||
$text .= "<tr><td colspan='2'><br /><br />";
|
$text .= "<hr /><div>";
|
||||||
while ($row = $sql->db_Fetch()) {
|
|
||||||
$text .= $cobj->render_comment($row);
|
while ($row2 = $sql->fetch())
|
||||||
|
{
|
||||||
|
$text .= e107::getComment()->render_comment($row2, 'poll', 'comment');
|
||||||
}
|
}
|
||||||
$text .= "</td></tr>";
|
$text .= "</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$text .= "</table>";
|
|
||||||
$ns->tablerender(POLL_ADLAN01." #".$poll_id, $text);
|
// $text .= "</table>";
|
||||||
|
$ns->tablerender(LAN_PLUGIN_POLL_NAME." #".$row['poll_id'], $text);
|
||||||
|
echo "<hr />";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$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))
|
// 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, "<div style='text-align:center'>".POLLAN_33."</div>");
|
$ns->tablerender(POLLAN_28, "<div style='text-align:center'>".POLLAN_33."</div>");
|
||||||
require_once(FOOTERF);
|
require_once(FOOTERF);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$array = $sql -> db_getList();
|
$array = array_slice($array, 1);
|
||||||
$oldpollArray = array_slice($array, 1);
|
|
||||||
|
|
||||||
if(!count($oldpollArray))
|
if(empty($array))
|
||||||
{
|
{
|
||||||
$ns->tablerender(POLLAN_28, "<div style='text-align:center'>".POLLAN_33."</div>");
|
$ns->tablerender(POLLAN_28, "<div style='text-align:center'>".POLLAN_33."</div>");
|
||||||
require_once(FOOTERF);
|
require_once(FOOTERF);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
$text = "<table class='fborder' style='".USER_WIDTH."'>
|
$text = "<table class='table fborder' style='".USER_WIDTH."'>
|
||||||
<tr>
|
<colgroup>
|
||||||
<td class='fcaption' style='width: 55%;'>".POLLAN_34."</td>
|
<col style='width: 55%;' />
|
||||||
<td class='fcaption' style='width: 15%;'>".POLLAN_35."</td>
|
<col style='width: 15%;' />
|
||||||
<td class='fcaption' style='width: 30%;'>".POLLAN_36."</td>
|
<col style='width: 30%;' />
|
||||||
</tr>\n";
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th class='fcaption'>".LAN_TITLE."</th>
|
||||||
|
<th class='fcaption'>".POLLAN_35."</th>
|
||||||
|
<th class='fcaption'>".POLLAN_36."</th>
|
||||||
|
</tr></thead><tbody>\n";
|
||||||
|
|
||||||
if (!is_object($tp->e_bb))
|
|
||||||
{
|
|
||||||
require_once(e_HANDLER.'bbcode_handler.php');
|
|
||||||
$tp->e_bb = new e_bbcode;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach($oldpollArray as $oldpoll)
|
foreach($array as $row)
|
||||||
{
|
{
|
||||||
extract($oldpoll);
|
|
||||||
$from = $gen->convert_date($poll_datestamp, "short");
|
$from = $tp->toDate($row['poll_datestamp'], "short");
|
||||||
$to = $gen->convert_date($poll_end_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']);
|
||||||
|
|
||||||
$poll_title = $tp->e_bb->parseBBCodes($poll_title, 0,TRUE,TRUE); // Strip bbcodes
|
|
||||||
//<a href='".e_BASE."user.php?id.{$poll_admin_id}'>{$user_name}</a>
|
|
||||||
$uparams = array('id' => $poll_admin_id, 'name' => $user_name);
|
|
||||||
$link = e107::getUrl()->create('user/profile/view', $uparams);
|
$link = e107::getUrl()->create('user/profile/view', $uparams);
|
||||||
$userlink = "<a href='".$link."'>".$user_name."</a>";
|
|
||||||
$text .= "<tr>
|
|
||||||
<td class='forumheader3' style='width: 55%;'><a href='".e_SELF."?{$poll_id}'>{$poll_title}</a></td>
|
|
||||||
<td class='forumheader3' style='width: 15%;'>".$userlink."</td>
|
|
||||||
<td class='forumheader3' style='width: 30%;'>{$from} ".POLLAN_38." {$to}</td>
|
|
||||||
</tr>\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
$text .= "</table>";
|
|
||||||
$ns->tablerender(POLLAN_28, $text);
|
$userlink = "<a href='".$link."'>".$row['user_name']."</a>";
|
||||||
require_once(FOOTERF);
|
$text .= "<tr>
|
||||||
|
<td class='forumheader3' style='width: 55%;'><a href='".e_SELF."?".$row['poll_id']."'>{$poll_title}</a></td>
|
||||||
|
<td class='forumheader3' style='width: 15%;'>".$userlink."</td>
|
||||||
|
<td class='forumheader3' style='width: 30%;'>".$from." ".POLLAN_38." ".$to."</td>
|
||||||
|
</tr>\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
$text .= "</tbody></table>";
|
||||||
|
e107::getRender()->tablerender(POLLAN_28, $text);
|
||||||
|
require_once(FOOTERF);
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
@@ -43,7 +43,7 @@ class poll
|
|||||||
$arr_polls_cookies = array();
|
$arr_polls_cookies = array();
|
||||||
foreach($_COOKIE as $cookie_name => $cookie_val)
|
foreach($_COOKIE as $cookie_name => $cookie_val)
|
||||||
{ // Collect poll cookies
|
{ // Collect poll cookies
|
||||||
list($str, $int) = explode('_', $cookie_name);
|
list($str, $int) = explode('_', $cookie_name, 2);
|
||||||
if (($str == 'poll') && is_numeric($int))
|
if (($str == 'poll') && is_numeric($int))
|
||||||
{ // Yes, its poll's cookie
|
{ // Yes, its poll's cookie
|
||||||
$arr_polls_cookies[] = $int;
|
$arr_polls_cookies[] = $int;
|
||||||
@@ -310,6 +310,12 @@ class poll
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function render_poll($pollArray = "", $type = "menu", $POLLMODE = "", $returnMethod=FALSE)
|
function render_poll($pollArray = "", $type = "menu", $POLLMODE = "", $returnMethod=FALSE)
|
||||||
{
|
{
|
||||||
$ns = e107::getRender();
|
$ns = e107::getRender();
|
||||||
@@ -321,6 +327,7 @@ class poll
|
|||||||
switch ($POLLMODE)
|
switch ($POLLMODE)
|
||||||
{
|
{
|
||||||
case 'query' : // Show poll, register any vote
|
case 'query' : // Show poll, register any vote
|
||||||
|
|
||||||
if ($this->get_poll($pollArray) === FALSE)
|
if ($this->get_poll($pollArray) === FALSE)
|
||||||
{
|
{
|
||||||
return ''; // No display if no poll
|
return ''; // No display if no poll
|
||||||
@@ -328,12 +335,24 @@ class poll
|
|||||||
$pollArray = $this->pollRow;
|
$pollArray = $this->pollRow;
|
||||||
$POLLMODE = $this->pollmode;
|
$POLLMODE = $this->pollmode;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'results' :
|
case 'results' :
|
||||||
if ($sql->gen($pollArray))
|
if ($sql->gen($pollArray))
|
||||||
{
|
{
|
||||||
$pollArray = $sql->fetch();
|
$pollArray = $sql->fetch();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'oldpolls':
|
||||||
|
$POLLMODE = 'results';
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
if(ADMIN)
|
||||||
|
{
|
||||||
|
return "<div class='alert alert-danger'>No \$POLLMODE set</div>";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -385,6 +404,18 @@ class poll
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$template = array();
|
||||||
|
|
||||||
|
if(deftrue('BOOTSTRAP'))
|
||||||
|
{
|
||||||
|
$template = ($type == 'forum') ? e107::getTemplate('forum','forum_poll') : e107::getTemplate('poll');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
/* get template */
|
/* get template */
|
||||||
if (file_exists(THEME.'poll_template.php'))
|
if (file_exists(THEME.'poll_template.php'))
|
||||||
{
|
{
|
||||||
@@ -395,179 +426,135 @@ class poll
|
|||||||
require(e_PLUGIN.'poll/templates/poll_template.php');
|
require(e_PLUGIN.'poll/templates/poll_template.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$template['form']['start'] = $POLL_NOTVOTED_START ;
|
||||||
|
$template['form']['item'] = $POLL_NOTVOTED_LOOP;
|
||||||
if(deftrue('BOOTSTRAP'))
|
$template['form']['end'] = $POLL_NOTVOTED_END;
|
||||||
{
|
$template['results']['start'] = $POLL_VOTED_START;
|
||||||
|
$template['results']['item'] = $POLL_VOTED_LOOP;
|
||||||
if($type == 'forum')
|
$template['results']['end'] = $POLL_VOTED_END;
|
||||||
{
|
$template['denied']['start'] = $POLL_DISALLOWED_START;
|
||||||
require_once(e_PLUGIN."forum/templates/forum_poll_template.php");
|
$template['denied']['item'] = $POLL_DISALLOWED_LOOP ;
|
||||||
|
$template['denied']['end'] = $POLL_DISALLOWED_END ;
|
||||||
$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'];
|
|
||||||
}
|
|
||||||
|
|
||||||
$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'];
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
$sc = e107::getScBatch('poll');
|
||||||
|
$sc->setVars($pollArray);
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
|
|
||||||
|
$sc->pollCount = $sql->count("polls", "(*)", "WHERE poll_id <= '".$pollArray['poll_id']."'");
|
||||||
|
$sc->pollRenderMode = $type;
|
||||||
|
$sc->pollVoteTotal = $voteTotal;
|
||||||
|
$sc->pollRenderType = $type;
|
||||||
|
|
||||||
|
|
||||||
$preview = FALSE;
|
|
||||||
if ($type == 'preview')
|
if ($type == 'preview')
|
||||||
{
|
{
|
||||||
$POLLMODE = 'notvoted';
|
$POLLMODE = 'notvoted';
|
||||||
}
|
}
|
||||||
elseif ($type == 'forum')
|
elseif ($type == 'forum')
|
||||||
{
|
{
|
||||||
$preview = TRUE;
|
$sc->pollPreview = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$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'] ? " <a href='".e_HTTP."comment.php?comment.poll.".$pollArray['poll_id']."'>".LAN_COMMENTS.": ".$comment_total."</a>" : "");
|
|
||||||
|
|
||||||
|
|
||||||
$poll_count = $sql->count("polls", "(*)", "WHERE poll_id <= '".$pollArray['poll_id']."'");
|
|
||||||
$OLDPOLLS = '';
|
|
||||||
|
|
||||||
if ($poll_count > 1)
|
|
||||||
{
|
|
||||||
$OLDPOLLS = ($type == 'menu' ? "<a href='".e_PLUGIN_ABS."poll/oldpolls.php'>".POLLAN_28."</a>" : "");
|
|
||||||
}
|
|
||||||
|
|
||||||
//"<a href='".e_HTTP."user.php?id.".$pollArray['poll_admin_id']."'>".$pollArray['user_name']."</a>"
|
|
||||||
$uparams = array('id' => $pollArray['poll_admin_id'], 'name' => $pollArray['user_name']);
|
|
||||||
$link = e107::getUrl()->create('user/profile/view', $uparams);
|
|
||||||
$userlink = "<a href='".$link."'>".$pollArray['user_name']."</a>";
|
|
||||||
$AUTHOR = POLLAN_35." ".($type == 'preview' || $type == 'forum' ? USERNAME : $userlink);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
$text = '';
|
||||||
|
|
||||||
switch ($POLLMODE)
|
switch ($POLLMODE)
|
||||||
{
|
{
|
||||||
|
|
||||||
case 'notvoted':
|
case 'notvoted':
|
||||||
$text = "<form method='post' action='".e_SELF.(e_QUERY ? "?".e_QUERY : "")."'>\n".preg_replace("/\{(.*?)\}/e", '$\1', ($type == "forum" ? $POLL_FORUM_NOTVOTED_START : $POLL_NOTVOTED_START));
|
|
||||||
|
$text = "<form method='post' action='".e_SELF.(e_QUERY ? "?".e_QUERY : "")."'>\n";
|
||||||
|
$text .= $tp->parseTemplate($template['form']['start'],true, $sc);
|
||||||
$count = 1;
|
$count = 1;
|
||||||
$sc->answerCount = 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;
|
$sc->answerOption = $option;
|
||||||
// $MODE = ($mode) ? $mode : ""; /* debug */
|
$text .= $tp->parseTemplate($template['form']['item'], true, $sc);
|
||||||
// $OPTIONBUTTON = ($pollArray['poll_allow_multiple'] ? "<input type='checkbox' name='votea[]' value='$count' />" : "<input type='radio' name='votea' value='$count' />");
|
|
||||||
// $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);
|
|
||||||
|
|
||||||
$count ++;
|
$count ++;
|
||||||
$sc->answerCount++;
|
$sc->answerCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$text .= $tp->parseTemplate($template['form']['end'], true, $sc);
|
||||||
|
|
||||||
$SUBMITBUTTON = "<input class='button btn btn-primary' type='submit' name='pollvote' value='".POLLAN_30."' />";
|
$text .= "</form>";
|
||||||
// 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 = "<input class='button btn btn-default e-tip' type='button' name='null' title='Disabled' value='".POLLAN_30."' />";
|
|
||||||
}
|
|
||||||
|
|
||||||
$text .= "\n".preg_replace("/\{(.*?)\}/e", '$\1', ($type == "forum" ? $POLL_FORUM_NOTVOTED_END : $POLL_NOTVOTED_END))."\n</form>";
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
case 'voted':
|
case 'voted':
|
||||||
case 'results' :
|
case 'results' :
|
||||||
|
|
||||||
if ($pollArray['poll_result_type'] && !strstr(e_SELF, "comment.php"))
|
if ($pollArray['poll_result_type'] && !strstr(e_SELF, "comment.php"))
|
||||||
{
|
{
|
||||||
$text = "<div style='text-align: center;'><br /><br />".POLLAN_39."<br /><br /><a href='".e_HTTP."comment.php?comment.poll.".$pollArray['poll_id']."'>".POLLAN_40."</a></div><br /><br />";
|
$text = "<div style='text-align: center;'><br /><br />".POLLAN_39."<br /><br /><a href='".e_HTTP."comment.php?comment.poll.".$pollArray['poll_id']."'>".POLLAN_40."</a></div><br /><br />";
|
||||||
}
|
}
|
||||||
else
|
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;
|
$count = 0;
|
||||||
|
$sc->answerCount = 0;
|
||||||
|
|
||||||
foreach ($optionArray as $option)
|
foreach ($optionArray as $option)
|
||||||
{
|
{
|
||||||
$OPTION = $tp->toHTML($option, TRUE);
|
$sc->pollPercentage = $percentage[$count];
|
||||||
$BAR = $this->generateBar($percentage[$count]);
|
$sc->answerOption = $option;
|
||||||
// $BAR = ($percentage[$count] ? "<div style='width: 100%'><div style='background-image: url($barl); width: 5px; height: 14px; float: left;'></div><div style='background-image: url($bar); width: ".min(intval($percentage[$count]), 90)."%; height: 14px; float: left;'></div><div style='background-image: url($barr); width: 5px; height: 14px; float: left;'></div></div>" : "");
|
$sc->pollVotes = $voteArray[$count];
|
||||||
$PERCENTAGE = $percentage[$count]."%";
|
|
||||||
$VOTES = POLLAN_31.": ".$voteArray[$count];
|
$text .= $tp->parseTemplate($template['results']['item'], true, $sc);
|
||||||
$text .= preg_replace("/\{(.*?)\}/e", '$\1', ($type == "forum" ? $POLL_FORUM_VOTED_LOOP : $POLL_VOTED_LOOP));
|
|
||||||
$count ++;
|
$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;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
case 'disallowed':
|
case 'disallowed':
|
||||||
$text = preg_replace("/\{(.*?)\}/e", '$\1', $POLL_DISALLOWED_START);
|
|
||||||
|
$text = $tp->parseTemplate($template['denied']['start'], true, $sc);
|
||||||
|
$count = 0;
|
||||||
|
|
||||||
foreach ($optionArray as $option)
|
foreach ($optionArray as $option)
|
||||||
{
|
{
|
||||||
$MODE = $mode; /* debug */
|
$sc->pollPercentage = $percentage[$count];
|
||||||
$OPTION = $tp->toHTML($option, TRUE);
|
$sc->answerOption = $option;
|
||||||
$text .= preg_replace("/\{(.*?)\}/e", '$\1', $POLL_DISALLOWED_LOOP);
|
$sc->pollVotes = $voteArray[$count];
|
||||||
|
|
||||||
|
$text .= $tp->parseTemplate($template['denied']['item'], true, $sc);
|
||||||
$count ++;
|
$count ++;
|
||||||
}
|
}
|
||||||
if ($pollArray['poll_vote_userclass'] == 253)
|
|
||||||
{
|
$text .= $tp->parseTemplate($template['denied']['end'], true, $sc);
|
||||||
$DISALLOWMESSAGE = POLLAN_41;
|
|
||||||
}
|
|
||||||
elseif ($pollArray['poll_vote_userclass'] == 254)
|
|
||||||
{
|
|
||||||
$DISALLOWMESSAGE = POLLAN_42;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$DISALLOWMESSAGE = POLLAN_43;
|
|
||||||
}
|
|
||||||
$text .= preg_replace("/\{(.*?)\}/e", '$\1', $POLL_DISALLOWED_END);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!defined("POLLRENDERED")) define("POLLRENDERED", TRUE);
|
if (!defined("POLLRENDERED")) define("POLLRENDERED", TRUE);
|
||||||
|
|
||||||
$caption = (file_exists(THEME."images/poll_menu.png") ? "<img src='".THEME_ABS."images/poll_menu.png' alt='' /> ".POLLAN_MENU_CAPTION : POLLAN_MENU_CAPTION);
|
$caption = (file_exists(THEME."images/poll_menu.png") ? "<img src='".THEME_ABS."images/poll_menu.png' alt='' /> ".POLLAN_MENU_CAPTION : POLLAN_MENU_CAPTION);
|
||||||
|
|
||||||
if ($type == 'preview')
|
if ($type == 'preview')
|
||||||
{
|
{
|
||||||
$caption = POLLAN_23.SEP."Preview"; // TODO LAN
|
$caption = POLLAN_23.SEP.LAN_PREVIEW; // "Preview"; // TODO LAN
|
||||||
$text = "<div class='clearfix'>\n<div class='well span3'>".$text."</div></div>";
|
$text = "<div class='clearfix'>\n<div class='well span3'>".$text."</div></div>";
|
||||||
}
|
}
|
||||||
elseif ($type == 'forum')
|
elseif ($type == 'forum')
|
||||||
@@ -898,34 +885,173 @@ class poll
|
|||||||
|
|
||||||
class poll_shortcodes extends e_shortcode
|
class poll_shortcodes extends e_shortcode
|
||||||
{
|
{
|
||||||
var $answerOption = array();
|
public $answerOption = array();
|
||||||
var $answerCount;
|
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='')
|
function sc_option($parm='')
|
||||||
|
{
|
||||||
|
if(!empty($this->answerOption))
|
||||||
{
|
{
|
||||||
return $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 = "<a href='".$link."'>".$this->var['user_name']."</a>";
|
||||||
|
|
||||||
|
// 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 "<a href='".e_PLUGIN_ABS."poll/oldpolls.php'>".POLLAN_28."</a>" ;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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 "<span class='label label-danger'>".$perc."</span>";
|
||||||
|
$val = intval($perc);
|
||||||
|
return '
|
||||||
|
<div class="progress">
|
||||||
|
<div class="bar progress-bar" role="progressbar" aria-valuenow="'.$val.'" aria-valuemin="0" aria-valuemax="100" style="width: '.$val.'%;">
|
||||||
|
<span class="sr-only">'.$val.'%</span>
|
||||||
|
</div>
|
||||||
|
</div>';
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$barl = $this->barl;
|
||||||
|
$barr = $this->barr;
|
||||||
|
$bar = $this->bar;
|
||||||
|
return ($perc ? "<div style='width: 100%'><div style='background-image: url($barl); width: 5px; height: 14px; float: left;'></div><div style='background-image: url($bar); width: ".min(intval($perc), 90)."%; height: 14px; float: left;'></div><div style='background-image: url($barr); width: 5px; height: 14px; float: left;'></div></div>" : "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function sc_optionbutton($parm='')
|
function sc_optionbutton($parm='')
|
||||||
{
|
{
|
||||||
return ($this->var['poll_allow_multiple'] ? "<input type='checkbox' name='votea[]' value='$count' />" : "<input type='radio' name='votea' value='".$this->answerCount."' />");
|
return ($this->var['poll_allow_multiple'] ? "<input type='checkbox' name='votea[]' value='$this->answerCount' />" : "<input type='radio' name='votea' value='".$this->answerCount."' />");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function sc_question($parm = "")
|
function sc_question($parm = "")
|
||||||
{
|
{
|
||||||
$tp = e107::getParser();
|
$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='')
|
function sc_answer($parm='')
|
||||||
{
|
{
|
||||||
$frm = e107::getForm();
|
$frm = e107::getForm();
|
||||||
$opt = array('label'=> $this->answerOption);
|
$opt = array('label'=> $this->answerOption);
|
||||||
|
|
||||||
|
if(empty($this->var['poll_allow_multiple']))
|
||||||
|
{
|
||||||
return $frm->radio('votea', $this->answerCount,false, $opt);
|
return $frm->radio('votea', $this->answerCount,false, $opt);
|
||||||
// $this->answerOption
|
}
|
||||||
|
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 "<input class='button btn btn-default e-tip' type='button' name='null' title='Disabled' value='".POLLAN_30."' />";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "<input class='button btn btn-primary' type='submit' name='pollvote' value='".POLLAN_30."' />";
|
||||||
|
// 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'] ? " <a href='".e_HTTP."comment.php?comment.poll.".$this->var['poll_id']."'>".LAN_COMMENTS.": ".$this->pollCommentTotal."</a>" : "");
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -233,8 +233,16 @@ $POLL_TEMPLATE['results']['end'] = "
|
|||||||
</div>
|
</div>
|
||||||
";
|
";
|
||||||
|
|
||||||
|
/* 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'] = "<div class='alert text-warning text-center'>{DISALLOWMESSAGE}</div>
|
||||||
|
<div class='text-center'><small>{VOTE_TOTAL}</small></div>
|
||||||
|
{COMMENTS} {OLDPOLLS}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
";
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
Reference in New Issue
Block a user