mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 13:54:02 -07:00
Moved poll functions to Poll class (#739)
This commit is contained in:
parent
22fbae61db
commit
d2588855fa
4 changed files with 53 additions and 43 deletions
|
@ -1574,45 +1574,6 @@ function build_topic_pagination($url, $replies, $per_page)
|
|||
return $pg;
|
||||
}
|
||||
|
||||
//
|
||||
// Poll
|
||||
//
|
||||
function get_poll_data_items_js($topic_id)
|
||||
{
|
||||
if (!$topic_id_csv = get_id_csv($topic_id)) {
|
||||
return is_array($topic_id) ? array() : false;
|
||||
}
|
||||
$items = array();
|
||||
|
||||
if (!$poll_data = CACHE('bb_poll_data')->get("poll_$topic_id")) {
|
||||
$poll_data = DB()->fetch_rowset("
|
||||
SELECT topic_id, vote_id, vote_text, vote_result
|
||||
FROM " . BB_POLL_VOTES . "
|
||||
WHERE topic_id IN($topic_id_csv)
|
||||
ORDER BY topic_id, vote_id
|
||||
");
|
||||
CACHE('bb_poll_data')->set("poll_$topic_id", $poll_data);
|
||||
}
|
||||
|
||||
foreach ($poll_data as $row) {
|
||||
$opt_text_for_js = htmlCHR($row['vote_text']);
|
||||
$opt_result_for_js = (int)$row['vote_result'];
|
||||
|
||||
$items[$row['topic_id']][$row['vote_id']] = array($opt_text_for_js, $opt_result_for_js);
|
||||
}
|
||||
foreach ($items as $k => $v) {
|
||||
$items[$k] = json_encode($v, JSON_THROW_ON_ERROR);
|
||||
}
|
||||
|
||||
return is_array($topic_id) ? $items : $items[$topic_id];
|
||||
}
|
||||
|
||||
function poll_is_active($t_data)
|
||||
{
|
||||
global $bb_cfg;
|
||||
return ($t_data['topic_vote'] == 1 && $t_data['topic_time'] > TIMENOW - $bb_cfg['poll_max_days'] * 86400);
|
||||
}
|
||||
|
||||
function print_confirmation($tpl_vars)
|
||||
{
|
||||
global $template, $lang;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue