Changeset 2777 for sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-committers.php
- Timestamp:
- 03/22/2016 06:21:26 AM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/plugins/plugin-directory/admin/metabox/class-committers.php
r2763 r2777 2 2 namespace WordPressdotorg\Plugin_Directory\Admin\Metabox; 3 3 use WordPressdotorg\Plugin_Directory\Admin\List_Table; 4 use WordPressdotorg\Plugin_Directory\Tools; 4 5 5 6 /** … … 35 36 */ 36 37 public static function add_committer() { 38 $login = isset( $_POST['add_committer'] ) ? sanitize_user( $_POST['add_committer'] ) : ''; 39 $post_id = isset( $_POST['post_id'] ) ? (int) $_POST['post_id'] : 0; 40 37 41 check_ajax_referer( 'add-committer' ); 38 42 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(); 43 $response = new \WP_Ajax_Response(); 44 $plugin_slug = get_post( $post_id )->post_name; 42 45 43 46 if ( ! $committer = get_user_by( 'login', $login ) ) { … … 49 52 } 50 53 51 // @todo: Capabilities. 52 if ( ! current_user_can( 'add_committers', $post_id ) ) { 53 // wp_die( -1 ); 54 if ( ! current_user_can( 'plugin_add_committer', $post_id ) ) { 55 wp_die( -1 ); 54 56 } 55 global $post, $wpdb;56 57 57 $post = get_post( $post_id ); 58 $result = $wpdb->insert( PLUGINS_TABLE_PREFIX . 'svn_access', array( 59 'path' => "/{$post->post_name}", 60 'user' => $login, 61 'access' => 'rw', 62 ) ); 58 $result = Tools::grant_plugin_committer( $plugin_slug, $committer ); 59 63 60 if ( ! $result ) { 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' ); 68 } 61 $message = __( 'An error has occurred. Please reload the page and try again.', 'wporg-plugins' ); 69 62 70 63 $response->add( array( … … 95 88 check_ajax_referer( "remove-committer-$id" ); 96 89 97 $response = new \WP_Ajax_Response(); 90 $response = new \WP_Ajax_Response(); 91 $plugin_slug = get_post( $post_id )->post_name; 98 92 99 93 if ( ! $committer = get_user_by( 'id', $id ) ) { … … 105 99 } 106 100 107 // @todo: Capabilities. 108 if ( ! current_user_can( 'remove_committers', $post_id ) ) { 109 // wp_die( -1 ); 101 if ( ! current_user_can( 'plugin_remove_committer', $post_id ) ) { 102 wp_die( -1 ); 110 103 } 111 104 112 $plugin_slug = get_post( $post_id )->post_name; 113 114 $result = $GLOBALS['wpdb']->delete( PLUGINS_TABLE_PREFIX . 'svn_access', array( 115 'path' => "/{$plugin_slug}", 116 'user' => $committer->user_login, 117 ) ); 105 $result = Tools::revoke_plugin_committer( $plugin_slug, $committer ); 118 106 119 107 wp_die( $result );
Note: See TracChangeset
for help on using the changeset viewer.