forumnav.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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: forumnav.php 34314 2014-02-20 01:04:24Z nemohou $
  7. */
  8. if(!defined('IN_MOBILE_API')) {
  9. exit('Access Denied');
  10. }
  11. include_once 'forum.php';
  12. class mobile_api {
  13. function common() {
  14. global $_G;
  15. $forums = array();
  16. $sql = !empty($_G['member']['accessmasks']) ?
  17. "SELECT f.fid, f.type, f.name, f.fup, f.status, ff.password, ff.redirect, ff.viewperm, ff.postperm, ff.threadtypes, ff.threadsorts
  18. FROM ".DB::table('forum_forum')." f
  19. LEFT JOIN ".DB::table('forum_forumfield')." ff ON ff.fid=f.fid
  20. LEFT JOIN ".DB::table('forum_access')." a ON a.uid='$_G[uid]' AND a.allowview>'0' AND a.fid=f.fid
  21. WHERE f.status='1' ORDER BY f.type, f.displayorder"
  22. : "SELECT f.fid, f.type, f.name, f.fup, f.status, ff.password, ff.redirect, ff.viewperm, ff.postperm, ff.threadtypes, ff.threadsorts
  23. FROM ".DB::table('forum_forum')." f
  24. LEFT JOIN ".DB::table('forum_forumfield')." ff USING(fid)
  25. WHERE f.status='1' ORDER BY f.type, f.displayorder";
  26. $query = DB::query($sql);
  27. while($forum = DB::fetch($query)) {
  28. if($forum['redirect'] || $forum['password']) {
  29. continue;
  30. }
  31. if(!$forum['viewperm'] || ($forum['viewperm'] && forumperm($forum['viewperm']))) {
  32. if($forum['threadsorts']) {
  33. $forum['threadsorts'] = mobile_core::getvalues(unserialize($forum['threadsorts']), array('required', 'types'));
  34. }
  35. if($forum['threadtypes']) {
  36. $forum['threadtypes'] = unserialize($forum['threadtypes']);
  37. $unsetthreadtype = false;
  38. if($_G['adminid'] == 3 && strpos($forum['moderators'], $_G['username']) === false) {
  39. $unsetthreadtype = true;
  40. }
  41. if($_G['adminid'] == 0) {
  42. $unsetthreadtype = true;
  43. }
  44. if($unsetthreadtype) {
  45. foreach ($forum['threadtypes']['moderators'] AS $k => $v) {
  46. if(!empty($v)) {
  47. unset($forum['threadtypes']['types'][$k]);
  48. }
  49. }
  50. }
  51. $flag = 0;
  52. foreach($forum['threadtypes']['types'] as $k => $v) {
  53. if($k == 0) {
  54. $flag = 1;
  55. break;
  56. }
  57. }
  58. if($flag == 1) {
  59. krsort($forum['threadtypes']['types']);
  60. }
  61. $forum['threadtypes'] = mobile_core::getvalues($forum['threadtypes'], array('required', 'types'));
  62. }
  63. $forums[] = mobile_core::getvalues($forum, array('fid', 'type', 'name', 'fup', 'viewperm', 'postperm', 'status', 'threadsorts', 'threadtypes'));
  64. }
  65. }
  66. $variable['forums'] = $forums;
  67. mobile_core::result(mobile_core::variable($variable));
  68. }
  69. function output() {}
  70. }
  71. ?>