找回密码
 注册加入

扫一扫,极速登录

QQ登录

只需一步,快速开始

搜索
查看: 6322|回复: 2

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

[复制链接]
发表于 2011-9-6 11:29:48 | 显示全部楼层 |阅读模式
修改Discuz X2投票统计结果,添加一项也是默认项为所有所有投票参与人。方便可多选的投票项目查看所有参与会员。

默认如图:

                               
登录/注册后可看大图

修改后效果图:

                               
登录/注册后可看大图



方法:
修改文件source\module\forum\ forum_misc.php的479-520行代码
  1. require_once libfile('function/post');
  2. $polloptionid = is_numeric($_G['gp_polloptionid']) ? $_G['gp_polloptionid'] : '';

  3. $page = intval($_GET['page']) ? intval($_GET['page']) : 1;
  4. $perpage = 100;

  5. $overt = DB::result_first("SELECT overt FROM ".DB::table('forum_poll')." WHERE tid='$_G[tid]'");

  6. $polloptions = array();
  7. $query = DB::query("SELECT polloptionid, polloption FROM ".DB::table('forum_polloption')." WHERE tid='$_G[tid]'");
  8. while($options = DB::fetch($query)) {
  9. if(empty($polloptionid)) {
  10. $polloptionid = $options['polloptionid'];
  11. }
  12. $options['polloption'] = preg_replace("/\[url=(https?){1}:\/\/([^\["']+?)\](.+?)\[\/url\]/i",
  13. "<a href="\\1://\\2" target="_blank">\\3</a>", $options['polloption']);
  14. $polloptions[] = $options;
  15. }

  16. $arrvoterids = array();
  17. if($overt || $_G['adminid'] == 1 || $thread['authorid'] == $_G['uid']) {
  18. $voterids = '';
  19. $voterids = DB::result_first("SELECT voterids FROM ".DB::table('forum_polloption')." WHERE polloptionid='$polloptionid'");
  20. $arrvoterids = explode("\t", trim($voterids));
  21. } else {
  22. showmessage('thread_poll_nopermission');
  23. }

  24. if(!empty($arrvoterids)) {
  25. $count = count($arrvoterids);
  26. $multi = $perpage * ($page - 1);
  27. $multipage = multi($count, $perpage, $page, "forum.php?mod=misc&action=viewvote&tid=$_G[tid]&polloptionid=$polloptionid".( $_G[gp_handlekey] ? "&handlekey=".$_G[gp_handlekey] : '' ));
  28. $arrvoterids = array_slice($arrvoterids, $multi, $perpage);
  29. }
  30. $voterlist = $voter = array();
  31. if($voterids = dimplode($arrvoterids)) {
  32. $query = DB::query("SELECT uid, username FROM ".DB::table('common_member')." WHERE uid IN ($voterids)");
  33. while($voter = DB::fetch($query)) {
  34. $voterlist[] = $voter;
  35. }
  36. }
  37. include template('forum/viewthread_poll_voter');
复制代码
替换为
  1.   require_once libfile('function/post');
  2. $polloptionid = is_numeric($_G['gp_polloptionid']) ? $_G['gp_polloptionid'] : '0';
  3. $page = intval($_GET['page']) ? intval($_GET['page']) : 1;
  4. $perpage = 100;
  5. $overt = DB::result_first("SELECT overt FROM ".DB::table('forum_poll')." WHERE tid='$_G[tid]'");
  6. $polloptions = array();
  7.   $options['polloptionid'] = 0;
  8.   $options['polloption'] = preg_replace("/\[url=(https?){1}:\/\/([^\["']+?)\](.+?)\[\/url\]/i",
  9.    "<a href="\\1://\\2" target="_blank">\\3</a>", "all user");
  10.   $polloptions[] = $options;
  11. $query = DB::query("SELECT polloptionid, polloption FROM ".DB::table('forum_polloption')." WHERE tid='$_G[tid]'");
  12. while($options = DB::fetch($query)) {
  13.   $options['polloption'] = preg_replace("/\[url=(https?){1}:\/\/([^\["']+?)\](.+?)\[\/url\]/i",
  14.    "<a href="\\1://\\2" target="_blank">\\3</a>", $options['polloption']);
  15.   $polloptions[] = $options;
  16. }
  17. $arrvoterids = array();
  18. if($overt || $_G['adminid'] == 1 || $thread['authorid'] == $_G['uid']) {
  19.   if($polloptionid == '0'){
  20.    $voterids = DB::query("SELECT uid FROM ".DB::table('forum_pollvoter')." WHERE tid='$_G[tid]' order by uid");
  21.    while($voteuid = DB::fetch($voterids)) {
  22.     $arrvoterids[] = $voteuid['uid'];
  23.    }
  24.   }else{
  25.    $voterids = '';
  26.    $voterids = DB::result_first("SELECT voterids FROM ".DB::table('forum_polloption')." WHERE polloptionid='$polloptionid'");
  27.    $arrvoterids = explode("\t", trim($voterids));
  28.   }
  29. } else {
  30.   showmessage('thread_poll_nopermission');
  31. }
  32. if(!empty($arrvoterids)) {
  33.   $count = count($arrvoterids);
  34.   $multi = $perpage * ($page - 1);
  35.   $multipage = multi($count, $perpage, $page, "forum.php?mod=misc&action=viewvote&tid=$_G[tid]&polloptionid=$polloptionid".( $_G[gp_handlekey] ? "&handlekey=".$_G[gp_handlekey] : '' ));
  36.   $arrvoterids = array_slice($arrvoterids, $multi, $perpage);
  37. }
  38. $voterlist = $voter = array();
  39. if($voterids = dimplode($arrvoterids)) {
  40.   $query = DB::query("SELECT uid, username FROM ".DB::table('common_member')." WHERE uid IN ($voterids)");
  41.   while($voter = DB::fetch($query)) {
  42.    $voterlist[] = $voter;
  43.   }
  44. }
  45. include template('forum/viewthread_poll_voter');
复制代码







发表于 2011-9-28 22:24:09 | 显示全部楼层
谢谢湖老大
回复 支持 反对

使用道具 举报

发表于 2011-10-10 09:38:46 | 显示全部楼层
按照上述代码改完后,出现下面的问题,
选好选项,点击提交时,无法自动刷新,必须按下F5,才能更新投票效果。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册加入  

本版积分规则

Archiver|手机版|小黑屋|Discuz!扩展中心 ( 浙ICP备14042422号-1 )|网站地图QQ机器人

GMT+8, 2024-4-29 13:04 , Processed in 0.169349 second(s), 13 queries , Gzip On, Redis On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表