public function onSearchGetAllThreads($num, $tId = 0, $orderType = 'ASC') { $orderType = strtoupper($orderType); $res = $data = $_tableInfo = array(); $minTid = $maxTid = 0; foreach (Cloud_Service_SearchHelper::getTables('thread') as $tableid) { $_threads = $this->_getAllThreads($tableid, $num, $tId, $orderType); if ($_threads['data']) { if (!$data) { $data = $_threads['data']; } else { $data = $data + $_threads['data']; } } if ($orderType == 'DESC') { if (!$minTid) { $minTid = $_threads['minTid']; } if ($minTid > $_threads['minTid']) { $minTid = $_threads['minTid']; } $_tableInfo['minTids'][] = array('current_index' => $i, 'minTid' => $_threads['minTid']); } else { if ($maxTid < $_threads['maxTid']) { $maxTid = $_threads['maxTid']; } $_tableInfo['maxTids'][] = array('current_index' => $i, 'maxTid' => $_threads['maxTid']); } } $_threadNum = 0; if ($orderType == 'DESC') { if ($minTid) { krsort($data); foreach ($data as $k => $v) { $_threadNum++; $res['minTid'] = $k; $res['data'][$k] = $v; if ($_threadNum == $num) { break; } } if (!$res['minTid']) { $res['minTid'] = $minTid; } } } else { if ($maxTid) { ksort($data); foreach ($data as $k => $v) { $_threadNum++; $res['data'][$k] = $v; $res['maxTid'] = $k; if ($_threadNum == $num) { break; } } if (!$res['maxTid']) { $res['maxTid'] = $maxTid; } } } if ($res['data']) { $_tableInfo['tables'] = $tables; $_tIds = array(); $authors = $gfIds = array(); foreach ($res['data'] as $tId => $thread) { $_tIds[$thread['postTableId']][] = $tId; $authors[$thread['authorId']][] = $thread['tId']; if ($thread['isGroup']) { $gfIds[$thread['fId']] = $thread['fId']; } } if ($_tIds) { $guestPerm = Cloud_Service_SearchHelper::getGuestPerm($gfIds); // GuestPerm $threadPosts = Cloud_Service_SearchHelper::getThreadPosts($_tIds); foreach ($res['data'] as $tId => $v) { $res['data'][$tId]['pId'] = $threadPosts[$tId]['pId']; if (in_array($v['fId'], $guestPerm['allowForumIds'])) { $res['data'][$tId]['isPublic'] = true; } else { $res['data'][$tId]['isPublic'] = false; } } } $authorids = array_keys($authors); if ($authorids) { $banuids = $uids = array(); foreach (C::t('common_member')->fetch_all($authorids) as $uid => $author) { $uids[$uid] = $uid; if ($author['groupid'] == 4 || $author['groupid'] == 5) { $banuids[] = $author['uid']; } } $deluids = array_diff($authorids, $uids); foreach ($deluids as $deluid) { if (!$deluid) { continue; } foreach ($authors[$deluid] as $tid) { $res['data'][$tid]['authorStatus'] = 'delete'; } } foreach ($banuids as $banuid) { foreach ($authors[$banuid] as $tid) { $res['data'][$tid]['authorStatus'] = 'ban'; } } } } return $res; }