public function validate_pollid(Module_Forum $m, $arg) { if (false === ($p = GWF_VoteMulti::getByID($arg))) { return $m->lang('err_poll'); } if ($p->getUserID() !== $this->user->getID()) { return $m->lang('err_poll'); } return false; }
private static function createLangBoard(Module_Forum $module, GWF_Language $lang, $parent) { $iso = $lang->getISO(); $title = $module->langISO($iso, 'lang_board_title', array($lang->getVar('name'))); if (false !== ($board = GWF_ForumBoard::getByTitle($title))) { return ''; } $descr = $module->langISO($iso, 'lang_board_descr', array($lang->getVar('lang_nativename'))); $options = GWF_ForumBoard::GUEST_VIEW | GWF_ForumBoard::ALLOW_THREADS; if (false === ($board = GWF_ForumBoard::createBoard($title, $descr, $parent, $options, 0))) { return GWF_HTML::err('ERR_DATABASE', __FILE__, __LINE__); } return ''; }
?> <h1><?php echo $options . $tLang->lang('forum_title') . $search . $newthreads . $pollsbtn; ?> </h1> <hr/> <!-- Nav Tree --> <?php if (!$b->isRoot()) { ?> <div class="gwf_board_quicktree"><?php echo Module_Forum::getNavTree(); ?> </div> <?php } ?> <hr/> <!-- Current Board --> <h2> <span><?php echo $b->display('board_title'); ?> </span> <span><?php
public static function newThread(GWF_User $user, $title = '', $message = '', $options = 0, $bid = 0, $gid = 0) { // No params if ($title === '' && $message === '') { return false; } // insert thread $postcount = $message === '' ? 0 : 1; $thread = self::fakeThread($user, $title, $bid, $gid, $postcount, $options); if (false === $thread->insert()) { return false; } // Insert message if there is one. if ($message !== '') { $threadid = $thread->getID(); $post = GWF_ForumPost::fakePost($user, $title, $message, $options, $threadid, $gid); if (false === $post->insert()) { return false; } } $thread->onApprove(false, $postcount); Module_Forum::getInstance()->cachePostcount(); return $thread; }
private static function sendSubscriptionB(Module_Forum $module, GWF_ForumThread $thread, GWF_User $user, $postername, $msg_block, $msg_count, $boardText, $threadTitle, $sender) { $userid = $user->getID(); $username = $user->displayUsername(); if (false === ($receiver = $user->getValidMail())) { GWF_Log::logCron('[ERROR] User ' . $username . ' has no valid email.'); return false; } if (false === ($options = GWF_ForumOptions::getUserOptions($user))) { GWF_Log::logCron('[ERROR] User ' . $username . ' has no valid forum options.'); } $token = $options->getVar('fopt_token'); $href = Common::getAbsoluteURL($thread->getLastPageHREF(false), false); $showLink = GWF_HTML::anchor($href, $href); $href = Common::getAbsoluteURL($thread->getExternalUnSubscribeHREF($userid, $token, true), false); $unsubLink = GWF_HTML::anchor($href, $href); $href = Common::getAbsoluteURL($thread->getExternalUnSubscribeAllHREF($userid, $token, true), false); $unsubLinkAll = GWF_HTML::anchor($href, $href); $mail = new GWF_Mail(); $mail->setSender($sender); $mail->setReceiver($receiver); $mail->setSubject($module->langUser($user, 'submail_subj', array($threadTitle, $postername, $boardText))); $mail->setBody($module->langUser($user, 'submail_body', array($username, $msg_count, $boardText, $threadTitle, $msg_block, $showLink, $unsubLink, $unsubLinkAll))); if (false === $mail->sendToUser($user)) { GWF_Log::logCron('[ERROR] Can not send mail to ' . $username . '; EMail: ' . $receiver); } else { GWF_Log::logCron('[+] Successfully sent Email to ' . $username . '; EMail: ' . $receiver); } }
public function getSubscrSelect(Module_Forum $module, $name = 'subscr') { $back = sprintf('<select name="%s">', $name); $val = $this->getVar('fopt_subscr'); foreach (self::$SUBSCR_MODES as $opt) { $sel = GWF_HTML::selected($opt === $val); $back .= sprintf('<option value="%s"%s>%s</option>', $opt, $sel, $module->lang('subscr_' . $opt)); } $back .= '</select>'; return $back; }
/** * Check if new threads are allowed in this board for current user. * @return boolean */ public function isNewThreadAllowed() { if (!$this->isOptionEnabled(self::ALLOW_THREADS)) { return false; } if ($this->isOptionEnabled(self::LOCKED)) { return false; } if (false === ($user = GWF_Session::getUser())) { if (!$this->isGuestPostAllowed()) { return false; } if (!Module_Forum::getInstance()->isGuestPostAllowed()) { return false; } } return $this->hasPermissionS(); }
public function onApprove(Module_Forum $module, $mark_unread = true) { # Sane? if (false === ($thread = $this->getThread())) { echo $module->error('err_thread'); return false; } if (false === ($board = $thread->getBoard())) { echo $module->error('err_board'); return false; } # Update Last Poster if (false === $thread->updateLastPost()) { return false; } # Increase counters if (false === $thread->increase('thread_postcount', 1)) { return false; } if (false === $board->adjustCounters(0, 1)) { return false; } # Mail us soon if (false === $this->saveOption(self::MAIL_OUT, true)) { return false; } if (false === $this->saveOption(self::IN_MODERATION, false)) { return false; } if ($mark_unread === true) { if (false === $this->onMarkUnread(is_object($this->getVar('post_uid')) ? $this->getVar('post_uid')->getID() : $this->getVar('post_uid'))) { return GWF_HTML::err('ERR_DATABASE', __FILE__, __LINE__); } } # We got approved if (false === $this->saveOption(GWF_ForumPost::IN_MODERATION, false)) { return GWF_HTML::err('ERR_DATABASE', __FILE__, __LINE__); } return true; }