public function onRequestInit() { GWF_ForumBoard::init(); # Init by Post if (0 !== ($this->post_id = (int) Common::getGet('pid', 0))) { if (false === ($this->post = GWF_ForumPost::getPost($this->post_id))) { $this->post_id = 0; } elseif (false !== ($this->thread = $this->post->getThread())) { $this->thread_id = $this->thread->getID(); if (false !== ($this->board = $this->thread->getBoard())) { $this->board_id = $this->board->getID(); } } } elseif (0 !== ($this->thread_id = (int) Common::getGet('tid', 0))) { if (false === ($this->thread = GWF_ForumThread::getThread($this->thread_id))) { $this->thread_id = 0; } elseif (false !== ($this->board = $this->thread->getBoard())) { $this->board_id = $this->board->getID(); } } else { $this->board_id = Common::getGetString('bid', '1'); if (false === ($this->board = GWF_ForumBoard::getBoard($this->board_id))) { $this->board_id = '1'; if (false === ($this->board = GWF_ForumBoard::getRoot())) { $this->board_id = '0'; } } } if ($this->thread_id !== 0 && 0 < ($cut = $this->cfgWatchTimeout())) { GWF_ForumVisitors::setWatching($this->thread, $cut); } }
private function onUnSubscribeExtThread($token) { if (false === $this->checkExternalToken($token)) { return $this->module->error('err_token'); } if (!GWF_ForumSubscription::hasSubscribedManually($this->user, $this->thread->getID())) { return $this->module->error('err_sub_by_global'); } if (false === GWF_ForumSubscription::unsubscribe($this->user->getID(), $this->thread->getID())) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } return $this->module->message('msg_unsubscribed', array($this->thread->getLastPageHREF())); }
public static function setWatching(GWF_ForumThread $thread, $cut) { $tid = $thread->getID(); # Insert current spectator // GDO::table(__CLASS__); $row = new self(array('fowa_sess' => GWF_Session::getSessID(), 'fowa_time' => time(), 'fowa_tid' => $tid)); if (false === $row->replace()) { return false; } # Delete old $cut = time() - $cut; if (false === $row->deleteWhere("fowa_time<{$cut}")) { return false; } # Set new amount if (false === $thread->saveVar('thread_watchers', $row->countRows("fowa_tid={$tid}"))) { return false; } return true; }
private function onReply() { $form = $this->getForm(); if (false !== ($error = $form->validate($this->module))) { return $error . $this->templateReply(); } # Gather vars $user = GWF_Session::getUser(); $is_mod = $user === false && $this->module->isGuestPostModerated(); $title = $form->getVar('title'); $message = $form->getVar('message'); $options = 0; $options |= Common::getPost('bbcode') === false ? 0 : GWF_ForumPost::DISABLE_BB; $options |= Common::getPost('smileys') === false ? 0 : GWF_ForumPost::DISABLE_SMILE; $options |= $is_mod ? GWF_ForumPost::IN_MODERATION : 0; // $options |= Common::getPost('guest_view') === false ? 0 : $this->thread->isGuestView(); $options |= $this->thread->isGuestView() ? GWF_ForumPost::GUEST_VIEW : 0; $threadid = $this->thread->getID(); $groupid = $this->thread->getGroupID(); # Post it $post = GWF_ForumPost::fakePost($user, $title, $message, $options, $threadid, $groupid); if (false === $post->insert()) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (!$is_mod) { if (false === $post->onApprove($this->module)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } // $this->thread->increase('thread_postcount', 1); # Increase cache :/ $this->module->cachePostcount(); return $this->module->message('msg_posted', array($post->getThread()->getLastPageHREF())); } else { GWF_ForumSubscription::sendModeratePost($this->module, $post); return $this->module->message('msg_posted_mod', array($this->thread->getLastPageHREF())); } }
private function getPageMenu() { $href = GWF_WEB_ROOT . sprintf('forum-t%s/%s-p%%PAGE%%.html', $this->thread->getID(), $this->thread->urlencodeSEO('thread_title')); return GWF_PageMenu::display($this->page, $this->nPages, $href); }
public static function sendModerateThread(Module_Forum $module, GWF_ForumThread $thread, $message) { $boardtxt = self::getBoardTreeText($thread->getBoard()); $threadtxt = $thread->display('thread_title'); $usertxt = $thread->display('thread_lastposter'); $title = $threadtxt; $tid = $thread->getID(); $token = $thread->getToken(); $addtxt = Common::getAbsoluteURL('index.php?mo=Forum&me=Moderate&yes_thread=' . $tid . '&token=' . $token); $remtxt = Common::getAbsoluteURL('index.php?mo=Forum&me=Moderate&no_thread=' . $tid . '&token=' . $token); return self::sendModMail($module, $boardtxt, $threadtxt, $usertxt, $title, $message, $addtxt, $remtxt); }
private function onMerge(GWF_ForumThread $first, GWF_ForumThread $last) { // Delete thread if (false === $last->delete()) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } // Sum counters if (false === $first->saveVar('thread_postcount', $first->getPostCount() + $last->getPostCount())) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === $first->saveVar('thread_viewcount', $first->getVar('thread_viewcount') + $last->getVar('thread_viewcount'))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === $first->saveVar('thread_thanks', $first->getVar('thread_thanks') + $last->getVar('thread_thanks'))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === $first->saveVar('thread_votes_up', $first->getVar('thread_votes_up') + $last->getVar('thread_votes_up'))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === $first->saveVar('thread_votes_down', $first->getVar('thread_votes_down') + $last->getVar('thread_votes_down'))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } // -1 thread if (false === $first->getBoard()->adjustCounters(-1, 0)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } // change threadid's $t1id = $first->getID(); $t2id = $last->getID(); if (false === GDO::table('GWF_ForumPost')->update("post_tid={$t1id}", "post_tid={$t2id}")) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } // Done return $this->module->message('msg_merged'); }