private function onEditBoard() { $form = $this->getForm(); if (false !== ($error = $form->validate($this->module))) { return $error; } if (!$this->board->isRoot()) { $bid = $this->board->getID(); if ($bid !== ($newpid = (int) $form->getVar('moveboard'))) { if ($this->board->getParentID() !== $newpid) { if (false !== ($newparent = GWF_ForumBoard::getBoard($newpid))) { if (false === $this->board->move($newparent)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } } } } } $this->board->saveVars(array('board_gid' => $form->getVar('groupid'), 'board_title' => $form->getVar('title'), 'board_descr' => $form->getVar('descr'))); # Options $this->board->saveOption(GWF_ForumBoard::ALLOW_THREADS, Common::getPost('allow_threads') !== false); $this->board->saveOption(GWF_ForumBoard::LOCKED, Common::getPost('is_locked') !== false); $this->board->saveOption(GWF_ForumBoard::GUEST_POSTS, Common::getPost('guests') !== false); $this->board->saveOption(GWF_ForumBoard::GUEST_VIEW, Common::getPost('guest_view') !== false); if (!$this->board->isRoot()) { $this->board->saveOption(GWF_ForumBoard::INVISIBLE, Common::getPost('invisible') !== false); } return $this->module->message('msg_edited_board', array($this->board->getShowBoardHREF())); }
private static function singleB(GWF_ForumBoard $board, &$back, $level, $selected) { $rep = '+' . str_repeat('=', $level * 2); $back .= sprintf('<option value="%s"%s>%s</option>', $board->getID(), GWF_HTML::selected($selected === $board->getID()), $rep . $board->display('board_title')); $childs = $board->getChilds(); if (count($childs) > 0) { foreach ($childs as $child) { self::singleB($child, $back, $level + 1, $selected); } } }
public function sanitize() { if (false === ($this->board = $this->module->getCurrentBoard())) { return $this->module->error('err_board'); } $threads = GDO::table('GWF_ForumThread'); $bid = $this->board->getID(); $this->tpp = $this->module->getThreadsPerPage(); $this->nThreads = $threads->countRows("thread_bid={$bid}"); $this->nPages = GWF_PageMenu::getPagecount($this->tpp, $this->nThreads); $this->page = Common::clamp((int) Common::getGet('tpage', '1'), 1, $this->nPages); $this->nBoards = count($this->board->getChilds()); $this->nBPages = GWF_PageMenu::getPagecount($this->tpp, $this->nBoards); $this->bPage = Common::clamp(Common::getGet('bpage', 1), 1, $this->nBPages); return false; }
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 onAddThread() { $form = $this->getForm(); if (false !== ($error = $form->validate($this->module))) { return $error . $this->templateAddThread(); } $user = GWF_Session::getUser(); $is_mod = $user === false && $this->module->isGuestPostModerated(); $title = $form->getVar('title'); $message = $form->getVar('message'); $bid = $this->board->getID(); $gid = $this->board->getGroupID(); $options = 0; $options |= $is_mod === false ? 0 : GWF_ForumThread::IN_MODERATION; $options |= $this->board->isGuestView() ? GWF_ForumThread::GUEST_VIEW : 0; // $options |= Common::getPost('guest_view') === false ? 0 : GWF_ForumThread::GUEST_VIEW; $date = GWF_Time::getDate(GWF_Time::LEN_SECOND); $thread = GWF_ForumThread::fakeThread($user, $title, $bid, $gid, 1, $options, $date); if (false === $thread->insert()) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } $tid = $thread->getID(); $gid = $thread->getGroupID(); $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 === false ? 0 : GWF_ForumPost::IN_MODERATION; $options |= $this->board->isGuestView() ? GWF_ForumPost::GUEST_VIEW : 0; $post = GWF_ForumPost::fakePost($user, $title, $message, $options, $tid, $gid, $date); if (false === $post->insert()) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (!$is_mod) { $thread->onApprove(); // $this->module->cachePostcoun(); return $this->module->message('msg_posted', array($thread->getLastPageHREF())); } else { GWF_ForumSubscription::sendModerateThread($this->module, $thread, $message); return $this->module->message('msg_posted_mod', array($this->board->getShowBoardHREF())); } }
private function onMove(GWF_ForumThread $t, GWF_ForumBoard $b) { // if (false === ($b->isThreadAllowed())) { // $_POST['move'] = $t->getBoardID(); // return $this->module->error('err_no_thread_allowed'); // } $pc = $t->getPostCount(); if (false === $t->getBoard()->adjustCounters(-1, -$pc)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === $b->adjustCounters(1, $pc)) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === $t->saveVars(array('thread_bid' => $b->getID(), 'thread_gid' => $b->getGroupID()))) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } if (false === $t->saveVar('thread_bid', $b->getID())) { return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__)); } return $this->module->message('msg_thread_moved', array($t->display('thread_title'), $b->display('board_title'))); }
/** * Move this board to another. * @param GWF_ForumBoard $newParent * @return true|false */ public function move(GWF_ForumBoard $newParent) { $newpid = $newParent->getID(); if (false === $this->getParent()->adjustCounters(-$this->getThreadCount(), -$this->getPostCount())) { return false; } if (false === $this->saveVar('board_pid', $newParent->getID())) { return false; } if (false === $newParent->adjustCounters($this->getThreadCount(), $this->getPostCount())) { return false; } return true; }