예제 #1
0
 private function sanitize()
 {
     if (false === ($this->thread = GWF_ForumThread::getByID(Common::getGetString('tid')))) {
         return $this->module->error('err_thread');
     }
     $this->ppt = $this->module->getPostsPerThread();
     $this->nPosts = $this->thread->getPostCount();
     $this->nPages = GWF_PageMenu::getPagecount($this->ppt, $this->nPosts);
     $default_page = isset($_GET['last_page']) ? $this->nPages : 1;
     $this->page = Common::clamp(Common::getGetInt('page'), $default_page, $this->nPages);
     if (!$this->thread->getBoard()) {
         return $this->module->error('err_thread_perm');
     }
     if (!$this->thread->hasPermission(GWF_Session::getUser())) {
         return $this->module->error('err_thread_perm');
     }
     if ($this->thread->isInModeration()) {
         return $this->module->error('err_in_mod');
     }
     return false;
 }
예제 #2
0
파일: Edit.php 프로젝트: sinfocol/gwf3
 public function newsToForum(GWF_News $news, $visible = true)
 {
     if (false === ($poster = $news->getUser())) {
         return GWF_HTML::error('News_Edit', 'News_Edit::newsToForum(): Nobody as Poster');
     }
     // Get News root.
     if (false === ($news_root = $this->getNewsForumRoot())) {
         return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
     }
     $root_id = $news_root->getID();
     $lang_roots = array();
     foreach ($news->getTranslations() as $t) {
         if (false === ($lang = GWF_Language::getByID($t['newst_langid']))) {
             return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
         if (false === ($lang_board = $this->getNewsForumLangCached($lang, $root_id))) {
             return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
         $iso = $lang->getISO();
         $tid = (int) $t['newst_threadid'];
         $lang_roots[$iso] = $lang_board;
         $bid = $lang_board->getID();
         $thread = GWF_ForumThread::getByID($tid);
         $title = $t['newst_title'];
         $message = $t['newst_message'];
         $gid = 0;
         $options = GWF_ForumThread::GUEST_VIEW;
         $options |= $visible ? 0 : GWF_ForumThread::INVISIBLE;
         if (!$visible) {
             if ($thread !== false) {
                 $thread->setVisible($visible);
             }
         } else {
             if ($thread === false) {
                 if (false === ($thread = GWF_ForumThread::newThread($poster, $title, $message, $options, $bid, $gid))) {
                     return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
                 }
             } else {
                 if (false === ($post = $thread->getFirstPost())) {
                     return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
                 }
                 if (false === $post->saveVar('post_message', $message)) {
                     return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
                 }
             }
             $thread->setVisible($visible);
         }
         $tid = $thread === false ? 0 : $thread->getID();
         $langid = $lang->getID();
         $newsid = $news->getID();
         // Save threadid
         if (false === GDO::table('GWF_NewsTranslation')->update("newst_threadid={$tid}", "newst_langid={$langid} AND newst_newsid={$newsid}")) {
             return GWF_HTML::err('ERR_DATABASE', array(__FILE__, __LINE__));
         }
     }
     // Set Boards Visible
     $news_root->setVisible($visible);
     foreach ($lang_roots as $iso => $board) {
         $board->setVisible($visible);
     }
     return '';
 }
예제 #3
0
파일: GWF_News.php 프로젝트: sinfocol/gwf3
 public function hrefThread($thread_id)
 {
     if (false === ($thread = GWF_ForumThread::getByID($thread_id))) {
         return '#';
     }
     return $thread->getLastPageHREF();
 }