From b2c3ace49aeee37c5e5de99042212d93798c6dd1 Mon Sep 17 00:00:00 2001 From: ryan Date: Sat, 6 Mar 2010 18:31:10 +0000 Subject: [PATCH] Update ms-sites UI. Props ocean90. see #12460 git-svn-id: http://svn.automattic.com/wordpress/trunk@13609 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/misc.php | 2 + wp-admin/includes/template.php | 6 + wp-admin/ms-edit.php | 51 ++++-- wp-admin/ms-sites.php | 312 +++++++++++++++++++++++---------- 4 files changed, 259 insertions(+), 112 deletions(-) diff --git a/wp-admin/includes/misc.php b/wp-admin/includes/misc.php index 0e6a07275c..77a4feead0 100644 --- a/wp-admin/includes/misc.php +++ b/wp-admin/includes/misc.php @@ -410,6 +410,8 @@ function set_screen_options() { switch ( $map_option ) { case 'edit_per_page': + case 'ms_sites_per_page': + case 'ms_users_per_page': case 'edit_comments_per_page': case 'upload_per_page': case 'categories_per_page': diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index df00d2cfca..385747f8c2 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -3767,6 +3767,12 @@ function screen_options($screen) { case 'edit-pages': $per_page_label = __('Pages per page:'); break; + case 'ms-sites': + $per_page_label = __('Sites per page:'); + break; + case 'ms-users': + $per_page_label = __('Users per page:'); + break; case 'edit-comments': $per_page_label = __('Comments per page:'); break; diff --git a/wp-admin/ms-edit.php b/wp-admin/ms-edit.php index 910bc49870..8f19e707a0 100644 --- a/wp-admin/ms-edit.php +++ b/wp-admin/ms-edit.php @@ -221,6 +221,9 @@ switch ( $_GET['action'] ) { // rewrite rules can't be flushed during switch to blog delete_option( 'rewrite_rules' ); + // update blogs count + delete_site_transient( "blog_count" ); + // update blogs table $blog_data = stripslashes_deep($_POST[ 'blog' ]); update_blog_details($id, $blog_data); @@ -292,35 +295,52 @@ switch ( $_GET['action'] ) { if ( $id != '0' && $id != $current_site->blog_id ) wpmu_delete_blog( $id, true ); - + wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'delete'), $_POST[ 'ref' ] ) ); exit(); break; case "allblogs": - check_admin_referer('allblogs'); + if ( isset($_POST['doaction']) || isset($_POST['doaction2']) ) { + check_admin_referer('bulk-sites'); + if ( ! current_user_can( 'manage_sites' ) ) wp_die( __('You do not have permission to access this page.') ); + if ( $_GET['action'] != -1 || $_POST['action2'] != -1 ) + $doaction = $doaction = ($_POST['action'] != -1) ? $_POST['action'] : $_POST['action2']; + + foreach ( (array) $_POST[ 'allblogs' ] as $key => $val ) { if ( $val != '0' && $val != $current_site->blog_id ) { - if ( isset($_POST['allblog_delete']) ) { - $blogfunction = 'all_delete'; - wpmu_delete_blog( $val, true ); - } elseif ( isset($_POST['allblog_spam']) ) { - $blogfunction = 'all_spam'; - update_blog_status( $val, "spam", '1', 0 ); - set_time_limit(60); - } elseif ( isset($_POST['allblog_notspam']) ) { - $blogfunction = 'all_notspam'; - update_blog_status( $val, "spam", '0', 0 ); - set_time_limit(60); + switch ( $doaction ) { + case 'delete': + $blogfunction = 'all_delete'; + wpmu_delete_blog( $val, true ); + break; + case 'spam': + $blogfunction = 'all_spam'; + update_blog_status( $val, "spam", '1', 0 ); + set_time_limit(60); + break; + case 'notspam': + $blogfunction = 'all_notspam'; + update_blog_status( $val, "spam", '0', 0 ); + set_time_limit(60); + break; } - } - } + } else { + wp_die( __('You are not allowed to change one of this sites.') ); + exit(); + }; + }; wp_redirect( add_query_arg( array('updated' => 'true', 'action' => $blogfunction), $_SERVER['HTTP_REFERER'] ) ); exit(); + + } else { + wp_redirect( admin_url("ms-sites.php") ); + } break; case "archiveblog": @@ -397,7 +417,6 @@ switch ( $_GET['action'] ) { case "unmature": update_blog_status( $id, 'mature', '0' ); do_action( 'unmature_blog', $id ); - wp_redirect( add_query_arg( array('updated' => 'true', 'action' => 'umature'), $_POST['ref'] ) ); exit(); break; diff --git a/wp-admin/ms-sites.php b/wp-admin/ms-sites.php index d7addba151..37294e2992 100644 --- a/wp-admin/ms-sites.php +++ b/wp-admin/ms-sites.php @@ -156,7 +156,7 @@ switch ( $action ) {

