[ Root ] [ Search ] [ Index ]

PHP Cross Reference of WordPress MU 2.9.2

Provided by Yoast

title

Body

[close]

/wp-admin/ -> wpmu-users.php (source)

   1  <?php
   2  require_once ('admin.php');
   3  
   4  $title = __('WordPress MU &rsaquo; Admin &rsaquo; Users');
   5  $parent_file = 'wpmu-admin.php';
   6  
   7  wp_enqueue_script( 'admin-forms' );
   8  
   9  require_once ('admin-header.php');
  10  
  11  if( is_site_admin() == false ) {
  12      wp_die( __('You do not have permission to access this page.') );
  13  }
  14  
  15  if ( $_GET['updated'] == 'true' ) {
  16      ?>
  17      <div id="message" class="updated fade"><p>
  18          <?php
  19          switch ($_GET['action']) {
  20              case 'delete':
  21                  _e('User deleted !');
  22              break;
  23              case 'all_spam':
  24                  _e('Users marked as spam !');
  25              break;
  26              case 'all_notspam': 
  27                  _e('Users marked as not spam !'); 
  28              break; 
  29              case 'all_delete':
  30                  _e('Users deleted !');
  31              break;
  32              case 'add':
  33                  _e('User added !');
  34              break;
  35          }
  36          ?>
  37      </p></div>
  38      <?php
  39  }
  40  ?>
  41  
  42  <div class="wrap" style="position:relative;">
  43      <?php
  44      $apage = isset( $_GET['apage'] ) ? intval( $_GET['apage'] ) : 1;
  45      $num = isset( $_GET['num'] ) ? intval( $_GET['num'] ) : 15;
  46      $s = wp_specialchars( trim( $_GET[ 's' ] ) );
  47  
  48      $query = "SELECT * FROM {$wpdb->users}";
  49  
  50      if( !empty( $s ) ) {
  51          $search = '%' . trim( $s ) . '%';
  52          $query .= " WHERE user_login LIKE '$search' OR user_email LIKE '$search'";
  53      }
  54  
  55      if( !isset($_GET['sortby']) ) {
  56          $_GET['sortby'] = 'id';
  57      }
  58  
  59      if( $_GET['sortby'] == 'email' ) {
  60          $query .= ' ORDER BY user_email ';
  61      } elseif( $_GET['sortby'] == 'id' ) {
  62          $query .= ' ORDER BY ID ';
  63      } elseif( $_GET['sortby'] == 'login' ) {
  64          $query .= ' ORDER BY user_login ';
  65      } elseif( $_GET['sortby'] == 'name' ) {
  66          $query .= ' ORDER BY display_name ';
  67      } elseif( $_GET['sortby'] == 'registered' ) {
  68          $query .= ' ORDER BY user_registered ';
  69      }
  70  
  71      $query .= ( $_GET['order'] == 'DESC' ) ? 'DESC' : 'ASC';
  72  
  73      if( !empty( $s )) {
  74          $total = $wpdb->get_var( str_replace('SELECT *', 'SELECT COUNT(ID)', $query) );
  75      } else {
  76          $total = $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->users}");
  77      }
  78  
  79      $query .= " LIMIT " . intval( ( $apage - 1 ) * $num) . ", " . intval( $num );
  80  
  81      $user_list = $wpdb->get_results( $query, ARRAY_A );
  82  
  83      // Pagination
  84      $user_navigation = paginate_links( array(
  85          'total' => ceil($total / $num),    
  86          'current' => $apage,
  87          'base' => add_query_arg( 'apage', '%#%' ),
  88          'format' => ''
  89      ));
  90      
  91      if ( $user_navigation ) {
  92          $user_navigation = sprintf( '<span class="displaying-num">' . __( 'Displaying %s&#8211;%s of %s' ) . '</span>%s',
  93              number_format_i18n( ( $apage - 1 ) * $num + 1 ),
  94              number_format_i18n( min( $apage * $num, $total ) ),
  95              number_format_i18n( $total ),
  96              $user_navigation
  97          );
  98      }
  99      
 100      ?>
 101      <div class="wrap">
 102      <h2><?php _e( $current_site->site_name ); ?> <?php _e("Users"); ?></h2>
 103      <form action="wpmu-users.php" method="get" class="search-form">
 104          <p class="search-box">
 105          <input type="text" name="s" value="<?php if (isset($_GET['s'])) _e( stripslashes( $s ) ); ?>" class="search-input" id="user-search-input" />
 106          <input type="submit" id="post-query-submit" value="<?php _e('Search Users') ?>" class="button" />
 107          </p>
 108      </form>
 109      </div>
 110  
 111      <form id="form-user-list" action='wpmu-edit.php?action=allusers' method='post'>
 112          <div class="tablenav">
 113              <?php if ( $user_navigation ) echo "<div class='tablenav-pages'>$user_navigation</div>"; ?>
 114  
 115              <div class="alignleft actions">
 116                  <input type="submit" value="<?php _e('Delete') ?>" name="alluser_delete" class="button-secondary delete" />
 117                  <input type="submit" value="<?php _e('Mark as Spammers') ?>" name="alluser_spam" class="button-secondary" />
 118                  <input type="submit" value="<?php _e('Not Spam') ?>" name="alluser_notspam" class="button-secondary" />
 119                  <?php wp_nonce_field( 'allusers' ); ?>
 120                  <br class="clear" />
 121              </div>
 122          </div>
 123  
 124          <?php if( isset($_GET['s']) && $_GET['s'] != '' ) : ?>
 125              <p><a href="wpmu-blogs.php?action=blogs&amp;s=<?php echo urlencode( stripslashes( $s ) ); ?>&blog_name=Search+blogs+by+name"><?php _e('Search Blogs for') ?> <strong><?php echo stripslashes( $s ) ?></strong></a></p>
 126          <?php endif; ?>
 127  
 128          <?php
 129          // define the columns to display, the syntax is 'internal name' => 'display name'
 130          $posts_columns = array(
 131              'checkbox'     => '',
 132              'login'      => __('Username'),
 133              'name'       => __('Name'),
 134              'email'      => __('E-mail'),
 135              'registered' => __('Registered'),
 136              'blogs'      => ''
 137          );
 138          $posts_columns = apply_filters('wpmu_users_columns', $posts_columns);
 139          ?>
 140          <table class="widefat" cellspacing="0">
 141              <thead>
 142              <tr>
 143                  <?php foreach( (array) $posts_columns as $column_id => $column_display_name) {
 144                      if( $column_id == 'blogs' ) {
 145                          echo '<th scope="col">'.__('Blogs').'</th>';
 146                      } elseif( $column_id == 'checkbox') {
 147                          echo '<th scope="col" class="check-column"><input type="checkbox" /></th>';
 148                      } else { ?>
 149                          <th scope="col"><a href="wpmu-users.php?sortby=<?php echo $column_id ?>&amp;<?php if( $_GET['sortby'] == $column_id ) { if( $_GET['order'] == 'DESC' ) { echo "order=ASC&amp;" ; } else { echo "order=DESC&amp;"; } } ?>apage=<?php echo $apage ?>"><?php echo $column_display_name; ?></a></th>
 150                      <?php } ?>
 151                  <?php } ?>
 152              </tr>
 153              </thead>
 154              <tbody id="users" class="list:user user-list">
 155              <?php if ($user_list) {
 156                  $bgcolor = '';
 157                  foreach ( (array) $user_list as $user) { 
 158                      $class = ('alternate' == $class) ? '' : 'alternate';
 159                      
 160                      $status_list = array( "spam" => "#faa", "deleted" => "#f55" );
 161                      
 162                      $bgcolour = "";
 163                      foreach ( $status_list as $status => $col ) {
 164                          if( $user[$status] ) {
 165                              $bgcolour = "style='background: $col'";
 166                          }
 167                      }
 168  
 169                      ?>
 170  
 171                      <tr <?php echo $bgcolour; ?> class="<?php echo $class; ?>">
 172                      <?php
 173                      foreach( (array) $posts_columns as $column_name=>$column_display_name) :
 174                          switch($column_name) {
 175                              case 'checkbox': ?>
 176                                  <th scope="row" class="check-column"><input type='checkbox' id='user_<?php echo $user['ID'] ?>' name='allusers[]' value='<?php echo $user['ID'] ?>' /></th>
 177                              <?php 
 178                              break;
 179  
 180                              case 'login':
 181                                  $avatar    = get_avatar( $user['user_email'], 32 );
 182                                  $edit    = clean_url( add_query_arg( 'wp_http_referer', urlencode( clean_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=".$user['ID'] ) );
 183                                  // @todo Make delete link work like delete button with transfering users (in wpmu-edit.php)
 184                                  //$delete    = clean_url( add_query_arg( 'wp_http_referer', urlencode( clean_url( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), wp_nonce_url( 'wpmu-edit.php', 'deleteuser' ) . '&amp;action=deleteuser&amp;id=' . $user['ID'] ) );
 185                                  ?>
 186                                  <td class="username column-username">
 187                                      <?php echo $avatar; ?><strong><a href="<?php echo $edit; ?>" class="edit"><?php echo stripslashes($user['user_login']); ?></a></strong>
 188                                      <br/>
 189                                      <div class="row-actions">
 190                                          <span class="edit"><a href="<?php echo $edit; ?>">Edit</a></span>
 191                                          <?php /*<span class="delete"><a href="<?php echo $delete; ?>" class="delete">Delete</a></span> */ ?>
 192                                      </div>
 193                                  </td>
 194                              <?php
 195                              break;
 196  
 197                              case 'name': ?>
 198                                  <td class="name column-name"><?php echo $user['display_name'] ?></td>
 199                              <?php
 200                              break;
 201  
 202                              case 'email': ?>
 203                                  <td class="email column-email"><a href="mailto:<?php echo $user['user_email'] ?>"><?php echo $user['user_email'] ?></a></td>
 204                              <?php
 205                              break;
 206  
 207                              case 'registered': ?>
 208                                  <td><?php echo mysql2date(__('Y-m-d \<\b\r \/\> g:i a'), $user['user_registered']); ?></td>
 209                              <?php
 210                              break;
 211  
 212                              case 'blogs': 
 213                                  $blogs = get_blogs_of_user( $user['ID'], true );
 214                                  ?>
 215                                  <td>
 216                                      <?php
 217                                      if( is_array( $blogs ) ) {
 218                                          foreach ( (array) $blogs as $key => $val ) {
 219                                              $path    = ($val->path == '/') ? '' : $val->path;
 220                                              echo '<a href="wpmu-blogs.php?action=editblog&amp;id=' . $val->userblog_id . '">' . str_replace( '.' . $current_site->domain, '', $val->domain . $path ) . '</a>';
 221                                              echo ' <small class="row-actions">';
 222                                              
 223                                              // Edit
 224                                              echo '<a href="wpmu-blogs.php?action=editblog&amp;id=' . $val->userblog_id . '">' . __('Edit') . '</a> | ';
 225                                              
 226                                              // View
 227                                              echo '<a '; 
 228                                              if( get_blog_status( $val->userblog_id, 'spam' ) == 1 )
 229                                                  echo 'style="background-color: #f66" ';
 230                                              echo 'target="_new" href="http://'.$val->domain . $val->path.'">' . __('View') . '</a>';
 231                                              
 232                                              echo '</small><br />'; 
 233                                          }
 234                                      }
 235                                      ?>
 236                                  </td>
 237                              <?php
 238                              break;
 239  
 240                              default: ?>
 241                                  <td><?php do_action('manage_users_custom_column', $column_name, $user['ID']); ?></td>
 242                              <?php
 243                              break;
 244                          }
 245                      endforeach
 246                      ?>
 247                      </tr> 
 248                      <?php
 249                  }
 250              } else {
 251              ?>
 252                  <tr style='background-color: <?php echo $bgcolor; ?>'> 
 253                      <td colspan="<?php echo (int) count($posts_columns); ?>"><?php _e('No users found.') ?></td> 
 254                  </tr> 
 255                  <?php
 256              } // end if ($users)
 257              ?> 
 258              </tbody>
 259          </table>
 260          
 261          <div class="tablenav">
 262              <?php if ( $user_navigation ) echo "<div class='tablenav-pages'>$user_navigation</div>"; ?>
 263  
 264              <div class="alignleft">
 265                  <input type="submit" value="<?php _e('Delete') ?>" name="alluser_delete" class="button-secondary delete" />
 266                  <input type="submit" value="<?php _e('Mark as Spammers') ?>" name="alluser_spam" class="button-secondary" />
 267                  <input type="submit" value="<?php _e('Not Spam') ?>" name="alluser_notspam" class="button-secondary" />
 268                  <?php wp_nonce_field( 'allusers' ); ?>
 269                  <br class="clear" />
 270              </div>
 271          </div>
 272      </form>
 273  </div>
 274  
 275  <?php
 276  if( apply_filters('show_adduser_fields', true) ) :
 277  ?>
 278  <div class="wrap">
 279      <h2><?php _e('Add user') ?></h2>
 280      <form action="wpmu-edit.php?action=adduser" method="post">
 281      <table class="form-table">
 282          <tr class="form-field form-required">
 283              <th scope='row'><?php _e('Username') ?></th>
 284              <td><input type="text" name="user[username]" /></td>
 285          </tr>
 286          <tr class="form-field form-required">
 287              <th scope='row'><?php _e('Email') ?></th>
 288              <td><input type="text" name="user[email]" /></td>
 289          </tr>
 290          <tr class="form-field">
 291              <td colspan='2'><?php _e('Username and password will be mailed to the above email address.') ?></td>
 292          </tr>
 293      </table>
 294      <p class="submit">
 295          <?php wp_nonce_field('add-user') ?>
 296          <input class="button" type="submit" name="Add user" value="<?php _e('Add user') ?>" /></p>
 297      </form>
 298  </div>
 299  <?php endif; ?>
 300  
 301  <?php include ('admin-footer.php'); ?>


Generated: Mon May 3 12:25:32 2010 Cross-referenced by PHPXref 0.7