湖中沉 发表于 2011-9-6 11:29:48

Discuz! X2投票统计查看所有投票参与人

修改Discuz X2投票统计结果,添加一项也是默认项为所有所有投票参与人。方便可多选的投票项目查看所有参与会员。

默认如图:
http://www.discuz.net/data/attachment/forum/201109/04/131314cnjcuar3zkaxjc5x.jpg.thumb.jpg
修改后效果图:
http://www.discuz.net/data/attachment/forum/201109/04/131313k57rfr428kkkfks7.jpg.thumb.jpg


方法:
修改文件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'");

$polloptions = array();
$query = DB::query("SELECT polloptionid, polloption FROM ".DB::table('forum_polloption')." WHERE tid='$_G'");
while($options = DB::fetch($query)) {
if(empty($polloptionid)) {
$polloptionid = $options['polloptionid'];
}
$options['polloption'] = preg_replace("/\+?)\](.+?)\[\/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&polloptionid=$polloptionid".( $_G ? "&handlekey=".$_G : '' ));
$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'");
$polloptions = array();
$options['polloptionid'] = 0;
$options['polloption'] = preg_replace("/\+?)\](.+?)\[\/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'");
while($options = DB::fetch($query)) {
$options['polloption'] = preg_replace("/\+?)\](.+?)\[\/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' 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&polloptionid=$polloptionid".( $_G ? "&handlekey=".$_G : '' ));
$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');






lfl 发表于 2011-9-28 22:24:09

谢谢湖老大

lfl 发表于 2011-10-10 09:38:46

按照上述代码改完后,出现下面的问题,
选好选项,点击提交时,无法自动刷新,必须按下F5,才能更新投票效果。
页: [1]
查看完整版本: Discuz! X2投票统计查看所有投票参与人