[ Index ]

PHP Cross Reference of BuddyPress

title

Body

[close]

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

   1  <?php
   2  require_once ('admin.php');
   3  
   4  if ( 'post' == strtolower( $_SERVER['REQUEST_METHOD'] ) ) {
   5      bb_check_admin_referer( 'topic-bulk' );
   6  
   7      $topic_ids = array_map( 'absint', $_POST['topic'] );
   8  
   9      $affected = 0;
  10  
  11      $action = trim( $_POST['action'] );
  12  
  13      switch ( $action ) {
  14      case 'close' :
  15          foreach ( $topic_ids as $topic_id ) {
  16              $affected += bb_close_topic( $topic_id );
  17          }
  18          $query_vars = array( 'message' => 'closed', 'count' => $affected );
  19          break;
  20      case 'open' :
  21          foreach ( $topic_ids as $topic_id ) {
  22              $affected += bb_open_topic( $topic_id );
  23          }
  24          $query_vars = array( 'message' => 'opened', 'count' => $affected );
  25          break;
  26      case 'delete' :
  27          foreach ( $topic_ids as $topic_id ) {
  28              $affected += (int) (bool) bb_delete_topic( $topic_id, 1 );
  29          }
  30          $query_vars = array( 'message' => 'deleted', 'count' => $affected );
  31          break;
  32      case 'undelete' :
  33          foreach ( $topic_ids as $topic_id ) {
  34              $affected += (int) (bool) bb_delete_topic( $topic_id, 0 );
  35          }
  36          $query_vars = array( 'message' => 'undeleted', 'count' => $affected );
  37          break;
  38      default :
  39          if ( $action )
  40              $query_vars = apply_filters( "bulk_topic__$action", array(), $topic_ids );
  41          break;
  42      }
  43  
  44      bb_safe_redirect( add_query_arg( $query_vars ) );
  45      exit;
  46  }
  47  
  48  if ( !empty( $_GET['message'] ) ) {
  49      $message_count = isset( $_GET['count'] ) ? (int) $_GET['count'] : 1;
  50  
  51      switch ( (string) $_GET['message'] ) {
  52          case 'undeleted':
  53              bb_admin_notice( sprintf( _n( '<strong>Topic undeleted.</strong>', '<strong>%s topics undeleted.</strong>', $message_count ), bb_number_format_i18n( $message_count ) ) );
  54              break;
  55          case 'deleted':
  56              bb_admin_notice( sprintf( _n( '<strong>Topic deleted.</strong>', '<strong>%s topics deleted.</strong>', $message_count ), bb_number_format_i18n( $message_count ) ) );
  57              break;
  58          case 'opened':
  59              bb_admin_notice( sprintf( _n( '<strong>Topic opened.</strong>', '<strong>%s topics opened.</strong>', $message_count ), bb_number_format_i18n( $message_count ) ) );
  60              break;
  61          case 'closed':
  62              bb_admin_notice( sprintf( _n( '<strong>Topic closed.</strong>', '<strong>%s topics closed.</strong>', $message_count ), bb_number_format_i18n( $message_count ) ) );
  63              break;
  64      }
  65  }
  66  
  67  $bb_admin_body_class = ' bb-admin-topics';
  68  
  69  bb_get_admin_header();
  70  
  71  if ( !bb_current_user_can('browse_deleted') )
  72      die(__("Now how'd you get here?  And what did you think you'd being doing?")); //This should never happen.
  73  add_filter( 'topic_link', 'bb_make_link_view_all' );
  74  add_filter( 'topic_last_post_link', 'bb_make_link_view_all' );
  75  $topic_query_vars = array( 'topic_status' => 'normal', 'open' => 'open', 'count' => true, 'per_page' => 20 );
  76  if ( isset($_POST['search']) && $_POST['search'] ) {
  77      $topic_query_vars['post_status'] = 'all';
  78  } elseif ( isset($_GET['search']) && $_GET['search'] ) {
  79      $topic_query_vars['post_status'] = 'all';
  80  }
  81  $topic_query = new BB_Query_Form( 'topic', $topic_query_vars );
  82  $topics = $topic_query->results;
  83  ?>
  84  
  85  <div class="wrap">
  86  
  87  <h2><?php _e( 'Topics' ); ?>
  88  <?php
  89  $h2_search = $topic_query->get( 'search' );
  90  $h2_forum  = $topic_query->get( 'forum_id' );
  91  $h2_tag    = $topic_query->get( 'tag_id' );
  92  $h2_author = $topic_query->get( 'topic_author_id' );
  93  
  94  $h2_search = $h2_search ? ' ' . sprintf( __('containing &#8220;%s&#8221;'), esc_html( $h2_search ) ) : '';
  95  $h2_forum  = $h2_forum  ? ' ' . sprintf( __('in &#8220;%s&#8221;')      , get_forum_name( $h2_forum ) ) : '';
  96  $h2_tag    = $h2_tag    ? ' ' . sprintf( __('with tag &#8220;%s&#8221;'), esc_html( bb_get_tag_name( $h2_tag ) ) ) : '';
  97  $h2_author = $h2_author ? ' ' . sprintf( __('by %s')                    , esc_html( get_user_name( $h2_author ) ) ) : '';
  98  
  99  if ( $h2_search || $h2_forum || $h2_tag || $h2_author ) {
 100      echo '<span class="subtitle">';
 101      
 102      printf( __( '%1$s%2$s%3$s%4$s' ), $h2_search, $h2_forum, $h2_tag, $h2_author );
 103      
 104      echo '</span>';
 105  }
 106  ?>
 107  </h2>
 108  <?php do_action( 'bb_admin_notices' ); ?>
 109  
 110  <?php $topic_query->form( array('tag' => true, 'topic_author' => true, 'topic_status' => true, 'open' => true, 'submit' => __('Filter')) ); ?>
 111  
 112  <div class="clear"></div>
 113  
 114  <?php if ( !$topics ) : ?>
 115  
 116  <p class="no-results"><?php _e('No topics found.'); ?></p>
 117  
 118  <?php
 119  
 120  else :
 121      bb_cache_first_posts( $topics ); bb_cache_last_posts( $topics );
 122  
 123      $bulk_actions = array(
 124          'delete' => __( 'Delete' ),
 125          'undelete' => __( 'Undelete' ),
 126          'open' => __( 'Open' ),
 127          'close' => __( 'Close' ),
 128      );
 129  
 130      if ( is_numeric( $bulk_action = $topic_query->get( 'topic_status' ) ) )
 131          unset( $bulk_actions[ $bulk_action ? 'delete' : 'undelete' ] );
 132  
 133  
 134      if ( is_numeric( $bulk_action = $topic_query->get( 'open' ) ) )
 135          unset( $bulk_actions[ $bulk_action ? 'open' : 'close' ] );
 136  
 137      unset( $bulk_action );
 138  
 139      do_action_ref_array( 'bulk_topic_actions', array( &$bulk_actions, $topic_query ) );
 140  ?>
 141  
 142  <form class="table-form bulk-form" method="post" action="">
 143  <fieldset>
 144      <select name="action">
 145          <option><?php _e( 'Bulk Actions' ); ?></option>
 146  <?php    foreach ( $bulk_actions as $value => $label ) : ?>
 147  
 148          <option value="<?php echo esc_attr( $value ); ?>"><?php echo esc_html( $label ); ?></option>
 149  <?php    endforeach; ?>
 150      </select>
 151      <input type="submit" value="<?php esc_attr_e( 'Apply' ); ?>" class="button submit-input" />
 152      <?php bb_nonce_field( 'topic-bulk' ); ?>
 153  </fieldset>
 154  
 155  <div class="tablenav">
 156  <?php if ( $topic_query->found_rows ) : ?>
 157      <div class="tablenav-pages">
 158          <span class="displaying-num"><?php echo $displaying_num = sprintf(
 159              __( '%1$s to %2$s of %3$s' ),
 160              bb_number_format_i18n( ( $page - 1 ) * $topic_query->get( 'per_page' ) + 1 ),
 161              $page * $topic_query->get( 'per_page' ) < $topic_query->found_rows ? bb_number_format_i18n( $page * $topic_query->get( 'per_page' ) ) : '<span class="total-type-count">' . bb_number_format_i18n( $topic_query->found_rows ) . '</span>',
 162              '<span class="total-type-count">' . bb_number_format_i18n( $topic_query->found_rows ) . '</span>'
 163          ); ?></span><span class="displaying-pages">
 164  <?php
 165  $_page_link_args = array(
 166      'page' => $page,
 167      'total' => $topic_query->found_rows,
 168      'per_page' => $topic_query->get( 'per_page' ),
 169      'mod_rewrite' => false,
 170      'prev_text' => __( '&laquo;' ),
 171      'next_text' => __( '&raquo;' )
 172  );
 173  echo $page_number_links = get_page_number_links( $_page_link_args );
 174  ?></span>
 175          <div class="clear"></div>
 176      </div>
 177  <?php endif; ?>
 178  </div>
 179  
 180  <div class="clear"></div>
 181  
 182  <table id="topics-list" class="widefat">
 183  <thead>
 184  <tr>
 185      <th scope="col" class="check-column"><input type="checkbox" /></th>
 186      <th scope="col"><?php _e('Topic') ?></th>
 187      <th scope="col"><?php _e('Author') ?></th>
 188      <th scope="col"><?php _e('Posts') ?></th>
 189      <th scope="col"><?php _e('Date') ?></th>
 190      <th scope="col"><?php _e('Freshness') ?></th>
 191  </tr>
 192  </thead>
 193  <tfoot>
 194  <tr>
 195      <th scope="col" class="check-column"><input type="checkbox" /></th>
 196      <th scope="col"><?php _e('Topic') ?></th>
 197      <th scope="col"><?php _e('Author') ?></th>
 198      <th scope="col"><?php _e('Posts') ?></th>
 199      <th scope="col"><?php _e('Date') ?></th>
 200      <th scope="col"><?php _e('Freshness') ?></th>
 201  </tr>
 202  </thead>
 203  
 204  <tbody>
 205  <?php foreach ( $topics as $topic ) : $first_post = bb_get_first_post( $topic ); ?>
 206  <tr id="topic-<?php echo $topic->topic_id; ?>"<?php topic_class(); ?>>
 207      <td class="check-column"><input type="checkbox" name="topic[]" value="<?php echo $topic->topic_id; ?>" /></td>
 208      <td class="topic">
 209          <span class="row-title"><?php bb_topic_labels(); ?> <a href="<?php topic_link(); ?>"><?php topic_title(); ?></a></span>
 210          <div>
 211          <span class="row-actions">
 212              <a href="<?php topic_link(); ?>"><?php _e( 'View' ); ?></a> |
 213              <?php if ( $first_post ) : post_edit_link( $first_post->post_id ); ?> |
 214              <?php endif; topic_close_link( array( 'id' => $topic->topic_id, 'before' => '', 'after' => '', 'close_text' => __( 'Close' ), 'open_text' => _x( 'Open', 'action' ) ) ); ?> |
 215              <?php topic_delete_link( array( 'id' => $topic->topic_id, 'before' => '', 'after' => '', 'delete_text' => __( 'Delete' ), 'undelete_text' => __( 'Undelete' ) ) ); ?>
 216          </span>&nbsp;
 217          </div>
 218      </td>
 219      <td class="author">
 220          <a class="author-link" href="<?php user_profile_link( $topic->topic_poster ); ?>">
 221              <?php echo bb_get_avatar( $topic->topic_poster, '16' ); ?>
 222              <?php topic_author(); ?>
 223          </a>
 224      </td>
 225      <td class="posts num"><?php topic_posts(); ?></td>
 226      <td class="date num">
 227  <?php
 228      if ( get_topic_start_time( 'U' ) < ( time() - 86400 ) ) {
 229          topic_start_time( 'Y/m/d\<\b\r \/\>H:i:s' );
 230      } else {
 231          printf( __( '%s ago' ), get_topic_start_time( 'since' ) );
 232      }
 233  ?>
 234      </td>
 235      <td class="freshness num"><a href="<?php topic_last_post_link(); ?>" title="<?php echo esc_attr( sprintf( __( 'Last post by %s' ), get_topic_last_poster() ) ); ?>">
 236  <?php
 237      if ( get_topic_time( 'U' ) < ( time() - 86400 ) ) {
 238          topic_time( 'Y/m/d\<\b\r \/\>H:i:s' );
 239      } else {
 240          printf( __( '%s ago' ), get_topic_time( 'since' ) );
 241      }
 242  ?>
 243      
 244      <?php //topic_time( bb_get_datetime_formatstring_i18n() ); ?>
 245      
 246      
 247      </a></td>
 248  </tr>
 249  <?php endforeach; ?>
 250  </tbody>
 251  </table>
 252  </form>
 253  <?php endif; ?>
 254  
 255  <div class="tablenav bottom">
 256  <?php if ( $topic_query->found_rows ) : ?>
 257      <div class="tablenav-pages">
 258          <span class="displaying-pages"><?php echo $page_number_links; ?></span>
 259          <div class="clear"></div>
 260      </div>
 261  <?php endif; ?>
 262  </div>
 263  <div class="clear"></div>
 264  
 265  </div>
 266  
 267  <?php bb_get_admin_footer(); ?>


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