misc_forumselect.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: misc_forumselect.php 34303 2014-01-15 04:32:19Z hypowang $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. if(!isset($_G['cache']['forums'])) {
  12. loadcache('forums');
  13. }
  14. $grouplist = $commonlist = '';
  15. $special = isset($_GET['special']) ? intval($_GET['special']) : null;
  16. $forumlist = $subforumlist = array();
  17. $i = array();
  18. if(!$special) {
  19. $commonfids = explode('D', $_G['cookie']['visitedfid']);
  20. foreach($commonfids as $k => $fid) {
  21. if($_G['cache']['forums'][$fid]['type'] == 'sub') {
  22. $commonfids[] = $_G['cache']['forums'][$fid]['fup'];
  23. unset($commonfids[$k]);
  24. }
  25. }
  26. $commonfids = array_unique($commonfids);
  27. foreach($commonfids as $fid) {
  28. $fid = intval($fid);
  29. $commonlist .= '<li fid="'.$fid.'">'.$_G['cache']['forums'][$fid]['name'].'</li>';
  30. }
  31. }
  32. foreach($_G['cache']['forums'] as $forum) {
  33. if(!$forum['status'] || $forum['status'] == 2) {
  34. continue;
  35. }
  36. if($forum['type'] != 'group' && $special !== null) {
  37. $allow = false;
  38. if(!$forum['postperm'] || $forum['postperm'] && forumperm($forum['postperm'])) {
  39. if($special == 1) {
  40. $allow = $_G['group']['allowpostpoll'] && substr($forum['allowpostspecial'], -1, 1);
  41. } elseif($special == 2) {
  42. $allow = $_G['group']['allowposttrade'] && substr($forum['allowpostspecial'], -2, 1);
  43. } elseif($special == 3) {
  44. $allow = $_G['group']['allowpostreward'] && isset($_G['setting']['extcredits'][$_G['setting']['creditstransextra'][2]]) && substr($forum['allowpostspecial'], -3, 1);
  45. } elseif($special == 4) {
  46. $allow = $_G['group']['allowpostactivity'] && substr($forum['allowpostspecial'], -4, 1);
  47. } elseif($special == 5) {
  48. $allow = $_G['group']['allowpostdebate'] && substr($forum['allowpostspecial'], -5, 1);
  49. } else {
  50. $allow = true;
  51. $special = 0;
  52. }
  53. }
  54. if(!$allow) {
  55. continue;
  56. }
  57. }
  58. if($forum['type'] == 'group') {
  59. $grouplist .= '<li fid="'.$forum['fid'].'">'.$forum['name'].'</li>';
  60. $visible[$forum['fid']] = true;
  61. } elseif($forum['type'] == 'forum' && isset($visible[$forum['fup']]) && (!$forum['viewperm'] || ($forum['viewperm'] && forumperm($forum['viewperm'])) || strstr($forum['users'], "\t$_G[uid]\t"))) {
  62. $forumlist[$forum['fup']] .= '<li fid="'.$forum['fid'].'">'.$forum['name'].'</li>';
  63. $visible[$forum['fid']] = true;
  64. } elseif($forum['type'] == 'sub' && isset($visible[$forum['fup']]) && (!$forum['viewperm'] || ($forum['viewperm'] && forumperm($forum['viewperm'])) || strstr($forum['users'], "\t$_G[uid]\t"))) {
  65. $subforumlist[$forum['fup']] .= '<li fid="'.$forum['fid'].'">'.$forum['name'].'</li>';
  66. }
  67. }
  68. include template('forum/post_forumselect');
  69. exit;
  70. ?>