table_forum_forumfield.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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: table_forum_forumfield.php 32916 2013-03-22 08:51:36Z zhangjie $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_forum_forumfield extends discuz_table
  12. {
  13. public function __construct() {
  14. $this->_table = 'forum_forumfield';
  15. $this->_pk = 'fid';
  16. parent::__construct();
  17. }
  18. public function fetch_all_by_fid($fids) {
  19. $fids = array_map('intval', (array)$fids);
  20. if(!empty($fids)) {
  21. return DB::fetch_all("SELECT * FROM %t WHERE fid IN(%n)", array($this->_table, $fids), $this->_pk);
  22. } else {
  23. return array();
  24. }
  25. }
  26. public function fetch_all_field_perm() {
  27. return DB::fetch_all("SELECT fid, viewperm, postperm, replyperm, getattachperm, postattachperm, postimageperm FROM ".DB::table($this->_table)." WHERE founderuid=0");
  28. }
  29. public function fetch_all_forum() {
  30. return DB::fetch_all("SELECT * FROM ".DB::table($this->_table));
  31. }
  32. public function fetch_groupnum_by_founderuid($uid) {
  33. if(empty($uid)) {
  34. return false;
  35. }
  36. return DB::result_first("SELECT COUNT(*) FROM ".DB::table($this->_table)." WHERE founderuid=%d", array($uid));
  37. }
  38. public function update_groupnum($fid, $num) {
  39. if(!intval($fid) || !intval($num)) {
  40. return false;
  41. }
  42. DB::query("UPDATE %t SET ".DB::field('groupnum', $num, '+')." WHERE fid=%d", array('forum_forumfield', $fid));
  43. }
  44. public function update_membernum($fid, $num = 1) {
  45. if(!intval($fid) || !intval($num)) {
  46. return false;
  47. }
  48. DB::query("UPDATE %t SET ".DB::field('membernum', $num, '+')." WHERE fid=%d", array('forum_forumfield', $fid));
  49. }
  50. public function fetch_info_for_attach($fid, $uid) {
  51. return DB::fetch_first("SELECT f.fid, f.viewperm, f.getattachperm, a.allowgetattach, a.allowgetimage FROM %t f LEFT JOIN %t a ON a.uid=%d AND a.fid=f.fid WHERE f.fid=%d", array('forum_forumfield', 'forum_access', $uid, $fid));
  52. }
  53. public function check_moderator_for_uid($fid, $uid, $accessmasks = 0) {
  54. if(!intval($fid) || !intval($uid)) {
  55. return false;
  56. }
  57. if($accessmasks) {
  58. $accessadd1 = ', a.allowview, a.allowpost, a.allowreply, a.allowgetattach, a.allowgetimage, a.allowpostattach';
  59. $accessadd2 = "LEFT JOIN ".DB::table('forum_access')." a ON a.".DB::field('uid', $uid)." AND a.".DB::field('fid', $fid);
  60. }
  61. return DB::fetch_first("SELECT ff.postperm, m.uid AS istargetmod $accessadd1
  62. FROM ".DB::table($this->_table)." ff
  63. $accessadd2
  64. LEFT JOIN ".DB::table('forum_moderator')." m ON m.fid=%d AND m.uid=%d
  65. WHERE ff.fid=%d", array($fid, $uid, $fid));
  66. }
  67. }
  68. ?>