private function get_threads($category_id) { //Get all threads for the category $category = category::get($category_id); $page_num = @$_POST['page']; $pageQueue = 0; if ($this->user['SiteRank'] >= $category['rankRead'] || $category['rankRead'] == '0') { if ($category != null) { // Page manager $num_rows = $category['noposts']; $bottomNav = ''; $num_pages = floor($num_rows / 10); if ($page_num == 0 || $page_num == null) { // If not set by url then default to the first page $page_num = 1; // default first page if ($num_rows > 10) { // if there are more than 10 rows $nextPageNumber = 2; // default next page if not defined in the url if ($pageQueue + 10 > $num_rows) { } else { $bottomNav = '<a href="' . site_url . '#/forum/' . $category_id . '/pg' . $nextPageNumber . '" class="forum-link pagination" data-page="' . $nextPageNumber . '">Next >></a><br/>'; } } } else { $nextPageNumber = $page_num + 1; $previousPage = $page_num - 1; if ($num_rows > 10) { if ($page_num == 1) { $pageQueue = 0; } else { $pageQueue = $page_num * 10 - 10; } if ($pageQueue + 10 > $num_rows) { $bottomNav = 'Page #' . $page_num . '/' . $num_pages . '<a href="' . site_url . '#/forum/' . $category_id . '/pg' . $previousPage . '" class="forum-link pagination" data-page="' . $previousPage . '"><< Back</a> '; } else { if ($page_num < 2) { $bottomNav = 'Page #' . $page_num . '/' . $num_pages . '<a href="' . site_url . '#/forum/' . $category_id . '/pg' . $nextPageNumber . '" class="forum-link pagination" data-page="' . $nextPageNumber . '">Next >></a><br/>'; } else { $bottomNav = '<a href="' . site_url . '#/forum/' . $category_id . '/pg' . $previousPage . '" class="forum-link pagination" data-page="' . $previousPage . '"><< Back</a> <span>Page #' . $page_num . ' / ' . $num_pages . '</span><a href="' . site_url . '#/forum/' . $category_id . '/pg' . $nextPageNumber . '" class="forum-link pagination" data-page="' . $nextPageNumber . '">Next >></a><br/>'; } } } } // Fetch threads $threads_sticky = thread::get_all($category_id, 1, 0, $pageQueue); $threads_normal = thread::get_all($category_id, 0, 0, $pageQueue); // Parse watching $watchers = explode(',', $category['watching']); if ($this->user['SiteRank'] >= $category['rankPost']) { echo ' <div id="forumTxtEditor" data-width="1200px" data-height="468px" data-max-width="95%" class="wbox"> <div class="wbox-title">New Thread</div> <div class="wbox-content"> <div id="newThreadTitle"><input id="forum-new-title" class="lot" placeholder="Thread title" /></div> <textarea id="textEditor"></textarea> </div> <div class="WBoxBtns-TE"> <input type="text" disabled="disabled" id="catID" class="noDisplay" value="' . $category_id . '" /> <input type="button" value="Post" id="forum-newThread-save" class="btn btn-green btn-row" /> </div> </div>'; } echo ' <div id="content-header-wrapper"> <div id="content-header-content"><div id="content-header-content-expand">▼</div> <div class="navLocBar-noWrap"><a href="' . site_url . '#/forum" class="forum-link">Forum</a> > ' . $category['name'] . '</div>'; if ($this->user['SiteRank'] >= $category['rankPost'] && $this->user['BanStatus'] == 0) { echo ' <div id="content-header-btns-right"> <button type="button" id="forum-newThread" class="btn btn-row btn-green"><span class="ion-plus"></span> New Thread</button>'; // Currently only for rank 4 & 5 if ($this->user['SiteRank'] >= 4 && array_search($this->user['Username'], $watchers)) { echo ' <button type="button" id="forum-cat-watch" class="btn btn-purple btn-row"><span class="ion-eye"> Watching</span></button>'; } if ($this->user['SiteRank'] >= 4 && array_search($this->user['Username'], $watchers) == false) { echo ' <button type="button" id="forum-cat-watch" class="btn btn-purple btn-row"><span class="ion-eye-disabled"> Watch</span></button>'; } if ($this->user['SiteRank'] >= 5) { echo ' <button type="button" id="forum-cat-admin" class="btn btn-blue btn-row"><span class="ion-edit"> Admin</span></button>'; echo ' <div id="forum-cat-admin-wbox" data-width="400px" data-height="250px" data-max-width="95%" class="wbox"> <div class="wbox-title">Category Admin</div> <div class="wbox-content"> <input type="text" id="forum-update-name" class="lot-adv" value="' . $category['name'] . '" /> <br/><br/> Access level (Read)<br/> <input type="number" class="lot-L" id="forum-cat-access-read" min="0" max="5" value="' . $category['rankRead'] . '" /> <br/><br/> Access level (Write)<br/> <input type="number" class="lot-L" id="forum-cat-access-write" min="0" max="5" value="' . $category['rankPost'] . '" /> </div> <div class="WBoxBtns-TE"> <input type="button" value="Update" id="forum-cat-adminUpdate" class="btn btn-green" /> </div> </div>'; } echo ' </div> '; } echo ' </div> </div> <div id="content-content">'; foreach ($threads_sticky->rows as $threads) { // Sticky Threads first $userPage = site_url . '#/user/' . $threads['lastposter']; // author url // Links $threadLink = site_url . '#/forum/' . $category_id . '/' . $threads['id']; if ($threads['locked'] == 1) { echo '<div class="forumThreadStickyLocked"><span class="forum-icon ion-pricetag"></span><span class="forum-icon ion-locked"></span>'; } else { echo '<div class="forumThreadSticky"><span class="forum-icon ion-pricetag"></span>'; } echo '<a href="' . $threadLink . '" class="forum-link">' . $threads['title'] . '</a> <div class="threadStats"> <div class="threadStat"> <div class="threadStat-title">Views</div> <div class="threadStat-value"><b>' . $threads['views'] . '</b></div> </div> <div class="threadStat"> <div class="threadStat-title">Replies</div> <div class="threadStat-value"><b>' . $threads['noreplys'] . '</b></div> </div>'; if ($threads['noreplys'] > 0) { echo ' <div class="threadStat threadStat-wide"> <div class="threadStat-title">Last Reply</div> <div class="thread-lastposter"><a href="' . $userPage . '" class="pgs-link">' . $threads['lastposter'] . '</a></div> </div>'; } echo ' </div> </div>'; } echo '<br/>'; foreach ($threads_normal->rows as $thread_row) { // Normal Threads $userPage = site_url . '#/user/' . $thread_row['lastposter']; // author url //Links $threadLink = site_url . '#/forum/' . $category_id . '/' . $thread_row['id']; if ($thread_row['locked'] == 1) { echo '<div class="forumThreadLocked"><span class="forum-icon ion-locked"></span>'; } else { echo '<div class="forumThread">'; } echo ' <a href="' . $threadLink . '" class="forum-link">' . $thread_row['title'] . '</a> <div class="threadStats"> <div class="threadStat"> <div class="threadStat-title">Views</div> <div class="threadStat-value"><b>' . $thread_row['views'] . '</b></div> </div> <div class="threadStat"> <div class="threadStat-title">Replies</div> <div class="threadStat-value"><b>' . $thread_row['noreplys'] . '</b></div> </div>'; if ($thread_row['noreplys'] > 0) { echo ' <div class="threadStat threadStat-wide"> <div class="threadStat-title">Last Reply</div> <div class="thread-lastposter"><a href="' . $userPage . '" class="pgs-link">' . $thread_row['lastposter'] . '</a></div> </div>'; } echo ' </div> </div>'; } // echo '</div>'; // forumThreads end echo '<div id="forum-bottom-nav">' . $bottomNav . '</div> </div>'; // Closing tag for #content-content } else { self::errorHTML('Category does not exist!'); } } else { self::errorHTML('Your account level needs to be upgraded! (This is to prevent spam on the forums!), if you are a guild member without access then request to have your account upgraded in game by a site admin.'); } }