修改Discuz X2投票统计结果,添加一项也是默认项为所有所有投票参与人。方便可多选的投票项目查看所有参与会员。
默认如图:
修改后效果图:
方法:
修改文件source\module\forum\ forum_misc.php的479-520行代码 - require_once libfile('function/post');
- $polloptionid = is_numeric($_G['gp_polloptionid']) ? $_G['gp_polloptionid'] : '';
- $page = intval($_GET['page']) ? intval($_GET['page']) : 1;
- $perpage = 100;
- $overt = DB::result_first("SELECT overt FROM ".DB::table('forum_poll')." WHERE tid='$_G[tid]'");
- $polloptions = array();
- $query = DB::query("SELECT polloptionid, polloption FROM ".DB::table('forum_polloption')." WHERE tid='$_G[tid]'");
- while($options = DB::fetch($query)) {
- if(empty($polloptionid)) {
- $polloptionid = $options['polloptionid'];
- }
- $options['polloption'] = preg_replace("/\[url=(https?){1}:\/\/([^\["']+?)\](.+?)\[\/url\]/i",
- "<a href="\\1://\\2" target="_blank">\\3</a>", $options['polloption']);
- $polloptions[] = $options;
- }
- $arrvoterids = array();
- if($overt || $_G['adminid'] == 1 || $thread['authorid'] == $_G['uid']) {
- $voterids = '';
- $voterids = DB::result_first("SELECT voterids FROM ".DB::table('forum_polloption')." WHERE polloptionid='$polloptionid'");
- $arrvoterids = explode("\t", trim($voterids));
- } else {
- showmessage('thread_poll_nopermission');
- }
- if(!empty($arrvoterids)) {
- $count = count($arrvoterids);
- $multi = $perpage * ($page - 1);
- $multipage = multi($count, $perpage, $page, "forum.php?mod=misc&action=viewvote&tid=$_G[tid]&polloptionid=$polloptionid".( $_G[gp_handlekey] ? "&handlekey=".$_G[gp_handlekey] : '' ));
- $arrvoterids = array_slice($arrvoterids, $multi, $perpage);
- }
- $voterlist = $voter = array();
- if($voterids = dimplode($arrvoterids)) {
- $query = DB::query("SELECT uid, username FROM ".DB::table('common_member')." WHERE uid IN ($voterids)");
- while($voter = DB::fetch($query)) {
- $voterlist[] = $voter;
- }
- }
- include template('forum/viewthread_poll_voter');
复制代码
替换为
- require_once libfile('function/post');
- $polloptionid = is_numeric($_G['gp_polloptionid']) ? $_G['gp_polloptionid'] : '0';
- $page = intval($_GET['page']) ? intval($_GET['page']) : 1;
- $perpage = 100;
- $overt = DB::result_first("SELECT overt FROM ".DB::table('forum_poll')." WHERE tid='$_G[tid]'");
- $polloptions = array();
- $options['polloptionid'] = 0;
- $options['polloption'] = preg_replace("/\[url=(https?){1}:\/\/([^\["']+?)\](.+?)\[\/url\]/i",
- "<a href="\\1://\\2" target="_blank">\\3</a>", "all user");
- $polloptions[] = $options;
- $query = DB::query("SELECT polloptionid, polloption FROM ".DB::table('forum_polloption')." WHERE tid='$_G[tid]'");
- while($options = DB::fetch($query)) {
- $options['polloption'] = preg_replace("/\[url=(https?){1}:\/\/([^\["']+?)\](.+?)\[\/url\]/i",
- "<a href="\\1://\\2" target="_blank">\\3</a>", $options['polloption']);
- $polloptions[] = $options;
- }
- $arrvoterids = array();
- if($overt || $_G['adminid'] == 1 || $thread['authorid'] == $_G['uid']) {
- if($polloptionid == '0'){
- $voterids = DB::query("SELECT uid FROM ".DB::table('forum_pollvoter')." WHERE tid='$_G[tid]' order by uid");
- while($voteuid = DB::fetch($voterids)) {
- $arrvoterids[] = $voteuid['uid'];
- }
- }else{
- $voterids = '';
- $voterids = DB::result_first("SELECT voterids FROM ".DB::table('forum_polloption')." WHERE polloptionid='$polloptionid'");
- $arrvoterids = explode("\t", trim($voterids));
- }
- } else {
- showmessage('thread_poll_nopermission');
- }
- if(!empty($arrvoterids)) {
- $count = count($arrvoterids);
- $multi = $perpage * ($page - 1);
- $multipage = multi($count, $perpage, $page, "forum.php?mod=misc&action=viewvote&tid=$_G[tid]&polloptionid=$polloptionid".( $_G[gp_handlekey] ? "&handlekey=".$_G[gp_handlekey] : '' ));
- $arrvoterids = array_slice($arrvoterids, $multi, $perpage);
- }
- $voterlist = $voter = array();
- if($voterids = dimplode($arrvoterids)) {
- $query = DB::query("SELECT uid, username FROM ".DB::table('common_member')." WHERE uid IN ($voterids)");
- while($voter = DB::fetch($query)) {
- $voterlist[] = $voter;
- }
- }
- include template('forum/viewthread_poll_voter');
复制代码 |