WordPress.org

Plugin Directory

Changeset 581487


Ignore:
Timestamp:
08/03/12 19:58:17 (21 months ago)
Author:
betzster
Message:
  • Adds a screen option for number of users per page
  • Makes it more obvious when an ajax action is loading
  • Doesn't allow current user to remove themself
Location:
bulk-user-management/trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • bulk-user-management/trunk/README.md

    r570809 r581487  
    77----- 
    88 
     9<<<<<<< HEAD 
    910* `bulk_user_management_blogs` - array of blogs to limit against. 
    1011* `bulk_user_management_parent_page` - sets parent page. 
    1112* `bulk_user_management_admin_users` - array of users that the plugin is active for 
     13======= 
     14* `bulk_user_management_blogs` - array of sites that can be managed 
     15* `bulk_user_management_parent_page` - sets parent page 
     16* `bulk_user_management_admin_users` - array of users by id that the plugin is active for 
     17* `bulk_user_management_admins_by_username` - array of users by username that the plugin is active for 
     18>>>>>>> develop 
  • bulk-user-management/trunk/bulk-user-management.php

    r581486 r581487  
    66Plugin URI:   http://wordpress.org/extend/plugins/bulk-user-management/ 
    77Description:  A plugin that lets you manage users across all your sites from one place on a multisite install 
    8 Version:      1.0.1 
     8Version:      1.1 
    99Author:       Automattic 
    1010Author URI:   http://automattic.com/wordpress-plugins/ 
     
    2121class Bulk_User_Management { 
    2222 
    23     const VERSION        = '1.0.0'; 
     23    const VERSION        = '1.1'; 
    2424    const PAGE_SLUG      = 'bulk_user_management'; 
    2525    const PER_PAGE       = 20; 
     
    4848 
    4949        add_action( 'wp_ajax_bulk_user_management_show_form', array( $this, 'show_users' ) ); 
     50 
     51        add_filter( 'set-screen-option', array( $this, 'bulk_user_management_set_option' ), 10, 3 ); 
    5052    } 
    5153 
     
    7375 
    7476    public function register_menus() { 
    75         if ( $this->current_user_can_bulk_edit() ) 
    76             add_submenu_page( $this->parent_page, esc_html__( 'Bulk User Management', 'bulk-user-management' ), esc_html__( 'User Management', 'bulk-user-management' ), 'manage_options', self::PAGE_SLUG, array( $this, 'users_page' ) ); 
     77        if ( $this->current_user_can_bulk_edit() ) { 
     78            $hook = add_submenu_page( $this->parent_page, esc_html__( 'Bulk User Management', 'bulk-user-management' ), esc_html__( 'User Management', 'bulk-user-management' ), 'manage_options', self::PAGE_SLUG, array( $this, 'users_page' ) ); 
     79            add_action( "load-$hook", array( $this, 'per_page' ) ); 
     80        } 
     81    } 
     82 
     83    public function per_page() { 
     84        $option = 'per_page'; 
     85 
     86        $args = array( 
     87            'label' => __( 'Users', 'bulk-user-management' ), 
     88            'default' => self::PER_PAGE, 
     89            'option' => 'bulk_user_management_per_page' 
     90        ); 
     91 
     92        add_screen_option( $option, $args ); 
     93    } 
     94 
     95    public function bulk_user_management_set_option( $status, $option, $value ) { 
     96        if ( 'bulk_user_management_per_page' == $option ) return $value; 
    7797    } 
    7898 
     
    142162                case 'user_email_pair': 
    143163                    $messages[] = __( 'Each new user must have an email address specified.', 'bulk-user-management' ); 
     164                    break; 
     165                case 'cant-remove-current': 
     166                    $messages[] = __( "Can't remove the current user", 'bulk-user-management' ); 
    144167                    break; 
    145168                case 'add_user_errors': 
     
    309332        $userids = array_map('intval', $_REQUEST['users']); 
    310333 
     334        // Don't let a user remove themself 
     335        if ( in_array( get_current_user_id(), $userids ) ) 
     336            $update = 'cant-remove-current'; 
     337 
    311338        // Check that the current user can remove users on all target blogs 
    312339        $errors = array(); 
     
    319346        } 
    320347 
    321         //TODO: handle case where user removes themself? 
    322  
    323348        if ( 'remove' == $update ) 
    324349            $this->remove_users($blogids, $userids); 
     
    343368            return true; 
    344369 
    345         $admins = array_map( 'sanitize_user', apply_filters( 'bulk_user_management_admin_users', array() ) );  
     370        // Add users by username 
     371        $admins = array_map( 'sanitize_user', apply_filters( 'bulk_user_management_admins_by_username', array() ) );  
    346372        if ( in_array( wp_get_current_user()->user_login, $admins ) )  
    347373            return true; 
    348374 
     375        // Add users by id 
     376        $admins = array_map( 'intval', apply_filters( 'bulk_user_management_admin_users', array() ) ); 
     377        if( in_array( get_current_user_id(), $admins ) ) 
     378            return true; 
     379 
    349380        return false; 
    350381    } 
  • bulk-user-management/trunk/css/bulk-user-management.css

    r570809 r581487  
    99    min-width: 49%; 
    1010} 
     11 
     12#loading { 
     13    position: absolute; 
     14    top: 125px; 
     15    left: 50%; 
     16    text-align: center; 
     17    font-size: 20px; 
     18    width: 150px; 
     19    margin-left: -75px; 
     20    height: 45px; 
     21    line-height: 45px; 
     22    border-radius: 5px; 
     23    background: rgba( 0,0,0,.1 ); 
     24} 
     25#loading span:before { 
     26    content: url(../images/wpspin_light.gif); 
     27    margin-right: 5px; 
     28} 
  • bulk-user-management/trunk/includes/class-bulk-user-table.php

    r573631 r581487  
    9999        global $wpdb; 
    100100 
    101         $per_page = 20; 
     101        $screen = get_current_screen(); 
     102         
     103        if ( isset( $screen ) ) { 
     104            // First check for a screen option the right way. 
     105            // If we're loaded with ajax, this won't work 
     106            $option = $screen->get_option( 'per_page', 'option' ); 
     107            $per_page = get_user_meta( get_current_user_id(), $option, true ); 
     108        } elseif ( isset( $_REQUEST['per_page'] ) ) { 
     109            // Check for per_page request variable 
     110            $per_page = intval( $_REQUEST['per_page' ] ); 
     111        } else { 
     112            // Fall back to a reasonable default 
     113            $per_page = 20; 
     114        } 
    102115 
    103116        $paged = $this->get_pagenum(); 
     
    132145 
    133146            // orderby and order 
    134  
    135147            usort( $query, array( $this, 'compare_users' ) ); 
    136148 
  • bulk-user-management/trunk/js/bulk-user-management-inline-edit.js

    r570809 r581487  
    9494            s: getParameterByName('s'), 
    9595            orderby: getParameterByName('orderby'), 
    96             order: getParameterByName('order') 
     96            order: getParameterByName('order'), 
     97            per_page: $("#bulk_user_management_per_page").val() 
    9798        }; 
    9899 
     100        $("#wpbody-content").prepend("<div id='loading'><span>Loading...</span></div>"); 
    99101        $(".actions").prepend("<img class='ajax-spinner' src='" + bulk_user_management_images + "/wpspin_light.gif'>"); 
    100         $(".wp-list-table").animate({"opacity":".4"}); 
     102        $(".wp-list-table").animate({"opacity":".3"}); 
    101103 
    102104        $.post(ajaxurl, data, function(response) { 
     
    139141            }); 
    140142        }).success(function(){ 
    141             $(".ajax-spinner").hide(); 
     143            $(".ajax-spinner, #loading").hide(); 
    142144            $(".wp-list-table").animate({"opacity":"1"}); 
    143145            $('.widefat tbody tr').each(function(){ 
  • bulk-user-management/trunk/readme.txt

    r573631 r581487  
    44Requires at least: 3.4 
    55Tested up to: 3.4.1 
    6 Stable tag: 1.0.1 
     6Stable tag: 1.1 
    77License: GPLv2 or later 
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html 
     
    2525* `bulk_user_management_blogs` - array of sites that can be managed 
    2626* `bulk_user_management_parent_page` - sets parent page 
    27 * `bulk_user_management_admin_users` - array of users that the plugin is active for 
     27* `bulk_user_management_admin_users` - array of users by id that the plugin is active for 
     28* `bulk_user_management_admins_by_username` - array of users by username that the plugin is active for 
    2829 
    2930== Frequently Asked Questions == 
     
    3536== Changelog == 
    3637 
    37 = 1.0 = 
    38 * Initial Release 
     38= 1.1 = 
     39* Adds a screen option for number of users per page 
     40* Makes it more obvious when an ajax action is loading 
     41* Doesn't allow current user to remove themself 
    3942 
    4043= 1.0.1 = 
    4144* Fix fatal error in PHP 5.2 
     45 
     46= 1.0 = 
     47* Initial Release 
Note: See TracChangeset for help on using the changeset viewer.