Ticket #19810: 19810.3.patch
File 19810.3.patch, 11.3 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' ), '20120125', 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
34 34 35 35 do_action( 'admin_init' ); 36 36 37 $core_actions_get = array( 'fetch-list', 'ajax-tag-search', 'compression-test', 'imgedit-preview', 'oembed_cache' );37 $core_actions_get = array( 'fetch-list', 'ajax-tag-search', 'compression-test', 'imgedit-preview', 'oembed_cache', 'autocomplete_user' ); 38 38 39 39 $core_actions_post = array( 40 40 'oembed_cache', 'image-editor', 'delete-comment', 'delete-tag', 'delete-link', … … 63 63 do_action( 'wp_ajax_nopriv_' . $_REQUEST['action'], $_REQUEST['action'] ); // Non-admin actions 64 64 65 65 // Default status 66 die( '-1' ); 67 No newline at end of file 66 die( '-1' ); -
wp-admin/includes/ajax-actions.php
146 146 die( $return ); 147 147 } 148 148 149 function wp_ajax_autocomplete_user() { 150 $return = array(); 151 152 // Exclude current users of this blog 153 $this_blog_users = new WP_User_Query( array( 154 'blog_id' => get_current_blog_id() 155 ) ); 156 157 $tbu_ids = array(); 158 if ( !empty( $this_blog_users->results ) ) { 159 foreach( $this_blog_users->results as $this_blog_user ) { 160 $tbu_ids[] = $this_blog_user->ID; 161 } 162 } 163 164 $users = new WP_User_Query( array( 165 'blog_id' => false, 166 'search' => '*' . $_REQUEST['term'] . '*', 167 'exclude' => $tbu_ids 168 ) ); 169 170 if ( empty( $users->results ) ) { 171 $return[] = array(); 172 } else { 173 foreach ( $users->results as $user ) { 174 $user_data = array(); 175 $user_data['label'] = $user->user_login . ' (' . $user->user_email . ')'; 176 $user_data['id'] = $user->ID; 177 $return[] = $user_data; 178 } 179 } 180 181 die( json_encode( $return ) ); 182 } 183 149 184 /* 150 185 * Ajax helper. 151 186 */ … … 1635 1670 1636 1671 update_user_meta( get_current_user_id(), 'dismissed_wp_pointers', $dismissed ); 1637 1672 die( '1' ); 1638 } 1639 No newline at end of file 1673 } -
wp-admin/js/user-new.dev.js
1 (function($){ 2 var ainput = $('#adduser-email'); 3 var ulist = $('#add-to-blog-users'); 4 5 function add_user_to_list( dname, user_id ) { 6 /* Don't add if it already exists */ 7 if ( $('#atb-user-' + user_id).length ) { 8 return; 9 } 10 11 $(ulist).append('<li class="atb-user" id="atb-user-' + user_id + '"><span class="remove"><a href="#">x</a></span> ' + dname + '</li>'); 12 $(ulist).append('<input type="hidden" name="add_ids[]" id="atb-input-' + user_id + '" value="' + user_id + '" />'); 13 14 $('#add-to-blog-users span.remove a').bind('click', function(){ 15 remove_user_from_list( $(this).parents('.atb-user').attr('id').split('-').pop() ); 16 return false; 17 }); 18 19 $(ainput).val(''); 20 } 21 22 function remove_user_from_list( uid ) { 23 $('#atb-user-' + uid).remove(); 24 $('#atb-input-' + uid).remove(); 25 } 26 27 $(document).ready(function() { 28 29 /* Prevent WP from running its form validation */ 30 $('form#adduser').removeClass('validate'); 31 $(ainput).parents('.form-field').removeClass('form-required'); 32 33 /* Prevent WP core admin script from running */ 34 /*$('form#adduser input[name="action"]').remove();*/ 35 36 var options = { 37 source: ajaxurl + '?action=autocomplete_user', 38 appendTo: 'form#adduser', 39 select: function(event,ui){ add_user_to_list(ui.item.value,ui.item.id); }, 40 search: function(){$(ainput).addClass('ajax-loading');}, 41 open: function(){$(ainput).removeClass('ajax-loading');}, 42 close: function(){$(ainput).val('');}, 43 delay: 500, // miliseconds 44 }; 45 46 a = $(ainput).autocomplete(options); 47 }); 48 49 })(jQuery); 50 -
wp-admin/user-new.php
Property changes on: wp-admin/js/user-new.dev.js ___________________________________________________________________ Added: svn:executable + *
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 ------------------------------------------------------------------------------*/