Skip to:
Content

bbPress.org

Changeset 2390 for trunk/bb-post.php


Ignore:
Timestamp:
01/13/2010 09:47:16 PM (16 years ago)
Author:
filosofo
Message:

Adding most anon posting functionality; fixes #1239

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bb-post.php

    r2075 r2390  
    22require('./bb-load.php');
    33
    4 bb_auth('logged_in');
     4if ( bb_is_login_required() ) {
     5    bb_auth('logged_in');
     6}
    57
    6 if ( $throttle_time = bb_get_option( 'throttle_time' ) )
    7     if ( isset($bb_current_user->data->last_posted) && time() < $bb_current_user->data->last_posted + $throttle_time && !bb_current_user_can('throttle') )
    8         bb_die(__('Slow down; you move too fast.'));
     8bb_check_comment_flood();
    99
    1010if ( !$post_content = trim($_POST['post_content']) )
    1111    bb_die(__('You need to actually submit some content!'));
    1212
     13$post_author = $post_email = $post_url = '';
     14
     15if ( ! bb_is_user_logged_in() ) {
     16    if ( bb_is_login_required() ) {
     17        bb_die(__('You are not allowed to post.  Are you logged in?'));
     18    } else {
     19        if ( ! $post_author = trim($_POST['author']) ) {
     20            bb_die(__('You need to submit your name!'));
     21        } elseif ( ! $post_email = trim($_POST['email']) ) {
     22            bb_die(__('You need to submit your email!'));
     23        }
     24
     25        if ( ! empty( $_POST['url'] ) ) {
     26            $post_url = trim($_POST['url']);
     27        }
     28    }
     29}
     30
     31
     32
     33
    1334if ( isset($_POST['topic']) && $forum_id = (int) $_POST['forum_id'] ) {
    14     if ( !bb_current_user_can('write_posts') )
     35    if ( bb_is_login_required() && ! bb_current_user_can('write_posts') )
    1536        bb_die(__('You are not allowed to post.  Are you logged in?'));
    1637
    17     if ( !bb_current_user_can( 'write_topic', $forum_id ) )
     38    if ( bb_is_login_required() && ! bb_current_user_can( 'write_topic', $forum_id ) )
    1839        bb_die(__('You are not allowed to write new topics.'));
    1940
     
    3354}
    3455
    35 if ( !bb_current_user_can( 'write_post', $topic_id ) )
     56if ( bb_is_login_required() && ! bb_current_user_can( 'write_post', $topic_id ) )
    3657    bb_die(__('You are not allowed to post.  Are you logged in?'));
    3758
     
    3960    bb_die(__('This topic has been closed'));
    4061
    41 $post_id = bb_new_post( $topic_id, $_POST['post_content'] );
     62$post_data = array(
     63    'post_text' => stripslashes($_POST['post_content']),
     64    'topic_id' => $topic_id,
     65);
     66
     67foreach( array('post_author', 'post_email', 'post_url') as $field ) {
     68    if ( ! empty( $$field ) ) {
     69        $post_data[$field] = $$field;
     70    }
     71}
     72
     73$post_id = bb_insert_post($post_data);
    4274
    4375$tags  = trim( $_POST['tags']  );
Note: See TracChangeset for help on using the changeset viewer.