Ticket #19810: 19810.patch
File 19810.patch, 8.5 KB (added by , 13 years ago) |
---|
-
wp-includes/script-loader.php
260 260 261 261 $scripts->add( 'user-profile', "/wp-admin/js/user-profile$suffix.js", array( 'jquery', 'password-strength-meter' ), false, 1 ); 262 262 263 $scripts->add( 'user-new', "/wp-admin/js/user-new$suffix.js", array( 'jquery', 'jquery-ui-autocomplete' ), '20120115', 1 ); 264 263 265 $scripts->add( 'admin-bar', "/wp-includes/js/admin-bar$suffix.js", array(), false, 1 ); 264 266 265 267 $scripts->add( 'wplink', "/wp-includes/js/wplink$suffix.js", array( 'jquery', 'wpdialogs' ), false, 1 ); -
wp-admin/admin-ajax.php
169 169 $return = ( $wp_embed->cache_oembed( $_GET['post'] ) ) ? '1' : '0'; 170 170 die( $return ); 171 171 break; 172 case 'add-existing-user-ac' : 173 $return = array(); 174 175 // Exclude current users of this blog 176 $this_blog_users = new WP_User_Query( array( 177 'blog_id' => get_current_blog_id() 178 ) ); 179 180 $tbu_ids = array(); 181 if ( !empty( $this_blog_users->results ) ) { 182 foreach( $this_blog_users->results as $this_blog_user ) { 183 $tbu_ids[] = $this_blog_user->ID; 184 } 185 } 186 187 $users = new WP_User_Query( array( 188 'blog_id' => false, 189 'search' => '*' . $_REQUEST['term'] . '*', 190 'exclude' => $tbu_ids 191 ) ); 192 193 if ( empty( $users->results ) ) { 194 $return[] = array(); 195 } else { 196 foreach ( $users->results as $user ) { 197 $user_data = array(); 198 $user_data['label'] = $user->user_login . ' (' . $user->user_email . ')'; 199 $user_data['id'] = $user->ID; 200 $return[] = $user_data; 201 } 202 } 203 204 die( json_encode( $return ) ); 205 break; 172 206 default : 173 207 do_action( 'wp_ajax_' . $_GET['action'] ); 174 208 die('0'); -
wp-admin/user-new.php
38 38 if ( isset($_REQUEST['action']) && 'adduser' == $_REQUEST['action'] ) { 39 39 check_admin_referer( 'add-user', '_wpnonce_add-user' ); 40 40 41 $user_details = null; 42 if ( false !== strpos($_REQUEST[ 'email' ], '@') ) { 43 $user_details = get_user_by('email', $_REQUEST[ 'email' ]); 41 $add_users = isset( $_REQUEST['add_ids'] ) ? (array)$_REQUEST['add_ids'] : $_REQUEST['email']; 42 43 $add_users_data = array(); 44 if ( is_array( $add_users ) ) { 45 foreach( $add_users as $add_id ) { 46 if ( current_user_can( 'promote_user', $add_id ) ) { 47 $add_users_data[] = get_userdata( (int)$add_id ); 48 } 49 } 44 50 } else { 45 if ( is_super_admin() ) {46 $ user_details = get_user_by('login', $_REQUEST[ 'email' ]);51 if ( false !== strpos($add_users, '@') ) { 52 $add_users_data[] = get_user_by('email', $add_users); 47 53 } else { 48 wp_redirect( add_query_arg( array('update' => 'enter_email'), 'user-new.php' ) ); 49 die(); 54 if ( is_super_admin() ) { 55 $add_users_data[] = get_user_by('login', $add_users); 56 } else { 57 wp_redirect( add_query_arg( array('update' => 'enter_email'), 'user-new.php' ) ); 58 die(); 59 } 50 60 } 61 62 if ( ! current_user_can('promote_user', $add_users_data[0]->ID) ) 63 wp_die(__('Cheatin’ uh?')); 51 64 } 52 65 53 if ( !$user_details) {66 if ( empty( $add_users_data ) ) { 54 67 wp_redirect( add_query_arg( array('update' => 'does_not_exist'), 'user-new.php' ) ); 55 68 die(); 56 69 } 57 58 if ( ! current_user_can('promote_user', $user_details->ID) ) 59 wp_die(__('Cheatin’ uh?')); 60 61 // Adding an existing user to this blog 62 $new_user_email = $user_details->user_email; 63 $redirect = 'user-new.php'; 64 $username = $user_details->user_login; 65 $user_id = $user_details->ID; 66 if ( ( $username != null && !is_super_admin( $user_id ) ) && ( array_key_exists($blog_id, get_blogs_of_user($user_id)) ) ) { 67 $redirect = add_query_arg( array('update' => 'addexisting'), 'user-new.php' ); 68 } else { 69 if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) { 70 add_existing_user_to_blog( array( 'user_id' => $user_id, 'role' => $_REQUEST[ 'role' ] ) ); 71 $redirect = add_query_arg( array('update' => 'addnoconfirmation'), 'user-new.php' ); 70 71 foreach( $add_users_data as $user_details ) { 72 // Adding an existing user to this blog 73 $new_user_email = $user_details->user_email; 74 $redirect = 'user-new.php'; 75 $username = $user_details->user_login; 76 $user_id = $user_details->ID; 77 if ( ( $username != null && !is_super_admin( $user_id ) ) && ( array_key_exists($blog_id, get_blogs_of_user($user_id)) ) ) { 78 $redirect = add_query_arg( array('update' => 'addexisting'), 'user-new.php' ); 72 79 } else { 73 $newuser_key = substr( md5( $user_id ), 0, 5 ); 74 add_option( 'new_user_' . $newuser_key, array( 'user_id' => $user_id, 'email' => $user_details->user_email, 'role' => $_REQUEST[ 'role' ] ) ); 75 /* translators: 1: Site name, 2: site URL, 3: role, 4: activation URL */ 76 $message = __( 'Hi, 77 80 if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) { 81 add_existing_user_to_blog( array( 'user_id' => $user_id, 'role' => $_REQUEST[ 'role' ] ) ); 82 $redirect = add_query_arg( array('update' => 'addnoconfirmation'), 'user-new.php' ); 83 } else { 84 $newuser_key = substr( md5( $user_id ), 0, 5 ); 85 add_option( 'new_user_' . $newuser_key, array( 'user_id' => $user_id, 'email' => $user_details->user_email, 'role' => $_REQUEST[ 'role' ] ) ); 86 /* translators: 1: Site name, 2: site URL, 3: role, 4: activation URL */ 87 $message = __( 'Hi, 88 78 89 You\'ve been invited to join \'%1$s\' at 79 90 %2$s with the role of %3$s. 80 91 81 92 Please click the following link to confirm the invite: 82 93 %4$s' ); 83 wp_mail( $new_user_email, sprintf( __( '[%s] Joining confirmation' ), get_option( 'blogname' ) ), sprintf($message, get_option('blogname'), home_url(), $_REQUEST[ 'role' ], home_url("/newbloguser/$newuser_key/"))); 84 $redirect = add_query_arg( array('update' => 'add'), 'user-new.php' ); 94 wp_mail( $new_user_email, sprintf( __( '[%s] Joining confirmation' ), get_option( 'blogname' ) ), sprintf($message, get_option('blogname'), site_url(), $_REQUEST[ 'role' ], site_url("/newbloguser/$newuser_key/"))); 95 $redirect = add_query_arg( array('update' => 'add'), 'user-new.php' ); 96 } 85 97 } 86 98 } 87 99 wp_redirect( $redirect ); … … 178 190 179 191 wp_enqueue_script('wp-ajax-response'); 180 192 wp_enqueue_script('user-profile'); 193 wp_enqueue_script('user-new'); 194 wp_enqueue_script('jquery-ui-autocomplete'); 181 195 182 196 require_once ('admin-header.php'); 183 197 … … 265 279 <table class="form-table"> 266 280 <tr class="form-field form-required"> 267 281 <th scope="row"><label for="adduser-email"><?php echo $label; ?></label></th> 268 <td><input name="email" type="text" id="adduser-email" value="" />< /td>282 <td><input name="email" type="text" id="adduser-email" value="" /><ul id="add-to-blog-users"></ul></td> 269 283 </tr> 270 284 <tr class="form-field"> 271 285 <th scope="row"><label for="adduser-role"><?php _e('Role'); ?></label></th> -
wp-admin/css/wp-admin.dev.css
892 892 margin: 0; 893 893 } 894 894 895 #wpcontent input[type="text"].ajax-loading { 896 background: transparent url('../images/loading.gif') no-repeat right center; 897 visibility: visible; 898 } 895 899 900 ul#add-to-blog-users { 901 margin: 0 0 0 14px; 902 } 903 904 form#adduser ul.ui-autocomplete { 905 padding: 0; 906 margin: 0; 907 list-style: none; 908 position: absolute; 909 z-index: 10000; 910 border-width: 1px; 911 border-style: solid; 912 913 background-color: #ffffff; 914 border-color: gray; 915 } 916 917 form#adduser .ui-widget-content { 918 background: #ececec; 919 } 920 921 form#adduser .ui-widget-content li { 922 padding: 2px 5px; 923 white-space: nowrap; 924 text-align: left; 925 color: #101010; 926 } 927 928 form#adduser .ui-widget-content li a { 929 display: block; 930 height: 100%; 931 padding: 2px 5px; 932 color: #333; 933 } 934 935 form#adduser .ui-widget-content li a.ui-state-hover { 936 background-color: #f0f0b8; 937 } 938 939 form#adduser a.remove { 940 margin: 6px 0pt 0pt -12px; 941 cursor: pointer; 942 width: 10px; 943 height: 10px; 944 display: block; 945 float: left; 946 text-indent: -9999px; 947 overflow: hidden; 948 position: absolute; 949 background: transparent url(../images/xit.gif) no-repeat; 950 } 951 952 form#adduser a.remove:hover { 953 background: transparent url(../images/xit.gif) no-repeat -10px 0; 954 } 955 956 896 957 /*------------------------------------------------------------------------------ 897 958 3.0 - Actions 898 959 ------------------------------------------------------------------------------*/