canPostTopic() public method

Params: $forum_id (integer) - forum id to check, $group_id (integer) - group id of the user
public canPostTopic ( $forum_id, $group_id = null )
コード例 #1
0
ファイル: view_forum.php プロジェクト: MistriHD/Nameless
         $subforum_topics = count($subforum_topics);
         if ($forum->forumExist($subforum->id, $user->data()->group_id)) {
             $subforum_string .= '<a href="/forum/view_forum/?fid=' . $subforum->id . '">' . htmlspecialchars($subforum->forum_title) . '</a> <span class="badge" rel="tooltip" data-trigger="hover" data-original-title="' . $subforum_topics . ' ' . $forum_language['topics'] . '">' . $subforum_topics . '</span>, ';
         }
         $subforum_string = rtrim($subforum_string, ", ");
         // remove the last comma
     }
 } else {
     $subforum_string = '';
 }
 $smarty->assign('SUBFORUMS', $subforum_string);
 $smarty->assign('SUBFORUMS_LANGUAGE', $forum_language['subforums']);
 // No topics yet
 $smarty->assign('FORUM_TITLE', htmlspecialchars($forum_query->forum_title));
 $smarty->assign('NO_TOPICS', $forum_language['no_topics']);
 if ($user->isLoggedIn() && $forum->canPostTopic($fid, $user->data()->group_id)) {
     $smarty->assign('NEW_TOPIC_BUTTON', '<a style="display: inline;" href="/forum/new_topic/?fid=' . $fid . '" class="btn btn-primary">' . $forum_language['new_topic'] . '</a>');
 } else {
     $smarty->assign('NEW_TOPIC_BUTTON', '');
 }
 $smarty->assign('FORUMS', $forum_language['forums']);
 // Forums sidebar
 $forums = $forum->listAllForums($user->data()->group_id, true);
 // second parameter states we're in latest discussions view
 $sidebar_forums = array();
 foreach ($forums as $key => $item) {
     $item = array_filter($item);
     if (!empty($item)) {
         foreach ($item as $sub_forum) {
             // Get forum ID
             $forum_id = $queries->getWhere('forums', array('forum_title', '=', $sub_forum));
コード例 #2
0
ファイル: new_topic.php プロジェクト: NamelessMC/Nameless
}
$forum = new Forum();
$mentionsParser = new MentionsParser();
if (!isset($_GET['fid']) || !is_numeric($_GET['fid'])) {
    Redirect::to('/forum/error/?error=not_exist');
    die;
}
$fid = (int) $_GET['fid'];
// Does the forum exist, and can the user view it?
$list = $forum->forumExist($fid, $user->data()->group_id);
if (!$list) {
    Redirect::to('/forum/error/?error=not_exist');
    die;
}
// Can the user post a topic in this forum?
$can_reply = $forum->canPostTopic($fid, $user->data()->group_id);
if (!$can_reply) {
    Redirect::to('/forum/view_forum/?fid=' . $fid);
    die;
}
// Deal with any inputted data
if (Input::exists()) {
    if (Token::check(Input::get('token'))) {
        $validate = new Validate();
        $validation = $validate->check($_POST, array('title' => array('required' => true, 'min' => 2, 'max' => 64), 'content' => array('required' => true, 'min' => 2, 'max' => 20480)));
        if ($validation->passed()) {
            try {
                $queries->create("topics", array('forum_id' => $fid, 'topic_title' => Input::get('title'), 'topic_creator' => $user->data()->id, 'topic_last_user' => $user->data()->id, 'topic_date' => date('U'), 'topic_reply_date' => date('U'), 'label' => Input::get('topic_label')));
                $topic_id = $queries->getLastId();
                $queries->create("posts", array('forum_id' => $fid, 'topic_id' => $topic_id, 'post_creator' => $user->data()->id, 'post_content' => htmlspecialchars(Input::get('content')), 'post_date' => date('Y-m-d H:i:s')));
                // Get last post ID