mirror of
https://github.com/e107inc/e107.git
synced 2025-08-08 07:36:32 +02:00
Show old polls link only if there are actual old polls available.
This commit is contained in:
@@ -16,24 +16,28 @@
|
|||||||
|
|
||||||
if (!defined('e107_INIT')) { exit; }
|
if (!defined('e107_INIT')) { exit; }
|
||||||
|
|
||||||
include_lan(e_PLUGIN."poll/languages/".e_LANGUAGE.".php");
|
include_lan(e_PLUGIN.'poll/languages/'.e_LANGUAGE.'.php');
|
||||||
define("POLLCLASS", TRUE);
|
define('POLLCLASS', TRUE);
|
||||||
define("POLL_MODE_COOKIE", 0);
|
define('POLL_MODE_COOKIE', 0);
|
||||||
define("POLL_MODE_IP", 1);
|
define('POLL_MODE_IP', 1);
|
||||||
define("POLL_MODE_USERID", 2);
|
define('POLL_MODE_USERID', 2);
|
||||||
|
|
||||||
class poll
|
class poll
|
||||||
{
|
{
|
||||||
|
|
||||||
var $pollRow;
|
var $pollRow;
|
||||||
var $pollmode;
|
var $pollmode;
|
||||||
|
|
||||||
|
/*
|
||||||
|
function delete_poll
|
||||||
|
parameter in: $existing - existing poll id to be deleted
|
||||||
|
parameter out: language text string on succesful delete, nothing on failed deletion
|
||||||
|
*/
|
||||||
function delete_poll($existing)
|
function delete_poll($existing)
|
||||||
{
|
{
|
||||||
global $sql, $admin_log;
|
global $sql, $admin_log;
|
||||||
if ($sql -> db_Delete("polls", " poll_id='".intval($existing)."' "))
|
if ($sql -> db_Delete("polls", " poll_id='".intval($existing)."' "))
|
||||||
{
|
{
|
||||||
if(function_exists("admin_purge_related"))
|
if (function_exists("admin_purge_related"))
|
||||||
{
|
{
|
||||||
admin_purge_related("poll", $existing);
|
admin_purge_related("poll", $existing);
|
||||||
}
|
}
|
||||||
@@ -42,43 +46,42 @@ class poll
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
function submit_poll
|
||||||
|
$mode = 1 :: poll is main poll
|
||||||
|
$mode = 2 :: poll is forum poll
|
||||||
|
returns message
|
||||||
|
*/
|
||||||
function submit_poll($mode=1)
|
function submit_poll($mode=1)
|
||||||
{
|
{
|
||||||
|
|
||||||
/*
|
|
||||||
$mode = 1 :: poll is main poll
|
|
||||||
$mode = 2 :: poll is forum poll
|
|
||||||
*/
|
|
||||||
|
|
||||||
global $tp, $sql, $admin_log;
|
global $tp, $sql, $admin_log;
|
||||||
|
$poll_title = $tp->toDB($_POST['poll_title']);
|
||||||
$poll_title = $tp->toDB($_POST['poll_title']);
|
$poll_comment = $tp -> toDB($_POST['poll_comment']);
|
||||||
$poll_comment= $tp -> toDB($_POST['poll_comment']);
|
$multipleChoice = intval($_POST['multipleChoice']);
|
||||||
$multipleChoice = intval($_POST['multipleChoice']);
|
$showResults = intval($_POST['showResults']);
|
||||||
$showResults = intval($_POST['showResults']);
|
$pollUserclass = intval($_POST['pollUserclass']);
|
||||||
$pollUserclass =intval($_POST['pollUserclass']);
|
$storageMethod = intval($_POST['storageMethod']);
|
||||||
$storageMethod = intval($_POST['storageMethod']);
|
$active_start = (!$_POST['startmonth'] || !$_POST['startday'] || !$_POST['startyear'] ? 0 : mktime (0, 0, 0, $_POST['startmonth'], $_POST['startday'], $_POST['startyear']));
|
||||||
$active_start = (!$_POST['startmonth'] || !$_POST['startday'] || !$_POST['startyear'] ? 0 : mktime (0, 0, 0, $_POST['startmonth'], $_POST['startday'], $_POST['startyear']));
|
$active_end = (!$_POST['endmonth'] || !$_POST['endday'] || !$_POST['endyear'] ? 0 : mktime (0, 0, 0, $_POST['endmonth'], $_POST['endday'], $_POST['endyear']));
|
||||||
$active_end = (!$_POST['endmonth'] || !$_POST['endday'] || !$_POST['endyear'] ? 0 : mktime (0, 0, 0, $_POST['endmonth'], $_POST['endday'], $_POST['endyear']));
|
$poll_options = '';
|
||||||
$poll_options = "";
|
|
||||||
|
|
||||||
$_POST['poll_option'] = array_filter($_POST['poll_option']);
|
$_POST['poll_option'] = array_filter($_POST['poll_option']);
|
||||||
foreach($_POST['poll_option'] as $key => $value)
|
foreach ($_POST['poll_option'] as $key => $value)
|
||||||
{
|
{
|
||||||
$poll_options .= $tp->toDB($value).chr(1);
|
$poll_options .= $tp->toDB($value).chr(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(POLLACTION == "edit" || vartrue($_POST['poll_id']))
|
if (POLLACTION == 'edit' || vartrue($_POST['poll_id']))
|
||||||
{
|
{
|
||||||
$sql -> db_Update("polls", "poll_title='{$poll_title}',
|
$sql -> db_Update("polls", "poll_title='{$poll_title}',
|
||||||
poll_options='{$poll_options}',
|
poll_options='{$poll_options}',
|
||||||
poll_comment='{$poll_comment}',
|
poll_comment='{$poll_comment}',
|
||||||
poll_type={$mode},
|
poll_type={$mode},
|
||||||
poll_allow_multiple={$multipleChoice},
|
poll_allow_multiple={$multipleChoice},
|
||||||
poll_result_type={$showResults},
|
poll_result_type={$showResults},
|
||||||
poll_vote_userclass={$pollUserclass},
|
poll_vote_userclass={$pollUserclass},
|
||||||
poll_storage_method={$storageMethod}
|
poll_storage_method={$storageMethod}
|
||||||
WHERE poll_id=".intval(POLLID));
|
WHERE poll_id=".intval(POLLID));
|
||||||
|
|
||||||
/* update poll results - bugtracker #1124 .... */
|
/* update poll results - bugtracker #1124 .... */
|
||||||
$sql -> db_Select("polls", "poll_votes", "poll_id='".intval(POLLID)."' ");
|
$sql -> db_Select("polls", "poll_votes", "poll_id='".intval(POLLID)."' ");
|
||||||
@@ -87,11 +90,11 @@ class poll
|
|||||||
|
|
||||||
$opt = count($poll_option) - count($voteA);
|
$opt = count($poll_option) - count($voteA);
|
||||||
|
|
||||||
if($opt)
|
if ($opt)
|
||||||
{
|
{
|
||||||
for($a=0; $a<=$opt; $a++)
|
for($a=0; $a<=$opt; $a++)
|
||||||
{
|
{
|
||||||
$foo['poll_votes'] .= "0".chr(1);
|
$foo['poll_votes'] .= '0'.chr(1);
|
||||||
}
|
}
|
||||||
$sql -> db_Update("polls", "poll_votes='".$foo['poll_votes']."' WHERE poll_id='".intval(POLLID)."' ");
|
$sql -> db_Update("polls", "poll_votes='".$foo['poll_votes']."' WHERE poll_id='".intval(POLLID)."' ");
|
||||||
}
|
}
|
||||||
@@ -101,19 +104,19 @@ class poll
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$votes = "";
|
$votes = '';
|
||||||
for($a=1; $a<=count($_POST['poll_option']); $a++)
|
for($a=1; $a<=count($_POST['poll_option']); $a++)
|
||||||
{
|
{
|
||||||
$votes .= "0".chr(1);
|
$votes .= '0'.chr(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($mode == 1)
|
if ($mode == 1)
|
||||||
{
|
{
|
||||||
/* deactivate other polls */
|
/* deactivate other polls */
|
||||||
if($sql -> db_Select("polls", "*", "poll_type=1 AND poll_vote_userclass!=255"))
|
if ($sql -> db_Select("polls", "*", "poll_type=1 AND poll_vote_userclass!=255"))
|
||||||
{
|
{
|
||||||
$deacArray = $sql -> db_getList();
|
$deacArray = $sql -> db_getList();
|
||||||
foreach($deacArray as $deacpoll)
|
foreach ($deacArray as $deacpoll)
|
||||||
{
|
{
|
||||||
$sql -> db_Update("polls", "poll_end_datestamp='".time()."', poll_vote_userclass='255' WHERE poll_id=".$deacpoll['poll_id']);
|
$sql -> db_Update("polls", "poll_end_datestamp='".time()."', poll_vote_userclass='255' WHERE poll_id=".$deacpoll['poll_id']);
|
||||||
}
|
}
|
||||||
@@ -129,7 +132,6 @@ class poll
|
|||||||
return $message;
|
return $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function get_poll($query)
|
function get_poll($query)
|
||||||
{
|
{
|
||||||
global $sql, $e107;
|
global $sql, $e107;
|
||||||
@@ -138,54 +140,54 @@ class poll
|
|||||||
$pollArray = $sql -> db_Fetch();
|
$pollArray = $sql -> db_Fetch();
|
||||||
if (!check_class($pollArray['poll_vote_userclass']))
|
if (!check_class($pollArray['poll_vote_userclass']))
|
||||||
{
|
{
|
||||||
$POLLMODE = "disallowed";
|
$POLLMODE = 'disallowed';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
switch($pollArray['poll_storage_method'])
|
switch($pollArray['poll_storage_method'])
|
||||||
{
|
{
|
||||||
case POLL_MODE_COOKIE:
|
case POLL_MODE_COOKIE:
|
||||||
$userid = "";
|
$userid = '';
|
||||||
$cookiename = "poll_".$pollArray['poll_id'];
|
$cookiename = 'poll_'.$pollArray['poll_id'];
|
||||||
if(isset($_COOKIE[$cookiename]))
|
if (isset($_COOKIE[$cookiename]))
|
||||||
{
|
{
|
||||||
$POLLMODE = "voted";
|
$POLLMODE = 'voted';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$POLLMODE = "notvoted";
|
$POLLMODE = 'notvoted';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case POLL_MODE_IP:
|
case POLL_MODE_IP:
|
||||||
$userid = $e107->getip();
|
$userid = $e107->getip();
|
||||||
$voted_ids = explode("^", substr($pollArray['poll_ip'], 0, -1));
|
$voted_ids = explode('^', substr($pollArray['poll_ip'], 0, -1));
|
||||||
if (in_array($userid, $voted_ids))
|
if (in_array($userid, $voted_ids))
|
||||||
{
|
{
|
||||||
$POLLMODE = "voted";
|
$POLLMODE = 'voted';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$POLLMODE = "notvoted";
|
$POLLMODE = 'notvoted';
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case POLL_MODE_USERID:
|
case POLL_MODE_USERID:
|
||||||
if(!USER)
|
if (!USER)
|
||||||
{
|
{
|
||||||
$POLLMODE = "disallowed";
|
$POLLMODE = 'disallowed';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$userid = USERID;
|
$userid = USERID;
|
||||||
$voted_ids = explode("^", substr($pollArray['poll_ip'], 0, -1));
|
$voted_ids = explode('^', substr($pollArray['poll_ip'], 0, -1));
|
||||||
if (in_array($userid, $voted_ids))
|
if (in_array($userid, $voted_ids))
|
||||||
{
|
{
|
||||||
$POLLMODE = "voted";
|
$POLLMODE = 'voted';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$POLLMODE = "notvoted";
|
$POLLMODE = 'notvoted';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -196,48 +198,48 @@ class poll
|
|||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if(isset($_POST['pollvote']) && $POLLMODE == "notvoted" && ($POLLMODE != "disallowed"))
|
if (isset($_POST['pollvote']) && $POLLMODE == 'notvoted' && ($POLLMODE != 'disallowed'))
|
||||||
{
|
{
|
||||||
if ($_POST['votea'])
|
if ($_POST['votea'])
|
||||||
{
|
{
|
||||||
// $sql -> db_Select("polls", "*", "poll_vote_userclass!=255 AND poll_type=1 ORDER BY poll_datestamp DESC LIMIT 0,1");
|
// $sql -> db_Select("polls", "*", "poll_vote_userclass!=255 AND poll_type=1 ORDER BY poll_datestamp DESC LIMIT 0,1");
|
||||||
$row = $pollArray;
|
$row = $pollArray;
|
||||||
extract($row);
|
extract($row);
|
||||||
$votes = explode(chr(1), $poll_votes);
|
$votes = explode(chr(1), $poll_votes);
|
||||||
if(is_array($_POST['votea']))
|
if (is_array($_POST['votea']))
|
||||||
|
{
|
||||||
|
/* multiple choice vote */
|
||||||
|
foreach ($_POST['votea'] as $vote)
|
||||||
{
|
{
|
||||||
/* multiple choice vote */
|
$vote = intval($vote);
|
||||||
foreach($_POST['votea'] as $vote)
|
$votes[($vote-1)] ++;
|
||||||
{
|
|
||||||
$vote = intval($vote);
|
|
||||||
$votes[($vote-1)] ++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$votes[($_POST['votea']-1)] ++;
|
||||||
|
}
|
||||||
|
$optionArray = explode(chr(1), $pollArray['poll_options']);
|
||||||
|
$optionArray = array_slice($optionArray, 0, -1);
|
||||||
|
foreach ($optionArray as $k=>$v)
|
||||||
|
{
|
||||||
|
if (!$votes[$k])
|
||||||
{
|
{
|
||||||
$votes[($_POST['votea']-1)] ++;
|
$votes[$k] = 0;
|
||||||
}
|
}
|
||||||
$optionArray = explode(chr(1), $pollArray['poll_options']);
|
}
|
||||||
$optionArray = array_slice($optionArray, 0, -1);
|
$votep = implode(chr(1), $votes);
|
||||||
foreach($optionArray as $k=>$v)
|
$pollArray['poll_votes'] = $votep;
|
||||||
{
|
|
||||||
if(!$votes[$k])
|
|
||||||
{
|
|
||||||
$votes[$k] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$votep = implode(chr(1), $votes);
|
|
||||||
$pollArray['poll_votes'] = $votep;
|
|
||||||
|
|
||||||
$sql->db_Update("polls", "poll_votes = '$votep', poll_ip='".$poll_ip.$userid."^' WHERE poll_id=".$poll_id);
|
$sql->db_Update("polls", "poll_votes = '$votep', poll_ip='".$poll_ip.$userid."^' WHERE poll_id=".$poll_id);
|
||||||
echo "
|
echo "
|
||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
<!--
|
<!--
|
||||||
setcook({$poll_id});
|
setcook({$poll_id});
|
||||||
//-->
|
//-->
|
||||||
</script>
|
</script>
|
||||||
";
|
";
|
||||||
$POLLMODE = "voted";
|
$POLLMODE = 'voted';
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -251,36 +253,36 @@ class poll
|
|||||||
global $POLLSTYLE, $sql, $tp, $ns;
|
global $POLLSTYLE, $sql, $tp, $ns;
|
||||||
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
|
||||||
}
|
}
|
||||||
$pollArray = $this->pollRow;
|
$pollArray = $this->pollRow;
|
||||||
$POLLMODE = $this->pollmode;
|
$POLLMODE = $this->pollmode;
|
||||||
break;
|
break;
|
||||||
case 'results' :
|
case 'results' :
|
||||||
if ($sql->db_Select_gen($pollArray))
|
if ($sql->db_Select_gen($pollArray))
|
||||||
{
|
{
|
||||||
$pollArray = $sql -> db_Fetch();
|
$pollArray = $sql -> db_Fetch();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$barl = (file_exists(THEME."images/barl.png") ? THEME_ABS."images/barl.png" : e_PLUGIN_ABS."poll/images/barl.png");
|
$barl = (file_exists(THEME.'images/barl.png') ? THEME_ABS.'images/barl.png' : e_PLUGIN_ABS.'poll/images/barl.png');
|
||||||
$barr = (file_exists(THEME."images/barr.png") ? THEME_ABS."images/barr.png" : e_PLUGIN_ABS."poll/images/barr.png");
|
$barr = (file_exists(THEME.'images/barr.png') ? THEME_ABS.'images/barr.png' : e_PLUGIN_ABS.'poll/images/barr.png');
|
||||||
$bar = (file_exists(THEME."images/bar.png") ? THEME_ABS."images/bar.png" : e_PLUGIN_ABS."poll/images/bar.png");
|
$bar = (file_exists(THEME.'images/bar.png') ? THEME_ABS.'images/bar.png' : e_PLUGIN_ABS.'poll/images/bar.png');
|
||||||
|
|
||||||
if($type == "preview")
|
if ($type == 'preview')
|
||||||
{
|
{
|
||||||
$optionArray = $pollArray['poll_option'];
|
$optionArray = $pollArray['poll_option'];
|
||||||
$voteArray = array();
|
$voteArray = array();
|
||||||
$voteArray = array_pad($voteArray, count($optionArray), 0);
|
$voteArray = array_pad($voteArray, count($optionArray), 0);
|
||||||
$pollArray['poll_allow_multiple'] = $pollArray['multipleChoice'];
|
$pollArray['poll_allow_multiple'] = $pollArray['multipleChoice'];
|
||||||
}
|
}
|
||||||
else if($type == "forum")
|
else if ($type == 'forum')
|
||||||
{
|
{
|
||||||
if(isset($_POST['fpreview']))
|
if (isset($_POST['fpreview']))
|
||||||
{
|
{
|
||||||
$pollArray['poll_allow_multiple'] = $pollArray['multipleChoice'];
|
$pollArray['poll_allow_multiple'] = $pollArray['multipleChoice'];
|
||||||
$optionArray = $pollArray['poll_option'];
|
$optionArray = $pollArray['poll_option'];
|
||||||
@@ -302,40 +304,38 @@ class poll
|
|||||||
}
|
}
|
||||||
|
|
||||||
$voteTotal = array_sum($voteArray);
|
$voteTotal = array_sum($voteArray);
|
||||||
|
|
||||||
$percentage = array();
|
$percentage = array();
|
||||||
|
|
||||||
|
if (count($voteArray))
|
||||||
if(count($voteArray))
|
|
||||||
{
|
{
|
||||||
foreach($voteArray as $votes)
|
foreach ($voteArray as $votes)
|
||||||
{
|
|
||||||
if ($voteTotal > 0)
|
|
||||||
{
|
{
|
||||||
$percentage[] = round(($votes/$voteTotal) * 100, 2);
|
if ($voteTotal > 0)
|
||||||
|
{
|
||||||
|
$percentage[] = round(($votes/$voteTotal) * 100, 2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$percentage[] = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
$percentage[] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/* get template */
|
/* get template */
|
||||||
if (file_exists(THEME."poll_template.php"))
|
if (file_exists(THEME.'poll_template.php'))
|
||||||
{
|
{
|
||||||
require(THEME."poll_template.php");
|
require(THEME.'poll_template.php');
|
||||||
}
|
}
|
||||||
else if(!isset($POLL_NOTVOTED_START))
|
else if (!isset($POLL_NOTVOTED_START))
|
||||||
{
|
{
|
||||||
require(e_PLUGIN."poll/templates/poll_template.php");
|
require(e_PLUGIN.'poll/templates/poll_template.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
$preview = FALSE;
|
$preview = FALSE;
|
||||||
if ($type == "preview")
|
if ($type == 'preview')
|
||||||
{
|
{
|
||||||
$POLLMODE = "notvoted";
|
$POLLMODE = 'notvoted';
|
||||||
}
|
}
|
||||||
elseif($type == "forum")
|
elseif ($type == 'forum')
|
||||||
{
|
{
|
||||||
$preview = TRUE;
|
$preview = TRUE;
|
||||||
}
|
}
|
||||||
@@ -346,46 +346,51 @@ class poll
|
|||||||
$comment_total = $sql->db_Count("comments", "(*)", "WHERE `comment_item_id`='".intval($pollArray['poll_id'])."' AND `comment_type`=4");
|
$comment_total = $sql->db_Count("comments", "(*)", "WHERE `comment_item_id`='".intval($pollArray['poll_id'])."' AND `comment_type`=4");
|
||||||
}
|
}
|
||||||
|
|
||||||
$QUESTION = $tp -> toHTML($pollArray['poll_title'], TRUE,"emotes_off, defs");
|
$QUESTION = $tp -> toHTML($pollArray['poll_title'], TRUE, "emotes_off, defs");
|
||||||
$VOTE_TOTAL = POLLAN_31.": ".$voteTotal;
|
$VOTE_TOTAL = POLLAN_31.": ".$voteTotal;
|
||||||
$COMMENTS = ($pollArray['poll_comment'] ? " <a href='".e_BASE."comment.php?comment.poll.".$pollArray['poll_id']."'>".POLLAN_27.": ".$comment_total."</a>" : "");
|
$COMMENTS = ($pollArray['poll_comment'] ? " <a href='".e_BASE."comment.php?comment.poll.".$pollArray['poll_id']."'>".POLLAN_27.": ".$comment_total."</a>" : "");
|
||||||
$OLDPOLLS = ($type == "menu" ? "<a href='".e_PLUGIN_ABS."poll/oldpolls.php'>".POLLAN_28."</a>" : "");
|
$poll_count = $sql->db_Count("polls", "(*)", "WHERE poll_id <= '".$pollArray['poll_id']."'");
|
||||||
$AUTHOR = POLLAN_35." ".($type == "preview" || $type == "forum" ? USERNAME : "<a href='".e_BASE."user.php?id.".$pollArray['poll_admin_id']."'>".$pollArray['user_name']."</a>");
|
$OLDPOLLS = '';
|
||||||
|
if ($poll_count > 1)
|
||||||
|
{
|
||||||
|
$OLDPOLLS = ($type == 'menu' ? "<a href='".e_PLUGIN_ABS."poll/oldpolls.php'>".POLLAN_28."</a>" : "");
|
||||||
|
}
|
||||||
|
$AUTHOR = POLLAN_35." ".($type == 'preview' || $type == 'forum' ? USERNAME : "<a href='".e_BASE."user.php?id.".$pollArray['poll_admin_id']."'>".$pollArray['user_name']."</a>");
|
||||||
|
|
||||||
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".preg_replace("/\{(.*?)\}/e", '$\1', ($type == "forum" ? $POLL_FORUM_NOTVOTED_START : $POLL_NOTVOTED_START));
|
||||||
$count = 1;
|
$count = 1;
|
||||||
$alt = 0; // alternate style.
|
$alt = 0; // alternate style.
|
||||||
foreach($optionArray as $option)
|
foreach ($optionArray as $option)
|
||||||
{
|
{
|
||||||
// $MODE = ($mode) ? $mode : ""; /* debug */
|
// $MODE = ($mode) ? $mode : ""; /* debug */
|
||||||
$OPTIONBUTTON = ($pollArray['poll_allow_multiple'] ? "<input type='checkbox' name='votea[]' value='$count' />" : "<input type='radio' name='votea' value='$count' />");
|
$OPTIONBUTTON = ($pollArray['poll_allow_multiple'] ? "<input type='checkbox' name='votea[]' value='$count' />" : "<input type='radio' name='votea' value='$count' />");
|
||||||
$OPTION = $tp->toHTML($option, TRUE);
|
$OPTION = $tp->toHTML($option, TRUE);
|
||||||
if(isset($POLL_NOTVOTED_LOOP_ALT) && $POLL_NOTVOTED_LOOP_ALT && $type != "forum")
|
if (isset($POLL_NOTVOTED_LOOP_ALT) && $POLL_NOTVOTED_LOOP_ALT && $type != "forum")
|
||||||
{ // alternating style
|
{ // alternating style
|
||||||
$text .= preg_replace("/\{(.*?)\}/e", '$\1', ($alt == 0 ? $POLL_NOTVOTED_LOOP : $POLL_NOTVOTED_LOOP_ALT));
|
$text .= preg_replace("/\{(.*?)\}/e", '$\1', ($alt == 0 ? $POLL_NOTVOTED_LOOP : $POLL_NOTVOTED_LOOP_ALT));
|
||||||
$alt = ($alt ==0) ? 1 : 0;
|
$alt = ($alt ==0) ? 1 : 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$text .= preg_replace("/\{(.*?)\}/e", '$\1', ($type == "forum" ? $POLL_FORUM_NOTVOTED_LOOP : $POLL_NOTVOTED_LOOP));
|
$text .= preg_replace("/\{(.*?)\}/e", '$\1', ($type == "forum" ? $POLL_FORUM_NOTVOTED_LOOP : $POLL_NOTVOTED_LOOP));
|
||||||
}
|
}
|
||||||
$count ++;
|
$count ++;
|
||||||
}
|
}
|
||||||
$SUBMITBUTTON = "<input class='button' type='submit' name='pollvote' value='".POLLAN_30."' />";
|
$SUBMITBUTTON = "<input class='button' type='submit' name='pollvote' value='".POLLAN_30."' />";
|
||||||
if(('preview' == $type || $preview == TRUE) && strpos(e_SELF, "viewtopic") === FALSE)
|
if (('preview' == $type || $preview == TRUE) && strpos(e_SELF, "viewtopic") === FALSE)
|
||||||
{
|
{
|
||||||
$SUBMITBUTTON = "[".POLLAN_30."]";
|
$SUBMITBUTTON = "[".POLLAN_30."]";
|
||||||
}
|
}
|
||||||
|
|
||||||
$text .= "\n".preg_replace("/\{(.*?)\}/e", '$\1', ($type == "forum" ? $POLL_FORUM_NOTVOTED_END : $POLL_NOTVOTED_END))."\n</form>";
|
$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_BASE."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_BASE."comment.php?comment.poll.".$pollArray['poll_id']."'>".POLLAN_40."</a></div><br /><br />";
|
||||||
}
|
}
|
||||||
@@ -393,7 +398,7 @@ class poll
|
|||||||
{
|
{
|
||||||
$text = preg_replace("/\{(.*?)\}/e", '$\1', ($type == "forum" ? $POLL_FORUM_VOTED_START : $POLL_VOTED_START));
|
$text = preg_replace("/\{(.*?)\}/e", '$\1', ($type == "forum" ? $POLL_FORUM_VOTED_START : $POLL_VOTED_START));
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach($optionArray as $option)
|
foreach ($optionArray as $option)
|
||||||
{
|
{
|
||||||
$OPTION = $tp->toHTML($option, TRUE);
|
$OPTION = $tp->toHTML($option, TRUE);
|
||||||
$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: ".(floor($percentage[$count]) != 100 ? floor($percentage[$count]) : 90)."%; height: 14px; float: left;'></div><div style='background-image: url($barr); width: 5px; height: 14px; float: left;'></div></div>" : "");
|
$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: ".(floor($percentage[$count]) != 100 ? floor($percentage[$count]) : 90)."%; height: 14px; float: left;'></div><div style='background-image: url($barr); width: 5px; height: 14px; float: left;'></div></div>" : "");
|
||||||
@@ -404,22 +409,22 @@ class poll
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$text .= preg_replace("/\{(.*?)\}/e", '$\1', ($type == "forum" ? $POLL_FORUM_VOTED_END : $POLL_VOTED_END));
|
$text .= preg_replace("/\{(.*?)\}/e", '$\1', ($type == "forum" ? $POLL_FORUM_VOTED_END : $POLL_VOTED_END));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "disallowed":
|
case 'disallowed':
|
||||||
$text = preg_replace("/\{(.*?)\}/e", '$\1', $POLL_DISALLOWED_START);
|
$text = preg_replace("/\{(.*?)\}/e", '$\1', $POLL_DISALLOWED_START);
|
||||||
foreach($optionArray as $option)
|
foreach ($optionArray as $option)
|
||||||
{
|
{
|
||||||
$MODE = $mode; /* debug */
|
$MODE = $mode; /* debug */
|
||||||
$OPTION = $tp->toHTML($option, TRUE);
|
$OPTION = $tp->toHTML($option, TRUE);
|
||||||
$text .= preg_replace("/\{(.*?)\}/e", '$\1', $POLL_DISALLOWED_LOOP);
|
$text .= preg_replace("/\{(.*?)\}/e", '$\1', $POLL_DISALLOWED_LOOP);
|
||||||
$count ++;
|
$count ++;
|
||||||
}
|
}
|
||||||
if($pollArray['poll_vote_userclass'] == 253)
|
if ($pollArray['poll_vote_userclass'] == 253)
|
||||||
{
|
{
|
||||||
$DISALLOWMESSAGE = POLLAN_41;
|
$DISALLOWMESSAGE = POLLAN_41;
|
||||||
}
|
}
|
||||||
elseif($pollArray['poll_vote_userclass'] == 254)
|
elseif ($pollArray['poll_vote_userclass'] == 254)
|
||||||
{
|
{
|
||||||
$DISALLOWMESSAGE = POLLAN_42;
|
$DISALLOWMESSAGE = POLLAN_42;
|
||||||
}
|
}
|
||||||
@@ -428,24 +433,22 @@ class poll
|
|||||||
$DISALLOWMESSAGE = POLLAN_43;
|
$DISALLOWMESSAGE = POLLAN_43;
|
||||||
}
|
}
|
||||||
$text .= preg_replace("/\{(.*?)\}/e", '$\1', $POLL_DISALLOWED_END);
|
$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;
|
$caption = POLLAN_23;
|
||||||
$text = "<div style='text-align:center; margin-left: auto; margin-right: auto;'>\n<table style='width:350px' class='fborder'>\n<tr>\n<td>\n$text\n</td></tr></table></div>";
|
$text = "<div style='text-align:center; margin-left: auto; margin-right: auto;'>\n<table style='width:350px' class='fborder'>\n<tr>\n<td>\n$text\n</td></tr></table></div>";
|
||||||
}
|
}
|
||||||
else if($type == "forum")
|
else if ($type == 'forum')
|
||||||
{
|
{
|
||||||
$caption = LAN_4;
|
$caption = LAN_4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($returnMethod)
|
||||||
|
|
||||||
if($returnMethod)
|
|
||||||
{
|
{
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
@@ -455,18 +458,16 @@ class poll
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
function renderPollForm($mode="admin")
|
function renderPollForm
|
||||||
|
$mode = "admin" :: called from admin_config.php
|
||||||
|
$mode = "forum" :: called from forum_post.php
|
||||||
|
*/
|
||||||
|
function renderPollForm($mode='admin')
|
||||||
{
|
{
|
||||||
/*
|
|
||||||
$mode = "admin" :: called from admin_config.php
|
|
||||||
$mode = "forum" :: called from forum_post.php
|
|
||||||
*/
|
|
||||||
$tp = e107::getParser();
|
$tp = e107::getParser();
|
||||||
|
|
||||||
//TODO Hardcoded FORUM code needs to be moved somewhere.
|
//TODO Hardcoded FORUM code needs to be moved somewhere.
|
||||||
|
if ($mode == 'forum')
|
||||||
if($mode == "forum")
|
|
||||||
{
|
{
|
||||||
$text = "<tr>
|
$text = "<tr>
|
||||||
<td colspan='2' class='nforumcaption2'>".LAN_4."</td>
|
<td colspan='2' class='nforumcaption2'>".LAN_4."</td>
|
||||||
@@ -486,12 +487,12 @@ class poll
|
|||||||
|
|
||||||
for($count = 1; $count <= $option_count; $count++)
|
for($count = 1; $count <= $option_count; $count++)
|
||||||
{
|
{
|
||||||
if($count != 1 && $_POST['poll_option'][($count-1)] =="")
|
if ($count != 1 && $_POST['poll_option'][($count-1)] =="")
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$opt = ($count==1) ? "id='pollopt'" : "";
|
$opt = ($count==1) ? "id='pollopt'" : "";
|
||||||
$text .="<span $opt><input class='tbox' type='text' name='poll_option[]' size='40' value=\"".$_POST['poll_option'][($count-1)]."\" maxlength='200' />";
|
$text .="<span {$opt}><input class='tbox' type='text' name='poll_option[]' size='40' value=\"".$_POST['poll_option'][($count-1)]."\" maxlength='200' />";
|
||||||
$text .= "</span><br />";
|
$text .= "</span><br />";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -523,7 +524,7 @@ class poll
|
|||||||
$formgo = e_SELF.(e_QUERY && !defined("RESET") && strpos(e_QUERY, 'delete') === FALSE ? "?".e_QUERY : "");
|
$formgo = e_SELF.(e_QUERY && !defined("RESET") && strpos(e_QUERY, 'delete') === FALSE ? "?".e_QUERY : "");
|
||||||
|
|
||||||
$text = "<div style='text-align:center'>
|
$text = "<div style='text-align:center'>
|
||||||
<form method='post' action='$formgo'>
|
<form method='post' action='{$formgo}'>
|
||||||
<table class='adminform' cellpadding='0' cellspacing='0'>
|
<table class='adminform' cellpadding='0' cellspacing='0'>
|
||||||
<colgroup span='2'>
|
<colgroup span='2'>
|
||||||
<col class='col-label' />
|
<col class='col-label' />
|
||||||
@@ -544,7 +545,7 @@ class poll
|
|||||||
for($count = 1; $count <= $option_count; $count++)
|
for($count = 1; $count <= $option_count; $count++)
|
||||||
{
|
{
|
||||||
$opt = ($count==1) ? "id='pollopt'" : "";
|
$opt = ($count==1) ? "id='pollopt'" : "";
|
||||||
$text .="<span $opt><input class='tbox' type='text' name='poll_option[]' size='40' value=\"".$tp -> post_toForm($_POST['poll_option'][($count-1)])."\" maxlength='200' />";
|
$text .="<span {$opt}><input class='tbox' type='text' name='poll_option[]' size='40' value=\"".$tp -> post_toForm($_POST['poll_option'][($count-1)])."\" maxlength='200' />";
|
||||||
$text .= "</span><br />";
|
$text .= "</span><br />";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -585,9 +586,6 @@ class poll
|
|||||||
<input type='radio' name='storageMethod' value='2'".(varset($_POST['storageMethod']) ==2 ? " checked='checked'" : "")." /> ".POLLAN_19."
|
<input type='radio' name='storageMethod' value='2'".(varset($_POST['storageMethod']) ==2 ? " checked='checked'" : "")." /> ".POLLAN_19."
|
||||||
</td></tr>
|
</td></tr>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>".POLLAN_20.": </td><td>
|
<td>".POLLAN_20.": </td><td>
|
||||||
<input type='radio' name='poll_comment' value='1'".(varset($_POST['poll_comment']) ? " checked='checked'" : "")." /> ".POLLAN_10."
|
<input type='radio' name='poll_comment' value='1'".(varset($_POST['poll_comment']) ? " checked='checked'" : "")." /> ".POLLAN_10."
|
||||||
@@ -601,7 +599,7 @@ class poll
|
|||||||
{
|
{
|
||||||
$text .= "<input class='button' type='submit' name='preview' value='".POLLAN_24."' /> ";
|
$text .= "<input class='button' type='submit' name='preview' value='".POLLAN_24."' /> ";
|
||||||
|
|
||||||
if (POLLACTION == "edit")
|
if (POLLACTION == 'edit')
|
||||||
{
|
{
|
||||||
$text .= "<input class='button' type='submit' name='submit' value='".POLLAN_22."' />
|
$text .= "<input class='button' type='submit' name='submit' value='".POLLAN_22."' />
|
||||||
<input type='hidden' name='poll_id' value='".intval($_POST['poll_id'])."' /> ";
|
<input type='hidden' name='poll_id' value='".intval($_POST['poll_id'])."' /> ";
|
||||||
@@ -639,5 +637,4 @@ function setcook(pollid){
|
|||||||
//-->
|
//-->
|
||||||
</script>
|
</script>
|
||||||
';
|
';
|
||||||
|
|
||||||
?>
|
?>
|
Reference in New Issue
Block a user