table_common_moderate.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514
  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_common_moderate.php 31513 2012-09-04 08:47:57Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ')) {
  9. exit('Access Denied');
  10. }
  11. class table_common_moderate extends discuz_table
  12. {
  13. var $_tables = array();
  14. public function __construct() {
  15. $this->_table = '';
  16. $this->_pk = '';
  17. $this->_tables = array(
  18. 'tid' => 'forum_thread_moderate',
  19. 'pid' => 'forum_post_moderate',
  20. 'blogid' => 'home_blog_moderate',
  21. 'picid' => 'home_pic_moderate',
  22. 'doid' => 'home_doing_moderate',
  23. 'sid' => 'home_share_moderate',
  24. 'aid' => 'portal_article_moderate',
  25. 'aid_cid' => 'portal_comment_moderate',
  26. 'topicid_cid' => 'portal_comment_moderate',
  27. 'uid_cid' => 'home_comment_moderate',
  28. 'blogid_cid' => 'home_comment_moderate',
  29. 'sid_cid' => 'home_comment_moderate',
  30. 'picid_cid' => 'home_comment_moderate',
  31. );
  32. parent::__construct();
  33. }
  34. private function _get_table($idtype) {
  35. return $this->_tables[$idtype];
  36. }
  37. private function _is_comment_table($idtype) {
  38. return in_array($this->_get_table($idtype), array('portal_comment_moderate', 'home_comment_moderate'));
  39. }
  40. public function count_by_idtype($idtype, $status = 0, $dateline = 0) {
  41. return $this->query_data(1, $idtype, $status, $dateline);
  42. }
  43. public function fetch_all_by_idtype($idtype, $status = 0, $dateline = 0) {
  44. return $this->query_data(0, $idtype, $status, $dateline);
  45. }
  46. private function query_data($type, $idtype, $status = 0, $dateline = 0) {
  47. if(!isset($this->_tables[$idtype])) {
  48. return $type ? 0 : array();
  49. }
  50. $parameter = array($this->_get_table($idtype), $this->_is_comment_table($idtype) ? "idtype='$idtype' AND" : '', $status);
  51. $othersql = '';
  52. if($dateline) {
  53. $othersql = " AND dateline>=%d";
  54. $parameter[] = $dateline;
  55. }
  56. if($type) {
  57. return DB::result_first("SELECT COUNT(*) FROM %t WHERE %i `status`=%d $othersql ORDER BY dateline DESC", $parameter);
  58. } else {
  59. return DB::fetch_all("SELECT * FROM %t WHERE %i `status`=%d $othersql ORDER BY dateline DESC", $parameter, 'id');
  60. }
  61. }
  62. public function fetch_all_for_article($status, $catid = 0, $username = '', $dateline = 'all', $count = 0, $start = 0, $limit = 0) {
  63. $sqlwhere = '';
  64. $status = dintval($status);
  65. if(($catid = dintval($catid))) {
  66. $sqlwhere .= " AND a.catid='$catid'";
  67. }
  68. if(!empty($username)) {
  69. $sqlwhere .= " AND a.username='".addslashes($username)."'";
  70. }
  71. if($dateline != 'all') {
  72. $sqlwhere .= " AND a.dateline>'".(TIMESTAMP - dintval($dateline))."'";
  73. }
  74. if($count) {
  75. return DB::result_first("SELECT COUNT(*)
  76. FROM ".DB::table('portal_article_moderate')." m
  77. LEFT JOIN ".DB::table('portal_article_title')." a ON a.aid=m.id
  78. WHERE m.status='$status' $sqlwhere");
  79. }
  80. return DB::fetch_all("SELECT a.aid, a.catid, a.uid, a.username, a.title, a.summary, a.dateline, cat.catname
  81. FROM ".DB::table('portal_article_moderate')." m
  82. LEFT JOIN ".DB::table('portal_article_title')." a ON a.aid=m.id
  83. LEFT JOIN ".DB::table('portal_category')." cat ON cat.catid=a.catid
  84. WHERE m.status='$status' $sqlwhere
  85. ORDER BY m.dateline DESC".DB::limit($start, $limit));
  86. }
  87. public function fetch_all_for_portalcomment($idtype, $tablename, $status, $catid = 0, $username = '', $dateline = 'all', $count = 0, $keyword = '', $start = 0, $limit = 0) {
  88. if(!isset($this->_tables[$idtype.'_cid'])) {
  89. return $count ? 0 : array();
  90. }
  91. if(!empty($catid)) {
  92. $sqlwhere .= " AND a.catid='$catid'";
  93. }
  94. if(!empty($username)) {
  95. $sqlwhere .= " AND a.username='$username'";
  96. }
  97. if($dateline != 'all') {
  98. $sqlwhere .= " AND a.dateline>'".(TIMESTAMP - $dateline)."'";
  99. }
  100. if(!empty($keyword)) {
  101. $sqlwhere .= " AND c.message LIKE '%$keyword%'";
  102. }
  103. $sqlwhere .= "AND c.idtype='$idtype'";
  104. if($count) {
  105. return DB::result_first("SELECT COUNT(*)
  106. FROM ".DB::table($this->_get_table($idtype.'_cid'))." m
  107. LEFT JOIN ".DB::table('portal_comment')." c ON c.cid=m.id
  108. LEFT JOIN ".DB::table($tablename)." a ON a.$idtype=c.id
  109. WHERE m.".DB::field('idtype', $idtype.'_cid')." AND m.status='$status' $sqlwhere");
  110. }
  111. return DB::fetch_all("SELECT c.cid, c.uid, c.username, c.id, c.postip, c.dateline, c.message, a.title
  112. FROM ".DB::table($this->_get_table($idtype.'_cid'))." m
  113. LEFT JOIN ".DB::table('portal_comment')." c ON c.cid=m.id
  114. LEFT JOIN ".DB::table($tablename)." a ON a.$idtype=c.id
  115. WHERE m.".DB::field('idtype', $idtype.'_cid')." AND m.status='$status' $sqlwhere
  116. ORDER BY m.dateline DESC".DB::limit($start, $limit));
  117. }
  118. public function count_group_idtype_by_status($status) {
  119. $return = array();
  120. foreach($this->_tables as $idtype => $table) {
  121. if($this->_is_comment_table($idtype)) {
  122. $return[] = array('idtype' => $idtype, 'count' => DB::result_first('SELECT COUNT(*) FROM %t WHERE idtype=%s AND status=%d', array($table, $idtype, $status)));
  123. } else {
  124. $return[] = array('idtype' => $idtype, 'count' => DB::result_first('SELECT COUNT(*) FROM %t WHERE status=%d', array($table, $status)));
  125. }
  126. }
  127. return $return;
  128. }
  129. public function delete($id, $idtype, $unbuffered = false) {
  130. if(!isset($this->_tables[$idtype])) {
  131. return false;
  132. }
  133. $table = $this->_get_table($idtype);
  134. $wheresql = array();
  135. $id && $wheresql[] = DB::field('id', $id);
  136. $this->_is_comment_table($idtype) && $wheresql[] = DB::field('idtype', $idtype);
  137. return DB::delete($table, implode(' AND ', $wheresql), 0, $unbuffered);
  138. }
  139. public function insert($idtype, $data, $return_insert_id = false, $replace = false, $silent = false) {
  140. if(!isset($this->_tables[$idtype]) || empty($data)) {
  141. return false;
  142. }
  143. $table = $this->_get_table($idtype);
  144. $this->_is_comment_table($idtype) && $data['idtype'] = $idtype;
  145. return DB::insert($table, $data, $return_insert_id, $replace, $silent);
  146. }
  147. public function update($id, $idtype, $data, $unbuffered = false, $low_priority = false) {
  148. if(!isset($this->_tables[$idtype]) || empty($data)) {
  149. return false;
  150. }
  151. $table = $this->_get_table($idtype);
  152. $wheresql = array();
  153. $id && $wheresql[] = DB::field('id', $id);
  154. $this->_is_comment_table($idtype) && $wheresql[] = DB::field('idtype', $idtype);
  155. return DB::update($table, $data, implode(' AND ', $wheresql), $unbuffered, $low_priority);
  156. }
  157. public function count_by_idtype_status_fid($idtype, $status, $fids) {
  158. if($idtype == 'tid') {
  159. $innertable = 'forum_thread';
  160. } elseif($idtype == 'pid') {
  161. $innertable = 'forum_post';
  162. } else {
  163. return 0;
  164. }
  165. return DB::result_first('SELECT COUNT(*) FROM %t m INNER JOIN %t t ON m.id=t.%i AND t.'.DB::field('fid', $fids).' WHERE m.status=%d',
  166. array($this->_get_table($idtype), $innertable, $idtype, $status));
  167. }
  168. public function count_by_search_for_post($posttable, $status = null, $first = null, $fids = null, $author = null, $dateline = null, $subject = null) {
  169. $wheresql = array();
  170. if($status !== null) {
  171. $wheresql[] = 'm.'.DB::field('status', $status);
  172. }
  173. if($first !== null) {
  174. $wheresql[] = 'p.'.DB::field('first', $first);
  175. }
  176. if($fids) {
  177. $wheresql[] = 'p.'.DB::field('fid', $fids);
  178. }
  179. if($author) {
  180. $wheresql[] = 'p.'.DB::field('author', $author);
  181. }
  182. if($dateline) {
  183. $wheresql[] = 'p.'.DB::field('dateline', $dateline, '>');
  184. }
  185. if($subject) {
  186. $wheresql[] = 'p.'.DB::field('message', '%'.$subject.'%', 'like');
  187. }
  188. return DB::result_first('SELECT COUNT(*) FROM %t m LEFT JOIN %t p ON p.pid=m.id WHERE %i',
  189. array($this->_get_table('pid'), $posttable, implode(' AND ', $wheresql)));
  190. }
  191. public function fetch_all_by_search_for_post($posttable, $status = null, $first = null, $fids = null, $author = null, $dateline = null, $subject = null, $start = 0, $limit = 0) {
  192. $wheresql = array();
  193. if($status !== null) {
  194. $wheresql[] = 'm.'.DB::field('status', $status);
  195. }
  196. if($first !== null) {
  197. $wheresql[] = 'p.'.DB::field('first', $first);
  198. }
  199. if($fids) {
  200. $wheresql[] = 'p.'.DB::field('fid', $fids);
  201. }
  202. if($author) {
  203. $wheresql[] = 'p.'.DB::field('author', $author);
  204. }
  205. if($dateline) {
  206. $wheresql[] = 'p.'.DB::field('dateline', $dateline, '>');
  207. }
  208. if($subject) {
  209. $wheresql[] = 'p.'.DB::field('message', '%'.$subject.'%', 'like');
  210. }
  211. return DB::fetch_all('SELECT p.pid, p.fid, p.tid,
  212. p.author, p.authorid, p.subject, p.dateline, p.message, p.useip, p.attachment, p.htmlon, p.smileyoff, p.bbcodeoff, p.status
  213. FROM %t m
  214. LEFT JOIN %t p on p.pid=m.id
  215. WHERE %i
  216. ORDER BY m.dateline DESC '.DB::limit($start, $limit),
  217. array($this->_get_table('pid'), $posttable, implode(' AND ', $wheresql)));
  218. }
  219. public function count_by_seach_for_thread($status = null, $fids = null) {
  220. $wheresql = array();
  221. if($status !== null) {
  222. $wheresql[] = 'm.'.DB::field('status', $status);
  223. }
  224. if($fids) {
  225. $wheresql[] = 't.'.DB::field('fid', $fids);
  226. }
  227. return DB::result_first('SELECT COUNT(*) FROM %t m LEFT JOIN %t t ON t.tid=m.id WHERE %i',
  228. array($this->_get_table('tid'), 'forum_thread', implode(' AND ', $wheresql)));
  229. }
  230. public function fetch_all_by_search_for_thread($status = null, $fids = null, $start = 0, $limit = 0) {
  231. $wheresql = array();
  232. if($status !== null) {
  233. $wheresql[] = 'm.'.DB::field('status', $status);
  234. }
  235. if($fids) {
  236. $wheresql[] = 't.'.DB::field('fid', $fids);
  237. }
  238. return DB::fetch_all('SELECT t.tid, t.fid, t.posttableid, t.author, t.sortid, t.authorid, t.subject as tsubject, t.dateline, t.attachment
  239. FROM %t m
  240. LEFT JOIN %t t ON t.tid=m.id
  241. WHERE %i
  242. ORDER BY m.dateline DESC '.DB::limit($start, $limit),
  243. array($this->_get_table('tid'), 'forum_thread', implode(' AND ', $wheresql)));
  244. }
  245. public function count_by_search_for_blog($status = null, $username = null, $dateline = null, $subject = null) {
  246. $wheresql = array();
  247. if($status !== null && !(is_array($status) && empty($status))) {
  248. $wheresql[] = 'm.'.DB::field('status', $status);
  249. }
  250. if($username) {
  251. $wheresql[] = 'b.'.DB::field('username', $username);
  252. }
  253. if($dateline) {
  254. $wheresql[] = 'b.'.DB::field('dateline', $dateline, '>');
  255. }
  256. if($subject) {
  257. $wheresql[] = 'b.'.DB::field('subject', '%'.$subject.'%', 'like');
  258. }
  259. return DB::result_first('SELECT COUNT(*)
  260. FROM %t m
  261. LEFT JOIN %t b ON b.blogid=m.id
  262. LEFT JOIN %t bf ON bf.blogid=b.blogid
  263. LEFT JOIN %t c ON b.classid=c.classid
  264. WHERE %i',
  265. array($this->_get_table('blogid'), 'home_blog', 'home_blogfield', 'home_class', implode(' AND ', $wheresql)));
  266. }
  267. public function fetch_all_by_search_for_blog($status = null, $username = null, $dateline = null, $subject = null, $start = 0, $limit = 0) {
  268. $wheresql = array();
  269. if($status !== null && !(is_array($status) && empty($status))) {
  270. $wheresql[] = 'm.'.DB::field('status', $status);
  271. }
  272. if($username) {
  273. $wheresql[] = 'b.'.DB::field('username', $username);
  274. }
  275. if($dateline) {
  276. $wheresql[] = 'b.'.DB::field('dateline', $dateline, '>');
  277. }
  278. if($subject) {
  279. $wheresql[] = 'b.'.DB::field('subject', '%'.$subject.'%', 'like');
  280. }
  281. return DB::fetch_all('SELECT b.blogid, b.uid, b.username, b.classid, b.subject, b.dateline, bf.message, bf.postip, c.classname
  282. FROM %t m
  283. LEFT JOIN %t b ON b.blogid=m.id
  284. LEFT JOIN %t bf ON bf.blogid=b.blogid
  285. LEFT JOIN %t c ON b.classid=c.classid
  286. WHERE %i
  287. ORDER BY m.dateline DESC '.DB::limit($start, $limit),
  288. array($this->_get_table('blogid'), 'home_blog', 'home_blogfield', 'home_class', implode(' AND ', $wheresql)));
  289. }
  290. public function count_by_search_for_commnet($idtype = null, $status = null, $author = null, $dateline = null, $message = null) {
  291. $wheresql = array();
  292. if($idtype) {
  293. $table = $this->_get_table($idtype.'_cid');
  294. $wheresql[] = 'm.'.DB::field('idtype', $idtype.'_cid');
  295. } else {
  296. $table = 'home_comment_moderate';
  297. }
  298. if($status !== null && !(is_array($status) && empty($status))) {
  299. $wheresql[] = 'm.'.DB::field('status', $status);
  300. }
  301. if($author) {
  302. $wheresql[] = 'c.'.DB::field('author', $author);
  303. }
  304. if($dateline) {
  305. $wheresql[] = 'c.'.DB::field('dateline', $dateline, '>');
  306. }
  307. if($message) {
  308. $message = str_replace(array('_', '%'), array('\_', '\%'), $message);
  309. $wheresql[] = 'c.'.DB::field('message', '%'.$message.'%', 'like');
  310. }
  311. return DB::result_first('SELECT COUNT(*) FROM %t m LEFT JOIN %t c ON c.cid=m.id WHERE %i',
  312. array($table, 'home_comment', implode(' AND ', $wheresql)));
  313. }
  314. public function fetch_all_by_search_for_comment($idtype = null, $status = null, $author = null, $dateline = null, $message = null, $start = 0, $limit = 0) {
  315. $wheresql = array();
  316. if($idtype) {
  317. $table = $this->_get_table($idtype.'_cid');
  318. $wheresql[] = 'm.'.DB::field('idtype', $idtype.'_cid');
  319. } else {
  320. $table = 'home_comment_moderate';
  321. }
  322. if($status !== null && !(is_array($status) && empty($status))) {
  323. $wheresql[] = 'm.'.DB::field('status', $status);
  324. }
  325. if($author) {
  326. $wheresql[] = 'c.'.DB::field('author', $author);
  327. }
  328. if($dateline) {
  329. $wheresql[] = 'c.'.DB::field('dateline', $dateline, '>');
  330. }
  331. if($message) {
  332. $message = str_replace(array('_', '%'), array('\_', '\%'), $message);
  333. $wheresql[] = 'c.'.DB::field('message', '%'.$message.'%', 'like');
  334. }
  335. return DB::fetch_all('SELECT c.cid, c.uid, c.id, c.idtype, c.authorid, c.author, c.message, c.dateline, c.ip
  336. FROM %t m
  337. LEFT JOIN %t c ON c.cid=m.id
  338. WHERE %i
  339. ORDER BY c.dateline DESC '.DB::limit($start, $limit),
  340. array($table, 'home_comment', implode(' AND ', $wheresql)));
  341. }
  342. public function count_by_search_for_doing($status = null, $username = null, $dateline = null, $message = null) {
  343. $wheresql = array();
  344. if($status !== null && !(is_array($status) && empty($status))) {
  345. $wheresql[] = 'm.'.DB::field('status', $status);
  346. }
  347. if($username) {
  348. $wheresql[] = 'd.'.DB::field('username', $username);
  349. }
  350. if($dateline) {
  351. $wheresql[] = 'd.'.DB::field('dateline', $dateline, '>');
  352. }
  353. if($message) {
  354. $message = str_replace(array('_', '%'), array('\_', '\%'), $message);
  355. $wheresql[] = 'd.'.DB::field('message', '%'.$message.'%', 'like');
  356. }
  357. return DB::result_first('SELECT COUNT(*)
  358. FROM %t m
  359. LEFT JOIN %t d ON d.doid=m.id
  360. WHERE %i',
  361. array($this->_get_table('doid'), 'home_doing', implode(' AND ', $wheresql)));
  362. }
  363. public function fetch_all_by_search_for_doing($status = null, $username = null, $dateline = null, $message = null, $start = 0, $limit = 0) {
  364. $wheresql = array();
  365. if($status !== null && !(is_array($status) && empty($status))) {
  366. $wheresql[] = 'm.'.DB::field('status', $status);
  367. }
  368. if($username) {
  369. $wheresql[] = 'd.'.DB::field('username', $username);
  370. }
  371. if($dateline) {
  372. $wheresql[] = 'd.'.DB::field('dateline', $dateline, '>');
  373. }
  374. if($message) {
  375. $message = str_replace(array('_', '%'), array('\_', '\%'), $message);
  376. $wheresql[] = 'd.'.DB::field('message', '%'.$message.'%', 'like');
  377. }
  378. return DB::fetch_all('SELECT d.doid, d.uid, d.username, d.dateline, d.message, d.ip
  379. FROM %t m
  380. LEFT JOIN %t d ON d.doid=m.id
  381. WHERE %i
  382. ORDER BY m.dateline DESC '.DB::limit($start, $limit),
  383. array($this->_get_table('doid'), 'home_doing', implode(' AND ', $wheresql)));
  384. }
  385. public function count_by_search_for_pic($status = null, $username = null, $dateline = null, $title = null) {
  386. $wheresql = array();
  387. if($status !== null && !(is_array($status) && empty($status))) {
  388. $wheresql[] = 'm.'.DB::field('status', $status);
  389. }
  390. if($username) {
  391. $wheresql[] = 'p.'.DB::field('username', $username);
  392. }
  393. if($dateline) {
  394. $wheresql[] = 'p.'.DB::field('dateline', $dateline, '>');
  395. }
  396. if($title) {
  397. $wheresql[] = 'p.'.DB::field('title', '%'.$title.'%', 'like');
  398. }
  399. return DB::result_first('SELECT COUNT(*)
  400. FROM %t m
  401. LEFT JOIN %t p ON p.picid=m.id
  402. WHERE %i',
  403. array($this->_get_table('picid'), 'home_pic', implode(' AND ', $wheresql)));
  404. }
  405. public function fetch_all_by_search_for_pic($status = null, $username = null, $dateline = null, $title = null, $start = 0, $limit = 0) {
  406. $wheresql = array();
  407. if($status !== null && !(is_array($status) && empty($status))) {
  408. $wheresql[] = 'm.'.DB::field('status', $status);
  409. }
  410. if($username) {
  411. $wheresql[] = 'p.'.DB::field('username', $username);
  412. }
  413. if($dateline) {
  414. $wheresql[] = 'p.'.DB::field('dateline', $dateline, '>');
  415. }
  416. if($title) {
  417. $wheresql[] = 'p.'.DB::field('title', '%'.$title.'%', 'like');
  418. }
  419. return DB::fetch_all('SELECT p.picid, p.albumid, p.uid, p.username, p.title, p.dateline, p.filepath, p.thumb, p.remote, p.postip, a.albumname
  420. FROM %t m
  421. LEFT JOIN %t p ON p.picid=m.id
  422. LEFT JOIN %t a ON p.albumid=a.albumid
  423. WHERE %i
  424. ORDER BY m.dateline DESC '.DB::limit($start, $limit),
  425. array($this->_get_table('picid'), 'home_pic', 'home_album', implode(' AND ', $wheresql)));
  426. }
  427. public function delete_by_status_idtype($status, $idtype) {
  428. if(!isset($this->_tables[$idtype])) {
  429. return false;
  430. }
  431. $table = $this->_get_table($idtype);
  432. $idtype = $table == 'home_comment_moderate' ? DB::field('idtype', $idtype).' AND' : '';
  433. return DB::query('DELETE FROM %t WHERE %i status=%d', array($table, $idtype, $status));
  434. }
  435. public function count_by_search_for_share($status = null, $username = null, $dateline = null, $body_general = null) {
  436. $wheresql = array();
  437. if($status !== null && !(is_array($status) && empty($status))) {
  438. $wheresql[] = 'm.'.DB::field('status', $status);
  439. }
  440. if($username) {
  441. $wheresql[] = 's.'.DB::field('username', $username);
  442. }
  443. if($dateline) {
  444. $wheresql[] = 's.'.DB::field('dateline', $dateline, '>');
  445. }
  446. if($body_general) {
  447. $body_general = str_replace(array('%', '_'), array('\%', '\_'), $body_general);
  448. $wheresql[] = 's.'.DB::field('body_general', '%'.$body_general.'%', 'like');
  449. }
  450. return DB::result_first('SELECT COUNT(*)
  451. FROM %t m
  452. LEFT JOIN %t s ON s.sid=m.id
  453. WHERE %i',
  454. array($this->_get_table('sid'), 'home_share', implode(' AND ', $wheresql)));
  455. }
  456. public function fetch_all_by_search_for_share($status = null, $username = null, $dateline = null, $body_general = null, $start = 0, $limit = 0) {
  457. $wheresql = array();
  458. if($status !== null && !(is_array($status) && empty($status))) {
  459. $wheresql[] = 'm.'.DB::field('status', $status);
  460. }
  461. if($username) {
  462. $wheresql[] = 's.'.DB::field('username', $username);
  463. }
  464. if($dateline) {
  465. $wheresql[] = 's.'.DB::field('dateline', $dateline, '>');
  466. }
  467. if($body_general) {
  468. $wheresql[] = 's.'.DB::field('body_general', '%'.$body_general.'%', 'like');
  469. }
  470. return DB::fetch_all('SELECT s.sid, s.type, s.uid, s.username, s.dateline, s.body_general, s.itemid, s.fromuid
  471. FROM %t m
  472. LEFT JOIN %t s ON s.sid=m.id
  473. WHERE %i
  474. ORDER BY m.dateline DESC '.DB::limit($start, $limit),
  475. array($this->_get_table('sid'), 'home_share', implode(' AND ', $wheresql)));
  476. }
  477. }
  478. ?>