Add delete_plugins and update_plugins caps. Props DD32. fixes #7096

git-svn-id: http://svn.automattic.com/wordpress/trunk@8060 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-06-06 19:21:35 +00:00
parent 5b1fffa322
commit 385d3d9500
6 changed files with 26 additions and 7 deletions

View File

@ -257,7 +257,7 @@ function populate_options() {
add_option('avatar_default', 'mystery'); add_option('avatar_default', 'mystery');
// Delete unused options // Delete unused options
$unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval'); $unusedoptions = array ('blodotgsping_url', 'bodyterminator', 'emailtestonly', 'phoneemail_separator', 'smilies_directory', 'subjectprefix', 'use_bbcode', 'use_blodotgsping', 'use_phoneemail', 'use_quicktags', 'use_weblogsping', 'weblogs_cache_file', 'use_preview', 'use_htmltrans', 'smilies_directory', 'fileupload_allowedusers', 'use_phoneemail', 'default_post_status', 'default_post_category', 'archive_mode', 'time_difference', 'links_minadminlevel', 'links_use_adminlevels', 'links_rating_type', 'links_rating_char', 'links_rating_ignore_zero', 'links_rating_single_image', 'links_rating_image0', 'links_rating_image1', 'links_rating_image2', 'links_rating_image3', 'links_rating_image4', 'links_rating_image5', 'links_rating_image6', 'links_rating_image7', 'links_rating_image8', 'links_rating_image9', 'weblogs_cacheminutes', 'comment_allowed_tags', 'search_engine_friendly_urls', 'default_geourl_lat', 'default_geourl_lon', 'use_default_geourl', 'weblogs_xml_url', 'new_users_can_blog', '_wpnonce', '_wp_http_referer', 'Update', 'action', 'rich_editing', 'autosave_interval', 'deactivated_plugins');
foreach ($unusedoptions as $option) : foreach ($unusedoptions as $option) :
delete_option($option); delete_option($option);
endforeach; endforeach;
@ -274,6 +274,7 @@ function populate_roles() {
populate_roles_210(); populate_roles_210();
populate_roles_230(); populate_roles_230();
populate_roles_250(); populate_roles_250();
populate_roles_260();
} }
function populate_roles_160() { function populate_roles_160() {
@ -429,4 +430,13 @@ function populate_roles_250() {
} }
} }
function populate_roles_260() {
$role = get_role( 'administrator' );
if ( !empty( $role ) ) {
$role->add_cap( 'update_plugins' );
$role->add_cap( 'delete_plugins' );
}
}
?> ?>

View File

@ -126,7 +126,7 @@ function wp_plugin_update_row( $file, $plugin_data ) {
$r = $current->response[ $file ]; $r = $current->response[ $file ];
echo '<tr><td colspan="5" class="plugin-update">'; echo '<tr><td colspan="5" class="plugin-update">';
if ( !current_user_can('edit_plugins') ) if ( ! current_user_can('update_plugins') )
printf( __('There is a new version of %1$s available. <a href="%2$s">Download version %3$s here</a>.'), $plugin_data['Name'], $r->url, $r->new_version); printf( __('There is a new version of %1$s available. <a href="%2$s">Download version %3$s here</a>.'), $plugin_data['Name'], $r->url, $r->new_version);
else if ( empty($r->package) ) else if ( empty($r->package) )
printf( __('There is a new version of %1$s available. <a href="%2$s">Download version %3$s here</a> <em>automatic upgrade unavailable for this plugin</em>.'), $plugin_data['Name'], $r->url, $r->new_version); printf( __('There is a new version of %1$s available. <a href="%2$s">Download version %3$s here</a> <em>automatic upgrade unavailable for this plugin</em>.'), $plugin_data['Name'], $r->url, $r->new_version);

View File

@ -208,6 +208,9 @@ function upgrade_all() {
if ( $wp_current_db_version < 7935 ) if ( $wp_current_db_version < 7935 )
upgrade_252(); upgrade_252();
if ( $wp_current_db_version < 8000 )
upgrade_260();
maybe_disable_automattic_widgets(); maybe_disable_automattic_widgets();
$wp_rewrite->flush_rules(); $wp_rewrite->flush_rules();
@ -742,6 +745,10 @@ function upgrade_252() {
$wpdb->query("UPDATE $wpdb->users SET user_activation_key = ''"); $wpdb->query("UPDATE $wpdb->users SET user_activation_key = ''");
} }
function upgrade_260() {
populate_roles_260();
}
// The functions we use to actually do stuff // The functions we use to actually do stuff
// General // General

View File

@ -72,6 +72,8 @@ if( !empty($action) ) {
exit; exit;
break; break;
case 'delete-selected': case 'delete-selected':
if( ! current_user_can('delete_plugins') )
wp_die(__('You do not have sufficient permissions to delete plugins for this blog.'));
check_admin_referer('mass-manage-plugins'); check_admin_referer('mass-manage-plugins');
$plugins = $_REQUEST['checked']; $plugins = $_REQUEST['checked'];
include(ABSPATH . 'wp-admin/update.php'); include(ABSPATH . 'wp-admin/update.php');
@ -250,7 +252,7 @@ function print_plugins_table($plugins, $context = '') {
<div class="tablenav"> <div class="tablenav">
<div class="alignleft"> <div class="alignleft">
<input type="submit" name="activate-selected" value="<?php _e('Activate') ?>" class="button-secondary" /> <input type="submit" name="activate-selected" value="<?php _e('Activate') ?>" class="button-secondary" />
<?php if( current_user_can('edit_plugins') ) : ?> <?php if( current_user_can('delete_plugins') ) : ?>
<input type="submit" name="delete-selected" value="<?php _e('Delete') ?>" class="button-secondary" /> <input type="submit" name="delete-selected" value="<?php _e('Delete') ?>" class="button-secondary" />
<?php endif; ?> <?php endif; ?>
</div> </div>
@ -267,7 +269,7 @@ function print_plugins_table($plugins, $context = '') {
<div class="tablenav"> <div class="tablenav">
<div class="alignleft"> <div class="alignleft">
<input type="submit" name="activate-selected" value="<?php _e('Activate') ?>" class="button-secondary" /> <input type="submit" name="activate-selected" value="<?php _e('Activate') ?>" class="button-secondary" />
<?php if( current_user_can('edit_plugins') ) : ?> <?php if( current_user_can('delete_plugins') ) : ?>
<input type="submit" name="delete-selected" value="<?php _e('Delete') ?>" class="button-secondary" /> <input type="submit" name="delete-selected" value="<?php _e('Delete') ?>" class="button-secondary" />
<?php endif; ?> <?php endif; ?>
</div> </div>

View File

@ -2,8 +2,8 @@
require_once('admin.php'); require_once('admin.php');
if ( !current_user_can('edit_plugins') ) if ( ! current_user_can('update_plugins') )
wp_die('<p>'.__('You do not have sufficient permissions to update plugins for this blog.').'</p>'); wp_die(__('You do not have sufficient permissions to update plugins for this blog.'));
function request_filesystem_credentials($form_post, $type = '', $error = false) { function request_filesystem_credentials($form_post, $type = '', $error = false) {
$req_cred = apply_filters('request_filesystem_credentials', '', $form_post, $type, $error); $req_cred = apply_filters('request_filesystem_credentials', '', $form_post, $type, $error);

View File

@ -16,6 +16,6 @@ $wp_version = '2.6-bleeding2';
* *
* @global int $wp_db_version * @global int $wp_db_version
*/ */
$wp_db_version = 7935; $wp_db_version = 8000;
?> ?>