-
+

@@ -178,7 +178,7 @@ switch ( $action ) { ?> - +
option_name ) ) ?>
-
+

@@ -326,27 +326,46 @@ switch ( $action ) { // List blogs case 'list': default: - $apage = ( isset($_GET['apage'] ) && intval( $_GET['apage'] ) ) ? absint( $_GET['apage'] ) : 1; - $num = ( isset($_GET['num'] ) && intval( $_GET['num'] ) ) ? absint( $_GET['num'] ) : 15; - $s = isset($_GET['s']) ? esc_attr( trim( $_GET[ 's' ] ) ) : ''; - $like_s = like_escape($s); + $pagenum = isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 0; + if ( empty($pagenum) ) + $pagenum = 1; + + $per_page = (int) get_user_option( 'ms_sites_per_page' ); + if ( empty( $per_page ) || $per_page < 1 ) + $per_page = 15; + + $per_page = apply_filters( 'ms_sites_per_page', $per_page ); + + $s = isset($_GET['s']) ? stripslashes( trim( $_GET[ 's' ] ) ) : ''; + $like_s = esc_sql( like_escape( $s ) ); $query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' "; - if ( isset($_GET['blog_name']) ) { - $query .= " AND ( {$wpdb->blogs}.domain LIKE '%{$like_s}%' OR {$wpdb->blogs}.path LIKE '%{$like_s}%' ) "; - } elseif ( isset($_GET['blog_id']) ) { - $query .= " AND blog_id = '". absint( $_GET['blog_id'] )."' "; - } elseif ( isset($_GET['blog_ip']) ) { - $query = "SELECT * - FROM {$wpdb->blogs}, {$wpdb->registration_log} - WHERE site_id = '{$wpdb->siteid}' - AND {$wpdb->blogs}.blog_id = {$wpdb->registration_log}.blog_id - AND {$wpdb->registration_log}.IP LIKE ('%{$like_s}%')"; + if ( isset( $_GET['blogstatus'] ) ) { + if ( 'deleted' == $_GET['blogstatus'] ) { + $query .= " AND {$wpdb->blogs}.deleted = '1' "; + } elseif ( 'archived' == $_GET['blogstatus'] ) { + $query .= " AND {$wpdb->blogs}.archived = '1' "; + } elseif ( 'spam' == $_GET['blogstatus'] ) { + $query .= " AND {$wpdb->blogs}.spam = '1' "; + } + } + + if ( isset( $_GET['searchaction'] ) ) { + if ( 'name' == $_GET['searchaction'] ) { + $query .= " AND ( {$wpdb->blogs}.domain LIKE '%{$like_s}%' OR {$wpdb->blogs}.path LIKE '%{$like_s}%' ) "; + } elseif ( 'id' == $_GET['searchaction'] ) { + $query .= " AND {$wpdb->blogs}.blog_id = '{$like_s}' "; + } elseif ( 'ip' == $_GET['searchaction'] ) { + $query = "SELECT * + FROM {$wpdb->blogs}, {$wpdb->registration_log} + WHERE site_id = '{$wpdb->siteid}' + AND {$wpdb->blogs}.blog_id = {$wpdb->registration_log}.blog_id + AND {$wpdb->registration_log}.IP LIKE ('%{$like_s}%')"; + } } $order_by = isset( $_GET['sortby'] ) ? $_GET['sortby'] : 'id'; - if ( $order_by == 'registered' ) { $query .= ' ORDER BY registered '; } elseif ( $order_by == 'lastupdated' ) { @@ -355,67 +374,120 @@ switch ( $action ) { $query .= ' ORDER BY domain '; } else { $order_by = 'id'; - $query .= ' ORDER BY ' . $wpdb->blogs . '.blog_id '; + $query .= " ORDER BY {$wpdb->blogs}.blog_id "; } - $order = isset($_GET['order']) ? $_GET['order'] : 'ASC'; - $order = ( 'DESC' == $order ) ? 'DESC' : 'ASC'; + $order = ( isset( $_GET['order'] ) && 'DESC' == $_GET['order'] ) ? "DESC" : "ASC"; $query .= $order; - if ( !empty($s) ) - $total = $wpdb->get_var( str_replace('SELECT *', 'SELECT COUNT(blog_id)', $query) ); - else - $total = $wpdb->get_var( "SELECT COUNT(blog_id) FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' "); + $total = $wpdb->get_var( str_replace('SELECT *', 'SELECT COUNT(blog_id)', $query) ); - $query .= " LIMIT " . intval( ( $apage - 1 ) * $num) . ", " . intval( $num ); + $query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page) . ", " . intval( $per_page ); $blog_list = $wpdb->get_results( $query, ARRAY_A ); - // Pagination - $url2 = "&order=" . $order . "&sortby=" . $order_by . "&s="; - if ( !empty($_GET[ 'blog_ip' ]) ) - $url2 .= "&ip_address=" . urlencode( $s ); - else - $url2 .= $s . "&ip_address=" . urlencode( $s ); - - $blog_navigation = paginate_links( array( - 'base' => add_query_arg( 'apage', '%#%' ).$url2, + $num_pages = ceil($total / $per_page); + $page_links = paginate_links( array( + 'base' => add_query_arg( 'paged', '%#%' ), 'format' => '', - 'total' => ceil($total / $num), - 'current' => $apage + 'prev_text' => __('«'), + 'next_text' => __('»'), + 'total' => $num_pages, + 'current' => $pagenum )); + + if ( empty($_GET['mode']) ) + $mode = 'list'; + else + $mode = esc_attr( $_GET['mode'] ); + + // for subsubsub and $blog_list + $status_list = array( 'archived' => array( 'site-archived', __('Archived') ), 'spam' => array( 'site-spammed', __('Spam') ), 'deleted' => array( 'site-deleted', __('Deleted') ) ); ?> -
+
-

+

+ + ' . __('Search results for “%s”') . '', esc_html( $s ) ); + ?> +

+ + -
- + +
- $blog_navigation
"; ?> - -
- - - - -
-
+
+ + +
-
+ +
+ ' . __( 'Displaying %s–%s of %s' ) . '%s', + number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ), + number_format_i18n( min( $pagenum * $per_page, $num_pages ) ), + number_format_i18n( $num_pages ), + $page_links + ); echo $page_links_text; ?> +
+ + + - -

- +
+ +
'display name' @@ -432,35 +504,55 @@ switch ( $action ) { $posts_columns['plugins'] = __('Actions'); $posts_columns = apply_filters('wpmu_blogs_columns', $posts_columns); - - $sortby_url = "s="; - if ( !empty($_GET[ 'blog_ip' ]) ) - $sortby_url .= "&ip_address=" . urlencode( $s ); - else - $sortby_url .= urlencode( $s ) . "&ip_address=" . urlencode( $s ); ?> - +
- - $column_display_name) { - $column_link = " + + + $column_display_name) { + $column_link = " $order2, 'paged' => $pagenum, 'sortby' => $column_id ), $_SERVER['REQUEST_URI'] ) ); + $column_link .= "'>{$column_display_name}"; $col_url = ($column_id == 'users' || $column_id == 'plugins') ? $column_display_name : $column_link; - ?> - + ?> + + + + + $column_display_name) { + $column_link = " $order2, 'paged' => $pagenum, 'sortby' => $column_id ), remove_query_arg( array('action', 'updated'), $_SERVER['REQUEST_URI'] ) ) ); + $column_link .= "'>{$column_display_name}"; + $col_url = ($column_id == 'users' || $column_id == 'plugins') ? $column_display_name : $column_link; + ?> + + + + array( 'site-archived', __('Archived') ), 'spam' => array( 'site-spammed', __('Spam') ), 'deleted' => array( 'site-deleted', __('Deleted') ) ); $class = ''; foreach ( $blog_list as $blog ) { $class = ('alternate' == $class) ? '' : 'alternate'; @@ -500,10 +592,12 @@ switch ( $action ) { break; case 'blogname': ?> - + g:i:s a'; + echo ( $blog['last_updated'] == '0000-00-00 00:00:00' ) ? __("Never") : mysql2date( __( $date ), $blog['last_updated'] ); ?> + + case 'registered': ?> - +
+ +
+ + + +
+ -
' . get_blog_option( $blog['blog_id'], 'blogname' ) . '- ' . get_blog_option( $blog['blog_id'], 'blogdescription ' ) . '

'; + $actions = array(); $actions[] = '' . __('Edit') . ''; $actions[] = "" . __('Backend') . ''; @@ -539,17 +633,21 @@ switch ( $action ) { case 'lastupdated': ?>
- g:i:s a'), $blog['last_updated']); ?> - - g:i:s a'), $blog['registered']); ?> + ' . __( 'More' ) . ''; } - foreach ( $blogusers as $key => $val ) - echo '' . $val->user_login . ' ('.$val->user_email.')
'; + foreach ( $blogusers as $key => $val ) { + echo '' . $val->user_login . ' '; + if ( 'list' != $mode ) + echo '(' . $val->user_email . ')'; + echo '
'; + } if ( $blogusers_warning != '' ) echo '' . $blogusers_warning . '
'; } @@ -592,7 +694,7 @@ switch ( $action ) { -
+
+ $page_links_text
"; + ?> + +
+ + +
+
+
+
- +

- + - - + + - - + +
- .domain;?> + .domain;?> domain . $current_site->path ?> + echo $current_site->domain . $current_site->path ?> " . __( 'Only the characters a-z and 0-9 recommended.' ) . "

"; ?>