function getThreadList($service, $maxResults, $method = "") { $user = '******'; $pageToken = NULL; $opt_param = array(); $opt_param['includeSpamTrash'] = false; // $opt_param['maxResults'] = $maxResults; // $opt_param['maxResults'] = 5; $opt_param['labelIds'] = ['INBOX']; // $opt_param['labelIds'] = ['INBOX', 'CATEGORY_PERSONAL']; $threadsResponse = $service->users_threads->listUsersThreads($user, $opt_param); if ($threadsResponse->getThreads()) { $threadObject = null; if ($method == "simple") { // $threadObject = array(); $threadObject = new ThreadList(); foreach ($threadsResponse->getThreads() as $thread) { $threadObject->addThread(new ThreadsSimple($thread->getId(), html_entity_decode($thread->getSnippet()))); // array_push($threadObject, new ThreadsSimple($thread->getId(), html_entity_decode($thread->getSnippet()))); } } else { if ($method == "minimal") { $threadObject = array(); foreach ($threadsResponse->getThreads() as $thread) { // $messageResponse = $service->users_messages-> $threadItem = thread_get($service, $user, $thread->getId()); printPre($threadItem); } } else { if ($method == "full") { listThreads($service, $maxResults); } else { if ($method == "allthreads") { $threadObject = new ThreadList(); foreach ($threadsResponse->getThreads() as $thread) { // $messageResponse = $service->users_messages-> $threadItem = thread_get($service, $user, $thread->getId()); // $threadObject->addThread(new ThreadItem($threadItem)); printPre($threadItem); } } } } } if ($threadObject != null) { printPre($threadObject); } } }
$crumbs->add(new PipeMenuHtmlEntry(userLink($user))); $crumbs->add(new PipeMenuTextEntry(__("Threads"))); makeBreadcrumbs($crumbs); $total = FetchResult("SELECT\n\t\t\t\t\t\tcount(*)\n\t\t\t\t\tFROM\n\t\t\t\t\t\t{threads} t\n\t\t\t\t\t\tLEFT JOIN {forums} f ON f.id=t.forum\n\t\t\t\t\tWHERE t.user={0} AND f.minpower <= {1}", $uid, $loguser["powerlevel"]); $tpp = $loguser['threadsperpage']; if (isset($_GET['from'])) { $from = (int) $_GET['from']; } else { $from = 0; } if (!$tpp) { $tpp = 50; } $rThreads = Query("\tSELECT\n\t\t\t\t\t\tt.*,\n\t\t\t\t\t\tf.(title, id),\n\t\t\t\t\t\t" . ($loguserid ? "tr.date readdate," : '') . "\n\t\t\t\t\t\tsu.(_userfields),\n\t\t\t\t\t\tlu.(_userfields)\n\t\t\t\t\tFROM\n\t\t\t\t\t\t{threads} t\n\t\t\t\t\t\t" . ($loguserid ? "LEFT JOIN {threadsread} tr ON tr.thread=t.id AND tr.id={3}" : '') . "\n\t\t\t\t\t\tLEFT JOIN {users} su ON su.id=t.user\n\t\t\t\t\t\tLEFT JOIN {users} lu ON lu.id=t.lastposter\n\t\t\t\t\t\tLEFT JOIN {forums} f ON f.id=t.forum\n\t\t\t\t\tWHERE t.user={0} AND " . forumAccessControlSql() . "\n\t\t\t\t\tORDER BY lastpostdate DESC LIMIT {1u}, {2u}", $uid, $from, $tpp, $loguserid); $numonpage = NumRows($rThreads); $pagelinks = PageLinks(actionLink("listthreads", $uid, "from="), $tpp, $from, $total); if ($pagelinks) { echo "<div class=\"smallFonts pages\">" . __("Pages:") . " " . $pagelinks . "</div>"; } $ppp = $loguser['postsperpage']; if (!$ppp) { $ppp = 20; } if (NumRows($rThreads)) { echo listThreads($rThreads, false, true); } else { Alert(__("No threads found."), __("Error")); } if ($pagelinks) { Write("<div class=\"smallFonts pages\">" . __("Pages:") . " {0}</div>", $pagelinks); }
if (isset($_GET['from'])) { $from = (int) $_GET['from']; } else { $from = 0; } if (!$tpp) { $tpp = 50; } $rThreads = Query("\tSELECT\n\t\t\t\t\t\tt.*,\n\t\t\t\t\t\t" . ($loguserid ? "tr.date readdate," : '') . "\n\t\t\t\t\t\tsu.(_userfields),\n\t\t\t\t\t\tlu.(_userfields)\n\t\t\t\t\tFROM\n\t\t\t\t\t\t{threads} t\n\t\t\t\t\t\t" . ($loguserid ? "LEFT JOIN {threadsread} tr ON tr.thread=t.id AND tr.id={3}" : '') . "\n\t\t\t\t\t\tLEFT JOIN {users} su ON su.id=t.user\n\t\t\t\t\t\tLEFT JOIN {users} lu ON lu.id=t.lastposter\n\t\t\t\t\tWHERE forum={0}\n\t\t\t\t\tORDER BY sticky DESC, lastpostdate DESC LIMIT {1u}, {2u}", $fid, $from, $tpp, $loguserid); $numonpage = NumRows($rThreads); $pagelinks = PageLinks(actionLink("forum", $fid, "from="), $tpp, $from, $total); if ($pagelinks) { echo "<div class=\"smallFonts pages\">" . __("Pages:") . " " . $pagelinks . "</div>"; } if (NumRows($rThreads)) { echo listThreads($rThreads, true, false); } else { if ($forum['minpowerthread'] > $loguser['powerlevel']) { Alert(__("You cannot start any threads here."), __("Empty forum")); } elseif ($loguserid) { Alert(format(__("Would you like to {0}?"), actionLinkTag(__("post something"), "newthread", $fid)), __("Empty forum")); } else { Alert(format(__("{0} so you can post something."), actionLinkTag(__("Log in"), "login")), __("Empty forum")); } } if ($pagelinks) { Write("<div class=\"smallFonts pages\">" . __("Pages:") . " {0}</div>", $pagelinks); } ForumJump(); printRefreshCode(); function fj_forumBlock($fora, $catid, $selID, $indent)