-
+ 127D96AC709E20BECDC00726237152D9B09655D090A2B6C08003351BB518C58A52568A62A673DCDA043916D72F59B1FCC378830A0674DC4B6ED695E3F6B93822
mp-wp/wp-admin/users.php
(0 . 0)(1 . 402)
59560 <?php
59561 /**
59562 * Users administration panel.
59563 *
59564 * @package WordPress
59565 * @subpackage Administration
59566 */
59567
59568 /** WordPress Administration Bootstrap */
59569 require_once('admin.php');
59570
59571 /** WordPress Registration API */
59572 require_once( ABSPATH . WPINC . '/registration.php');
59573
59574 if ( !current_user_can('edit_users') )
59575 wp_die(__('Cheatin’ uh?'));
59576
59577 $title = __('Users');
59578 $parent_file = 'users.php';
59579
59580 $update = $doaction = '';
59581 if ( isset($_REQUEST['action']) )
59582 $doaction = $_REQUEST['action'] ? $_REQUEST['action'] : $_REQUEST['action2'];
59583
59584 if ( empty($doaction) ) {
59585 if ( isset($_GET['changeit']) && !empty($_GET['new_role']) )
59586 $doaction = 'promote';
59587 }
59588
59589 if ( empty($_REQUEST) ) {
59590 $referer = '<input type="hidden" name="wp_http_referer" value="'. attribute_escape(stripslashes($_SERVER['REQUEST_URI'])) . '" />';
59591 } elseif ( isset($_REQUEST['wp_http_referer']) ) {
59592 $redirect = remove_query_arg(array('wp_http_referer', 'updated', 'delete_count'), stripslashes($_REQUEST['wp_http_referer']));
59593 $referer = '<input type="hidden" name="wp_http_referer" value="' . attribute_escape($redirect) . '" />';
59594 } else {
59595 $redirect = 'users.php';
59596 $referer = '';
59597 }
59598
59599 switch ($doaction) {
59600
59601 case 'promote':
59602 check_admin_referer('bulk-users');
59603
59604 if (empty($_REQUEST['users'])) {
59605 wp_redirect($redirect);
59606 exit();
59607 }
59608
59609 if ( !current_user_can('edit_users') )
59610 wp_die(__('You can’t edit users.'));
59611
59612 $userids = $_REQUEST['users'];
59613 $update = 'promote';
59614 foreach($userids as $id) {
59615 if ( ! current_user_can('edit_user', $id) )
59616 wp_die(__('You can’t edit that user.'));
59617 // The new role of the current user must also have edit_users caps
59618 if($id == $current_user->ID && !$wp_roles->role_objects[$_REQUEST['new_role']]->has_cap('edit_users')) {
59619 $update = 'err_admin_role';
59620 continue;
59621 }
59622
59623 $user = new WP_User($id);
59624 $user->set_role($_REQUEST['new_role']);
59625 }
59626
59627 wp_redirect(add_query_arg('update', $update, $redirect));
59628 exit();
59629
59630 break;
59631
59632 case 'dodelete':
59633
59634 check_admin_referer('delete-users');
59635
59636 if ( empty($_REQUEST['users']) ) {
59637 wp_redirect($redirect);
59638 exit();
59639 }
59640
59641 if ( !current_user_can('delete_users') )
59642 wp_die(__('You can’t delete users.'));
59643
59644 $userids = $_REQUEST['users'];
59645 $update = 'del';
59646 $delete_count = 0;
59647
59648 foreach ( (array) $userids as $id) {
59649 if ( ! current_user_can('delete_user', $id) )
59650 wp_die(__('You can’t delete that user.'));
59651
59652 if($id == $current_user->ID) {
59653 $update = 'err_admin_del';
59654 continue;
59655 }
59656 switch($_REQUEST['delete_option']) {
59657 case 'delete':
59658 wp_delete_user($id);
59659 break;
59660 case 'reassign':
59661 wp_delete_user($id, $_REQUEST['reassign_user']);
59662 break;
59663 }
59664 ++$delete_count;
59665 }
59666
59667 $redirect = add_query_arg( array('delete_count' => $delete_count, 'update' => $update), $redirect);
59668 wp_redirect($redirect);
59669 exit();
59670
59671 break;
59672
59673 case 'delete':
59674
59675 check_admin_referer('bulk-users');
59676
59677 if ( empty($_REQUEST['users']) && empty($_REQUEST['user']) ) {
59678 wp_redirect($redirect);
59679 exit();
59680 }
59681
59682 if ( !current_user_can('delete_users') )
59683 $errors = new WP_Error('edit_users', __('You can’t delete users.'));
59684
59685 if ( empty($_REQUEST['users']) )
59686 $userids = array(intval($_REQUEST['user']));
59687 else
59688 $userids = $_REQUEST['users'];
59689
59690 include ('admin-header.php');
59691 ?>
59692 <form action="" method="post" name="updateusers" id="updateusers">
59693 <?php wp_nonce_field('delete-users') ?>
59694 <?php echo $referer; ?>
59695
59696 <div class="wrap">
59697 <?php screen_icon(); ?>
59698 <h2><?php _e('Delete Users'); ?></h2>
59699 <p><?php _e('You have specified these users for deletion:'); ?></p>
59700 <ul>
59701 <?php
59702 $go_delete = false;
59703 foreach ( (array) $userids as $id ) {
59704 $id = (int) $id;
59705 $user = new WP_User($id);
59706 if ( $id == $current_user->ID ) {
59707 echo "<li>" . sprintf(__('ID #%1s: %2s <strong>The current user will not be deleted.</strong>'), $id, $user->user_login) . "</li>\n";
59708 } else {
59709 echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />" . sprintf(__('ID #%1s: %2s'), $id, $user->user_login) . "</li>\n";
59710 $go_delete = true;
59711 }
59712 }
59713 $all_logins = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users ORDER BY user_login");
59714 $user_dropdown = '<select name="reassign_user">';
59715 foreach ( (array) $all_logins as $login )
59716 if ( $login->ID == $current_user->ID || !in_array($login->ID, $userids) )
59717 $user_dropdown .= "<option value=\"{$login->ID}\">{$login->user_login}</option>";
59718 $user_dropdown .= '</select>';
59719 ?>
59720 </ul>
59721 <?php if ( $go_delete ) : ?>
59722 <fieldset><p><legend><?php _e('What should be done with posts and links owned by this user?'); ?></legend></p>
59723 <ul style="list-style:none;">
59724 <li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" checked="checked" />
59725 <?php _e('Delete all posts and links.'); ?></label></li>
59726 <li><input type="radio" id="delete_option1" name="delete_option" value="reassign" />
59727 <?php echo '<label for="delete_option1">'.__('Attribute all posts and links to:')."</label> $user_dropdown"; ?></li>
59728 </ul></fieldset>
59729 <input type="hidden" name="action" value="dodelete" />
59730 <p class="submit"><input type="submit" name="submit" value="<?php _e('Confirm Deletion'); ?>" class="button-secondary" /></p>
59731 <?php else : ?>
59732 <p><?php _e('There are no valid users selected for deletion.'); ?></p>
59733 <?php endif; ?>
59734 </div>
59735 </form>
59736 <?php
59737
59738 break;
59739
59740 default:
59741
59742 if ( !empty($_GET['_wp_http_referer']) ) {
59743 wp_redirect(remove_query_arg(array('_wp_http_referer', '_wpnonce'), stripslashes($_SERVER['REQUEST_URI'])));
59744 exit;
59745 }
59746
59747 wp_enqueue_script('admin-users');
59748
59749 include('admin-header.php');
59750
59751 $usersearch = isset($_GET['usersearch']) ? $_GET['usersearch'] : null;
59752 $userspage = isset($_GET['userspage']) ? $_GET['userspage'] : null;
59753 $role = isset($_GET['role']) ? $_GET['role'] : null;
59754
59755 // Query the users
59756 $wp_user_search = new WP_User_Search($usersearch, $userspage, $role);
59757
59758 $messages = array();
59759 if ( isset($_GET['update']) ) :
59760 switch($_GET['update']) {
59761 case 'del':
59762 case 'del_many':
59763 $delete_count = isset($_GET['delete_count']) ? (int) $_GET['delete_count'] : 0;
59764 $messages[] = '<div id="message" class="updated fade"><p>' . sprintf(__ngettext('%s user deleted', '%s users deleted', $delete_count), $delete_count) . '</p></div>';
59765 break;
59766 case 'add':
59767 $messages[] = '<div id="message" class="updated fade"><p>' . __('New user created.') . '</p></div>';
59768 break;
59769 case 'promote':
59770 $messages[] = '<div id="message" class="updated fade"><p>' . __('Changed roles.') . '</p></div>';
59771 break;
59772 case 'err_admin_role':
59773 $messages[] = '<div id="message" class="error"><p>' . __("The current user's role must have user editing capabilities.") . '</p></div>';
59774 $messages[] = '<div id="message" class="updated fade"><p>' . __('Other user roles have been changed.') . '</p></div>';
59775 break;
59776 case 'err_admin_del':
59777 $messages[] = '<div id="message" class="error"><p>' . __("You can't delete the current user.") . '</p></div>';
59778 $messages[] = '<div id="message" class="updated fade"><p>' . __('Other users have been deleted.') . '</p></div>';
59779 break;
59780 }
59781 endif; ?>
59782
59783 <?php if ( isset($errors) && is_wp_error( $errors ) ) : ?>
59784 <div class="error">
59785 <ul>
59786 <?php
59787 foreach ( $errors->get_error_messages() as $err )
59788 echo "<li>$err</li>\n";
59789 ?>
59790 </ul>
59791 </div>
59792 <?php endif;
59793
59794 if ( ! empty($messages) ) {
59795 foreach ( $messages as $msg )
59796 echo $msg;
59797 } ?>
59798
59799 <div class="wrap">
59800 <?php screen_icon(); ?>
59801 <h2><?php echo wp_specialchars( $title );
59802 if ( isset($_GET['s']) && $_GET['s'] )
59803 printf( '<span class="subtitle">' . __('Search results for “%s”') . '</span>', wp_specialchars( get_search_query() ) ); ?>
59804 </h2>
59805
59806 <div class="filter">
59807 <form id="list-filter" action="" method="get">
59808 <ul class="subsubsub">
59809 <?php
59810 $role_links = array();
59811 $avail_roles = array();
59812 $users_of_blog = get_users_of_blog();
59813 $total_users = count( $users_of_blog );
59814 foreach ( (array) $users_of_blog as $b_user ) {
59815 $b_roles = unserialize($b_user->meta_value);
59816 foreach ( (array) $b_roles as $b_role => $val ) {
59817 if ( !isset($avail_roles[$b_role]) )
59818 $avail_roles[$b_role] = 0;
59819 $avail_roles[$b_role]++;
59820 }
59821 }
59822 unset($users_of_blog);
59823
59824 $current_role = false;
59825 $class = empty($role) ? ' class="current"' : '';
59826 $role_links[] = "<li><a href='users.php'$class>" . sprintf( __ngettext( 'All <span class="count">(%s)</span>', 'All <span class="count">(%s)</span>', $total_users ), number_format_i18n( $total_users ) ) . '</a>';
59827 foreach ( $wp_roles->get_names() as $this_role => $name ) {
59828 if ( !isset($avail_roles[$this_role]) )
59829 continue;
59830
59831 $class = '';
59832
59833 if ( $this_role == $role ) {
59834 $current_role = $role;
59835 $class = ' class="current"';
59836 }
59837
59838 $name = translate_with_context($name);
59839 $name = sprintf( _c('%1$s <span class="count">(%2$s)</span>|user role with count'), $name, $avail_roles[$this_role] );
59840 $role_links[] = "<li><a href='users.php?role=$this_role'$class>$name</a>";
59841 }
59842 echo implode( " |</li>\n", $role_links) . '</li>';
59843 unset($role_links);
59844 ?>
59845 </ul>
59846 </form>
59847 </div>
59848
59849 <form class="search-form" action="" method="get">
59850 <p class="search-box">
59851 <label class="hidden" for="user-search-input"><?php _e( 'Search Users' ); ?>:</label>
59852 <input type="text" class="search-input" id="user-search-input" name="usersearch" value="<?php echo attribute_escape($wp_user_search->search_term); ?>" />
59853 <input type="submit" value="<?php _e( 'Search Users' ); ?>" class="button" />
59854 </p>
59855 </form>
59856
59857 <form id="posts-filter" action="" method="get">
59858 <div class="tablenav">
59859
59860 <?php if ( $wp_user_search->results_are_paged() ) : ?>
59861 <div class="tablenav-pages"><?php $wp_user_search->page_links(); ?></div>
59862 <?php endif; ?>
59863
59864 <div class="alignleft actions">
59865 <select name="action">
59866 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
59867 <option value="delete"><?php _e('Delete'); ?></option>
59868 </select>
59869 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction" id="doaction" class="button-secondary action" />
59870 <label class="hidden" for="new_role"><?php _e('Change role to…') ?></label><select name="new_role" id="new_role"><option value=''><?php _e('Change role to…') ?></option><?php wp_dropdown_roles(); ?></select>
59871 <input type="submit" value="<?php _e('Change'); ?>" name="changeit" class="button-secondary" />
59872 <?php wp_nonce_field('bulk-users'); ?>
59873 </div>
59874
59875 <br class="clear" />
59876 </div>
59877
59878 <?php if ( is_wp_error( $wp_user_search->search_errors ) ) : ?>
59879 <div class="error">
59880 <ul>
59881 <?php
59882 foreach ( $wp_user_search->search_errors->get_error_messages() as $message )
59883 echo "<li>$message</li>";
59884 ?>
59885 </ul>
59886 </div>
59887 <?php endif; ?>
59888
59889
59890 <?php if ( $wp_user_search->get_results() ) : ?>
59891
59892 <?php if ( $wp_user_search->is_search() ) : ?>
59893 <p><a href="users.php"><?php _e('← Back to All Users'); ?></a></p>
59894 <?php endif; ?>
59895
59896 <table class="widefat fixed" cellspacing="0">
59897 <thead>
59898 <tr class="thead">
59899 <?php print_column_headers('users') ?>
59900 </tr>
59901 </thead>
59902
59903 <tfoot>
59904 <tr class="thead">
59905 <?php print_column_headers('users', false) ?>
59906 </tr>
59907 </tfoot>
59908
59909 <tbody id="users" class="list:user user-list">
59910 <?php
59911 $style = '';
59912 foreach ( $wp_user_search->get_results() as $userid ) {
59913 $user_object = new WP_User($userid);
59914 $roles = $user_object->roles;
59915 $role = array_shift($roles);
59916
59917 $style = ( ' class="alternate"' == $style ) ? '' : ' class="alternate"';
59918 echo "\n\t" . user_row($user_object, $style, $role);
59919 }
59920 ?>
59921 </tbody>
59922 </table>
59923
59924 <div class="tablenav">
59925
59926 <?php if ( $wp_user_search->results_are_paged() ) : ?>
59927 <div class="tablenav-pages"><?php $wp_user_search->page_links(); ?></div>
59928 <?php endif; ?>
59929
59930 <div class="alignleft actions">
59931 <select name="action2">
59932 <option value="" selected="selected"><?php _e('Bulk Actions'); ?></option>
59933 <option value="delete"><?php _e('Delete'); ?></option>
59934 </select>
59935 <input type="submit" value="<?php _e('Apply'); ?>" name="doaction2" id="doaction2" class="button-secondary action" />
59936 </div>
59937
59938 <br class="clear" />
59939 </div>
59940
59941 <?php endif; ?>
59942
59943 </form>
59944 </div>
59945
59946 <?php
59947 foreach ( array('user_login' => 'user_login', 'first_name' => 'user_firstname', 'last_name' => 'user_lastname', 'email' => 'user_email', 'url' => 'user_uri', 'role' => 'user_role') as $formpost => $var ) {
59948 $var = 'new_' . $var;
59949 $$var = isset($_REQUEST[$formpost]) ? attribute_escape(stripslashes($_REQUEST[$formpost])) : '';
59950 }
59951 unset($name);
59952 ?>
59953
59954 <br class="clear" />
59955 <?php
59956 break;
59957
59958 } // end of the $doaction switch
59959
59960 include('admin-footer.php');
59961 ?>