Ticket #12460: ms-sites.php.1.diff
| File ms-sites.php.1.diff, 20.5 KB (added by , 16 years ago) |
|---|
-
wp-admin/includes/template.php
3767 3767 case 'edit-pages': 3768 3768 $per_page_label = __('Pages per page:'); 3769 3769 break; 3770 case 'ms-sites': 3771 $per_page_label = __('Sites per page:'); 3772 break; 3773 case 'ms-users': 3774 $per_page_label = __('Users per page:'); 3775 break; 3770 3776 case 'edit-comments': 3771 3777 $per_page_label = __('Comments per page:'); 3772 3778 break; -
wp-admin/ms-edit.php
298 298 break; 299 299 300 300 case "allblogs": 301 check_admin_referer('allblogs'); 302 if ( ! current_user_can( 'manage_sites' ) ) 303 wp_die( __('You do not have permission to access this page.') ); 304 305 foreach ( (array) $_POST[ 'allblogs' ] as $key => $val ) { 306 if ( $val != '0' && $val != $current_site->blog_id ) { 307 if ( isset($_POST['allblog_delete']) ) { 308 $blogfunction = 'all_delete'; 309 wpmu_delete_blog( $val, true ); 310 } elseif ( isset($_POST['allblog_spam']) ) { 311 $blogfunction = 'all_spam'; 312 update_blog_status( $val, "spam", '1', 0 ); 313 set_time_limit(60); 314 } elseif ( isset($_POST['allblog_notspam']) ) { 315 $blogfunction = 'all_notspam'; 316 update_blog_status( $val, "spam", '0', 0 ); 317 set_time_limit(60); 318 } 319 } 320 } 321 322 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => $blogfunction), $_SERVER['HTTP_REFERER'] ) ); 323 exit(); 301 302 if ( isset($_POST['doaction']) || isset($_POST['doaction2']) ) { 303 check_admin_referer('bulk-sites'); 304 305 if ( ! current_user_can( 'manage_sites' ) ) 306 wp_die( __('You do not have permission to access this page.') ); 307 308 // Handle bulk actions 309 if ( $_GET['action'] != -1 || $_POST['action2'] != -1 ) { 310 $doaction = $doaction = ($_POST['action'] != -1) ? $_POST['action'] : $_POST['action2']; 311 } 312 313 foreach ( (array) $_POST[ 'allblogs' ] as $key => $val ) { 314 if ( $val != '0' && $val != $current_site->blog_id ) { 315 switch ( $doaction ) { 316 case 'delete': 317 $blogfunction = 'all_delete'; 318 wpmu_delete_blog( $val, true ); 319 break; 320 case 'spam': 321 $blogfunction = 'all_spam'; 322 update_blog_status( $val, "spam", '1', 0 ); 323 set_time_limit(60); 324 break; 325 case 'notspam': 326 $blogfunction = 'all_notspam'; 327 update_blog_status( $val, "spam", '0', 0 ); 328 set_time_limit(60); 329 break; 330 } 331 } else { 332 wp_die( __('You are not allowed to change this site.') ); 333 }; 334 }; 335 336 wp_redirect( add_query_arg( array('updated' => 'true', 'action' => $blogfunction), wp_get_referer() ) ); 337 exit(); 338 } else { 339 wp_redirect( admin_url("ms-sites.php") ); 340 } 324 341 break; 325 342 326 343 case "archiveblog": -
wp-admin/ms-sites.php
178 178 ?> 179 179 <tr class="form-field"> 180 180 <th scope="row"><?php echo ucwords( str_replace( "_", " ", $option->option_name ) ) ?></th> 181 <td><textarea rows="5" cols="40" name="option[<?php echo esc_attr($option->option_name) ?>]" type="text"id="<?php echo esc_attr($option->option_name) ?>"<?php echo $disabled ?>><?php echo esc_html( $option->option_value ) ?></textarea></td>181 <td><textarea rows="5" cols="40" name="option[<?php echo esc_attr($option->option_name) ?>]" id="<?php echo esc_attr($option->option_name) ?>"<?php echo $disabled ?>><?php echo esc_html( $option->option_value ) ?></textarea></td> 182 182 </tr> 183 183 <?php 184 184 } else { … … 323 323 <?php 324 324 break; 325 325 326 // List blogs326 // List sites 327 327 case 'list': 328 328 default: 329 $apage = ( isset($_GET['apage'] ) && intval( $_GET['apage'] ) ) ? absint( $_GET['apage'] ) : 1; 330 $num = ( isset($_GET['num'] ) && intval( $_GET['num'] ) ) ? absint( $_GET['num'] ) : 15; 331 $s = isset($_GET['s']) ? esc_attr( trim( $_GET[ 's' ] ) ) : ''; 332 $like_s = like_escape($s); 329 330 $pagenum = isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 0; 331 if ( empty($pagenum) ) 332 $pagenum = 1; 333 // Todo: doesn't work :( 334 $per_page = (int) get_user_option( 'ms_sites_per_page' ); 335 if ( empty( $per_page ) || $per_page < 1 ) 336 $per_page = 15; 333 337 338 $per_page = apply_filters( 'ms_sites_per_page', $per_page ); 339 340 341 $s = isset($_GET['s']) ? stripslashes( trim( $_GET[ 's' ] ) ) : ''; 342 $like_s = esc_sql( like_escape( $s ) ); 343 334 344 $query = "SELECT * FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' "; 335 345 336 if ( isset($_GET['blog_name']) ) { 337 $query .= " AND ( {$wpdb->blogs}.domain LIKE '%{$like_s}%' OR {$wpdb->blogs}.path LIKE '%{$like_s}%' ) "; 338 } elseif ( isset($_GET['blog_id']) ) { 339 $query .= " AND blog_id = '". absint( $_GET['blog_id'] )."' "; 340 } elseif ( isset($_GET['blog_ip']) ) { 341 $query = "SELECT * 342 FROM {$wpdb->blogs}, {$wpdb->registration_log} 343 WHERE site_id = '{$wpdb->siteid}' 344 AND {$wpdb->blogs}.blog_id = {$wpdb->registration_log}.blog_id 345 AND {$wpdb->registration_log}.IP LIKE ('%{$like_s}%')"; 346 } 347 346 if ( isset( $_GET['searchaction'] ) ) { 347 if ( 'name' == $_GET['searchaction'] ) { 348 $query .= " AND ( {$wpdb->blogs}.domain LIKE '%{$like_s}%' OR {$wpdb->blogs}.path LIKE '%{$like_s}%' ) "; 349 } elseif ( 'id' == $_GET['searchaction'] ) { 350 $query .= " AND {$wpdb->blogs}.blog_id = '{$like_s}' "; 351 } elseif ( 'ip' == $_GET['searchaction'] ) { 352 $query = "SELECT * 353 FROM {$wpdb->blogs}, {$wpdb->registration_log} 354 WHERE site_id = '{$wpdb->siteid}' 355 AND {$wpdb->blogs}.blog_id = {$wpdb->registration_log}.blog_id 356 AND {$wpdb->registration_log}.IP LIKE ('%{$like_s}%')"; 357 } 358 } 359 360 // Todo: Filter Sites by status 361 /*if ( isset ( $_POST['status'] ) ) { 362 if ( 'archived' == $_POST['status'] ) { 363 $query .= " AND {$wpdb->blogs}.archived = '1' "; 364 } 365 }*/ 366 348 367 $order_by = isset( $_GET['sortby'] ) ? $_GET['sortby'] : 'id'; 349 368 350 369 if ( $order_by == 'registered' ) { … … 367 386 else 368 387 $total = $wpdb->get_var( "SELECT COUNT(blog_id) FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' "); 369 388 370 $query .= " LIMIT " . intval( ( $ apage - 1 ) * $num) . ", " . intval( $num);389 $query .= " LIMIT " . intval( ( $pagenum - 1 ) * $per_page) . ", " . intval( $per_page ); 371 390 $blog_list = $wpdb->get_results( $query, ARRAY_A ); 372 391 373 // Pagination 374 $url2 = "&order=" . $order . "&sortby=" . $order_by . "&s="; 375 if ( !empty($_GET[ 'blog_ip' ]) ) 376 $url2 .= "&ip_address=" . urlencode( $s ); 377 else 378 $url2 .= $s . "&ip_address=" . urlencode( $s ); 392 $num_pages = ceil($total / $per_page); 393 394 $page_links = paginate_links( array( 395 'base' => add_query_arg( 'paged', '%#%' ), 396 'format' => '', 397 'prev_text' => __('«'), 398 'next_text' => __('»'), 399 'total' => $num_pages, 400 'current' => $pagenum 401 )); 402 403 if ( empty($_GET['mode']) ) 404 $mode = 'list'; 405 else 406 $mode = esc_attr($_GET['mode']); 407 ?> 379 408 380 $blog_navigation = paginate_links( array(381 'base' => add_query_arg( 'apage', '%#%' ).$url2,382 'format' => '',383 'total' => ceil($total / $num),384 'current' => $apage385 ));386 ?>387 388 409 <div class="wrap" style="position:relative;"> 389 410 <?php screen_icon(); ?> 390 <h2><?php _e('Sites') ?></h2> 391 411 <h2><?php _e('Sites') ?> 412 <a href="#form-add-site" class="button add-new-h2"><?php echo esc_html_x('Add New', 'sites'); ?></a> <?php 413 if ( isset($_GET['s']) && $_GET['s'] ) 414 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', esc_html( $s ) ); ?> 415 </h2> 416 392 417 <form action="ms-sites.php" method="get" id="ms-search"> 418 <p class="search-box"> 393 419 <input type="hidden" name="action" value="blogs" /> 394 <input type="text" name="s" value="<?php echo($s); ?>" size="17" /> 395 <input type="submit" class="button" name="blog_name" value="<?php esc_attr_e('Search blogs by name') ?>" /> 396 <input type="submit" class="button" name="blog_id" value="<?php esc_attr_e('by blog ID') ?>" /> 397 <input type="submit" class="button" name="blog_ip" value="<?php esc_attr_e('by IP address') ?>" /> 420 <input type="text" name="s" value="<?php esc_attr_e( $s ); ?>" /> 421 <input type="submit" class="button" value="<?php esc_attr_e('Search Site by') ?>" /> 422 <select name="searchaction"> 423 <option value="name" selected="selected"><?php _e('Name'); ?></option> 424 <option value="id"><?php _e('ID'); ?></option> 425 <option value="ip"><?php _e('IP address'); ?></option> 426 </select> 427 </p> 398 428 </form> 399 429 400 430 <form id="form-blog-list" action="ms-edit.php?action=allblogs" method="post"> 431 <input type="hidden" name="mode" value="<?php echo esc_attr($mode); ?>" /> 432 <div class="tablenav"> 433 434 <div class="alignleft actions"> 435 <select name="action"> 436 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> 437 <option value="delete"><?php _e('Delete'); ?></option> 438 <option value="spam"><?php _e('Mark as Spam'); ?></option> 439 <option value="notspam"><?php _e('Not Spam'); ?></option> 440 </select> 441 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" /> 442 <?php wp_nonce_field('bulk-sites'); ?> 443 401 444 402 <div class="tablenav"> 403 <?php if ( $blog_navigation ) echo "<div class='tablenav-pages'>$blog_navigation</div>"; ?> 445 <select name="status"> 446 <option<?php selected( $s, 0 ); ?> value="-1"><?php _e('Show all status'); ?></option> 447 <option value="archived"><?php _e('Archived'); ?></option> 448 <option value="spammed"><?php _e('Spam'); ?></option> 449 <option value="deleted"><?php _e('Deleted'); ?></option> 450 </select> 451 <input type="submit" id="sites-query-submit" value="<?php esc_attr_e('Filter'); ?>" class="button-secondary" /> 452 </div> 453 454 <?php if ( $page_links ) { ?> 455 <div class="tablenav-pages"><?php $page_links_text = sprintf( '<span class="displaying-num">' . __( 'Displaying %s–%s of %s' ) . '</span>%s', 456 number_format_i18n( ( $pagenum - 1 ) * $per_page + 1 ), 457 number_format_i18n( min( $pagenum * $per_page, $num_pages ) ), 458 number_format_i18n( $num_pages ), 459 $page_links 460 ); echo $page_links_text; ?></div> 461 <?php } ?> 462 463 <div class="view-switch"> 464 <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> 465 <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> 466 </div> 467 468 <div class="clear"></div> 469 </div> 470 471 <div class="clear"></div> 404 472 405 <div class="alignleft">406 <input type="submit" value="<?php esc_attr_e('Delete') ?>" name="allblog_delete" class="button-secondary delete" />407 <input type="submit" value="<?php esc_attr_e('Mark as Spam') ?>" name="allblog_spam" class="button-secondary" />408 <input type="submit" value="<?php esc_attr_e('Not Spam') ?>" name="allblog_notspam" class="button-secondary" />409 <?php wp_nonce_field( 'allblogs' ); ?>410 <br class="clear" />411 </div>412 </div>413 414 <br class="clear" />415 416 <?php if ( isset($_GET['s']) && !empty($_GET['s']) ) : ?>417 <p><a href="ms-users.php?action=users&s=<?php echo urlencode( stripslashes( $s ) ) ?>"><?php _e('Search Users:') ?> <strong><?php echo stripslashes( $s ); ?></strong></a></p>418 <?php endif; ?>419 420 473 <?php 421 474 // define the columns to display, the syntax is 'internal name' => 'display name' 422 475 $blogname_columns = ( is_subdomain_install() ) ? __('Domain') : __('Path'); … … 440 493 $sortby_url .= urlencode( $s ) . "&ip_address=" . urlencode( $s ); 441 494 ?> 442 495 443 <table width="100%" cellpadding="3" cellspacing="3" class="widefat">496 <table cellspacing="0" class="widefat"> 444 497 <thead> 445 498 <tr> 446 <th s cope="col" class="check-column"></th>499 <th style="" class="manage-column column-cb check-column" id="cb" scope="col"><input type="checkbox" /></th> 447 500 <?php foreach($posts_columns as $column_id => $column_display_name) { 448 501 $column_link = "<a href='ms-sites.php?{$sortby_url}&sortby={$column_id}&"; 449 502 if ( $order_by == $column_id ) { 503 $column_link .= ($order == 'DESC') ? 'order=ASC&' : 'order=DESC&'; 504 } 505 $column_link .= "paged={$pagenum}'>{$column_display_name}</a>"; 506 507 $col_url = ($column_id == 'users' || $column_id == 'plugins') ? $column_display_name : $column_link; 508 ?> 509 <th scope="col"><?php echo $col_url ?></th> 510 <?php } ?> 511 </tr> 512 </thead> 513 <tfoot> 514 <tr> 515 <th style="" class="manage-column column-cb check-column" id="cb" scope="col"><input type="checkbox" /></th> 516 <?php foreach($posts_columns as $column_id => $column_display_name) { 517 $column_link = "<a href='ms-sites.php?{$sortby_url}&sortby={$column_id}&"; 518 if ( $order_by == $column_id ) { 450 519 $column_link .= ($order_by == 'DESC') ? 'order=ASC&' : 'order=DESC&'; 451 520 } 452 $column_link .= " apage={$apage}'>{$column_display_name}</a>";521 $column_link .= "paged={$pagenum}'>{$column_display_name}</a>"; 453 522 454 523 $col_url = ($column_id == 'users' || $column_id == 'plugins') ? $column_display_name : $column_link; 455 524 ?> 456 525 <th scope="col"><?php echo $col_url ?></th> 457 526 <?php } ?> 458 527 </tr> 459 </t head>528 </tfoot> 460 529 <tbody id="the-list"> 461 530 <?php 462 531 if ( $blog_list ) { … … 491 560 switch ( $column_name ) { 492 561 case 'id': ?> 493 562 <th scope="row" class="check-column"> 494 <input type= 'checkbox' id='blog_<?php echo $blog['blog_id'] ?>' name='allblogs[]' value='<?php echo esc_attr($blog['blog_id']) ?>'/>563 <input type="checkbox" id="blog_<?php echo $blog['blog_id'] ?>" name="allblogs[]" value="<?php echo esc_attr($blog['blog_id']) ?>" /> 495 564 </th> 496 565 <th scope="row"> 497 566 <?php echo $blog['blog_id'] ?> … … 500 569 break; 501 570 502 571 case 'blogname': ?> 503 <td valign="top">572 <td class="column-title"> 504 573 <a href="ms-sites.php?action=editblog&id=<?php echo $blog['blog_id'] ?>" class="edit"><?php echo $blogname; echo $blog_state?></a> 505 <br/> 574 <p> 575 <?php 576 if ( 'list' != $mode ) 577 echo get_blog_option( $blog['blog_id'], 'blogname' ) . '- <em>' . get_blog_option( $blog['blog_id'], 'blogdescription ' ) . '</em>'; ?> 578 </p> 506 579 <?php 507 580 $actions = array(); 508 581 $actions[] = '<a href="ms-sites.php?action=editblog&id=' . $blog['blog_id'] . '" class="edit">' . __('Edit') . '</a>'; … … 539 612 540 613 case 'lastupdated': ?> 541 614 <td valign="top"> 542 <?php echo ( $blog['last_updated'] == '0000-00-00 00:00:00' ) ? __("Never") : mysql2date(__('Y-m-d \<\b\r \/\> g:i:s a'), $blog['last_updated']); ?> 615 <?php 616 if ( 'list' == $mode ) 617 $date = 'Y/m/d'; 618 else 619 $date = 'Y/m/d \<\b\r \/\> g:i:s a'; 620 echo ( $blog['last_updated'] == '0000-00-00 00:00:00' ) ? __("Never") : mysql2date( __( $date ), $blog['last_updated'] ); ?> 543 621 </td> 544 622 <?php 545 623 break; 546 624 case 'registered': ?> 547 625 <td valign="top"> 548 <?php echo mysql2date(__( 'Y-m-d \<\b\r \/\> g:i:s a'), $blog['registered']); ?>626 <?php echo mysql2date(__( $date ), $blog['registered'] ); ?> 549 627 </td> 550 628 <?php 551 629 break; … … 592 670 <?php 593 671 } 594 672 } else { ?> 595 <tr style='background-color: <?php echo $bgcolor; ?>'>673 <tr > 596 674 <td colspan="8"><?php _e('No blogs found.') ?></td> 597 675 </tr> 598 676 <?php … … 601 679 602 680 </tbody> 603 681 </table> 682 683 <div class="tablenav"> 684 <?php 685 if ( $page_links ) 686 echo "<div class='tablenav-pages'>$page_links_text</div>"; 687 ?> 688 689 <div class="alignleft actions"> 690 <select name="action2"> 691 <option value="-1" selected="selected"><?php _e('Bulk Actions'); ?></option> 692 <option value="delete"><?php _e('Delete'); ?></option> 693 <option value="spam"><?php _e('Mark as Spam'); ?></option> 694 <option value="notspam"><?php _e('Not Spam'); ?></option> 695 </select> 696 <input type="submit" value="<?php esc_attr_e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> 697 </div> 698 <br class="clear" /> 699 </div> 700 604 701 </form> 605 702 </div> 606 703 607 704 <div class="wrap"> 608 <a name="form-add- blog"></a>705 <a name="form-add-site"></a> 609 706 <h2><?php _e('Add Site') ?></h2> 610 707 <form method="post" action="ms-edit.php?action=addblog"> 611 708 <?php wp_nonce_field('add-blog') ?> 612 709 <table class="form-table"> 613 710 <tr class="form-field form-required"> 614 <th s tyle="text-align:center;" scope='row'><?php _e('Site Address') ?></th>711 <th scope='row'><?php _e('Site Address') ?></th> 615 712 <td> 616 713 <?php if ( is_subdomain_install() ) { ?> 617 <input name="blog[domain]" type="text" title="<?php _e('Domain') ?>"/>.<?php echo $current_site->domain;?>714 <input name="blog[domain]" type="text" class="regular-text" title="<?php _e('Domain') ?>"/>.<?php echo $current_site->domain;?> 618 715 <?php } else { 619 echo $current_site->domain . $current_site->path ?><input name="blog[domain]" type="text" title="<?php _e('Domain') ?>"/>716 echo $current_site->domain . $current_site->path ?><input name="blog[domain]" type="text" class="regular-text" title="<?php _e('Domain') ?>"/> 620 717 <?php } 621 718 echo "<p>" . __( 'Only the characters a-z and 0-9 recommended.' ) . "</p>"; 622 719 ?> 623 720 </td> 624 721 </tr> 625 722 <tr class="form-field form-required"> 626 <th s tyle="text-align:center;" scope='row'><?php _e('Site Title') ?></th>627 <td><input name="blog[title]" type="text" size="20" title="<?php _e('Title') ?>"/></td>723 <th scope='row'><?php _e('Site Title') ?></th> 724 <td><input name="blog[title]" type="text" class="regular-text" title="<?php _e('Title') ?>"/></td> 628 725 </tr> 629 726 <tr class="form-field form-required"> 630 <th s tyle="text-align:center;" scope='row'><?php _e('Admin Email') ?></th>631 <td><input name="blog[email]" type="text" size="20" title="<?php _e('Email') ?>"/></td>727 <th scope='row'><?php _e('Admin Email') ?></th> 728 <td><input name="blog[email]" type="text" class="regular-text" title="<?php _e('Email') ?>"/></td> 632 729 </tr> 633 730 <tr class="form-field"> 634 731 <td colspan='2'><?php _e('A new user will be created if the above email address is not in the database.') ?><br /><?php _e('The username and password will be mailed to this email address.') ?></td>