mirror of
https://github.com/e107inc/e107.git
synced 2025-08-04 05:37:32 +02:00
Poll plugin code clean-up
This commit is contained in:
@@ -82,9 +82,9 @@ if (varset($_POST['edit']) || varset($_GET['mode'])=='create' && !varset($_POST[
|
|||||||
define("POLLACTION",'edit');
|
define("POLLACTION",'edit');
|
||||||
}
|
}
|
||||||
|
|
||||||
$poll_total = $sql->db_Select("polls");
|
$poll_total = $sql->select("polls");
|
||||||
$text = $poll -> renderPollForm();
|
$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();
|
$sql = e107::getDb();
|
||||||
$id = key($_POST['edit']);
|
$id = key($_POST['edit']);
|
||||||
|
|
||||||
if ($sql->db_Select("polls", "*", "poll_id=".$id))
|
if ($sql->select("polls", "*", "poll_id=".$id))
|
||||||
{
|
{
|
||||||
$_GET['mode'] = 'create';
|
$_GET['mode'] = 'create';
|
||||||
$row = $sql->db_Fetch();
|
$row = $sql->fetch();
|
||||||
extract($row);
|
extract($row); // FIXME
|
||||||
|
|
||||||
$tmpArray = explode(chr(1), $poll_options);
|
$tmpArray = explode(chr(1), $poll_options);
|
||||||
|
|
||||||
@@ -177,14 +177,14 @@ function poll_list()
|
|||||||
$text = "
|
$text = "
|
||||||
<form action='".e_SELF."' method='post' id='del_poll'>";
|
<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 .= "<table class='table adminlist'>";
|
||||||
$text .= $frm->colGroup($fields,$fieldpref).
|
$text .= $frm->colGroup($fields,$fieldpref).
|
||||||
$frm->thead($fields,$fieldpref);
|
$frm->thead($fields,$fieldpref);
|
||||||
$text .= "<tbody>";
|
$text .= "<tbody>";
|
||||||
|
|
||||||
while ($row = $sql->db_Fetch())
|
while ($row = $sql->fetch())
|
||||||
{
|
{
|
||||||
extract($row); // FIXME
|
extract($row); // FIXME
|
||||||
|
|
||||||
|
@@ -6,8 +6,6 @@
|
|||||||
* Released under the terms and conditions of the
|
* Released under the terms and conditions of the
|
||||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
*
|
*
|
||||||
* $URL$
|
|
||||||
* $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//define("POLL_ADLAN01", "Poll");
|
//define("POLL_ADLAN01", "Poll");
|
||||||
|
@@ -6,8 +6,6 @@
|
|||||||
* Released under the terms and conditions of the
|
* Released under the terms and conditions of the
|
||||||
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
|
||||||
*
|
*
|
||||||
* $URL$
|
|
||||||
* $Id$
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!defined('e107_INIT')) { exit; }
|
if (!defined('e107_INIT')) { exit; }
|
||||||
@@ -35,7 +33,6 @@ class poll
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
function remove_poll_cookies
|
function remove_poll_cookies
|
||||||
Remove unused poll cookies. See: http://krijnhoetmer.nl/stuff/javascript/maximum-cookies/ Thanks Fanat1k - bugtracker #4983
|
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;
|
global $admin_log;
|
||||||
$sql = e107::getDb();
|
$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"))
|
if (function_exists("admin_purge_related"))
|
||||||
{
|
{
|
||||||
@@ -116,7 +113,7 @@ class poll
|
|||||||
|
|
||||||
if (POLLACTION == 'edit' || vartrue($_POST['poll_id']))
|
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_options='{$poll_options}',
|
||||||
poll_comment='{$poll_comment}',
|
poll_comment='{$poll_comment}',
|
||||||
poll_type={$mode},
|
poll_type={$mode},
|
||||||
@@ -127,8 +124,8 @@ class poll
|
|||||||
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->select("polls", "poll_votes", "poll_id='".intval(POLLID)."' ");
|
||||||
$foo = $sql -> db_Fetch();
|
$foo = $sql->fetch();
|
||||||
$voteA = explode(chr(1), $foo['poll_votes']);
|
$voteA = explode(chr(1), $foo['poll_votes']);
|
||||||
|
|
||||||
$opt = count($poll_option) - count($voteA);
|
$opt = count($poll_option) - count($voteA);
|
||||||
@@ -139,7 +136,7 @@ class poll
|
|||||||
{
|
{
|
||||||
$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->update("polls", "poll_votes='".$foo['poll_votes']."' WHERE poll_id='".intval(POLLID)."' ");
|
||||||
}
|
}
|
||||||
|
|
||||||
$admin_log->log_event('POLL_02','ID: '.POLLID.' - '.$poll_title,'');
|
$admin_log->log_event('POLL_02','ID: '.POLLID.' - '.$poll_title,'');
|
||||||
@@ -156,20 +153,20 @@ class poll
|
|||||||
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->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->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
|
$admin_log->log_event('POLL_03','ID: '.$ret.' - '.$poll_title,''); // Intentionally only log admin-entered polls
|
||||||
}
|
}
|
||||||
else
|
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;
|
return $message;
|
||||||
@@ -178,12 +175,11 @@ class poll
|
|||||||
function get_poll($query)
|
function get_poll($query)
|
||||||
{
|
{
|
||||||
global $e107;
|
global $e107;
|
||||||
|
|
||||||
$sql = e107::getDb();
|
$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']))
|
if (!check_class($pollArray['poll_vote_userclass']))
|
||||||
{
|
{
|
||||||
$POLLMODE = 'disallowed';
|
$POLLMODE = 'disallowed';
|
||||||
@@ -312,9 +308,9 @@ class poll
|
|||||||
$POLLMODE = $this->pollmode;
|
$POLLMODE = $this->pollmode;
|
||||||
break;
|
break;
|
||||||
case 'results' :
|
case 'results' :
|
||||||
if ($sql->db_Select_gen($pollArray))
|
if ($sql->gen($pollArray))
|
||||||
{
|
{
|
||||||
$pollArray = $sql -> db_Fetch();
|
$pollArray = $sql->fetch();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -404,7 +400,6 @@ class poll
|
|||||||
$POLL_VOTED_LOOP = $POLL_TEMPLATE['results']['item'];
|
$POLL_VOTED_LOOP = $POLL_TEMPLATE['results']['item'];
|
||||||
$POLL_VOTED_END = $POLL_TEMPLATE['results']['end'];
|
$POLL_VOTED_END = $POLL_TEMPLATE['results']['end'];
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -422,7 +417,7 @@ class poll
|
|||||||
$comment_total = 0;
|
$comment_total = 0;
|
||||||
if ($pollArray['poll_comment'])
|
if ($pollArray['poll_comment'])
|
||||||
{ // Only get comments if they're allowed on poll. And we only need the count ATM
|
{ // 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');
|
$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>" : "");
|
$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 = '';
|
$OLDPOLLS = '';
|
||||||
|
|
||||||
if ($poll_count > 1)
|
if ($poll_count > 1)
|
||||||
@@ -544,7 +539,7 @@ class poll
|
|||||||
|
|
||||||
if ($type == 'preview')
|
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>";
|
$text = "<div class='clearfix'>\n<div class='well span3'>".$text."</div></div>";
|
||||||
}
|
}
|
||||||
elseif ($type == 'forum')
|
elseif ($type == 'forum')
|
||||||
@@ -604,7 +599,6 @@ class poll
|
|||||||
if ($mode == 'front')
|
if ($mode == 'front')
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
$text = "
|
$text = "
|
||||||
|
|
||||||
<div class='alert alert-info'>
|
<div class='alert alert-info'>
|
||||||
@@ -890,12 +884,6 @@ class poll_shortcodes extends e_shortcode
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
e107::js('inline', '
|
e107::js('inline', '
|
||||||
|
|
||||||
function setcook(pollid){
|
function setcook(pollid){
|
||||||
|
Reference in New Issue
Block a user