diff --git a/capsman-enhanced.php b/capsman-enhanced.php index 76bc572f..e20e42a0 100644 --- a/capsman-enhanced.php +++ b/capsman-enhanced.php @@ -142,7 +142,7 @@ function cme_submenus() { $cap_name = ( is_super_admin() ) ? 'manage_capabilities' : 'restore_roles'; add_management_page(__('Capability Manager', 'capsman-enhanced'), __('Capability Manager', 'capsman-enhanced'), $cap_name, 'capsman' . '-tool', 'cme_fakefunc'); - if ( did_action( 'pp_admin_menu' ) ) { // Put Capabilities link on Permissions menu if Press Permit is active and user has access to it + if (did_action('pp_admin_menu')) { // Put Capabilities link on Permissions menu if Press Permit is active and user has access to it global $pp_admin; $menu_caption = ( defined('WPLANG') && WPLANG && ( 'en_EN' != WPLANG ) ) ? __('Capabilities', 'capsman-enhanced') : 'Role Capabilities'; add_submenu_page( $pp_admin->get_menu('options'), __('Capability Manager', 'capsman-enhanced'), $menu_caption, 'manage_capabilities', 'capsman', 'cme_fakefunc' ); diff --git a/includes/admin.php b/includes/admin.php index d4cb8334..2ecd0f39 100644 --- a/includes/admin.php +++ b/includes/admin.php @@ -267,7 +267,7 @@ ); $type_caps = array(); $type_metacaps = array(); - + // Role Scoper and PP1 adjust attachment access based only on user's capabilities for the parent post if ( defined('OLD_PRESSPERMIT_ACTIVE') ) { unset( $defined['type']['attachment'] ); @@ -299,131 +299,131 @@ if ( ! $any_term_deletion_caps ) continue; } - - if ( ! count( $cap_properties[$cap_type][$item_type] ) ) - continue; - - echo '
'; + echo ' | |||
---|---|---|---|
'; + + // label cap properties + foreach( $cap_properties[$cap_type][$item_type] as $prop ) { + $prop = str_replace( '_posts', '', $prop ); + $prop = str_replace( '_pages', '', $prop ); + $prop = str_replace( '_terms', '', $prop ); + $tip = ( isset( $cap_tips[$prop] ) ) ? "title='{$cap_tips[$prop]}'" : ''; + $prop = str_replace( '_', ' | ";
- // label cap properties
- foreach( $cap_properties[$cap_type][$item_type] as $prop ) {
- $prop = str_replace( '_posts', '', $prop );
- $prop = str_replace( '_pages', '', $prop );
- $prop = str_replace( '_terms', '', $prop );
- $tip = ( isset( $cap_tips[$prop] ) ) ? "title='{$cap_tips[$prop]}'" : '';
- $prop = str_replace( '_', ' ', $prop ); - $th_class = ( 'taxonomy' == $item_type ) ? ' class="term-cap"' : ' class="post-cap"'; - echo " | "; - - if ( ( 'delete' != $prop ) || ( 'taxonomy' != $item_type ) || cme_get_detailed_taxonomies() ) { - echo ucwords($prop); - } - - echo ' | '; + if ( ( 'delete' != $prop ) || ( 'taxonomy' != $item_type ) || cme_get_detailed_taxonomies() ) { + echo ucwords($prop); } + + echo ''; + } - echo '|
" . $type_obj->labels->name . ''; + $row .= ' x '; + $row .= ' | '; - $row .= "" . $type_obj->labels->name . ''; - $row .= ' x '; - $row .= ' | '; - - $display_row = ! empty($force_distinct_ui); + $display_row = ! empty($force_distinct_ui); - foreach( $cap_properties[$cap_type][$item_type] as $prop ) { - $td_classes = array(); - $checkbox = ''; - $title = ''; + foreach( $cap_properties[$cap_type][$item_type] as $prop ) { + $td_classes = array(); + $checkbox = ''; + $title = ''; + + if ( ! empty($type_obj->cap->$prop) && ( in_array( $type_obj->name, array( 'post', 'page' ) ) + || ! in_array( $type_obj->cap->$prop, $default_caps ) + || ( ( 'manage_categories' == $type_obj->cap->$prop ) && ( 'manage_terms' == $prop ) && ( 'category' == $type_obj->name ) ) ) ) { + + // if edit_published or edit_private cap is same as edit_posts cap, don't display a checkbox for it + if ( ( ! in_array( $prop, array( 'edit_published_posts', 'edit_private_posts', 'create_posts' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->edit_posts ) ) + && ( ! in_array( $prop, array( 'delete_published_posts', 'delete_private_posts' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->delete_posts ) ) + && ( ! in_array( $prop, array( 'edit_terms', 'delete_terms' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->manage_terms ) ) - if ( ! empty($type_obj->cap->$prop) && ( in_array( $type_obj->name, array( 'post', 'page' ) ) - || ! in_array( $type_obj->cap->$prop, $default_caps ) - || ( ( 'manage_categories' == $type_obj->cap->$prop ) && ( 'manage_terms' == $prop ) && ( 'category' == $type_obj->name ) ) ) ) { - - // if edit_published or edit_private cap is same as edit_posts cap, don't display a checkbox for it - if ( ( ! in_array( $prop, array( 'edit_published_posts', 'edit_private_posts', 'create_posts' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->edit_posts ) ) - && ( ! in_array( $prop, array( 'delete_published_posts', 'delete_private_posts' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->delete_posts ) ) - && ( ! in_array( $prop, array( 'edit_terms', 'delete_terms' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->manage_terms ) ) + && ( ! in_array( $prop, array( 'manage_terms', 'edit_terms', 'delete_terms', 'assign_terms' ) ) + || empty($cme_cap_helper->all_taxonomy_caps[$type_obj->cap->$prop]) + || ( $cme_cap_helper->all_taxonomy_caps[ $type_obj->cap->$prop ] <= 1 ) + || $type_obj->cap->$prop == str_replace( '_terms', "_{$type_obj->name}s", $prop ) + || $type_obj->cap->$prop == str_replace( '_terms', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop ) + ) + + && ( in_array( $prop, array( 'manage_terms', 'edit_terms', 'delete_terms', 'assign_terms' ) ) + || empty($cme_cap_helper->all_type_caps[$type_obj->cap->$prop]) + || ( $cme_cap_helper->all_type_caps[ $type_obj->cap->$prop ] <= 1 ) + || $type_obj->cap->$prop == 'upload_files' && 'create_posts' == $prop && 'attachment' == $type_obj->name + || $type_obj->cap->$prop == str_replace( '_posts', "_{$type_obj->name}s", $prop ) + || $type_obj->cap->$prop == str_replace( '_pages', "_{$type_obj->name}s", $prop ) + || $type_obj->cap->$prop == str_replace( '_posts', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop ) + || $type_obj->cap->$prop == str_replace( '_pages', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop ) + ) + ) { + // only present these term caps up top if we are ensuring that they get enforced separately from manage_terms + if ( in_array( $prop, array( 'edit_terms', 'delete_terms', 'assign_terms' ) ) && ( ! in_array( $type_obj->name, cme_get_detailed_taxonomies() ) || defined( 'OLD_PRESSPERMIT_ACTIVE' ) ) ) { + continue; + } - && ( ! in_array( $prop, array( 'manage_terms', 'edit_terms', 'delete_terms', 'assign_terms' ) ) - || empty($cme_cap_helper->all_taxonomy_caps[$type_obj->cap->$prop]) - || ( $cme_cap_helper->all_taxonomy_caps[ $type_obj->cap->$prop ] <= 1 ) - || $type_obj->cap->$prop == str_replace( '_terms', "_{$type_obj->name}s", $prop ) - || $type_obj->cap->$prop == str_replace( '_terms', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop ) - ) + $cap_name = $type_obj->cap->$prop; - && ( in_array( $prop, array( 'manage_terms', 'edit_terms', 'delete_terms', 'assign_terms' ) ) - || empty($cme_cap_helper->all_type_caps[$type_obj->cap->$prop]) - || ( $cme_cap_helper->all_type_caps[ $type_obj->cap->$prop ] <= 1 ) - || $type_obj->cap->$prop == 'upload_files' && 'create_posts' == $prop && 'attachment' == $type_obj->name - || $type_obj->cap->$prop == str_replace( '_posts', "_{$type_obj->name}s", $prop ) - || $type_obj->cap->$prop == str_replace( '_pages', "_{$type_obj->name}s", $prop ) - || $type_obj->cap->$prop == str_replace( '_posts', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop ) - || $type_obj->cap->$prop == str_replace( '_pages', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop ) - ) - ) { - // only present these term caps up top if we are ensuring that they get enforced separately from manage_terms - if ( in_array( $prop, array( 'edit_terms', 'delete_terms', 'assign_terms' ) ) && ( ! in_array( $type_obj->name, cme_get_detailed_taxonomies() ) || defined( 'OLD_PRESSPERMIT_ACTIVE' ) ) ) { - continue; + if ( 'taxonomy' == $item_type ) + $td_classes []= "term-cap"; + else + $td_classes []= "post-cap"; + + if ( ! empty($pp_metagroup_caps[$cap_name]) ) + $td_classes []='cm-has-via-pp'; + + if ( $is_administrator || current_user_can($cap_name) ) { + if ( ! empty($pp_metagroup_caps[$cap_name]) ) { + $title_text = sprintf( __( '%s: assigned by Permission Group', 'capsman-enhanced' ), $cap_name ); + } else { + $title_text = $cap_name; } - $cap_name = $type_obj->cap->$prop; + $disabled = ''; + $checked = checked(1, ! empty($rcaps[$cap_name]), false ); - if ( 'taxonomy' == $item_type ) - $td_classes []= "term-cap"; - else - $td_classes []= "post-cap"; + $checkbox = ''; - if ( ! empty($pp_metagroup_caps[$cap_name]) ) - $td_classes []='cm-has-via-pp'; - - if ( $is_administrator || current_user_can($cap_name) ) { - if ( ! empty($pp_metagroup_caps[$cap_name]) ) { - $title_text = sprintf( __( '%s: assigned by Permission Group', 'capsman-enhanced' ), $cap_name ); - } else { - $title_text = $cap_name; - } - - $disabled = ''; - $checked = checked(1, ! empty($rcaps[$cap_name]), false ); - - $checkbox = ''; - - $type_caps [$cap_name] = true; - $display_row = true; - } - } else { - //$td_classes []= "cap-unreg"; - $title = 'title="' . sprintf( __( 'shared capability: %s', 'capsman-enhanced' ), esc_attr( $type_obj->cap->$prop ) ) . '"'; - } - - if ( isset($rcaps[$cap_name]) && empty($rcaps[$cap_name]) ) { - $td_classes []= "cap-neg"; - } + $type_caps [$cap_name] = true; + $display_row = true; + } } else { - $td_classes []= "cap-unreg"; + //$td_classes []= "cap-unreg"; + $title = 'title="' . sprintf( __( 'shared capability: %s', 'capsman-enhanced' ), esc_attr( $type_obj->cap->$prop ) ) . '"'; } - $td_class = ( $td_classes ) ? 'class="' . implode(' ', $td_classes) . '"' : ''; - - $row .= "X$checkbox"; - - if ( false !== strpos( $td_class, 'cap-neg' ) ) - $row .= ''; - - $row .= " | "; + if ( isset($rcaps[$cap_name]) && empty($rcaps[$cap_name]) ) { + $td_classes []= "cap-neg"; + } + } else { + $td_classes []= "cap-unreg"; } + + $td_class = ( $td_classes ) ? 'class="' . implode(' ', $td_classes) . '"' : ''; + + $row .= "X$checkbox"; + + if ( false !== strpos( $td_class, 'cap-neg' ) ) + $row .= ''; + + $row .= " | "; + } if ('type' == $item_type) { $type_metacaps[$type_obj->cap->read_post] = true; @@ -433,15 +433,15 @@ $type_metacaps[$type_obj->cap->edit_term] = true; $type_metacaps[$type_obj->cap->delete_term] = true; } - } + } - if ( $display_row ) { - $row .= '