Mod Name:Additional Polls
http://custom.simplemachines.org/mods/index.php?mod=1586File Edits
./Sources/Display.phpFind:
p.question, p.voting_locked, p.hide_results, p.expire_time, p.max_votes, p.change_vote,
Replace With: [Select]
p.id_poll, p.question, p.voting_locked, p.hide_results, p.expire_time, p.max_votes, p.change_vote,
Find: [Select]
WHERE p.id_poll = {int:id_poll}
LIMIT 1',
array(
'id_poll' => $topicinfo['id_poll'],
)
Replace With: [Select]
WHERE p.id_poll = {int:id_poll} OR p.id_topic = {int:topic}
ORDER BY p.question',
array(
'id_poll' => $topicinfo['id_poll'],
'topic' => $topic,
)
Find: [Select]
$pollinfo = $smcFunc['db_fetch_assoc']($request);
$smcFunc['db_free_result']($request);
Replace With: [Select]
$pollinfo = array();
while($row = $smcFunc['db_fetch_assoc']($request)) $pollinfo[] = $row;
$smcFunc['db_free_result']($request);
foreach($pollinfo as $poll)
{
Find: [Select]
$request = $smcFunc['db_query']('', '
SELECT COUNT(DISTINCT id_member) AS total
FROM {db_prefix}log_polls
WHERE id_poll = {int:id_poll}
AND id_member != {int:not_guest}',
array(
'id_poll' => $topicinfo['id_poll'],
'not_guest' => 0,
)
);
list ($pollinfo['total']) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
// Total voters needs to include guest voters
$pollinfo['total'] += $pollinfo['num_guest_voters'];
Replace With: [Select]
$request = $smcFunc['db_query']('', '
SELECT COUNT(DISTINCT id_member) AS total
FROM {db_prefix}log_polls
WHERE id_poll = {int:id_poll}
AND id_member != {int:not_guest}',
array(
'id_poll' => $poll['id_poll'],
'not_guest' => 0,
)
);
list ($poll['total']) = $smcFunc['db_fetch_row']($request);
$smcFunc['db_free_result']($request);
// Total voters needs to include guest voters
$poll['total'] += $poll['num_guest_voters'];
Find: [Select]
'current_member' => $user_info['id'],
'id_poll' => $topicinfo['id_poll'],
Replace With: [Select]
'current_member' => $user_info['id'],
'id_poll' => $poll['id_poll'],
Find: [Select]
$pollinfo['has_voted'] = false;
Replace With: [Select]
$poll['has_voted'] = false;
Find: [Select]
$pollinfo['has_voted'] |= $row['voted_this'] != -1;
Replace With: [Select]
$poll['has_voted'] |= $row['voted_this'] != -1;
Find: [Select]
if (!empty($_COOKIE['guest_poll_vote']) && preg_match('~^[0-9,;]+$~', $_COOKIE['guest_poll_vote']) && strpos($_COOKIE['guest_poll_vote'], ';' . $topicinfo['id_poll'] . ',') !== false)
Replace With: [Select]
if (!empty($_COOKIE['guest_poll_vote']) && preg_match('~^[0-9,;]+$~', $_COOKIE['guest_poll_vote']) && strpos($_COOKIE['guest_poll_vote'], ';' . $poll['id_poll'] . ',') !== false)
Find: [Select]
if ($guestvoted[0] == $topicinfo['id_poll'])
Replace With: [Select]
if ($guestvoted[0] == $poll['id_poll'])
Find: [Select]
if ($pollinfo['reset_poll'] > $guestvoted[1])
Replace With: [Select]
if ($poll['reset_poll'] > $guestvoted[1])
Find: [Select]
$pollinfo['has_voted'] |= $pollOptions[$choice]['voted_this'] != -1;
Replace With: [Select]
$poll['has_voted'] |= $pollOptions[$choice]['voted_this'] != -1;
Find: [Select]
if ($user_info['is_guest'] && $pollinfo['guest_vote'] && allowedTo('poll_vote'))
Replace With: [Select]
if ($user_info['is_guest'] && $poll['guest_vote'] && allowedTo('poll_vote'))
Find: [Select]
'id' => $topicinfo['id_poll'],
'image' => 'normal_' . (empty($pollinfo['voting_locked']) ? 'poll' : 'locked_poll'),
'question' => parse_bbc($pollinfo['question']),
'total_votes' => $pollinfo['total'],
'change_vote' => !empty($pollinfo['change_vote']),
'is_locked' => !empty($pollinfo['voting_locked']),
'options' => array(),
'lock' => allowedTo('poll_lock_any') || ($context['user']['started'] && allowedTo('poll_lock_own')),
'edit' => allowedTo('poll_edit_any') || ($context['user']['started'] && allowedTo('poll_edit_own')),
'allowed_warning' => $pollinfo['max_votes'] > 1 ? sprintf($txt['poll_options6'], min(count($pollOptions), $pollinfo['max_votes'])) : '',
'is_expired' => !empty($pollinfo['expire_time']) && $pollinfo['expire_time'] < time(),
'expire_time' => !empty($pollinfo['expire_time']) ? timeformat($pollinfo['expire_time']) : 0,
'has_voted' => !empty($pollinfo['has_voted']),
'starter' => array(
'id' => $pollinfo['id_member'],
'name' => $row['poster_name'],
'href' => $pollinfo['id_member'] == 0 ? '' : $scripturl . '?action=profile;u=' . $pollinfo['id_member'],
'link' => $pollinfo['id_member'] == 0 ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $pollinfo['id_member'] . '">' . $row['poster_name'] . '</a>'
)
);
Replace With: [Select]
'id' => $poll['id_poll'],
'image' => 'normal_' . (empty($poll['voting_locked']) ? 'poll' : 'locked_poll'),
'question' => parse_bbc($poll['question']),
'total_votes' => $poll['total'],
'change_vote' => !empty($poll['change_vote']),
'is_locked' => !empty($poll['voting_locked']),
'options' => array(),
'lock' => allowedTo('poll_lock_any') || ($context['user']['started'] && allowedTo('poll_lock_own')),
'edit' => allowedTo('poll_edit_any') || ($context['user']['started'] && allowedTo('poll_edit_own')),
'allowed_warning' => $poll['max_votes'] > 1 ? sprintf($txt['poll_options6'], min(count($pollOptions), $poll['max_votes'])) : '',
'is_expired' => !empty($poll['expire_time']) && $poll['expire_time'] < time(),
'expire_time' => !empty($poll['expire_time']) ? timeformat($poll['expire_time']) : 0,
'has_voted' => !empty($poll['has_voted']),
'starter' => array(
'id' => $poll['id_member'],
'name' => $row['poster_name'],
'href' => $poll['id_member'] == 0 ? '' : $scripturl . '?action=profile;u=' . $poll['id_member'],
'link' => $poll['id_member'] == 0 ? $row['poster_name'] : '<a href="' . $scripturl . '?action=profile;u=' . $poll['id_member'] . '">' . $row['poster_name'] . '</a>'
)
);
Find: [Select]
$context['allow_vote'] = !$context['poll']['is_expired'] && (!$user_info['is_guest'] || ($pollinfo['guest_vote'] && allowedTo('poll_vote'))) && empty($pollinfo['voting_locked']) && allowedTo('poll_vote') && !$context['poll']['has_voted'];
Replace With: [Select]
$context['poll']['allow_vote'] = !$context['poll']['is_expired'] && (!$user_info['is_guest'] || ($poll['guest_vote'] && allowedTo('poll_vote'))) && empty($poll['voting_locked']) && allowedTo('poll_vote') && !$context['poll']['has_voted'];
Find: [Select]
$context['allow_poll_view'] = allowedTo('moderate_board') || $pollinfo['hide_results'] == 0 || ($pollinfo['hide_results'] == 1 && $context['poll']['has_voted']) || $context['poll']['is_expired'];
Replace With: [Select]
$context['poll']['allow_poll_view'] = allowedTo('moderate_board') || $poll['hide_results'] == 0 || ($poll['hide_results'] == 1 && $context['poll']['has_voted']) || $context['poll']['is_expired'];
Find: [Select]
$context['poll']['show_results'] = $context['allow_poll_view'] && (isset($_REQUEST['viewresults']) || isset($_REQUEST['viewResults']));
Replace With: [Select]
$context['poll']['show_results'] = $context['poll']['allow_poll_view'] &&(isset($_REQUEST['viewresults']) || isset($_REQUEST['viewResults'])) && $poll['id_poll'] == $_REQUEST['poll'];
Find: [Select]
$context['show_view_results_button'] = $context['allow_vote'] && $context['allow_poll_view'] && !$context['poll']['show_results'];
Replace With: [Select]
$context['poll']['show_view_results_button'] = $context['poll']['allow_vote'] && (!$context['poll']['allow_poll_view'] || !$context['poll']['show_results'] || !$context['poll']['has_voted']);
Find: [Select]
$context['allow_change_vote'] = !$context['poll']['is_expired'] && !$user_info['is_guest'] && empty($pollinfo['voting_locked']) && allowedTo('poll_vote') && $context['poll']['has_voted'] && $context['poll']['change_vote'];
Replace With: [Select]
$context['poll']['allow_change_vote'] = !$context['poll']['is_expired'] && !$user_info['is_guest'] && empty($poll['voting_locked']) && allowedTo('poll_vote') && $context['poll']['has_voted'] && $context['poll']['change_vote'];
Find: [Select]
$context['allow_return_vote'] = $context['allow_vote'] && $context['poll']['show_results'];
Replace With: [Select]
$context['poll']['allow_return_vote'] = $context['poll']['allow_vote'] && $context['poll']['show_results'];
Find: [Select]
'vote_button' => '<input type="' . ($pollinfo['max_votes'] > 1 ? 'checkbox' : 'radio') . '" name="options[]" id="options-' . $i . '" value="' . $i . '" class="input_' . ($pollinfo['max_votes'] > 1 ? 'check' : 'radio') . '" />'
Replace With: [Select]
'vote_button' => '<input type="' . ($poll['max_votes'] > 1 ? 'checkbox' : 'radio') . '" name="options[]" id="options-' . $i . '" value="' . $i . '" class="input_' . ($poll['max_votes'] > 1 ? 'check' : 'radio') . '" />'
Find: [Select]
}
// Calculate the fastest way to get the messages!
Add Before: [Select]
$context['polls'][] = $context['poll'];
unset($context['poll']);
}
Find: [Select]
$context['can_add_poll'] &= $modSettings['pollMode'] == '1' && $topicinfo['id_poll'] <= 0;
Replace With: [Select]
$context['can_add_poll'] &= $modSettings['pollMode'] == '1';