public function write($title, $text) { db()->forum_thread->insert(array('board' => $this->id, 'title' => $title)); $tid = db()->id(); $thread = forum_thread::create($tid, $this); $thread->reply($title, $text); return $tid; }
public function showThread(forum_thread $thread) { /** @var rights_container $rights */ $rights = iv::get('rights'); $user = iv::get('user'); $board = $thread->loadBoard(); $flags = $rights->flags('forum', $board->id); if (!$board->public_read && !$rights->has('forum', $board->id)) { throw new Exception('Sie haben keinen Zugriff auf dieses Forum!'); } $thread->markRead(); $pagination = new data_pagination(new html_link(PAGE_SELF . '&thread=' . $thread->id), 25, 'thread_'); $this->context['postings'] = $pagination->query("SELECT p.*, u.name as user_name, u.id as user_id, u.email as user_email\n\t\t\tFROM forum_post p LEFT JOIN user_data u ON u.id = p.create_by\n\t\t\tWHERE p.thread = %d ORDER BY id", $thread->id)->assocs(); $this->context['author'] = db()->user_data->row($thread->create_by)->assoc(); $this->context['breadcrumb'] = $board->breadcrumb(); $this->context['thread'] = $thread; $this->context['reply'] = $user && (!$thread->closed || $flags['moderate']) && ($board->public_reply || $flags['reply']); $this->context['moderate'] = $flags['moderate']; $this->context['user'] = $user; $this->context['pagination'] = $pagination->get(); template('forum/thread')->display($this->context); }
} if (!empty($_POST['title']) && !empty($_POST['text'])) { db()->forum_post->updateRow(array('title' => $_POST['title'], 'text_raw' => $_POST['text']), $posting['id']); throw new redirect(PAGE_SELF . '&thread=' . $thread->id); } $forumView->edit($posting, $thread); } elseif (!empty($_GET['create'])) { $board = forum_board::load($_GET['create']); $board->checkRights('write'); if (!empty($_POST['title']) && !empty($_POST['text'])) { $threadId = $board->write($_POST['title'], $_POST['text']); throw new redirect(PAGE_SELF . '&thread=' . $threadId); } $forumView->createThread($board); } elseif (!empty($_GET['reply'])) { $thread = forum_thread::load($_GET['reply']); $board = $thread->loadBoard(); $board->checkRights('reply'); if ($thread->closed) { $board->checkRights('moderate'); } if (!empty($_POST['title']) && !empty($_POST['text'])) { $thread->reply($_POST['title'], $_POST['text']); throw new redirect(PAGE_SELF . '&thread=' . $thread->id); } $forumView->reply($thread); } elseif (!empty($_GET['thread'])) { $forumView->showThread(db()->forum_thread->row($_GET['thread'])->object('forum_thread')); } elseif (!empty($_GET['board'])) { if (db()->forum_board->id($_GET['board'])->name != "") { $forumView->showBoard($_GET['board']);