Hack Name: View Poll Voters Description: This hack will do the following: - Click on a link to view who voted for what option in a Poll. Only Staff members can see this though. Compatibility: XMB 1.9.11 Version: 1.1 Author: Mouser Release Date: 2011-05-08 License Note: This mod is released under the GPL License. Give credit where credit is due. Note: For your own safety, backup the effected PHP file and template before proceeding with this hack. Administration Panel -> Insert RAW SQL ---------------------------------------------------------------------- ALTER TABLE $table_vote_voters ADD `vote_option_id` tinyint(4) unsigned NOT NULL default '0'; ---------------------------------------------------------------------- Edit PHP File: vtmisc.php Find: ---------------------------------------------------------------------- $db->query("INSERT INTO ".X_PREFIX."vote_voters (vote_id, vote_user_id, vote_user_ip) VALUES ($vote_id, {$self['uid']}, '".encode_ip($onlineip)."')"); ---------------------------------------------------------------------- Replace With: ---------------------------------------------------------------------- $db->query("INSERT INTO ".X_PREFIX."vote_voters (vote_id, vote_user_id, vote_user_ip, vote_option_id) VALUES ($vote_id, {$self['uid']}, '".encode_ip($onlineip)."', $postopnum)"); ---------------------------------------------------------------------- Edit PHP File: topicadmin.php Find: ---------------------------------------------------------------------- default: $kill = TRUE; break; ---------------------------------------------------------------------- Replace With: ---------------------------------------------------------------------- case 'poll_view': break; default: $kill = TRUE; break; ---------------------------------------------------------------------- Find: ---------------------------------------------------------------------- case 'delete': if (noSubmit('deletesubmit')) { $tid = implode(',', $tids); eval('echo "'.template('topicadmin_delete').'";'); } else { ---------------------------------------------------------------------- Replace With: ---------------------------------------------------------------------- case 'poll_view': $query = $db->query("SELECT * FROM ".X_PREFIX."vote_desc WHERE topic_id=$tid"); if ($db->num_rows($query) == 0) { error('The chosen thread contains no Poll.', FALSE); } $Poll = $db->fetch_array($query); $db->free_result($query); $dummy = 0; $num_votes = 0; $Poll_Voters = array(); $query = $db->query("SELECT v.* , m.username " . "FROM ".X_PREFIX."vote_voters v " . "LEFT JOIN ".X_PREFIX."members AS m ON v.vote_user_id = m.uid " . "WHERE v.vote_id = ".$Poll['vote_id']." ORDER BY m.username"); while($result = $db->fetch_array($query)) { $opt_id = $result['vote_option_id']; $dummy += $opt_id; $Poll_Voters[$opt_id][] = $result['username']; $num_votes += 1; } if ( $dummy == 0 ) { message('This option does not exist for this Poll.', false, '', '', false, true, false, true); } echo '
'; $query = $db->query("SELECT * FROM ".X_PREFIX."vote_results WHERE vote_id=".$Poll['vote_id']." ORDER BY vote_option_id ASC"); while($Pollres = $db->fetch_array($query)) { $opt_id = $Pollres['vote_option_id']; $orig = round($Pollres['vote_result']/$num_votes*100, 2); $percentage = round($orig, 2); $percentage .= '%'; echo ''; echo ''; } echo '
'.rawHTMLsubject(stripslashes($Poll['vote_text'])).'
'.postify($Pollres['vote_option_text'], 'no', 'no', 'yes', 'no', 'yes', 'yes').'           ('.$Pollres['vote_result'].') ('.$percentage.')
'; if ( $Pollres['vote_result'] > 0 ) { $pre = ''; foreach ($Poll_Voters[$opt_id] as $username) { echo $pre.''.$username.''; $pre = ', '; } } else { echo 'N/A'; } echo '
'; break; case 'delete': if (noSubmit('deletesubmit')) { $tid = implode(',', $tids); eval('echo "'.template('topicadmin_delete').'";'); } else { ---------------------------------------------------------------------- Edit PHP File: viewthread.php Find: ---------------------------------------------------------------------- if ($vote_id > 0) { if (X_MEMBER) { ---------------------------------------------------------------------- Replace With: ---------------------------------------------------------------------- $view_voters = ''; if ($vote_id > 0) { if (X_MEMBER) { if ('Moderator' == $status1) { $view_voters = '[Admin]'; } ---------------------------------------------------------------------- Edit Template : viewthread_poll Find: ---------------------------------------------------------------------- $results ---------------------------------------------------------------------- Replace With: ---------------------------------------------------------------------- $results $view_voters ----------------------------------------------------------------------