function getThreads($tIds, $isReturnPostId = true) { global $_G; $tables = array(); $infos = unserialize($_G['setting']['threadtable_info']); if ($infos) { foreach ($infos as $id => $row) { $suffix = $id ? "_{$id}" : ''; $tables[] = 'forum_thread' . $suffix; } } else { $tables = array('forum_thread'); } $tableNum = count($tables); $res = $data = $_tableInfo = array(); for ($i = 0; $i < $tableNum; $i++) { $_threads = SearchHelper::preGetThreads(DB::table($tables[$i]), $tIds); if ($_threads) { if (!$data) { $data = $_threads; } else { $data = $data + $_threads; } if (count($data) == count($tIds)) { break; } } } if ($isReturnPostId) { $threadIds = array(); foreach ($data as $tId => $thread) { $postTableId = $thread['postTableId']; $threadIds[$postTableId][] = $tId; } $threadPosts = SearchHelper::getThreadPosts($threadIds); foreach ($data as $tId => $thread) { $data[$tId]['pId'] = $threadPosts[$tId]['pId']; } } return $data; }
function _removeThreads($tIds) { global $_G; $tables = array(); $infos = unserialize($_G['setting']['threadtable_info']); if ($infos) { foreach ($infos as $id => $row) { $suffix = $id ? "_{$id}" : ''; $tables[] = 'forum_thread' . $suffix; } } else { $tables = array('forum_thread'); } $tableThreads = array(); foreach ($tables as $table) { $_threads = SearchHelper::preGetThreads(DB::table($table), $tIds); $tableThreads[$table] = $_threads; } foreach ($tableThreads as $table => $threads) { $_tids = $_threadIds = array(); foreach ($threads as $thread) { $_tids[] = $thread['tId']; $postTable = $thread['postTableId'] ? '-' . $thread['postTableId'] : ''; $_threadIds[$postTable][] = $thread['tId']; } if ($_tids) { $sql = sprintf('DELETE FROM %s WHERE tid IN (%s)', DB::table($table), implode(',', $_tids)); DB::query($sql); } if ($_threadIds) { foreach ($_threadIds as $postTable => $_tIds) { if ($_tIds) { $sql = sprintf('DELETE FROM %s WHERE tid IN (%s)', DB::table('forum_post' . $postTable), implode(',', $_tIds)); DB::query($sql); } } } } return true; }
function _removeThreads($tIds, $isRecycle = false) { $tables = SearchHelper::getTables('thread'); $tableThreads = array(); foreach ($tables as $table) { $_threads = SearchHelper::preGetThreads(DB::table($table), $tIds); $tableThreads[$table] = $_threads; } foreach ($tableThreads as $table => $threads) { $_tids = $_threadIds = array(); foreach ($threads as $thread) { $_tids[] = $thread['tId']; $postTable = $thread['postTableId'] ? '_' . $thread['postTableId'] : ''; $_threadIds[$postTable][] = $thread['tId']; } if ($_tids) { if ($isRecycle) { $sql = sprintf('UPDATE %s SET displayorder = -1 WHERE tid IN (%s)', DB::table($table), implode(',', $_tids)); DB::query($sql); continue; } $sql = sprintf('DELETE FROM %s WHERE tid IN (%s)', DB::table($table), implode(',', $_tids)); DB::query($sql); foreach ($_threadIds as $postTable => $_tIds) { if ($_tIds) { $sql = sprintf('DELETE FROM %s WHERE tid IN (%s)', DB::table('forum_post' . $postTable), implode(',', $_tIds)); DB::query($sql); } } } } return true; }