Changeset 15491 for trunk/wp-admin/network/users.php
- Timestamp:
- 08/11/2010 09:54:51 PM (16 years ago)
- File:
-
- 1 edited
-
trunk/wp-admin/network/users.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/network/users.php
r15481 r15491 33 33 ); 34 34 35 wp_enqueue_script( 'admin-forms' );35 require_once( './includes/default-list-tables.php' ); 36 36 37 require_once( '../admin-header.php' );37 $table = new WP_MS_Users_Table; 38 38 39 if ( isset( $_GET['updated'] ) && $_GET['updated'] == 'true' && ! empty( $_GET['action'] ) ) { 39 require_once( './admin-header.php' ); 40 41 if ( isset( $_REQUEST['updated'] ) && $_REQUEST['updated'] == 'true' && ! empty( $_REQUEST['action'] ) ) { 40 42 ?> 41 43 <div id="message" class="updated"><p> 42 44 <?php 43 switch ( $_ GET['action'] ) {45 switch ( $_REQUEST['action'] ) { 44 46 case 'delete': 45 47 _e( 'User deleted.' ); … … 62 64 <?php 63 65 } 64 65 $pagenum = isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 0;66 if ( empty( $pagenum ) )67 $pagenum = 1;68 69 $per_page = (int) get_user_option( 'ms_users_per_page' );70 if ( empty( $per_page ) || $per_page < 1 )71 $per_page = 15;72 73 $per_page = apply_filters( 'ms_users_per_page', $per_page );74 75 $s = isset( $_GET['s'] ) ? stripslashes( trim( $_GET[ 's' ] ) ) : '';76 $like_s = esc_sql( like_escape( $s ) );77 78 $query = "SELECT * FROM {$wpdb->users}";79 80 if ( !empty( $like_s ) ) {81 $query .= " WHERE user_login LIKE '%$like_s%' OR user_email LIKE '%$like_s%'";82 }83 84 $order_by = isset( $_GET['sortby'] ) ? $_GET['sortby'] : 'id';85 if ( $order_by == 'email' ) {86 $query .= ' ORDER BY user_email ';87 } elseif ( $order_by == 'login' ) {88 $query .= ' ORDER BY user_login ';89 } elseif ( $order_by == 'name' ) {90 $query .= ' ORDER BY display_name ';91 } elseif ( $order_by == 'registered' ) {92 $query .= ' ORDER BY user_registered ';93 } else {94 $order_by = 'id';95 $query .= ' ORDER BY ID ';96 }97 98 $order = ( isset( $_GET['order'] ) && 'DESC' == $_GET['order'] ) ? 'DESC' : 'ASC';99 $query .= $order;100 101 $total = $wpdb->get_var( str_replace( 'SELECT *', 'SELECT COUNT(ID)', $query ) );102 103 $query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page) . ", " . intval( $per_page );104 105 $user_list = $wpdb->get_results( $query, ARRAY_A );106 107 $num_pages = ceil( $total / $per_page );108 $page_links = paginate_links( array(109 'base' => add_query_arg( 'paged', '%#%' ),110 'format' => '',111 'prev_text' => __( '«' ),112 'next_text' => __( '»' ),113 'total' => $num_pages,114 'current' => $pagenum115 ));116 117 if ( empty( $_GET['mode'] ) )118 $mode = 'list';119 else120 $mode = esc_attr( $_GET['mode'] );121 122 66 ?> 123 <div class="wrap">67 <div class="wrap"> 124 68 <?php screen_icon(); ?> 125 69 <h2><?php esc_html_e( 'Users' ); ?> 126 70 <a href="#form-add-user" class="button add-new-h2"><?php echo esc_html_x( 'Add New' , 'users'); ?></a> 127 71 <?php 128 if ( isset( $_ GET['s'] ) && $_GET['s'] )72 if ( isset( $_REQUEST['s'] ) && $_REQUEST['s'] ) 129 73 printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $s ) ); 130 74 ?> 131 75 </h2> 132 76 133 <form action=" users.php" method="get" class="search-form">77 <form action="ms-users.php" method="get" class="search-form"> 134 78 <p class="search-box"> 135 79 <input type="text" name="s" value="<?php echo esc_attr( $s ); ?>" class="search-input" id="user-search-input" /> … … 138 82 </form> 139 83 140 <form id="form-user-list" action='edit.php?action=allusers' method='post'> 141 <input type="hidden" name="mode" value="<?php echo esc_attr( $mode ); ?>" /> 142 <div class="tablenav"> 143 <div class="alignleft actions"> 144 <select name="action"> 145 <option value="-1" selected="selected"><?php _e( 'Bulk Actions' ); ?></option> 146 <option value="delete"><?php _e( 'Delete' ); ?></option> 147 <option value="spam"><?php _ex( 'Mark as Spam', 'user' ); ?></option> 148 <option value="notspam"><?php _ex( 'Not Spam', 'user' ); ?></option> 149 </select> 150 <input type="submit" value="<?php esc_attr_e( 'Apply' ); ?>" name="doaction" id="doaction" class="button-secondary action" /> 151 <?php wp_nonce_field( 'bulk-ms-users', '_wpnonce_bulk-ms-users' ); ?> 152 </div> 153 154 <?php if ( $page_links ) { ?> 155 <div class="tablenav-pages"> 156 <?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s', 157 number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ), 158 number_format_i18n( min( $pagenum * $per_page, $total ) ), 159 number_format_i18n( $total ), 160 $page_links 161 ); echo $page_links_text; ?> 162 </div> 163 <?php } ?> 164 165 <div class="view-switch"> 166 <a href="<?php echo esc_url( add_query_arg( 'mode', 'list', $_SERVER['REQUEST_URI'] ) ) ?>"><img <?php if ( 'list' == $mode ) echo 'class="current"'; ?> id="view-switch-list" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e( 'List View' ) ?>" alt="<?php _e( 'List View' ) ?>" /></a> 167 <a href="<?php echo esc_url( add_query_arg( 'mode', 'excerpt', $_SERVER['REQUEST_URI'] ) ) ?>"><img <?php if ( 'excerpt' == $mode ) echo 'class="current"'; ?> id="view-switch-excerpt" src="<?php echo esc_url( includes_url( 'images/blank.gif' ) ); ?>" width="20" height="20" title="<?php _e( 'Excerpt View' ) ?>" alt="<?php _e( 'Excerpt View' ) ?>" /></a> 168 </div> 169 </div> 170 <div class="clear"></div> 171 172 <?php 173 // define the columns to display, the syntax is 'internal name' => 'display name' 174 $users_columns = array( 175 'id' => __( 'ID' ), 176 'login' => __( 'Username' ), 177 'name' => __( 'Name' ), 178 'email' => __( 'E-mail' ), 179 'registered' => _x( 'Registered', 'user' ), 180 'blogs' => __( 'Sites' ) 181 ); 182 $users_columns = apply_filters( 'wpmu_users_columns', $users_columns ); 183 ?> 184 <table class="widefat"> 185 <thead> 186 <tr> 187 <th class="manage-column column-cb check-column" scope="col"> 188 <input type="checkbox" /> 189 </th> 190 <?php 191 $col_url = ''; 192 foreach($users_columns as $column_id => $column_display_name) { 193 $column_link = "<a href='"; 194 $order2 = ''; 195 if ( $order_by == $column_id ) 196 $order2 = ( $order == 'DESC' ) ? 'ASC' : 'DESC'; 197 198 $column_link .= esc_url( add_query_arg( array( 'order' => $order2, 'paged' => $pagenum, 'sortby' => $column_id ), remove_query_arg( array( 'action', 'updated' ), $_SERVER['REQUEST_URI'] ) ) ); 199 $column_link .= "'>{$column_display_name}</a>"; 200 $col_url .= '<th scope="col">' . ( $column_id == 'blogs' ? $column_display_name : $column_link ) . '</th>'; 201 } 202 echo $col_url; ?> 203 </tr> 204 </thead> 205 <tfoot> 206 <tr> 207 <th class="manage-column column-cb check-column" scope="col"> 208 <input type="checkbox" /> 209 </th> 210 <?php echo $col_url; ?> 211 </tr> 212 </tfoot> 213 <tbody id="the-user-list" class="list:user"> 214 <?php if ( $user_list ) { 215 $class = ''; 216 $super_admins = get_super_admins(); 217 foreach ( (array) $user_list as $user ) { 218 $class = ( 'alternate' == $class ) ? '' : 'alternate'; 219 220 $status_list = array( 'spam' => 'site-spammed', 'deleted' => 'site-deleted' ); 221 222 foreach ( $status_list as $status => $col ) { 223 if ( $user[$status] ) 224 $class = $col; 225 } 226 227 ?> 228 <tr class="<?php echo $class; ?>"> 229 <?php 230 foreach( (array) $users_columns as $column_name=>$column_display_name ) : 231 switch( $column_name ) { 232 case 'id': ?> 233 <th scope="row" class="check-column"> 234 <input type="checkbox" id="blog_<?php echo $user['ID'] ?>" name="allusers[]" value="<?php echo esc_attr( $user['ID'] ) ?>" /> 235 </th> 236 <th valign="top" scope="row"> 237 <?php echo $user['ID'] ?> 238 </th> 239 <?php 240 break; 241 242 case 'login': 243 $avatar = get_avatar( $user['user_email'], 32 ); 244 $edit_link = ( $current_user->ID == $user['ID'] ) ? 'profile.php' : 'user-edit.php?user_id=' . $user['ID']; 245 ?> 246 <td class="username column-username"> 247 <?php echo $avatar; ?><strong><a href="<?php echo esc_url( network_admin_url( $edit_link ) ); ?>" class="edit"><?php echo stripslashes( $user['user_login'] ); ?></a><?php 248 if ( in_array( $user['user_login'], $super_admins ) ) 249 echo ' - ' . __( 'Super admin' ); 250 ?></strong> 251 <br/> 252 <div class="row-actions"> 253 <span class="edit"><a href="<?php echo esc_url( network_admin_url( $edit_link ) ); ?>"><?php _e( 'Edit' ); ?></a></span> 254 <?php if ( ! in_array( $user['user_login'], $super_admins ) ) { ?> 255 | <span class="delete"><a href="<?php echo $delete = esc_url( admin_url( add_query_arg( '_wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), wp_nonce_url( 'edit.php', 'deleteuser' ) . '&action=deleteuser&id=' . $user['ID'] ) ) ); ?>" class="delete"><?php _e( 'Delete' ); ?></a></span> 256 <?php } ?> 257 </div> 258 </td> 259 <?php 260 break; 261 262 case 'name': ?> 263 <td class="name column-name"><?php echo $user['display_name'] ?></td> 264 <?php 265 break; 266 267 case 'email': ?> 268 <td class="email column-email"><a href="mailto:<?php echo $user['user_email'] ?>"><?php echo $user['user_email'] ?></a></td> 269 <?php 270 break; 271 272 case 'registered': 273 if ( 'list' == $mode ) 274 $date = 'Y/m/d'; 275 else 276 $date = 'Y/m/d \<\b\r \/\> g:i:s a'; 277 ?> 278 <td><?php echo mysql2date( __( $date ), $user['user_registered'] ); ?></td> 279 <?php 280 break; 281 282 case 'blogs': 283 $blogs = get_blogs_of_user( $user['ID'], true ); 284 ?> 285 <td> 286 <?php 287 if ( is_array( $blogs ) ) { 288 foreach ( (array) $blogs as $key => $val ) { 289 $path = ( $val->path == '/' ) ? '' : $val->path; 290 echo '<a href="'. esc_url( network_admin_url( 'sites.php?action=editblog&id=' . $val->userblog_id ) ) .'">' . str_replace( '.' . $current_site->domain, '', $val->domain . $path ) . '</a>'; 291 echo ' <small class="row-actions">'; 292 293 // Edit 294 echo '<a href="'. esc_url( network_admin_url( 'sites.php?action=editblog&id=' . $val->userblog_id ) ) .'">' . __( 'Edit' ) . '</a> | '; 295 296 // View 297 echo '<a '; 298 if ( get_blog_status( $val->userblog_id, 'spam' ) == 1 ) 299 echo 'style="background-color: #faa" '; 300 echo 'href="' . esc_url( get_home_url( $val->userblog_id ) ) . '">' . __( 'View' ) . '</a>'; 301 302 echo '</small><br />'; 303 } 304 } 305 ?> 306 </td> 307 <?php 308 break; 309 310 default: ?> 311 <td><?php do_action( 'manage_users_custom_column', $column_name, $user['ID'] ); ?></td> 312 <?php 313 break; 314 } 315 endforeach 316 ?> 317 </tr> 318 <?php 319 } 320 } else { 321 ?> 322 <tr> 323 <td colspan="<?php echo (int) count($users_columns); ?>"><?php _e( 'No users found.' ) ?></td> 324 </tr> 325 <?php 326 } // end if ($users) 327 ?> 328 </tbody> 329 </table> 330 331 <div class="tablenav"> 332 <?php 333 if ( $page_links ) 334 echo "<div class='tablenav-pages'>$page_links_text</div>"; 335 ?> 336 337 <div class="alignleft actions"> 338 <select name="action2"> 339 <option value="-1" selected="selected"><?php _e( 'Bulk Actions' ); ?></option> 340 <option value="delete"><?php _e( 'Delete' ); ?></option> 341 <option value="spam"><?php _ex( 'Mark as Spam', 'user' ); ?></option> 342 <option value="notspam"><?php _ex( 'Not Spam', 'user' ); ?></option> 343 </select> 344 <input type="submit" value="<?php esc_attr_e( 'Apply' ); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 345 </div> 346 <br class="clear" /> 347 </div> 348 349 </form> 350 </div> 84 <form id="form-user-list" action='ms-edit.php?action=allusers' method='post'> 85 <?php $table->display(); ?> 86 </form> 87 </div> 351 88 352 89 <?php … … 355 92 <div class="wrap" id="form-add-user"> 356 93 <h3><?php _e( 'Add User' ) ?></h3> 357 <form action=" edit.php?action=adduser" method="post">94 <form action="ms-edit.php?action=adduser" method="post"> 358 95 <table class="form-table"> 359 96 <tr class="form-field form-required"> … … 376 113 <?php endif; ?> 377 114 378 <?php include( '. ./admin-footer.php' ); ?>115 <?php include( './admin-footer.php' ); ?>
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)