if (!isset($polllib)) { $polllib = new PollLib($dbTiki); } if ($feature_polls != 'y') { $smarty->assign('msg', tra("This feature is disabled") . ": feature_polls"); $smarty->display("error.tpl"); die; } if (!isset($_REQUEST["pollId"])) { $smarty->assign('msg', tra("No poll indicated")); $smarty->display("error.tpl"); die; } $poll_info = $polllib->get_poll($_REQUEST["pollId"]); $polls = $polllib->list_active_polls(0, -1, 'publishDate_desc', ''); $options = $polllib->list_poll_options($_REQUEST["pollId"]); $temp_max = count($options); for ($i = 0; $i < $temp_max; $i++) { if ($poll_info["votes"] == 0) { $percent = 0; } else { $percent = number_format($options[$i]["votes"] * 100 / $poll_info["votes"], 2); $options[$i]["percent"] = $percent; } $width = $percent * 200 / 100; $options[$i]["width"] = $percent; } // Poll comments if ($feature_poll_comments == 'y') { $comments_per_page = $poll_comments_per_page; $comments_default_ordering = $poll_comments_default_ordering;
$smarty->assign_by_ref('find', $_REQUEST['find']); $polls = $polllib->list_active_polls(0, $_REQUEST["maxRecords"], "votes_desc", $_REQUEST['find']); $pollIds = array(); if (isset($_REQUEST["pollId"])) { $pollIds[] = $_REQUEST["pollId"]; } else { foreach ($polls["data"] as $pId) { $pollIds[] = $pId["pollId"]; } } $poll_info_arr = array(); foreach ($pollIds as $pK => $pId) { // iterate each poll $poll_info = $polllib->get_poll($pId); $poll_info_arr[$pK] = $poll_info; $options = $polllib->list_poll_options($pId); $temp_max = count($options); $total = 0; $isNum = true; // try to find if it is a numeric poll with a title like +1, -2, 1 point... for ($i = 0; $i < $temp_max; $i++) { if ($poll_info["votes"] == 0) { $percent = 0; } else { $percent = number_format($options[$i]["votes"] * 100 / $poll_info["votes"], 2); $options[$i]["percent"] = $percent; if ($isNum) { if (preg_match('/^([+-]?[0-9]+).*/', $options[$i]['title'], $matches)) { $total += $options[$i]['votes'] * $matches[1]; } else { $isNum = false;
/** * @version $Header$ * * Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al. * Copyright (c) 2006, Stephan Borg <*****@*****.**> * All Rights Reserved. See below for details and a complete list of authors. * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See http://www.gnu.org/copyleft/lesser.html for details. * * @package polls * @subpackage functions */ /** * required setup */ require_once '../kernel/setup_inc.php'; include_once POLLS_PKG_PATH . 'poll_lib.php'; $gBitSystem->verifyPackage('polls'); $gBitSystem->verifyPermission('bit_p_vote_poll'); if (!isset($polllib)) { $polllib = new PollLib(); } if (!isset($_REQUEST["poll_id"])) { $gBitSystem->fatalError(tra("No poll indicated")); } $poll_info = $polllib->get_poll($_REQUEST["poll_id"]); $options = $polllib->list_poll_options($_REQUEST["poll_id"], 0, -1, 'title_desc', ''); $gBitSmarty->assign_by_ref('poll_info', $poll_info); $gBitSmarty->assign_by_ref('polls', $options["data"]); // Display the template $gBitSystem->display('bitpackage:polls/poll_form.tpl', tra('Poll Form'), array('display_mode' => 'display'));
$sort_mode = $_REQUEST["sort_mode"]; } if (!isset($_REQUEST["offset"])) { $offset = 0; } else { $offset = $_REQUEST["offset"]; } $gBitSmarty->assign_by_ref('offset', $offset); if (isset($_REQUEST["find"])) { $find = $_REQUEST["find"]; } else { $find = ''; } $gBitSmarty->assign('find', $find); $gBitSmarty->assign_by_ref('sort_mode', $sort_mode); $polls = $polllib->list_poll_options($_REQUEST["poll_id"], 0, -1, $sort_mode, $find); $cant_pages = ceil($polls["cant"] / $maxRecords); $gBitSmarty->assign_by_ref('cant_pages', $cant_pages); $gBitSmarty->assign('actual_page', 1 + $offset / $maxRecords); if ($polls["cant"] > $offset + $maxRecords) { $gBitSmarty->assign('next_offset', $offset + $maxRecords); } else { $gBitSmarty->assign('next_offset', -1); } // If offset is > 0 then prev_offset if ($offset > 0) { $gBitSmarty->assign('prev_offset', $offset - $maxRecords); } else { $gBitSmarty->assign('prev_offset', -1); } $gBitSmarty->assign_by_ref('polls', $polls["data"]);
/** * required setup */ require_once '../kernel/setup_inc.php'; include_once POLLS_PKG_PATH . 'poll_lib.php'; $gBitSystem->verifyPackage('polls'); $gBitSystem->verifyPermission('bit_p_view_polls'); if (!isset($polllib)) { $polllib = new PollLib(); } if (!isset($_REQUEST["poll_id"])) { $gBitSystem->fatalError(tra("No poll indicated")); } $poll_info = $polllib->get_poll($_REQUEST["poll_id"]); $polls = $polllib->list_active_polls(0, -1, 'publish_date_desc', ''); $options = $polllib->list_poll_options($_REQUEST["poll_id"], 0, -1, 'option_id_asc', ''); for ($i = 0; $i < count($options["data"]); $i++) { if ($poll_info["votes"] == 0) { $percent = 0; } else { $percent = number_format($options["data"][$i]["votes"] * 100 / $poll_info["votes"], 2); $options["data"][$i]["percent"] = $percent; } $width = $percent * 200 / 100; $options["data"][$i]["width"] = $percent; } // Poll comments if ($gBitSystem->isFeatureActive('poll_comments')) { /* TODO - To fix $comments_per_page = $poll_comments_per_page;