1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-03 21:27:25 +02:00

Poll plugin code clean-up

This commit is contained in:
Moc
2013-03-31 11:52:27 +02:00
parent 0c5f1ec880
commit 81aa6032d6
3 changed files with 34 additions and 48 deletions

View File

@@ -82,9 +82,9 @@ if (varset($_POST['edit']) || varset($_GET['mode'])=='create' && !varset($_POST[
define("POLLACTION",'edit');
}
$poll_total = $sql->db_Select("polls");
$poll_total = $sql->select("polls");
$text = $poll -> renderPollForm();
$ns->tablerender(POLLAN_MENU_CAPTION." - ".POLLAN_2, $mes->render() . $text);
$ns->tablerender(POLLAN_MENU_CAPTION.SEP.POLLAN_2, $mes->render() . $text);
}
@@ -101,11 +101,11 @@ function edit_poll()
$sql = e107::getDb();
$id = key($_POST['edit']);
if ($sql->db_Select("polls", "*", "poll_id=".$id))
if ($sql->select("polls", "*", "poll_id=".$id))
{
$_GET['mode'] = 'create';
$row = $sql->db_Fetch();
extract($row);
$row = $sql->fetch();
extract($row); // FIXME
$tmpArray = explode(chr(1), $poll_options);
@@ -177,14 +177,14 @@ function poll_list()
$text = "
<form action='".e_SELF."' method='post' id='del_poll'>";
if ($poll_total = $sql->db_Select("polls", "*", "poll_type=1"))
if ($poll_total = $sql->select("polls", "*", "poll_type=1"))
{
$text .= "<table class='table adminlist'>";
$text .= $frm->colGroup($fields,$fieldpref).
$frm->thead($fields,$fieldpref);
$text .= "<tbody>";
while ($row = $sql->db_Fetch())
while ($row = $sql->fetch())
{
extract($row); // FIXME

View File

@@ -6,8 +6,6 @@
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* $URL$
* $Id$
*/
//define("POLL_ADLAN01", "Poll");

View File

@@ -6,8 +6,6 @@
* Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
*
* $URL$
* $Id$
*/
if (!defined('e107_INIT')) { exit; }
@@ -35,7 +33,6 @@ class poll
}
/*
function remove_poll_cookies
Remove unused poll cookies. See: http://krijnhoetmer.nl/stuff/javascript/maximum-cookies/ Thanks Fanat1k - bugtracker #4983
@@ -72,7 +69,7 @@ class poll
global $admin_log;
$sql = e107::getDb();
if ($sql -> db_Delete("polls", " poll_id='".intval($existing)."' "))
if ($sql->delete("polls", " poll_id='".intval($existing)."' "))
{
if (function_exists("admin_purge_related"))
{
@@ -116,7 +113,7 @@ class poll
if (POLLACTION == 'edit' || vartrue($_POST['poll_id']))
{
$sql -> db_Update("polls", "poll_title='{$poll_title}',
$sql->update("polls", "poll_title='{$poll_title}',
poll_options='{$poll_options}',
poll_comment='{$poll_comment}',
poll_type={$mode},
@@ -127,8 +124,8 @@ class poll
WHERE poll_id=".intval(POLLID));
/* update poll results - bugtracker #1124 .... */
$sql -> db_Select("polls", "poll_votes", "poll_id='".intval(POLLID)."' ");
$foo = $sql -> db_Fetch();
$sql->select("polls", "poll_votes", "poll_id='".intval(POLLID)."' ");
$foo = $sql->fetch();
$voteA = explode(chr(1), $foo['poll_votes']);
$opt = count($poll_option) - count($voteA);
@@ -139,7 +136,7 @@ class poll
{
$foo['poll_votes'] .= '0'.chr(1);
}
$sql -> db_Update("polls", "poll_votes='".$foo['poll_votes']."' WHERE poll_id='".intval(POLLID)."' ");
$sql->update("polls", "poll_votes='".$foo['poll_votes']."' WHERE poll_id='".intval(POLLID)."' ");
}
$admin_log->log_event('POLL_02','ID: '.POLLID.' - '.$poll_title,'');
@@ -156,20 +153,20 @@ class poll
if ($mode == 1)
{
/* deactivate other polls */
if ($sql -> db_Select("polls", "*", "poll_type=1 AND poll_vote_userclass!=255"))
if ($sql->select("polls", "*", "poll_type=1 AND poll_vote_userclass!=255"))
{
$deacArray = $sql->db_getList();
foreach ($deacArray as $deacpoll)
{
$sql -> db_Update("polls", "poll_end_datestamp='".time()."', poll_vote_userclass='255' WHERE poll_id=".$deacpoll['poll_id']);
$sql->update("polls", "poll_end_datestamp='".time()."', poll_vote_userclass='255' WHERE poll_id=".$deacpoll['poll_id']);
}
}
$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)."'");
$ret = $sql->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
}
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)."'");
$sql->insert("polls", "'0', ".intval($_POST['iid']).", '0', '0', ".USERID.", '$poll_title', '$poll_options', '$votes', '', '2', '0', '".intval($multipleChoice)."', '0', '0', '".intval($storageMethod)."'");
}
}
return $message;
@@ -178,12 +175,11 @@ class poll
function get_poll($query)
{
global $e107;
$sql = e107::getDb();
if ($sql->db_Select_gen($query))
if ($sql->gen($query))
{
$pollArray = $sql -> db_Fetch();
$pollArray = $sql->fetch();
if (!check_class($pollArray['poll_vote_userclass']))
{
$POLLMODE = 'disallowed';
@@ -312,9 +308,9 @@ class poll
$POLLMODE = $this->pollmode;
break;
case 'results' :
if ($sql->db_Select_gen($pollArray))
if ($sql->gen($pollArray))
{
$pollArray = $sql -> db_Fetch();
$pollArray = $sql->fetch();
}
break;
}
@@ -404,7 +400,6 @@ class poll
$POLL_VOTED_LOOP = $POLL_TEMPLATE['results']['item'];
$POLL_VOTED_END = $POLL_TEMPLATE['results']['end'];
}
@@ -422,7 +417,7 @@ class poll
$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");
$comment_total = $sql->count("comments", "(*)", "WHERE `comment_item_id`='".intval($pollArray['poll_id'])."' AND `comment_type`=4");
}
$sc = e107::getScBatch('poll');
@@ -437,7 +432,7 @@ class poll
$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']."'");
$poll_count = $sql->count("polls", "(*)", "WHERE poll_id <= '".$pollArray['poll_id']."'");
$OLDPOLLS = '';
if ($poll_count > 1)
@@ -544,7 +539,7 @@ class poll
if ($type == 'preview')
{
$caption = POLLAN_23.SEP."Preview";
$caption = POLLAN_23.SEP."Preview"; // TODO LAN
$text = "<div class='clearfix'>\n<div class='well span3'>".$text."</div></div>";
}
elseif ($type == 'forum')
@@ -604,7 +599,6 @@ class poll
if ($mode == 'front')
{
$text = "
<div class='alert alert-info'>
@@ -890,12 +884,6 @@ class poll_shortcodes extends e_shortcode
e107::js('inline', '
function setcook(pollid){