topic_id ) ) if ( !$tag = bb_get_tag( $tag_id ) ) continue; $tag->user_id = bb_get_current_user_info( 'id' ); $tag_id_val = $tag->tag_id . '_' . $tag->user_id; $tag->raw_tag = attribute_escape( $tag->raw_tag ); $x->add( array( 'what' => 'tag', 'id' => $tag_id_val, 'data' => _bb_list_tag_item( $tag, array( 'list_id' => 'tags-list', 'format' => 'list' ) ) ) ); } $x->send(); break; case 'delete-tag' : list($tag_id, $user_id) = explode('_', $_POST['id']); $tag_id = (int) $tag_id; $user_id = (int) $user_id; $topic_id = (int) $_POST['topic_id']; if ( !bb_current_user_can('edit_tag_by_on', $user_id, $topic_id) ) die('-1'); bb_check_ajax_referer( "remove-tag_$tag_id|$topic_id" ); add_action('bb_rpe_tag_removed', 'bb_grab_results', 10, 3); $tag = bb_get_tag( $tag_id ); $user = bb_get_user( $user_id ); $topic = get_topic ( $topic_id ); if ( !$tag || !$topic ) die('0'); if ( false !== bb_remove_topic_tag( $tag_id, $user_id, $topic_id ) ) die('1'); break; case 'dim-favorite' : $user_id = bb_get_current_user_info( 'id' ); if ( !$topic = get_topic( $id ) ) die('0'); if ( !bb_current_user_can( 'edit_favorites_of', $user_id ) ) die('-1'); bb_check_ajax_referer( "toggle-favorite_$topic->topic_id" ); $is_fav = is_user_favorite( $user_id, $topic->topic_id ); if ( 1 == $is_fav ) { if ( bb_remove_user_favorite( $user_id, $topic->topic_id ) ) die('1'); } elseif ( false === $is_fav ) { if ( bb_add_user_favorite( $user_id, $topic->topic_id ) ) die('1'); } break; case 'delete-post' : // $id is post_id if ( !bb_current_user_can( 'delete_post', $id ) ) die('-1'); bb_check_ajax_referer( "delete-post_$id" ); $page = (int) $_POST['page']; $last_mod = (int) $_POST['last_mod']; $bb_post = bb_get_post( $id ); if ( !$bb_post ) die('0'); $topic = get_topic( $bb_post->topic_id ); if ( bb_delete_post( $id, 1 ) ) die('1'); break; /* case 'add-post' : // Can put last_modified stuff back in later bb_check_ajax_referer( $action ); $error = false; $post_id = 0; $topic_id = (int) $_POST['topic_id']; $last_mod = (int) $_POST['last_mod']; if ( !$post_content = trim($_POST['post_content']) ) $error = new WP_Error( 'no-content', __('You need to actually submit some content!') ); if ( !bb_current_user_can( 'write_post', $topic_id ) ) die('-1'); if ( !$topic = get_topic( $topic_id ) ) die('0'); if ( !topic_is_open( $topic_id ) ) $error = new WP_Error( 'topic-closed', __('This topic is closed.') ); if ( $throttle_time = bb_get_option( 'throttle_time' ) ) if ( isset($bb_current_user->data->last_posted) && time() < $bb_current_user->data->last_posted + $throttle_time && !bb_current_user_can('throttle') ) $error = new WP_Error( 'throttle-limit', sprintf( __('Slow down! You can only post every %d seconds.'), $throttle_time ); if ( !$error ) : if ( !$post_id = bb_new_post( $topic_id, rawurldecode($_POST['post_content']) ) ) die('0'); $bb_post = bb_get_post( $post_id ); $new_page = get_page_number( $bb_post->post_position ); ob_start(); echo "