Changeset 13941
- Timestamp:
- 04/02/2010 06:46:07 AM (15 years ago)
- Location:
- trunk/wp-admin
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-admin/includes/ms.php
r13918 r13941 794 794 } 795 795 796 /** 797 * Grants super admin privileges. 798 * 799 * @since 3.0.0 800 * @param $user_id 801 */ 802 function grant_super_admin( $user_id ) { 803 $super_admins = get_site_option( 'site_admins', array( 'admin' ) ); 804 805 $user = new WP_User( $user_id ); 806 if ( ! in_array( $user->user_login, $super_admins ) ) { 807 $super_admins[] = $user->user_login; 808 update_site_option( 'site_admins' , $super_admins ); 809 } 810 } 811 812 /** 813 * Revokes super admin privileges. 814 * 815 * @since 3.0.0 816 * @param $user_id 817 */ 818 function revoke_super_admin( $user_id ) { 819 $super_admins = get_site_option( 'site_admins', array( 'admin' ) ); 820 $admin_email = get_site_option( 'admin_email' ); 821 822 $user = new WP_User( $user_id ); 823 if ( $user->ID != $current_user->ID || $user->user_email != $admin_email ) { 824 foreach ( $super_admins as $key => $username ) { 825 if ( $username == $user->user_login ) { 826 unset( $super_admins[$key] ); 827 break; 828 } 829 } 830 } 831 832 update_site_option( 'site_admins' , $super_admins ); 833 } 796 834 ?> -
trunk/wp-admin/ms-edit.php
r13918 r13941 525 525 526 526 foreach ( (array) $_POST['allusers'] as $key => $val ) { 527 if ( $val != '' || $val != '0') {527 if ( !empty( $val ) ) { 528 528 switch ( $doaction ) { 529 529 case 'delete': … … 540 540 case 'superadmin': 541 541 $userfunction = 'add_superadmin'; 542 $super_admins = get_site_option( 'site_admins', array( 'admin' ) ); 543 544 $user = new WP_User( $val ); 545 if ( ! in_array( $user->user_login, $super_admins ) ) { 546 if ( $current_site->blog_id ) 547 add_user_to_blog( $current_site->blog_id, $user->ID, 'administrator' ); 548 549 $super_admins[] = $user->user_login; 550 update_site_option( 'site_admins' , $super_admins ); 551 } 542 grant_super_admin( $val ); 552 543 break; 553 544 554 545 case 'notsuperadmin': 555 546 $userfunction = 'remove_superadmin'; 556 $super_admins = get_site_option( 'site_admins', array( 'admin' ) ); 557 $admin_email = get_site_option( 'admin_email' ); 558 559 $user = new WP_User( $val ); 560 if ( $user->ID != $current_user->ID || $user->user_email != $admin_email ) { 561 foreach ( $super_admins as $key => $username ) { 562 if ( $username == $user->user_login ) { 563 unset( $super_admins[$key] ); 564 break; 565 } 566 } 567 } 568 569 update_site_option( 'site_admins' , $super_admins ); 547 revoke_super_admin( $val ); 570 548 break; 571 549 -
trunk/wp-admin/ms-users.php
r13918 r13941 34 34 case 'add': 35 35 _e( 'User added.' ); 36 break;37 case 'add_superadmin':38 _e( 'Network admin added.' );39 break;40 case 'remove_superadmin':41 _e( 'Network admin removed.' );42 36 break; 43 37 } … … 129 123 <option value="-1" selected="selected"><?php _e( 'Bulk Actions' ); ?></option> 130 124 <option value="delete"><?php _e( 'Delete' ); ?></option> 131 <option value="spam"><?php _e( 'Mark as Spam mers' ); ?></option>125 <option value="spam"><?php _e( 'Mark as Spam' ); ?></option> 132 126 <option value="notspam"><?php _e( 'Not Spam' ); ?></option> 133 <option value="superadmin"><?php _e( 'Add Super Admins' ); ?></option>134 <option value="notsuperadmin"><?php _e( 'Remove Super Admins' ); ?></option>135 127 </select> 136 128 <input type="submit" value="<?php esc_attr_e( 'Apply' ); ?>" name="doaction" id="doaction" class="button-secondary action" /> … … 228 220 case 'login': 229 221 $avatar = get_avatar( $user['user_email'], 32 ); 222 $edit_link = ( $current_user->ID == $user['ID'] ) ? 'profile.php' : 'user-edit.php?user_id=' . $user['ID']; 230 223 ?> 231 224 <td class="username column-username"> 232 <?php echo $avatar; ?><strong><a href="<?php echo esc_url( admin_url( 'user-edit.php?user_id=' . $user['ID']) ); ?>" class="edit"><?php echo stripslashes( $user['user_login'] ); ?></a><?php225 <?php echo $avatar; ?><strong><a href="<?php echo esc_url( admin_url( $edit_link ) ); ?>" class="edit"><?php echo stripslashes( $user['user_login'] ); ?></a><?php 233 226 if ( in_array( $user['user_login'], $super_admins ) ) 234 227 echo ' - ' . __( 'Super admin' ); … … 236 229 <br/> 237 230 <div class="row-actions"> 238 <span class="edit"><a href="<?php echo esc_url( admin_url( 'user-edit.php?user_id=' . $user['ID'] ) ); ?>"><?php _e( 'Edit'); ?></a></span>231 <span class="edit"><a href="<?php echo esc_url( admin_url( $edit_link ) ); ?>"><?php _e( 'Edit' ); ?></a></span> 239 232 <?php if ( ! in_array( $user['user_login'], $super_admins ) ) { ?> 240 233 | <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( 'ms-edit.php', 'deleteuser' ) . '&action=deleteuser&id=' . $user['ID'] ) ) ); ?>" class="delete"><?php _e( 'Delete' ); ?></a></span> … … 324 317 <option value="-1" selected="selected"><?php _e( 'Bulk Actions' ); ?></option> 325 318 <option value="delete"><?php _e( 'Delete' ); ?></option> 326 <option value="spam"><?php _e( 'Mark as Spam mers' ); ?></option>319 <option value="spam"><?php _e( 'Mark as Spam' ); ?></option> 327 320 <option value="notspam"><?php _e( 'Not Spam' ); ?></option> 328 <option value="superadmin"><?php _e( 'Add Super Admins' ); ?></option>329 <option value="notsuperadmin"><?php _e( 'Remove Super Admins' ); ?></option>330 321 </select> 331 322 <input type="submit" value="<?php esc_attr_e( 'Apply' ); ?>" name="doaction2" id="doaction2" class="button-secondary action" /> -
trunk/wp-admin/user-edit.php
r13820 r13941 10 10 require_once('admin.php'); 11 11 12 if ( !defined('IS_PROFILE_PAGE') ) 13 define('IS_PROFILE_PAGE', false); 12 wp_reset_vars(array('action', 'redirect', 'profile', 'user_id', 'wp_http_referer')); 13 14 $user_id = (int) $user_id; 15 $current_user = wp_get_current_user(); 16 if ( ! defined( 'IS_PROFILE_PAGE' ) ) 17 define( 'IS_PROFILE_PAGE', ( $user_id == $current_user->ID ) ); 18 19 if ( ! $user_id && IS_PROFILE_PAGE ) 20 $user_id = $current_user->ID; 21 elseif ( ! $user_id && ! IS_PROFILE_PAGE ) 22 wp_die(__( 'Invalid user ID.' ) ); 23 elseif ( ! get_userdata( $user_id ) ) 24 wp_die( __('Invalid user ID.') ); 14 25 15 26 wp_enqueue_script('user-profile'); … … 23 34 $parent_file = 'users.php'; 24 35 25 wp_reset_vars(array('action', 'redirect', 'profile', 'user_id', 'wp_http_referer'));26 27 36 $wp_http_referer = remove_query_arg(array('update', 'delete_count'), stripslashes($wp_http_referer)); 28 29 $user_id = (int) $user_id;30 31 if ( !$user_id ) {32 if ( IS_PROFILE_PAGE ) {33 $current_user = wp_get_current_user();34 $user_id = $current_user->ID;35 } else {36 wp_die(__('Invalid user ID.'));37 }38 } elseif ( !get_userdata($user_id) ) {39 wp_die( __('Invalid user ID.') );40 }41 37 42 38 $all_post_caps = array('posts', 'pages'); … … 124 120 $errors = edit_user($user_id); 125 121 if ( $delete_role ) // stops users being added to current blog when they are edited 126 update_user_meta( $user_id, $blog_prefix . 'capabilities' , '' ); 122 delete_user_meta( $user_id, $blog_prefix . 'capabilities' ); 123 124 if ( is_multisite() && is_super_admin() && !IS_PROFILE_PAGE ) 125 empty( $_POST['super_admin'] ) ? revoke_super_admin( $user_id ) : grant_super_admin( $user_id ); 127 126 } 128 127 … … 143 142 ?> 144 143 144 <?php if ( !IS_PROFILE_PAGE && is_super_admin( $profileuser->ID ) ) { ?> 145 <div class="updated"><p><strong><?php _e('Important:'); ?></strong> <?php _e('This user has super admin privileges.'); ?></p></div> 146 <?php } ?> 145 147 <?php if ( isset($_GET['updated']) ) : ?> 146 148 <div id="message" class="updated"> … … 166 168 <h2><?php echo esc_html( $title ); ?></h2> 167 169 168 <form id="your-profile" action="<?php if ( IS_PROFILE_PAGE ) { echo admin_url('profile.php'); } else { echo admin_url('user-edit.php'); }?>" method="post">170 <form id="your-profile" action="<?php echo esc_url( admin_url( IS_PROFILE_PAGE ? 'profile.php' : 'user-edit.php' ) ); ?>" method="post"> 169 171 <?php wp_nonce_field('update-user_' . $user_id) ?> 170 172 <?php if ( $wp_http_referer ) : ?> … … 233 235 echo '<option value="" selected="selected">' . __('— No role for this blog —') . '</option>'; 234 236 ?> 235 </select></td></tr> 237 </select> 238 <?php if ( is_multisite() && is_super_admin() ) { ?> 239 <p><label><input type="checkbox" id="super_admin" name="super_admin"<?php checked( is_super_admin( $profileuser->ID ) ); ?> /> <?php _e( 'Grant this user super admin privileges for the Network.'); ?></label></p> 240 <?php } ?> 241 </td></tr> 236 242 <?php endif; //!IS_PROFILE_PAGE ?> 237 243 … … 332 338 333 339 <?php 334 if ( IS_PROFILE_PAGE ) { 335 do_action('show_user_profile', $profileuser); 336 } else { 337 do_action('edit_user_profile', $profileuser); 338 } 340 if ( IS_PROFILE_PAGE ) 341 do_action( 'show_user_profile', $profileuser ); 342 else 343 do_action( 'edit_user_profile', $profileuser ); 339 344 ?> 340 345
Note: See TracChangeset
for help on using the changeset viewer.