1
0
mirror of https://github.com/e107inc/e107.git synced 2025-01-17 20:58:30 +01:00
php-e107/e107_plugins/poll/poll_class.php

673 lines
22 KiB
PHP
Raw Normal View History

2006-12-02 04:36:16 +00:00
<?php
/*
2009-11-17 10:46:35 +00:00
* e107 website system
*
2009-11-18 01:06:08 +00:00
* Copyright (C) 2008-2009 e107 Inc (e107.org)
2009-11-17 10:46:35 +00:00
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
*
*
* $Source: /cvs_backup/e107_0.8/e107_plugins/poll/poll_class.php,v $
2010-02-10 18:18:01 +00:00
* $Revision$
* $Date$
* $Author$
2009-11-17 10:46:35 +00:00
*/
2006-12-02 04:36:16 +00:00
if (!defined('e107_INIT')) { exit; }
include_lan(e_PLUGIN.'poll/languages/'.e_LANGUAGE.'.php');
define('POLLCLASS', TRUE);
define('POLL_MODE_COOKIE', 0);
define('POLL_MODE_IP', 1);
define('POLL_MODE_USERID', 2);
2006-12-02 04:36:16 +00:00
class poll
{
var $pollRow;
var $pollmode;
/*
function remove_poll_cookies
Remove unused poll cookies. See: http://krijnhoetmer.nl/stuff/javascript/maximum-cookies/ Thanks Fanat1k - bugtracker #4983
no parameters
*/
function remove_poll_cookies()
{
$arr_polls_cookies = array();
foreach($_COOKIE as $cookie_name => $cookie_val)
{ // Collect poll cookies
list($str, $int) = explode('_', $cookie_name);
if (($str == 'poll') && is_numeric($int))
{ // Yes, its poll's cookie
$arr_polls_cookies[] = $int;
}
}
if (count($arr_polls_cookies) > 1)
{ // Remove all except first (assumption: there is always only one active poll)
rsort($arr_polls_cookies);
for($i = 1; $i < count($arr_polls_cookies); $i++)
{
cookie("poll_{$arr_polls_cookies[$i]}", "", (time() - 2592000));
}
}
}
/*
function delete_poll
parameter in: $existing - existing poll id to be deleted
parameter out: language text string on succesful delete, nothing on failed deletion
*/
2006-12-02 04:36:16 +00:00
function delete_poll($existing)
{
2008-08-17 11:54:40 +00:00
global $sql, $admin_log;
2006-12-02 04:36:16 +00:00
if ($sql -> db_Delete("polls", " poll_id='".intval($existing)."' "))
{
if (function_exists("admin_purge_related"))
2006-12-02 04:36:16 +00:00
{
admin_purge_related("poll", $existing);
}
2008-08-17 11:54:40 +00:00
$admin_log->log_event('POLL_01',POLL_ADLAN08.': '.$existing,'');
return POLL_ADLAN08;
2006-12-02 04:36:16 +00:00
}
}
/*
function submit_poll
$mode = 1 :: poll is main poll
$mode = 2 :: poll is forum poll
returns message
*/
2006-12-02 04:36:16 +00:00
function submit_poll($mode=1)
{
2008-08-17 11:54:40 +00:00
global $tp, $sql, $admin_log;
$poll_title = $tp->toDB($_POST['poll_title']);
$poll_comment = $tp -> toDB($_POST['poll_comment']);
$multipleChoice = intval($_POST['multipleChoice']);
$showResults = intval($_POST['showResults']);
$pollUserclass = intval($_POST['pollUserclass']);
$storageMethod = intval($_POST['storageMethod']);
$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']));
$poll_options = '';
2006-12-02 04:36:16 +00:00
$_POST['poll_option'] = array_filter($_POST['poll_option']);
foreach ($_POST['poll_option'] as $key => $value)
2006-12-02 04:36:16 +00:00
{
2008-08-04 20:31:49 +00:00
$poll_options .= $tp->toDB($value).chr(1);
2006-12-02 04:36:16 +00:00
}
if (POLLACTION == 'edit' || vartrue($_POST['poll_id']))
2006-12-02 04:36:16 +00:00
{
$sql -> db_Update("polls", "poll_title='{$poll_title}',
poll_options='{$poll_options}',
poll_comment='{$poll_comment}',
poll_type={$mode},
poll_allow_multiple={$multipleChoice},
poll_result_type={$showResults},
poll_vote_userclass={$pollUserclass},
poll_storage_method={$storageMethod}
WHERE poll_id=".intval(POLLID));
2006-12-02 04:36:16 +00:00
/* update poll results - bugtracker #1124 .... */
$sql -> db_Select("polls", "poll_votes", "poll_id='".intval(POLLID)."' ");
$foo = $sql -> db_Fetch();
$voteA = explode(chr(1), $foo['poll_votes']);
$opt = count($poll_option) - count($voteA);
if ($opt)
2006-12-02 04:36:16 +00:00
{
for($a=0; $a<=$opt; $a++)
{
$foo['poll_votes'] .= '0'.chr(1);
2006-12-02 04:36:16 +00:00
}
$sql -> db_Update("polls", "poll_votes='".$foo['poll_votes']."' WHERE poll_id='".intval(POLLID)."' ");
}
2008-08-17 11:54:40 +00:00
$admin_log->log_event('POLL_02','ID: '.POLLID.' - '.$poll_title,'');
2006-12-02 04:36:16 +00:00
$message = POLLAN_45;
2008-08-17 11:54:40 +00:00
}
else
{
$votes = '';
2006-12-02 04:36:16 +00:00
for($a=1; $a<=count($_POST['poll_option']); $a++)
{
$votes .= '0'.chr(1);
2006-12-02 04:36:16 +00:00
}
if ($mode == 1)
2006-12-02 04:36:16 +00:00
{
/* deactivate other polls */
if ($sql -> db_Select("polls", "*", "poll_type=1 AND poll_vote_userclass!=255"))
2006-12-02 04:36:16 +00:00
{
$deacArray = $sql -> db_getList();
foreach ($deacArray as $deacpoll)
2006-12-02 04:36:16 +00:00
{
$sql -> db_Update("polls", "poll_end_datestamp='".time()."', poll_vote_userclass='255' WHERE poll_id=".$deacpoll['poll_id']);
}
}
2008-08-17 11:54:40 +00:00
$ret = $sql -> db_Insert("polls", "'0', ".time().", ".intval($active_start).", ".intval($active_end).", ".ADMINID.", '{$poll_title}', '{$poll_options}', '{$votes}', '', '1', '".$tp -> toDB($poll_comment)."', '".intval($multipleChoice)."', '".intval($showResults)."', '".intval($pollUserclass)."', '".intval($storageMethod)."'");
$admin_log->log_event('POLL_03','ID: '.$ret.' - '.$poll_title,''); // Intentionally only log admin-entered polls
2006-12-02 04:36:16 +00:00
}
else
{
$sql -> db_Insert("polls", "'0', ".intval($_POST['iid']).", '0', '0', ".USERID.", '$poll_title', '$poll_options', '$votes', '', '2', '0', '".intval($multipleChoice)."', '0', '0', '".intval($storageMethod)."'");
}
}
return $message;
}
function get_poll($query)
{
global $sql, $e107;
if ($sql->db_Select_gen($query))
{
$pollArray = $sql -> db_Fetch();
if (!check_class($pollArray['poll_vote_userclass']))
{
$POLLMODE = 'disallowed';
2006-12-02 04:36:16 +00:00
}
else
{
switch($pollArray['poll_storage_method'])
{
case POLL_MODE_COOKIE:
$userid = '';
$cookiename = 'poll_'.$pollArray['poll_id'];
if (isset($_COOKIE[$cookiename]))
2006-12-02 04:36:16 +00:00
{
$POLLMODE = 'voted';
2006-12-02 04:36:16 +00:00
}
else
{
$POLLMODE = 'notvoted';
2006-12-02 04:36:16 +00:00
}
break;
case POLL_MODE_IP:
$userid = e107::getIPHandler()->getIP(FALSE);
$voted_ids = explode('^', substr($pollArray['poll_ip'], 0, -1));
2006-12-02 04:36:16 +00:00
if (in_array($userid, $voted_ids))
{
$POLLMODE = 'voted';
2006-12-02 04:36:16 +00:00
}
else
{
$POLLMODE = 'notvoted';
2006-12-02 04:36:16 +00:00
}
break;
case POLL_MODE_USERID:
if (!USER)
2006-12-02 04:36:16 +00:00
{
$POLLMODE = 'disallowed';
2006-12-02 04:36:16 +00:00
}
else
{
$userid = USERID;
$voted_ids = explode('^', substr($pollArray['poll_ip'], 0, -1));
2006-12-02 04:36:16 +00:00
if (in_array($userid, $voted_ids))
{
$POLLMODE = 'voted';
2006-12-02 04:36:16 +00:00
}
else
{
$POLLMODE = 'notvoted';
2006-12-02 04:36:16 +00:00
}
}
break;
}
}
}
else
{
return FALSE;
}
if (isset($_POST['pollvote']) && $POLLMODE == 'notvoted' && ($POLLMODE != 'disallowed'))
2006-12-02 04:36:16 +00:00
{
if ($_POST['votea'])
{
2006-12-02 04:36:16 +00:00
// $sql -> db_Select("polls", "*", "poll_vote_userclass!=255 AND poll_type=1 ORDER BY poll_datestamp DESC LIMIT 0,1");
$row = $pollArray;
extract($row);
$votes = explode(chr(1), $poll_votes);
if (is_array($_POST['votea']))
{
/* multiple choice vote */
foreach ($_POST['votea'] as $vote)
2006-12-02 04:36:16 +00:00
{
$vote = intval($vote);
$votes[($vote-1)] ++;
2006-12-02 04:36:16 +00:00
}
}
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])
2006-12-02 04:36:16 +00:00
{
$votes[$k] = 0;
2006-12-02 04:36:16 +00:00
}
}
$votep = implode(chr(1), $votes);
$pollArray['poll_votes'] = $votep;
$sql->db_Update("polls", "poll_votes = '$votep'".($pollArray['poll_storage_method'] != POLL_MODE_COOKIE ? ", poll_ip='".$poll_ip.$userid."^'" : '')." WHERE poll_id=".$poll_id);
echo "
2006-12-02 04:36:16 +00:00
<script type='text/javascript'>
<!--
setcook({$poll_id});
//-->
</script>
";
$POLLMODE = 'voted';
2006-12-02 04:36:16 +00:00
}
}
$this->pollRow = $pollArray;
$this->pollmode = $POLLMODE;
}
function render_poll($pollArray = "", $type = "menu", $POLLMODE = "", $returnMethod=FALSE)
{
global $POLLSTYLE, $sql, $tp, $ns;
switch ($POLLMODE)
2006-12-02 04:36:16 +00:00
{
case 'query' : // Show poll, register any vote
if ($this->get_poll($pollArray) === FALSE)
{
return ''; // No display if no poll
}
$pollArray = $this->pollRow;
$POLLMODE = $this->pollmode;
break;
case 'results' :
if ($sql->db_Select_gen($pollArray))
{
$pollArray = $sql -> db_Fetch();
}
break;
2006-12-02 04:36:16 +00:00
}
$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');
$bar = (file_exists(THEME.'images/bar.png') ? THEME_ABS.'images/bar.png' : e_PLUGIN_ABS.'poll/images/bar.png');
2006-12-02 04:36:16 +00:00
if ($type == 'preview')
2006-12-02 04:36:16 +00:00
{
$optionArray = $pollArray['poll_option'];
$voteArray = array();
$voteArray = array_pad($voteArray, count($optionArray), 0);
$pollArray['poll_allow_multiple'] = $pollArray['multipleChoice'];
}
else if ($type == 'forum')
2006-12-02 04:36:16 +00:00
{
if (isset($_POST['fpreview']))
2006-12-02 04:36:16 +00:00
{
$pollArray['poll_allow_multiple'] = $pollArray['multipleChoice'];
$optionArray = $pollArray['poll_option'];
}
else
{
$optionArray = explode(chr(1), $pollArray['poll_options']);
$optionArray = array_slice($optionArray, 0, -1);
}
$voteArray = explode(chr(1), $pollArray['poll_votes']);
// $voteArray = array_slice($voteArray, 0, -1);
}
else
{ // Get existing results
2006-12-02 04:36:16 +00:00
$optionArray = explode(chr(1), $pollArray['poll_options']);
$optionArray = array_slice($optionArray, 0, -1);
$voteArray = explode(chr(1), $pollArray['poll_votes']);
// $voteArray = array_slice($voteArray, 0, -1);
}
$voteTotal = array_sum($voteArray);
$percentage = array();
if (count($voteArray))
2006-12-02 04:36:16 +00:00
{
foreach ($voteArray as $votes)
2007-08-08 19:34:52 +00:00
{
if ($voteTotal > 0)
{
$percentage[] = round(($votes/$voteTotal) * 100, 2);
}
else
{
$percentage[] = 0;
}
2006-12-02 04:36:16 +00:00
}
}
/* get template */
if (file_exists(THEME.'poll_template.php'))
2006-12-02 04:36:16 +00:00
{
require(THEME.'poll_template.php');
2006-12-02 04:36:16 +00:00
}
else if (!isset($POLL_NOTVOTED_START))
2006-12-02 04:36:16 +00:00
{
require(e_PLUGIN.'poll/templates/poll_template.php');
2006-12-02 04:36:16 +00:00
}
$preview = FALSE;
if ($type == 'preview')
2006-12-02 04:36:16 +00:00
{
$POLLMODE = 'notvoted';
2006-12-02 04:36:16 +00:00
}
elseif ($type == 'forum')
{
2006-12-02 04:36:16 +00:00
$preview = 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->db_Count("comments", "(*)", "WHERE `comment_item_id`='".intval($pollArray['poll_id'])."' AND `comment_type`=4");
}
2006-12-02 04:36:16 +00:00
$QUESTION = $tp -> toHTML($pollArray['poll_title'], TRUE, "emotes_off, defs");
2006-12-02 04:36:16 +00:00
$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>" : "");
$poll_count = $sql->db_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>" : "");
}
$AUTHOR = POLLAN_35." ".($type == 'preview' || $type == 'forum' ? USERNAME : "<a href='".e_BASE."user.php?id.".$pollArray['poll_admin_id']."'>".$pollArray['user_name']."</a>");
2006-12-02 04:36:16 +00:00
switch ($POLLMODE)
{
case 'notvoted':
2006-12-02 04:36:16 +00:00
$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;
$alt = 0; // alternate style.
foreach ($optionArray as $option)
{
// $MODE = ($mode) ? $mode : ""; /* debug */
2006-12-02 04:36:16 +00:00
$OPTIONBUTTON = ($pollArray['poll_allow_multiple'] ? "<input type='checkbox' name='votea[]' value='$count' />" : "<input type='radio' name='votea' value='$count' />");
$OPTION = $tp->toHTML($option, TRUE);
if (isset($POLL_NOTVOTED_LOOP_ALT) && $POLL_NOTVOTED_LOOP_ALT && $type != "forum")
{ // alternating style
2006-12-02 04:36:16 +00:00
$text .= preg_replace("/\{(.*?)\}/e", '$\1', ($alt == 0 ? $POLL_NOTVOTED_LOOP : $POLL_NOTVOTED_LOOP_ALT));
$alt = ($alt ==0) ? 1 : 0;
}
else
{
2006-12-02 04:36:16 +00:00
$text .= preg_replace("/\{(.*?)\}/e", '$\1', ($type == "forum" ? $POLL_FORUM_NOTVOTED_LOOP : $POLL_NOTVOTED_LOOP));
}
$count ++;
}
$SUBMITBUTTON = "<input class='button' type='submit' name='pollvote' value='".POLLAN_30."' />";
if (('preview' == $type || $preview == TRUE) && strpos(e_SELF, "viewtopic") === FALSE)
2006-12-02 04:36:16 +00:00
{
$SUBMITBUTTON = "[".POLLAN_30."]";
}
$text .= "\n".preg_replace("/\{(.*?)\}/e", '$\1', ($type == "forum" ? $POLL_FORUM_NOTVOTED_END : $POLL_NOTVOTED_END))."\n</form>";
break;
2006-12-02 04:36:16 +00:00
case 'voted':
case 'results' :
if ($pollArray['poll_result_type'] && !strstr(e_SELF, "comment.php"))
2006-12-02 04:36:16 +00:00
{
$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 />";
}
else
{
$text = preg_replace("/\{(.*?)\}/e", '$\1', ($type == "forum" ? $POLL_FORUM_VOTED_START : $POLL_VOTED_START));
$count = 0;
foreach ($optionArray as $option)
2006-12-02 04:36:16 +00:00
{
$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: ".min(intval($percentage[$count]), 90)."%; height: 14px; float: left;'></div><div style='background-image: url($barr); width: 5px; height: 14px; float: left;'></div></div>" : "");
2006-12-02 04:36:16 +00:00
$PERCENTAGE = $percentage[$count]."%";
$VOTES = POLLAN_31.": ".$voteArray[$count];
$text .= preg_replace("/\{(.*?)\}/e", '$\1', ($type == "forum" ? $POLL_FORUM_VOTED_LOOP : $POLL_VOTED_LOOP));
$count ++;
}
}
$text .= preg_replace("/\{(.*?)\}/e", '$\1', ($type == "forum" ? $POLL_FORUM_VOTED_END : $POLL_VOTED_END));
break;
2006-12-02 04:36:16 +00:00
case 'disallowed':
2006-12-02 04:36:16 +00:00
$text = preg_replace("/\{(.*?)\}/e", '$\1', $POLL_DISALLOWED_START);
foreach ($optionArray as $option)
2006-12-02 04:36:16 +00:00
{
$MODE = $mode; /* debug */
$OPTION = $tp->toHTML($option, TRUE);
$text .= preg_replace("/\{(.*?)\}/e", '$\1', $POLL_DISALLOWED_LOOP);
$count ++;
}
if ($pollArray['poll_vote_userclass'] == 253)
2006-12-02 04:36:16 +00:00
{
$DISALLOWMESSAGE = POLLAN_41;
}
elseif ($pollArray['poll_vote_userclass'] == 254)
2006-12-02 04:36:16 +00:00
{
$DISALLOWMESSAGE = POLLAN_42;
}
else
{
$DISALLOWMESSAGE = POLLAN_43;
}
$text .= preg_replace("/\{(.*?)\}/e", '$\1', $POLL_DISALLOWED_END);
break;
2006-12-02 04:36:16 +00:00
}
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);
if ($type == 'preview')
2006-12-02 04:36:16 +00:00
{
$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>";
}
else if ($type == 'forum')
2006-12-02 04:36:16 +00:00
{
$caption = LAN_4;
}
if ($returnMethod)
2006-12-02 04:36:16 +00:00
{
return $text;
}
else
{
$ns->tablerender($caption, $text, 'poll');
}
}
/*
function renderPollForm
$mode = "admin" :: called from admin_config.php
$mode = "forum" :: called from forum_post.php
*/
function renderPollForm($mode='admin')
2006-12-02 04:36:16 +00:00
{
$tp = e107::getParser();
2012-11-26 15:43:42 -08:00
$frm = e107::getForm();
//TODO Hardcoded FORUM code needs to be moved somewhere.
if ($mode == 'forum')
2006-12-02 04:36:16 +00:00
{
$text = "<tr>
<td colspan='2' class='nforumcaption2'>".LAN_4."</td>
</tr>
<tr>
2009-07-10 14:25:23 +00:00
<td colspan='2'>
2006-12-02 04:36:16 +00:00
<span class='smalltext'>".LAN_386."</span>
</td>
</tr>
2009-07-10 14:25:23 +00:00
<tr><td style='width:20%'><div class='normaltext'>".LAN_5."</div></td><td style='width:80%'class='forumheader3'><input class='tbox' type='text' name='poll_title' size='70' value='".$tp->post_toForm($_POST['poll_title'])."' maxlength='200' /></td></tr>";
2006-12-02 04:36:16 +00:00
$option_count = (count($_POST['poll_option']) ? count($_POST['poll_option']) : 1);
$text .= "<tr>
2009-07-10 14:25:23 +00:00
<td style='width:20%'>".LAN_391."</td>
<td style='width:80%'>
2006-12-02 04:36:16 +00:00
<div id='pollsection'>";
for($count = 1; $count <= $option_count; $count++)
{
if ($count != 1 && $_POST['poll_option'][($count-1)] =="")
2006-12-02 04:36:16 +00:00
{
break;
}
$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' />";
2006-12-02 04:36:16 +00:00
$text .= "</span><br />";
}
$text .="</div><input class='button' type='button' name='addoption' value='".LAN_6."' onclick=\"duplicateHTML('pollopt','pollsection')\" /><br />
</td></tr>
<tr>
2009-07-10 14:25:23 +00:00
<td style='width:20%'>".POLL_506."</td>
<td style='width:80%'>
2006-12-02 04:36:16 +00:00
<input type='radio' name='multipleChoice' value='1'".($_POST['multipleChoice'] ? " checked='checked'" : "")." /> ".POLL_507."&nbsp;&nbsp;
<input type='radio' name='multipleChoice' value='0'".(!$_POST['multipleChoice'] ? " checked='checked'" : "")." /> ".POLL_508."
</td>
</tr>
<tr>
2009-07-10 14:25:23 +00:00
<td style='width:30%'>".POLLAN_16."</td>
<td>
2006-12-02 04:36:16 +00:00
<input type='radio' name='storageMethod' value='0'".(!$_POST['storageMethod'] ? " checked='checked'" : "")." /> ".POLLAN_17."<br />
<input type='radio' name='storageMethod' value='1'".($_POST['storageMethod'] == 1 ? " checked='checked'" : "")." /> ".POLLAN_18."<br />
<input type='radio' name='storageMethod' value='2'".($_POST['storageMethod'] ==2 ? " checked='checked'" : "")." /> ".POLLAN_19."
2009-07-10 14:25:23 +00:00
</td></tr>
2006-12-02 04:36:16 +00:00
";
return $text;
}
$formgo = e_SELF.(e_QUERY && !defined("RESET") && strpos(e_QUERY, 'delete') === FALSE ? "?".e_QUERY : "");
$text = "<div style='text-align:center'>
<form method='post' action='{$formgo}'>
2012-11-26 15:43:42 -08:00
<table class='table adminform'>
<colgroup>
2009-07-10 14:25:23 +00:00
<col class='col-label' />
<col class='col-control' />
</colgroup>
2006-12-02 04:36:16 +00:00
<tr>
2009-07-10 14:25:23 +00:00
<td style='width:30%'><div class='normaltext'>".POLLAN_3.":</div></td>
<td style='width:70%'>
<input class='tbox' type='text' name='poll_title' size='70' value='".$tp -> post_toForm(varset($_POST['poll_title']))."' maxlength='200' />";
2006-12-02 04:36:16 +00:00
$option_count = (varset($_POST['poll_option']) && count($_POST['poll_option']) ? count($_POST['poll_option']) : 2);
2006-12-02 04:36:16 +00:00
2009-07-10 14:25:23 +00:00
$text .= "</td></tr><tr>
<td style='width:30%;vertical-align:top'>".LAN_OPTIONS." :</td>
<td style='width:70%'>
2006-12-02 04:36:16 +00:00
<div id='pollsection'>";
for($count = 1; $count <= $option_count; $count++)
{
$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' />";
2006-12-02 04:36:16 +00:00
$text .= "</span><br />";
}
$text .="</div><input class='button' type='button' name='addoption' value='".POLLAN_8."' onclick=\"duplicateHTML('pollopt','pollsection')\" /><br />
</td></tr>
<tr>
2009-07-10 14:25:23 +00:00
<td style='width:30%'>".POLLAN_9."</td>
<td style='width:70%'>
<input type='radio' name='multipleChoice' value='1'".(varset($_POST['multipleChoice']) ? " checked='checked'" : "")." /> ".POLLAN_10."&nbsp;&nbsp;
<input type='radio' name='multipleChoice' value='0'".(!varset($_POST['multipleChoice']) ? " checked='checked'" : "")." /> ".POLLAN_11."
2006-12-02 04:36:16 +00:00
</td>
</tr>
<tr>
2009-07-10 14:25:23 +00:00
<td style='width:30%'>".POLLAN_12."</td>
<td style='width:70%'>
<input type='radio' name='showResults' value='0'".(!varset($_POST['showResults']) ? " checked='checked'" : "")." /> ".POLLAN_13."<br />
<input type='radio' name='showResults' value='1'".(varset($_POST['showResults']) ? " checked='checked'" : "")." /> ".POLLAN_14."
2006-12-02 04:36:16 +00:00
</td>
</tr>
<tr>
<td style='width:30%'>".POLLAN_15."</td>";
$uclass = (ADMIN) ? "" : "public,member,admin,classes,matchclass";
$text .= "
<td>".r_userclass("pollUserclass", $_POST['pollUserclass'], 'off', $uclass)."</td>
2006-12-02 04:36:16 +00:00
</tr>
<tr>
2009-07-10 14:25:23 +00:00
<td style='width:30%'>".POLLAN_16."</td>
<td>
<input type='radio' name='storageMethod' value='0'".(!varset($_POST['storageMethod']) ? " checked='checked'" : "")." /> ".POLLAN_17."<br />
<input type='radio' name='storageMethod' value='1'".(varset($_POST['storageMethod']) ==1 ? " checked='checked'" : "")." /> ".POLLAN_18."<br />
<input type='radio' name='storageMethod' value='2'".(varset($_POST['storageMethod']) ==2 ? " checked='checked'" : "")." /> ".POLLAN_19."
2009-07-10 14:25:23 +00:00
</td></tr>
2006-12-02 04:36:16 +00:00
<tr>
<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='0'".(!varset($_POST['poll_comment']) ? " checked='checked'" : "")." /> ".POLLAN_11."
2006-12-02 04:36:16 +00:00
</td>
</tr>
2009-07-10 14:25:23 +00:00
</table>
<div class='buttons-bar center'>";
2006-12-02 04:36:16 +00:00
if (isset($_POST['preview']) || varset($_POST['edit']))
{
$text .= "<input class='button' type='submit' name='preview' value='".POLLAN_24."' /> ";
if (POLLACTION == 'edit')
{
$text .= "<input class='button' type='submit' name='submit' value='".POLLAN_22."' />
<input type='hidden' name='poll_id' value='".intval($_POST['poll_id'])."' /> ";
}
else
{
2012-11-26 15:43:42 -08:00
$text .= $frm->admin_button('submit','no-value','submit',POLLAN_23);
// $text .= "<input class='button' type='submit' name='submit' value='".POLLAN_23."' /> ";
2006-12-02 04:36:16 +00:00
}
2012-11-26 15:43:42 -08:00
}
else
{
$text .= $frm->admin_button('preview','no-value','preview',POLLAN_24);
// $text .= "<input class='button' type='submit' name='preview' value='".POLLAN_24."' /> ";
2006-12-02 04:36:16 +00:00
}
2012-11-26 15:43:42 -08:00
if (defset('POLLID'))
{
$text .= $frm->admin_button('reset','no-value','reset',POLLAN_25);
// $text .= "<input class='button' type='submit' name='reset' value='".POLLAN_25."' /> ";
2006-12-02 04:36:16 +00:00
}
2009-07-10 14:25:23 +00:00
$text .= "</div>
2006-12-02 04:36:16 +00:00
</form>
</div>";
return $text;
}
}
echo '<script type="text/javascript">
<!--
function setcook(pollid){
var name = "poll_"+pollid;
var date = new Date();
var value = pollid;
date.setTime(date.getTime()+(365*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
document.cookie = name+"="+value+expires+"; path=/";
}
//-->
</script>
';
?>