[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

/src/bp-forums/bbpress/ -> bb-edit.php (source)

   1  <?php
   2  require ('./bb-load.php');
   3  
   4  bb_auth('logged_in');
   5  
   6  $post_id = (int) $_POST['post_id'];
   7  
   8  $bb_post = bb_get_post( $post_id );
   9  
  10  if ( !$bb_post ) {
  11      wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) );
  12      die();
  13  }
  14  
  15  if ( !bb_current_user_can( 'edit_post', $post_id ) )
  16      bb_die(__('Sorry, post is too old.'));
  17  
  18  bb_check_admin_referer( 'edit-post_' . $post_id );
  19  
  20  if ( 0 != $bb_post->post_status && 'all' == $_GET['view'] ) // We're trying to edit a deleted post
  21      add_filter('bb_is_first_where', 'bb_no_where');
  22  
  23  // Check possible anonymous user data
  24  $post_author = $post_email = $post_url = '';
  25  
  26  if ( !bb_get_user( get_post_author_id( $post_id ) ) ) {
  27      if ( !$post_author = sanitize_user( trim( $_POST['author'] ) ) )
  28          bb_die( __( 'Every post needs an author name!' ) );
  29      elseif ( !$post_email = sanitize_email( trim( $_POST['email'] ) ) )
  30          bb_die( __( 'Every post needs a valid email address!' ) );
  31  
  32      if ( !empty( $_POST['url'] ) )
  33          $post_url = esc_url( trim( $_POST['url'] ) );
  34  }
  35  
  36  // Loop through possible anonymous post data
  37  foreach( array('post_author', 'post_email', 'post_url') as $field ) {
  38      if ( ! empty( $$field ) ) {
  39          $post_data[$field] = $$field;
  40      }
  41  }
  42  
  43  // Setup topic data
  44  if ( bb_is_first( $bb_post->post_id ) && bb_current_user_can( 'edit_topic', $bb_post->topic_id ) ) {
  45  
  46      $post_data['topic_title'] = stripslashes( $_POST['topic'] );
  47      $post_data['topic_id']    = $bb_post->topic_id;
  48  
  49      bb_insert_topic( $post_data );
  50  }
  51  
  52  // Setup post data
  53  $post_data['post_text'] = stripslashes( $_POST['post_content'] );
  54  $post_data['post_id']   = $post_id;
  55  
  56  bb_insert_post( $post_data );
  57  
  58  if ( $post_id ) {
  59      if ( $_REQUEST['view'] === 'all' ) {
  60          add_filter( 'get_post_link', 'bb_make_link_view_all' );
  61      }
  62      $post_link = get_post_link( $post_id );
  63      wp_redirect( $post_link );
  64  } else {
  65      wp_redirect( bb_get_uri(null, null, BB_URI_CONTEXT_HEADER) );
  66  }
  67  exit;
  68  ?>


Generated: Thu Dec 7 01:01:35 2017 Cross-referenced by PHPXref 0.7.1