/bp-forums/bbpress/bb-admin/posts.php

  1. <?php 
  2. require_once('admin.php'); 
  3.  
  4. if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) ) { 
  5. bb_check_admin_referer( 'post-bulk' ); 
  6.  
  7. $post_ids = array_map( 'absint', $_POST['post'] ); 
  8.  
  9. $count = 0; 
  10.  
  11. $action = trim( $_POST['action'] ); 
  12.  
  13. switch ( $action ) { 
  14. case 'delete' : 
  15. foreach ( $post_ids as $post_id ) { 
  16. $count += (int) (bool) bb_delete_post( $post_id, 1 ); 
  17. $query_vars = array( 'message' => 'deleted', 'count' => $count ); 
  18. break; 
  19. case 'undelete' : 
  20. foreach ( $post_ids as $post_id ) { 
  21. $count += (int) (bool) bb_delete_post( $post_id, 0 ); 
  22. $query_vars = array( 'message' => 'undeleted', 'count' => $count ); 
  23. break; 
  24. default : 
  25. if ( $action ) 
  26. $query_vars = apply_filters( "bulk_post__$action", array(), $post_ids, $action ); 
  27. break; 
  28.  
  29. bb_safe_redirect( add_query_arg( $query_vars ) ); 
  30. exit; 
  31.  
  32. if ( !empty( $_GET['message'] ) ) { 
  33. $message_count = isset( $_GET['count'] ) ? (int) $_GET['count'] : 1; 
  34.  
  35. switch ( (string) $_GET['message'] ) { 
  36. case 'undeleted': 
  37. bb_admin_notice( sprintf( _n( '<strong>Post undeleted.</strong>', '<strong>%s posts undeleted.</strong>', $message_count ), bb_number_format_i18n( $message_count ) ) ); 
  38. break; 
  39. case 'deleted': 
  40. bb_admin_notice( sprintf( _n( '<strong>Post deleted.</strong>', '<strong>%s posts deleted.</strong>', $message_count ), bb_number_format_i18n( $message_count ) ) ); 
  41. break; 
  42. case 'spammed': 
  43. bb_admin_notice( sprintf( _n( '<strong>Post spammed.</strong>', '<strong>%s posts spammed.</strong>', $message_count ), bb_number_format_i18n( $message_count ) ) ); 
  44. break; 
  45. case 'unspammed-normal': 
  46. bb_admin_notice( sprintf( _n( '<strong>Post removed from spam.</strong> It is now a normal post.', '<strong>%s posts removed from spam.</strong> They are now normal posts.', $message_count ), bb_number_format_i18n( $message_count ) ) ); 
  47. break; 
  48. case 'unspammed-deleted': 
  49. bb_admin_notice( sprintf( _n( '<strong>Post removed from spam.</strong> It is now a deleted post.', '<strong>%s posts removed from spam.</strong> They are nowdeleted posts.', $message_count ), bb_number_format_i18n( $message_count ) ) ); 
  50. break; 
  51.  
  52. $ip_available = false; 
  53. if ( bb_current_user_can( 'view_by_ip' ) ) { 
  54. $ip_available = true; 
  55. } elseif (isset($_GET['poster_ip'])) { 
  56. unset( $_GET['poster_ip'] ); 
  57.  
  58. $bb_admin_body_class = ' bb-admin-posts'; 
  59.  
  60. bb_get_admin_header(); 
  61.  
  62. if ( !bb_current_user_can('browse_deleted') ) 
  63. die(__("Now how'd you get here? And what did you think you'd being doing?")); //This should never happen. 
  64. add_filter( 'get_topic_where', 'bb_no_where' ); 
  65. add_filter( 'get_topic_link', 'bb_make_link_view_all' ); 
  66. add_filter( 'post_edit_uri', 'bb_make_link_view_all' ); 
  67. $post_query = new BB_Query_Form( 'post', array( 'post_status' => 'normal', 'count' => true, 'per_page' => 20 ) ); 
  68. $bb_posts =& $post_query->results; 
  69. $total = $post_query->found_rows; 
  70. ?> 
  71.  
  72. <div class="wrap"> 
  73.  
  74. <h2><?php _e( 'Posts' ); ?> 
  75. <?php 
  76. $h2_search = $post_query->get( 'post_text' ); 
  77. $h2_forum = $post_query->get( 'forum_id' ); 
  78. $h2_tag = $post_query->get( 'tag_id' ); 
  79. $h2_author = $post_query->get( 'post_author_id' ); 
  80.  
  81. $h2_search = $h2_search ? ' ' . sprintf( __('containing “%s”'), esc_html( $h2_search ) ) : ''; 
  82. $h2_forum = $h2_forum ? ' ' . sprintf( __('in “%s”') , get_forum_name( $h2_forum ) ) : ''; 
  83. $h2_tag = $h2_tag ? ' ' . sprintf( __('with tag “%s”'), esc_html( bb_get_tag_name( $h2_tag ) ) ) : ''; 
  84. $h2_author = $h2_author ? ' ' . sprintf( __('by %s') , esc_html( get_user_name( $h2_author ) ) ) : ''; 
  85.  
  86. if ($ip_available) { 
  87. $h2_ip = $post_query->get( 'poster_ip' ); 
  88. $h2_ip = $h2_ip ? ' ' . sprintf( __('from IP address %s'), esc_html( $h2_ip ) ) : ''; 
  89. } else { 
  90. $h2_ip = ''; 
  91.  
  92. if ( $h2_search || $h2_forum || $h2_tag || $h2_author || $h2_ip ) { 
  93. echo '<span class="subtitle">'; 
  94.  
  95. printf( __( '%1$s%2$s%3$s%4$s%5$s' ), $h2_search, $h2_forum, $h2_tag, $h2_author, $h2_ip ); 
  96.  
  97. echo '</span>'; 
  98. ?> 
  99. </h2> 
  100. <?php 
  101.  
  102. do_action( 'bb_admin_notices' ); 
  103.  
  104. $post_query->form( array( 'poster_ip' => $ip_available, 'tag' => true, 'post_author' => true, 'post_status' => true, 'submit' => __( 'Filter' ) ) ); 
  105.  
  106. $bulk_actions = array( 
  107. 'delete' => __( 'Delete' ),  
  108. 'undelete' => __( 'Undelete' ),  
  109. ); 
  110.  
  111. if ( is_numeric( $bulk_action = $post_query->get( 'post_status' ) ) ) { 
  112. switch ( $bulk_action ) { 
  113. case 0 : 
  114. unset( $bulk_actions['undelete'] ); 
  115. break; 
  116. case 1 :  
  117. unset( $bulk_actions['delete'] ); 
  118.  
  119. unset( $bulk_action ); 
  120.  
  121. do_action_ref_array( 'bulk_post_actions', array( &$bulk_actions, &$post_query ) ); 
  122.  
  123. ?> 
  124.  
  125. <div class="clear"></div> 
  126.  
  127. <form class="table-form bulk-form" method="post" action=""> 
  128.  
  129. <fieldset> 
  130. <select name="action"> 
  131. <option><?php _e( 'Bulk Actions' ); ?></option> 
  132. <?php foreach ( $bulk_actions as $value => $label ) : ?> 
  133.  
  134. <option value="<?php echo esc_attr( $value ); ?>"><?php echo esc_html( $label ); ?></option> 
  135. <?php endforeach; ?> 
  136. </select> 
  137. <input type="submit" value="<?php esc_attr_e( 'Apply' ); ?>" class="button submit-input" /> 
  138. <?php bb_nonce_field( 'post-bulk' ); ?> 
  139. </fieldset> 
  140.  
  141. <div class="tablenav"> 
  142. <?php if ( $total ) : ?> 
  143. <div class="tablenav-pages"> 
  144. <span class="displaying-num"><?php echo $displaying_num = sprintf( 
  145. __( '%1$s to %2$s of %3$s' ),  
  146. bb_number_format_i18n( ( $page - 1 ) * $post_query->get( 'per_page' ) + 1 ),  
  147. $page * $post_query->get( 'per_page' ) < $total ? bb_number_format_i18n( $page * $post_query->get( 'per_page' ) ) : '<span class="total-type-count">' . bb_number_format_i18n( $total ) . '</span>',  
  148. '<span class="total-type-count">' . bb_number_format_i18n( $total ) . '</span>' 
  149. ); ?></span><span class="displaying-pages"> 
  150. <?php 
  151. $_page_link_args = array( 
  152. 'page' => $page,  
  153. 'total' => $total,  
  154. 'per_page' => $post_query->get( 'per_page' ),  
  155. 'mod_rewrite' => false,  
  156. 'prev_text' => __( '«' ),  
  157. 'next_text' => __( '»' ) 
  158. ); 
  159. echo $page_number_links = get_page_number_links( $_page_link_args ); 
  160. ?></span> 
  161. <div class="clear"></div> 
  162. </div> 
  163. <?php endif; ?> 
  164. </div> 
  165.  
  166. <div class="clear"></div> 
  167.  
  168. <?php bb_admin_list_posts(); ?> 
  169.  
  170. </form> 
  171.  
  172. <div class="tablenav bottom"> 
  173. <?php if ( $total ) : ?> 
  174. <div class="tablenav-pages"> 
  175. <span class="displaying-pages"><?php echo $page_number_links; ?></span> 
  176. <div class="clear"></div> 
  177. </div> 
  178. <?php endif; ?> 
  179. </div> 
  180. <div class="clear"></div> 
  181.  
  182. </div> 
  183.  
  184. <?php bb_get_admin_footer(); ?> 
.