Changeset 2753
- Timestamp:
- 03/15/2016 09:11:27 PM (9 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/class-committers-list-table.php
r2752 r2753 122 122 <p class="wp-hidden-child"> 123 123 <?php wp_nonce_field( 'add-committer', '_ajax_nonce', false ); ?> 124 <span id="committer-error" class="notice notice-alt notice-error" style="display:none;"></span> 124 125 <input type="text" name="add_committer" class="form-required" value="" aria-required="true"> 125 126 <input type="button" id="add-committer-submit" class="button" data-wp-lists="add:the-committer-list:add-committer::post_id=<?php echo get_post()->ID; ?>" value="<?php _e( 'Add Committer', 'wporg-plugins' ); ?>"> -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-committers.php
r2752 r2753 22 22 } 23 23 24 /** 25 * Displays a list of committers for the current plugin. 26 */ 24 27 public static function display() { 25 28 $list = new Committers_List_Table(); … … 28 31 } 29 32 33 /** 34 * Ajax handler for adding a new committer. 35 */ 30 36 public static function add_committer() { 31 37 check_ajax_referer( 'add-committer' ); 32 38 33 $login = isset( $_POST['add_committer'] ) ? sanitize_user( $_POST['add_committer'] ) : ''; 34 $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0; 39 $login = isset( $_POST['add_committer'] ) ? sanitize_user( $_POST['add_committer'] ) : ''; 40 $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0; 41 $response = new \WP_Ajax_Response(); 35 42 36 43 if ( ! $committer = get_user_by( 'login', $login ) ) { 37 wp_die( time() ); 44 $response->add( array( 45 'what' => 'committer', 46 'data' => new \WP_Error( 'error', sprintf( __( 'The user %s does not exist.', 'wporg-plugins' ), '<code>' . $login . '</code>' ) ), 47 ) ); 48 $response->send(); 38 49 } 39 50 40 if ( ! current_user_can( 'manage_committers', $post_id ) ) { 41 // wp_die( -1 ); 51 // @todo: Capabilities. 52 if ( ! current_user_can( 'add_committers', $post_id ) ) { 53 // wp_die( -1 ); 42 54 } 43 55 global $post, $wpdb; 44 56 45 $response = new \WP_Ajax_Response(); 46 $post = get_post( $post_id ); 47 57 $post = get_post( $post_id ); 48 58 $result = $wpdb->insert( PLUGINS_TABLE_PREFIX . 'svn_access', array( 49 59 'path' => "/{$post->post_name}", … … 51 61 'access' => 'rw', 52 62 ) ); 53 54 63 if ( ! $result ) { 55 $message = __( 'An error has occurred. Please reload the page and try again.' ); 56 if ( is_wp_error( $result ) && $result->get_error_message() ) { 57 $message = $result->get_error_message(); 64 if ( 'Duplicate entry' === substr( $wpdb->last_error, 0, 15 ) ) { 65 $message = __( 'Duplicate committer detected.', 'wporg-plugins' ); 66 } else { 67 $message = __( 'An error has occurred. Please reload the page and try again.', 'wporg-plugins' ); 58 68 } 59 69 … … 76 86 } 77 87 88 /** 89 * Ajax handler for removing a committer. 90 */ 78 91 public static function remove_committer() { 79 92 $id = isset( $_POST['id'] ) ? (int) $_POST['id'] : 0; … … 82 95 check_ajax_referer( "remove-committer-$id" ); 83 96 97 $response = new \WP_Ajax_Response(); 98 84 99 if ( ! $committer = get_user_by( 'id', $id ) ) { 85 wp_die( time() ); 100 $response->add( array( 101 'what' => 'committer', 102 'data' => new \WP_Error( 'error', sprintf( __( 'The user %s does not exist.', 'wporg-plugins' ), '<code>' . $login . '</code>' ) ), 103 ) ); 104 $response->send(); 86 105 } 87 106 88 if ( ! current_user_can( 'manage_committers', $post_id ) ) { 89 // wp_die( -1 ); 107 // @todo: Capabilities. 108 if ( ! current_user_can( 'remove_committers', $post_id ) ) { 109 // wp_die( -1 ); 90 110 } 91 111 … … 93 113 94 114 $result = $GLOBALS['wpdb']->delete( PLUGINS_TABLE_PREFIX . 'svn_access', array( 95 'path' 96 'user' 115 'path' => "/{$plugin_slug}", 116 'user' => $committer->user_login, 97 117 ) ); 98 118 -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/css/edit-form.css
r2752 r2753 149 149 width: 100%; 150 150 } 151 152 .add-committer .notice { 153 display: block; 154 padding: 0.5em 0 0.5em 1em; 155 } -
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/js/edit-form.js
r2752 r2753 33 33 } 34 34 return true; 35 } 35 }, 36 addAfter: PluginEdit.committerRequestAfter, 37 delAfter: PluginEdit.committerRequestAfter 36 38 }).on( 'wpListAddEnd', function() { 37 39 $( 'input[name="add_committer"]', '#add-committer' ).val( '' ).focus(); … … 125 127 } 126 128 } ); 129 }, 130 131 committerRequestAfter: function( response, data ) { 132 if ( data.parsed.errors ) { 133 $( '#committer-error' ).text( data.parsed.responses[0].errors[0].message ).show(); 134 } else { 135 $( '#committer-error' ).empty().hide(); 136 } 127 137 } 128 138 };
Note: See TracChangeset
for help on using the changeset viewer.