Version Description
- Compat : bbPress 2.2 (supports customization of dynamic forum role capabilities)
- Compat : Press Permit + bbPress - customized role capabilities were not properly maintained on bbPress activation / deactivation, in some scenarios
- Fixed : Role update and copy failed if currently stored capability array is corrupted
Download this release
Release Info
| Developer | kevinB |
| Plugin | |
| Version | 1.4.6 |
| Comparing to | |
| See all releases | |
Code changes from version 1.4.5 to 1.4.6
- capsman-enhanced.php +12 -5
- includes/admin.php +16 -11
- includes/manager.php +73 -12
- readme.txt +14 -2
capsman-enhanced.php
CHANGED
|
@@ -3,7 +3,7 @@
|
|
| 3 |
Plugin Name: Capability Manager Enhanced
|
| 4 |
Plugin URI: http://presspermit.com/capability-manager
|
| 5 |
Description: Manage WordPress role definitions. Organizes available capabilities by post type, status and source.
|
| 6 |
-
Version: 1.4.
|
| 7 |
Author: Jordi Canals, Kevin Behrens
|
| 8 |
Author URI: http://agapetry.net
|
| 9 |
*/
|
|
@@ -32,8 +32,8 @@ Author URI: http://agapetry.net
|
|
| 32 |
*/
|
| 33 |
|
| 34 |
if ( ! defined( 'CAPSMAN_VERSION' ) ) {
|
| 35 |
-
define( 'CAPSMAN_VERSION', '1.4.
|
| 36 |
-
define( 'CAPSMAN_ENH_VERSION', '1.4.
|
| 37 |
}
|
| 38 |
|
| 39 |
if ( cme_is_plugin_active( 'capsman.php' ) ) {
|
|
@@ -80,11 +80,18 @@ if ( cme_is_plugin_active( 'capsman.php' ) ) {
|
|
| 80 |
}
|
| 81 |
}
|
| 82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
// perf enchancement: display submenu links without loading framework and plugin code
|
| 84 |
function cme_submenus() {
|
| 85 |
-
if ( defined(
|
| 86 |
add_action( 'pp_permissions_menu', '_cme_pp_menu' );
|
| 87 |
-
else {
|
| 88 |
$menu_caption = ( defined('WPLANG') && WPLANG ) ? __('Capabilities', 'capsman') : __('Role Capabilities', 'capsman');
|
| 89 |
add_users_page( __('Capability Manager', 'capsman'), $menu_caption, 'manage_capabilities', 'capsman', 'cme_fakefunc');
|
| 90 |
}
|
| 3 |
Plugin Name: Capability Manager Enhanced
|
| 4 |
Plugin URI: http://presspermit.com/capability-manager
|
| 5 |
Description: Manage WordPress role definitions. Organizes available capabilities by post type, status and source.
|
| 6 |
+
Version: 1.4.6
|
| 7 |
Author: Jordi Canals, Kevin Behrens
|
| 8 |
Author URI: http://agapetry.net
|
| 9 |
*/
|
| 32 |
*/
|
| 33 |
|
| 34 |
if ( ! defined( 'CAPSMAN_VERSION' ) ) {
|
| 35 |
+
define( 'CAPSMAN_VERSION', '1.4.6' );
|
| 36 |
+
define( 'CAPSMAN_ENH_VERSION', '1.4.6' );
|
| 37 |
}
|
| 38 |
|
| 39 |
if ( cme_is_plugin_active( 'capsman.php' ) ) {
|
| 80 |
}
|
| 81 |
}
|
| 82 |
|
| 83 |
+
add_action( 'plugins_loaded', '_cme_act_pp_active' );
|
| 84 |
+
|
| 85 |
+
function _cme_act_pp_active() {
|
| 86 |
+
if ( defined('PP_VERSION') || defined('PPC_VERSION') )
|
| 87 |
+
define( 'PP_ACTIVE', true );
|
| 88 |
+
}
|
| 89 |
+
|
| 90 |
// perf enchancement: display submenu links without loading framework and plugin code
|
| 91 |
function cme_submenus() {
|
| 92 |
+
if ( defined('PP_ACTIVE') ) { // Press Permit integrates into Permissions menu
|
| 93 |
add_action( 'pp_permissions_menu', '_cme_pp_menu' );
|
| 94 |
+
} else {
|
| 95 |
$menu_caption = ( defined('WPLANG') && WPLANG ) ? __('Capabilities', 'capsman') : __('Role Capabilities', 'capsman');
|
| 96 |
add_users_page( __('Capability Manager', 'capsman'), $menu_caption, 'manage_capabilities', 'capsman', 'cme_fakefunc');
|
| 97 |
}
|
includes/admin.php
CHANGED
|
@@ -29,11 +29,13 @@
|
|
| 29 |
$roles = $this->roles;
|
| 30 |
$default = $this->current;
|
| 31 |
|
| 32 |
-
if( defined('
|
| 33 |
global $wpdb;
|
| 34 |
|
| 35 |
-
|
| 36 |
-
|
|
|
|
|
|
|
| 37 |
|
| 38 |
$pp_filtered_types = pp_get_enabled_types('post');
|
| 39 |
$pp_metagroup_caps = array();
|
|
@@ -54,7 +56,7 @@ if( defined('PP_VERSION') ) {
|
|
| 54 |
|
| 55 |
?>
|
| 56 |
<div class="wrap">
|
| 57 |
-
<?php if( defined('
|
| 58 |
pp_icon();
|
| 59 |
$style = 'style="height:60px;"';
|
| 60 |
?>
|
|
@@ -76,7 +78,7 @@ if( defined('PP_VERSION') ) {
|
|
| 76 |
<dt><?php printf(__('Capabilities for %s', $this->ID), $roles[$default]); ?></dt>
|
| 77 |
<dd>
|
| 78 |
<?php
|
| 79 |
-
if ( defined( '
|
| 80 |
if ( pp_get_option('display_hints') ) {
|
| 81 |
echo '<div>';
|
| 82 |
_e( 'Use this form to view and modify the capabilities WordPress natively associates with each role. Note:', $this->ID );
|
|
@@ -146,6 +148,9 @@ if( defined('PP_VERSION') ) {
|
|
| 146 |
echo '</div></div>';
|
| 147 |
}
|
| 148 |
|
|
|
|
|
|
|
|
|
|
| 149 |
$current = get_role($default);
|
| 150 |
$rcaps = $current->capabilities;
|
| 151 |
|
|
@@ -167,13 +172,13 @@ if( defined('PP_VERSION') ) {
|
|
| 167 |
|
| 168 |
$cap_properties['edit']['taxonomy'] = array( 'manage_terms' );
|
| 169 |
|
| 170 |
-
if ( ! defined( '
|
| 171 |
$cap_properties['edit']['taxonomy'] = array_merge( $cap_properties['edit']['taxonomy'], array( 'edit_terms', 'assign_terms' ) );
|
| 172 |
|
| 173 |
$cap_properties['delete']['type'] = array( 'delete_posts', 'delete_others_posts' );
|
| 174 |
$cap_properties['delete']['type'] = array_merge( $cap_properties['delete']['type'], array( 'delete_published_posts', 'delete_private_posts' ) );
|
| 175 |
|
| 176 |
-
if ( ! defined( '
|
| 177 |
$cap_properties['delete']['taxonomy'] = array( 'delete_terms' );
|
| 178 |
else
|
| 179 |
$cap_properties['delete']['taxonomy'] = array();
|
|
@@ -219,7 +224,7 @@ if( defined('PP_VERSION') ) {
|
|
| 219 |
$defined['taxonomy'] = get_taxonomies( array( 'public' => true ), 'object' );
|
| 220 |
|
| 221 |
// Press Permit grants attachment capabilities based on user's capabilities for the parent post
|
| 222 |
-
if ( defined( '
|
| 223 |
unset( $defined['type']['attachment'] );
|
| 224 |
|
| 225 |
echo '<ul class="cme-listhoriz">';
|
|
@@ -456,7 +461,7 @@ if( defined('PP_VERSION') ) {
|
|
| 456 |
</table>
|
| 457 |
|
| 458 |
<br />
|
| 459 |
-
<?php if ( ! defined('
|
| 460 |
<div class="cme-subtext">
|
| 461 |
<?php _e( 'Note: Underscores replace spaces in stored capability name ("edit users" => "edit_users").', 'pp' ); ?>
|
| 462 |
</div>
|
|
@@ -467,7 +472,7 @@ if( defined('PP_VERSION') ) {
|
|
| 467 |
</dl>
|
| 468 |
|
| 469 |
<?php
|
| 470 |
-
$support_pp_only_roles = defined('
|
| 471 |
?>
|
| 472 |
|
| 473 |
<?php if ( $support_pp_only_roles && ! in_array( $default, array( 'subscriber', 'contributor', 'author', 'editor', 'administrator' ) ) ) : ?>
|
|
@@ -550,7 +555,7 @@ if( defined('PP_VERSION') ) {
|
|
| 550 |
</dd>
|
| 551 |
</dl>
|
| 552 |
|
| 553 |
-
<?php if ( defined('
|
| 554 |
<dl>
|
| 555 |
<dt><?php _e('Force Type-Specific Capabilities', $this->ID); ?></dt>
|
| 556 |
<dd style="text-align:center;">
|
| 29 |
$roles = $this->roles;
|
| 30 |
$default = $this->current;
|
| 31 |
|
| 32 |
+
if( defined('PP_ACTIVE') ) {
|
| 33 |
global $wpdb;
|
| 34 |
|
| 35 |
+
if ( defined( 'PPC_VERSION' ) )
|
| 36 |
+
$pp_supplemental_roles = $wpdb->get_col( "SELECT role_name FROM $wpdb->ppc_roles AS r INNER JOIN $wpdb->pp_groups AS g ON g.ID = r.group_id AND r.group_type = 'pp_group' WHERE g.metagroup_type = 'wp_role' AND g.metagroup_id = '$default'" );
|
| 37 |
+
else
|
| 38 |
+
$pp_supplemental_roles = $wpdb->get_col( "SELECT role_name FROM $wpdb->pp_roles AS r INNER JOIN $wpdb->pp_groups AS g ON g.ID = r.group_id AND r.group_type = 'pp_group' AND r.scope = 'site' WHERE g.metagroup_type = 'wp_role' AND g.metagroup_id = '$default'" );
|
| 39 |
|
| 40 |
$pp_filtered_types = pp_get_enabled_types('post');
|
| 41 |
$pp_metagroup_caps = array();
|
| 56 |
|
| 57 |
?>
|
| 58 |
<div class="wrap">
|
| 59 |
+
<?php if( defined('PP_ACTIVE') ) :
|
| 60 |
pp_icon();
|
| 61 |
$style = 'style="height:60px;"';
|
| 62 |
?>
|
| 78 |
<dt><?php printf(__('Capabilities for %s', $this->ID), $roles[$default]); ?></dt>
|
| 79 |
<dd>
|
| 80 |
<?php
|
| 81 |
+
if ( defined( 'PP_ACTIVE' ) ) {
|
| 82 |
if ( pp_get_option('display_hints') ) {
|
| 83 |
echo '<div>';
|
| 84 |
_e( 'Use this form to view and modify the capabilities WordPress natively associates with each role. Note:', $this->ID );
|
| 148 |
echo '</div></div>';
|
| 149 |
}
|
| 150 |
|
| 151 |
+
$capsman = ak_get_object('capsman');
|
| 152 |
+
$capsman->reinstate_db_roles();
|
| 153 |
+
|
| 154 |
$current = get_role($default);
|
| 155 |
$rcaps = $current->capabilities;
|
| 156 |
|
| 172 |
|
| 173 |
$cap_properties['edit']['taxonomy'] = array( 'manage_terms' );
|
| 174 |
|
| 175 |
+
if ( ! defined( 'PP_ACTIVE' ) )
|
| 176 |
$cap_properties['edit']['taxonomy'] = array_merge( $cap_properties['edit']['taxonomy'], array( 'edit_terms', 'assign_terms' ) );
|
| 177 |
|
| 178 |
$cap_properties['delete']['type'] = array( 'delete_posts', 'delete_others_posts' );
|
| 179 |
$cap_properties['delete']['type'] = array_merge( $cap_properties['delete']['type'], array( 'delete_published_posts', 'delete_private_posts' ) );
|
| 180 |
|
| 181 |
+
if ( ! defined( 'PP_ACTIVE' ) )
|
| 182 |
$cap_properties['delete']['taxonomy'] = array( 'delete_terms' );
|
| 183 |
else
|
| 184 |
$cap_properties['delete']['taxonomy'] = array();
|
| 224 |
$defined['taxonomy'] = get_taxonomies( array( 'public' => true ), 'object' );
|
| 225 |
|
| 226 |
// Press Permit grants attachment capabilities based on user's capabilities for the parent post
|
| 227 |
+
if ( defined( 'PP_ACTIVE' ) || defined('SCOPER_VERSION') )
|
| 228 |
unset( $defined['type']['attachment'] );
|
| 229 |
|
| 230 |
echo '<ul class="cme-listhoriz">';
|
| 461 |
</table>
|
| 462 |
|
| 463 |
<br />
|
| 464 |
+
<?php if ( ! defined('PP_ACTIVE') || pp_get_option('display_hints') ) :?>
|
| 465 |
<div class="cme-subtext">
|
| 466 |
<?php _e( 'Note: Underscores replace spaces in stored capability name ("edit users" => "edit_users").', 'pp' ); ?>
|
| 467 |
</div>
|
| 472 |
</dl>
|
| 473 |
|
| 474 |
<?php
|
| 475 |
+
$support_pp_only_roles = defined('PP_ACTIVE') && ( defined('PPC_VERSION') || version_compare( PP_VERSION, '1.0-beta1.4', '>=') );
|
| 476 |
?>
|
| 477 |
|
| 478 |
<?php if ( $support_pp_only_roles && ! in_array( $default, array( 'subscriber', 'contributor', 'author', 'editor', 'administrator' ) ) ) : ?>
|
| 555 |
</dd>
|
| 556 |
</dl>
|
| 557 |
|
| 558 |
+
<?php if ( defined('PP_ACTIVE') && current_user_can( 'pp_manage_settings' ) ) :?>
|
| 559 |
<dl>
|
| 560 |
<dt><?php _e('Force Type-Specific Capabilities', $this->ID); ?></dt>
|
| 561 |
<dd style="text-align:center;">
|
includes/manager.php
CHANGED
|
@@ -31,7 +31,7 @@ include_once ( AK_CLASSES . '/abstract/plugin.php' );
|
|
| 31 |
add_action( 'init', 'cme_update_pp_usage' ); // update early so resulting post type cap changes are applied for this request's UI construction
|
| 32 |
|
| 33 |
function cme_update_pp_usage() {
|
| 34 |
-
if ( defined( '
|
| 35 |
static $updated;
|
| 36 |
if ( ! empty($updated) ) { return true; }
|
| 37 |
|
|
@@ -121,6 +121,8 @@ class CapabilityManager extends akPluginAbstract
|
|
| 121 |
*/
|
| 122 |
private $max_level;
|
| 123 |
|
|
|
|
|
|
|
| 124 |
/**
|
| 125 |
* Creates some filters at module load time.
|
| 126 |
*
|
|
@@ -135,8 +137,37 @@ class CapabilityManager extends akPluginAbstract
|
|
| 135 |
|
| 136 |
// Users with roles that cannot be managed, are not allowed to be edited.
|
| 137 |
add_filter('map_meta_cap', array(&$this, 'filterUserEdit'), 10, 4);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 140 |
/**
|
| 141 |
* Sets default settings values.
|
| 142 |
*
|
|
@@ -192,7 +223,7 @@ class CapabilityManager extends akPluginAbstract
|
|
| 192 |
$this->setAdminCapability();
|
| 193 |
}
|
| 194 |
|
| 195 |
-
if ( defined( '
|
| 196 |
add_action( 'pp_permissions_menu', array( &$this, 'pp_menu' ) );
|
| 197 |
} else {
|
| 198 |
add_users_page( __('Capability Manager', $this->ID), __('Capabilities', $this->ID), 'manage_capabilities', $this->ID, array($this, 'generalManager'));
|
|
@@ -356,13 +387,6 @@ class CapabilityManager extends akPluginAbstract
|
|
| 356 |
}
|
| 357 |
|
| 358 |
$this->current = $post['current'];
|
| 359 |
-
|
| 360 |
-
if ( defined( 'PP_VERSION' ) ) { // log customized role caps for subsequent restoration
|
| 361 |
-
$plugins = get_option('active_plugins');
|
| 362 |
-
$customized_roles = (array) pp_get_option( 'customized_roles' );
|
| 363 |
-
$customized_roles[$post['role']] = (object) array( 'caps' => $post['caps'], 'plugins' => $plugins );
|
| 364 |
-
pp_update_option( 'customized_roles', $customized_roles );
|
| 365 |
-
}
|
| 366 |
|
| 367 |
// Select a new role.
|
| 368 |
if ( ! empty($post['LoadRole']) ) {
|
|
@@ -397,6 +421,28 @@ class CapabilityManager extends akPluginAbstract
|
|
| 397 |
} elseif ( ! empty($post['SaveRole']) ) {
|
| 398 |
$this->saveRoleCapabilities($post['current'], $post['caps'], $post['level']);
|
| 399 |
ak_admin_notify(__('New capabilities saved.', $this->ID));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 400 |
|
| 401 |
// Create New Capability and adds it to current role.
|
| 402 |
} elseif ( ! empty($post['AddCap']) ) {
|
|
@@ -420,7 +466,7 @@ class CapabilityManager extends akPluginAbstract
|
|
| 420 |
ak_admin_error(__('Bad form received.', $this->ID));
|
| 421 |
}
|
| 422 |
|
| 423 |
-
if ( ! empty($newrole) && ! empty( $_REQUEST['new_role_pp_only'] ) && defined('
|
| 424 |
$pp_only = (array) pp_get_option( 'supplemental_role_defs' );
|
| 425 |
$pp_only[]= $newrole;
|
| 426 |
pp_update_option( 'supplemental_role_defs', $pp_only );
|
|
@@ -495,6 +541,13 @@ class CapabilityManager extends akPluginAbstract
|
|
| 495 |
remove_role($this->current);
|
| 496 |
unset($this->roles[$this->current]);
|
| 497 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 498 |
ak_admin_notify(sprintf(__('Role has been deleted. %1$d users moved to default role %2$s.', $this->ID), $count, $this->roles[$default]));
|
| 499 |
$this->current = $default;
|
| 500 |
}
|
|
@@ -672,6 +725,9 @@ class CapabilityManager extends akPluginAbstract
|
|
| 672 |
* @return string|false Returns the name of the new role created or false if failed.
|
| 673 |
*/
|
| 674 |
private function createRole( $name, $caps = array() ) {
|
|
|
|
|
|
|
|
|
|
| 675 |
$role = $this->createNewName($name);
|
| 676 |
if ( ! is_array($role) ) {
|
| 677 |
return false;
|
|
@@ -695,8 +751,13 @@ class CapabilityManager extends akPluginAbstract
|
|
| 695 |
private function saveRoleCapabilities( $role_name, $caps, $level ) {
|
| 696 |
$this->generateNames();
|
| 697 |
$role = get_role($role_name);
|
| 698 |
-
|
| 699 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 700 |
$new_caps = ( is_array($caps) ) ? array_map('intval', $caps) : array();
|
| 701 |
$new_caps = array_merge($new_caps, ak_level2caps($level));
|
| 702 |
|
| 31 |
add_action( 'init', 'cme_update_pp_usage' ); // update early so resulting post type cap changes are applied for this request's UI construction
|
| 32 |
|
| 33 |
function cme_update_pp_usage() {
|
| 34 |
+
if ( defined( 'PP_ACTIVE' ) && current_user_can( 'pp_manage_settings' ) ) {
|
| 35 |
static $updated;
|
| 36 |
if ( ! empty($updated) ) { return true; }
|
| 37 |
|
| 121 |
*/
|
| 122 |
private $max_level;
|
| 123 |
|
| 124 |
+
private $log_db_role_objects = array();
|
| 125 |
+
|
| 126 |
/**
|
| 127 |
* Creates some filters at module load time.
|
| 128 |
*
|
| 137 |
|
| 138 |
// Users with roles that cannot be managed, are not allowed to be edited.
|
| 139 |
add_filter('map_meta_cap', array(&$this, 'filterUserEdit'), 10, 4);
|
| 140 |
+
|
| 141 |
+
// ensure storage, retrieval of db-stored customizations to bbPress dynamic roles
|
| 142 |
+
global $wpdb;
|
| 143 |
+
$role_key = $wpdb->prefix . 'user_roles';
|
| 144 |
+
add_filter( 'option_' . $role_key, array( &$this, 'log_db_roles' ), 0 );
|
| 145 |
+
add_filter( 'option_' . $role_key, array( &$this, 'reinstate_db_roles' ), 50 );
|
| 146 |
}
|
| 147 |
+
|
| 148 |
+
function log_db_roles( $passthru_roles ) {
|
| 149 |
+
global $wp_roles;
|
| 150 |
+
|
| 151 |
+
$this->log_db_role_objects = $wp_roles->role_objects;
|
| 152 |
+
|
| 153 |
+
return $passthru_roles;
|
| 154 |
+
}
|
| 155 |
+
|
| 156 |
+
// note: this is only applied when accessing the cme role edit form
|
| 157 |
+
function reinstate_db_roles( $passthru_roles = array() ) {
|
| 158 |
+
global $wp_roles;
|
| 159 |
|
| 160 |
+
if ( $this->log_db_role_objects ) {
|
| 161 |
+
$intersect = array_intersect_key( $wp_roles->role_objects, $this->log_db_role_objects );
|
| 162 |
+
foreach( array_keys( $intersect ) as $key ) {
|
| 163 |
+
if ( ! empty( $this->log_db_role_objects[$key]->capabilities ) )
|
| 164 |
+
$wp_roles->role_objects[$key]->capabilities = $this->log_db_role_objects[$key]->capabilities;
|
| 165 |
+
}
|
| 166 |
+
}
|
| 167 |
+
|
| 168 |
+
return $passthru_roles;
|
| 169 |
+
}
|
| 170 |
+
|
| 171 |
/**
|
| 172 |
* Sets default settings values.
|
| 173 |
*
|
| 223 |
$this->setAdminCapability();
|
| 224 |
}
|
| 225 |
|
| 226 |
+
if ( defined( 'PP_ACTIVE' ) ) { // Press Permit integrates into Permissions menu
|
| 227 |
add_action( 'pp_permissions_menu', array( &$this, 'pp_menu' ) );
|
| 228 |
} else {
|
| 229 |
add_users_page( __('Capability Manager', $this->ID), __('Capabilities', $this->ID), 'manage_capabilities', $this->ID, array($this, 'generalManager'));
|
| 387 |
}
|
| 388 |
|
| 389 |
$this->current = $post['current'];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 390 |
|
| 391 |
// Select a new role.
|
| 392 |
if ( ! empty($post['LoadRole']) ) {
|
| 421 |
} elseif ( ! empty($post['SaveRole']) ) {
|
| 422 |
$this->saveRoleCapabilities($post['current'], $post['caps'], $post['level']);
|
| 423 |
ak_admin_notify(__('New capabilities saved.', $this->ID));
|
| 424 |
+
|
| 425 |
+
if ( defined( 'PP_ACTIVE' ) ) { // log customized role caps for subsequent restoration
|
| 426 |
+
if ( function_exists( 'bbp_get_version' ) && version_compare( bbp_get_version(), '2.2', '<' ) ) {
|
| 427 |
+
// for bbPress < 2.2, need to log customization of roles following bbPress activation
|
| 428 |
+
$plugins = get_option('active_plugins');
|
| 429 |
+
foreach( $plugins as $key => $plugin ) {
|
| 430 |
+
if ( false === strpos($plugin, 'bbpress.php' ) )
|
| 431 |
+
unset( $plugins[$key] ); // reduce storage size
|
| 432 |
+
}
|
| 433 |
+
} else {
|
| 434 |
+
$plugins = array(); // back compat
|
| 435 |
+
}
|
| 436 |
+
|
| 437 |
+
if ( ! $customized_roles = get_option( 'pp_customized_roles' ) )
|
| 438 |
+
$customized_roles = array();
|
| 439 |
+
|
| 440 |
+
$customized_roles[$post['role']] = (object) array( 'caps' => $post['caps'], 'plugins' => $plugins );
|
| 441 |
+
update_option( 'pp_customized_roles', $customized_roles );
|
| 442 |
+
|
| 443 |
+
global $wpdb;
|
| 444 |
+
$wpdb->query( "UPDATE $wpdb->options SET autoload = 'no' WHERE option_name = 'pp_customized_roles'" );
|
| 445 |
+
}
|
| 446 |
|
| 447 |
// Create New Capability and adds it to current role.
|
| 448 |
} elseif ( ! empty($post['AddCap']) ) {
|
| 466 |
ak_admin_error(__('Bad form received.', $this->ID));
|
| 467 |
}
|
| 468 |
|
| 469 |
+
if ( ! empty($newrole) && ! empty( $_REQUEST['new_role_pp_only'] ) && defined('PP_ACTIVE') ) {
|
| 470 |
$pp_only = (array) pp_get_option( 'supplemental_role_defs' );
|
| 471 |
$pp_only[]= $newrole;
|
| 472 |
pp_update_option( 'supplemental_role_defs', $pp_only );
|
| 541 |
remove_role($this->current);
|
| 542 |
unset($this->roles[$this->current]);
|
| 543 |
|
| 544 |
+
if ( $customized_roles = get_option( 'pp_customized_roles' ) ) {
|
| 545 |
+
if ( isset( $customized_roles[$this->current] ) ) {
|
| 546 |
+
unset( $customized_roles[$this->current] );
|
| 547 |
+
update_option( 'pp_customized_roles', $customized_roles );
|
| 548 |
+
}
|
| 549 |
+
}
|
| 550 |
+
|
| 551 |
ak_admin_notify(sprintf(__('Role has been deleted. %1$d users moved to default role %2$s.', $this->ID), $count, $this->roles[$default]));
|
| 552 |
$this->current = $default;
|
| 553 |
}
|
| 725 |
* @return string|false Returns the name of the new role created or false if failed.
|
| 726 |
*/
|
| 727 |
private function createRole( $name, $caps = array() ) {
|
| 728 |
+
if ( ! is_array($caps) )
|
| 729 |
+
$caps = array();
|
| 730 |
+
|
| 731 |
$role = $this->createNewName($name);
|
| 732 |
if ( ! is_array($role) ) {
|
| 733 |
return false;
|
| 751 |
private function saveRoleCapabilities( $role_name, $caps, $level ) {
|
| 752 |
$this->generateNames();
|
| 753 |
$role = get_role($role_name);
|
| 754 |
+
|
| 755 |
+
// workaround to ensure db storage of customizations to bbp dynamic roles
|
| 756 |
+
$role->name = $role_name;
|
| 757 |
+
|
| 758 |
+
$stored_role_caps = ( ! empty($role->capabilities) && is_array($role->capabilities) ) ? array_intersect( $role->capabilities, array(true, 1) ) : array();
|
| 759 |
+
|
| 760 |
+
$old_caps = array_intersect_key( $stored_role_caps, $this->capabilities);
|
| 761 |
$new_caps = ( is_array($caps) ) ? array_map('intval', $caps) : array();
|
| 762 |
$new_caps = array_merge($new_caps, ak_level2caps($level));
|
| 763 |
|
readme.txt
CHANGED
|
@@ -3,8 +3,8 @@ Contributors: txanny, kevinB
|
|
| 3 |
Help link: http://wordpress.org/tags/capsman-enhanced
|
| 4 |
Tags: roles, capabilities, manager, editor, rights, role, capability, types, taxonomies
|
| 5 |
Requires at least: 3.1
|
| 6 |
-
Tested up to: 3.4.
|
| 7 |
-
Stable tag:
|
| 8 |
|
| 9 |
A simple way to manage WordPress roles and capabilities. With this plugin you will be able to easily create and manage roles and capabilities.
|
| 10 |
|
|
@@ -79,6 +79,13 @@ Capability Manager Enhanced also adds <a href="http://presspermit.com">Press Per
|
|
| 79 |
|
| 80 |
== Frequently Asked Questions ==
|
| 81 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 82 |
= Where can I find more information about this plugin, usage and support ? =
|
| 83 |
|
| 84 |
* If you need help, <a href="http://wordpress.org/tags/capsman-enhanced">ask in the Support forum</a>.
|
|
@@ -96,6 +103,11 @@ You should have received a copy of the GNU General Public License along with thi
|
|
| 96 |
|
| 97 |
== Changelog ==
|
| 98 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 99 |
= 1.4.5 =
|
| 100 |
* Fixed : Capabilities were needlessly re-saved on role load
|
| 101 |
* Fixed : Capability labels in "Other WordPress" section did not toggle checkbox selection
|
| 3 |
Help link: http://wordpress.org/tags/capsman-enhanced
|
| 4 |
Tags: roles, capabilities, manager, editor, rights, role, capability, types, taxonomies
|
| 5 |
Requires at least: 3.1
|
| 6 |
+
Tested up to: 3.4.2
|
| 7 |
+
Stable tag: 1.4.6
|
| 8 |
|
| 9 |
A simple way to manage WordPress roles and capabilities. With this plugin you will be able to easily create and manage roles and capabilities.
|
| 10 |
|
| 79 |
|
| 80 |
== Frequently Asked Questions ==
|
| 81 |
|
| 82 |
+
= How can I grant capabilities for a custom post type =
|
| 83 |
+
The custom post type must be defined to impose type-specific capability requirements. This is normally done by setting the "capability type" property equal to the post type name.
|
| 84 |
+
|
| 85 |
+
= I have configured a role to edit a custom post type. Why do the users still see "You are not allowed the edit this post?" when they try to save/submit a new post? =
|
| 86 |
+
|
| 87 |
+
Probably because your custom post type definition not having map_meta_cap set true. If you are calling register_post_type manually, just add this property to the options array. Unfortunately, none of the free CPT plugins deal with this important detail.
|
| 88 |
+
|
| 89 |
= Where can I find more information about this plugin, usage and support ? =
|
| 90 |
|
| 91 |
* If you need help, <a href="http://wordpress.org/tags/capsman-enhanced">ask in the Support forum</a>.
|
| 103 |
|
| 104 |
== Changelog ==
|
| 105 |
|
| 106 |
+
= 1.4.6 =
|
| 107 |
+
* Compat : bbPress 2.2 (supports customization of dynamic forum role capabilities)
|
| 108 |
+
* Compat : Press Permit + bbPress - customized role capabilities were not properly maintained on bbPress activation / deactivation, in some scenarios
|
| 109 |
+
* Fixed : Role update and copy failed if currently stored capability array is corrupted
|
| 110 |
+
|
| 111 |
= 1.4.5 =
|
| 112 |
* Fixed : Capabilities were needlessly re-saved on role load
|
| 113 |
* Fixed : Capability labels in "Other WordPress" section did not toggle checkbox selection
|
