forumnav.php 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. $forum['name'] = strip_tags($forum['name']);
  33. if($forum['threadsorts']) {
  34. $forum['threadsorts'] = unserialize($forum['threadsorts']);
  35. foreach($forum['threadsorts']['types'] as $k => $v) {
  36. $forum['threadsorts']['types'][$k] = strip_tags($v);
  37. }
  38. $forum['threadsorts'] = mobile_core::getvalues($forum['threadsorts'], array('required', 'types'));
  39. }
  40. if($forum['threadtypes']) {
  41. $forum['threadtypes'] = unserialize($forum['threadtypes']);
  42. $unsetthreadtype = false;
  43. if($_G['adminid'] == 3 && strpos($forum['moderators'], $_G['username']) === false) {
  44. $unsetthreadtype = true;
  45. }
  46. if($_G['adminid'] == 0) {
  47. $unsetthreadtype = true;
  48. }
  49. if($unsetthreadtype) {
  50. foreach ($forum['threadtypes']['moderators'] AS $k => $v) {
  51. if(!empty($v)) {
  52. unset($forum['threadtypes']['types'][$k]);
  53. }
  54. }
  55. }
  56. $flag = 0;
  57. foreach($forum['threadtypes']['types'] as $k => $v) {
  58. $forum['threadtypes']['types'][$k] = strip_tags($v);
  59. if($k == 0) {
  60. $flag = 1;
  61. }
  62. }
  63. if($flag == 1) {
  64. krsort($forum['threadtypes']['types']);
  65. }
  66. $forum['threadtypes'] = mobile_core::getvalues($forum['threadtypes'], array('required', 'types'));
  67. }
  68. $forums[] = mobile_core::getvalues($forum, array('fid', 'type', 'name', 'fup', 'viewperm', 'postperm', 'status', 'threadsorts', 'threadtypes'));
  69. }
  70. }
  71. $variable['forums'] = $forums;
  72. mobile_core::result(mobile_core::variable($variable));
  73. }
  74. function output() {}
  75. }
  76. ?>