admin.php
7 years ago
backup-handler.php
7 years ago
backup.php
7 years ago
filters-woocommerce.php
7 years ago
filters.php
7 years ago
handler.php
7 years ago
manager.php
7 years ago
network.php
7 years ago
pp-handler.php
11 years ago
pp-ui.php
7 years ago
admin.php
751 lines
| 1 | <?php |
| 2 | /** |
| 3 | * General Admin for Capability Manager. |
| 4 | * Provides admin pages to create and manage roles and capabilities. |
| 5 | * |
| 6 | * @author Jordi Canals, Kevin Behrens |
| 7 | * @copyright Copyright (C) 2009, 2010 Jordi Canals, (C) 2019 PublishPress |
| 8 | * @license GNU General Public License version 2 |
| 9 | * @link https://publishpress.com |
| 10 | * |
| 11 | |
| 12 | Copyright 2009, 2010 Jordi Canals <devel@jcanals.cat> |
| 13 | Modifications Copyright 2019, PublishPress <help@publishpress.com> |
| 14 | |
| 15 | This program is free software; you can redistribute it and/or |
| 16 | modify it under the terms of the GNU General Public License |
| 17 | version 2 as published by the Free Software Foundation. |
| 18 | |
| 19 | This program is distributed in the hope that it will be useful, |
| 20 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | GNU General Public License for more details. |
| 23 | |
| 24 | You should have received a copy of the GNU General Public License |
| 25 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 26 | */ |
| 27 | |
| 28 | $roles = $this->roles; |
| 29 | $default = $this->current; |
| 30 | |
| 31 | if( defined('PP_ACTIVE') ) { |
| 32 | require_once( dirname(__FILE__).'/pp-ui.php' ); |
| 33 | $pp_ui = new Capsman_PP_UI(); |
| 34 | $pp_metagroup_caps = $pp_ui->get_metagroup_caps( $default ); |
| 35 | } else |
| 36 | $pp_metagroup_caps = array(); |
| 37 | ?> |
| 38 | <div class="wrap"> |
| 39 | <?php if( defined('PP_ACTIVE') ) : |
| 40 | pp_icon(); |
| 41 | $style = 'style="height:60px;"'; |
| 42 | ?> |
| 43 | <?php else: |
| 44 | $style = ''; |
| 45 | ?> |
| 46 | <div id="icon-capsman-admin" class="icon32"></div> |
| 47 | <?php endif; ?> |
| 48 | |
| 49 | <h1 <?php echo $style;?>><?php _e('Roles and Capabilities', 'capsman-enhanced') ?></h1> |
| 50 | |
| 51 | <form method="post" action="admin.php?page=<?php echo $this->ID ?>"> |
| 52 | <?php wp_nonce_field('capsman-general-manager'); ?> |
| 53 | <fieldset> |
| 54 | <table id="akmin"> |
| 55 | <tr> |
| 56 | <td class="content"> |
| 57 | <dl> |
| 58 | <dt><?php printf(__('Capabilities for %s', 'capsman-enhanced'), $roles[$default]); ?></dt> |
| 59 | <dd> |
| 60 | <div> |
| 61 | <?php _e( 'View and modify capabilities WordPress associates with each role. Changes <strong>remain in the database</strong> even if you deactivate this plugin.', 'capsman-enhanced' ); ?> |
| 62 | </div> |
| 63 | |
| 64 | <?php |
| 65 | if ( defined( 'PP_ACTIVE' ) ) { |
| 66 | $pp_ui->show_capability_hints( $default ); |
| 67 | } else { |
| 68 | global $capsman; |
| 69 | $img_url = $capsman->mod_url . '/images/'; |
| 70 | ?> |
| 71 | <div style="margin-top:5px"> |
| 72 | <span class="publishpress"><?php printf( __( 'Thanks for using the %1$sPublishPress%2$s family of professional publishing tools.', 'capsman-enhanced'), '<a href="https://publishpress.com/" target="_blank">', '</a>' );?></span> |
| 73 | </div> |
| 74 | |
| 75 | <script type="text/javascript"> |
| 76 | /* <![CDATA[ */ |
| 77 | jQuery(document).ready( function($) { |
| 78 | $('a[href=#pp-more]').click( function() { |
| 79 | $('#pp_features').show(); |
| 80 | return false; |
| 81 | }); |
| 82 | $('a[href=#pp-hide]').click( function() { |
| 83 | $('#pp_features').hide(); |
| 84 | return false; |
| 85 | }); |
| 86 | }); |
| 87 | /* ]]> */ |
| 88 | </script> |
| 89 | <style> |
| 90 | #pp_features {display:none;border:1px solid #eee;padding:5px;text-align:center;min-width:600px} |
| 91 | div.pp-logo { text-align: center } |
| 92 | div.features-wrap { margin-left: auto; margin-right: auto; text-align: center; width: 540px; } |
| 93 | ul.pp-features { list-style: none; padding-top:10px; text-align:left; margin-left: auto } |
| 94 | ul.pp-features li:before { content: "\2713\0020"; } |
| 95 | ul.pp-features li { padding-bottom: 5px } |
| 96 | img.cme-play { margin-bottom: -3px; margin-left: 5px;} |
| 97 | </style> |
| 98 | |
| 99 | <?php /* play.png icon by Pavel: http://kde-look.org/usermanager/search.php?username=InFeRnODeMoN */ ?> |
| 100 | |
| 101 | <br /><div id="pp_features"><div class="pp-logo"><a href="http://presspermit.com"><img src="<?php echo $img_url;?>pp-logo.png" /></a></div><div class="features-wrap"><ul class="pp-features"> |
| 102 | <li> |
| 103 | <?php _e( "Automatically define type-specific capabilities for your custom post types and taxonomies", 'capsman-enhanced' );?> |
| 104 | <a href="http://presspermit.com/tutorial/regulate-post-type-access" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li> |
| 105 | |
| 106 | <li> |
| 107 | <?php _e( "Assign standard WP roles supplementally for a specific post type", 'capsman-enhanced' );?> |
| 108 | <a href="http://presspermit.com/tutorial/regulate-post-type-access" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li> |
| 109 | |
| 110 | <li> |
| 111 | <?php _e( "Assign custom WP roles supplementally for a specific post type <em>(Pro)</em>", 'capsman-enhanced' );?> |
| 112 | <a href="http://presspermit.com/tutorial/custom-role-usage" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li> |
| 113 | |
| 114 | <li> |
| 115 | <?php _e( "Customize reading permissions per-category or per-post", 'capsman-enhanced' );?> |
| 116 | <a href="http://presspermit.com/tutorial/category-exceptions" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li> |
| 117 | |
| 118 | <li> |
| 119 | <?php _e( "Customize editing permissions per-category or per-post <em>(Pro)</em>", 'capsman-enhanced' );?> |
| 120 | <a href="http://presspermit.com/tutorial/page-editing-exceptions" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li> |
| 121 | |
| 122 | <li> |
| 123 | <?php _e( "Custom Post Visibility statuses, fully implemented throughout wp-admin <em>(Pro)</em>", 'capsman-enhanced' );?> |
| 124 | <a href="http://presspermit.com/tutorial/custom-post-visibility" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li> |
| 125 | |
| 126 | <li> |
| 127 | <?php _e( "Custom Moderation statuses for access-controlled, multi-step publishing workflow <em>(Pro)</em>", 'capsman-enhanced' );?> |
| 128 | <a href="http://presspermit.com/tutorial/multi-step-moderation" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li> |
| 129 | |
| 130 | <li> |
| 131 | <?php _e( "Regulate permissions for Edit Flow post statuses <em>(Pro)</em>", 'capsman-enhanced' );?> |
| 132 | <a href="http://presspermit.com/tutorial/edit-flow-integration" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li> |
| 133 | |
| 134 | <li> |
| 135 | <?php _e( "Customize the moderated editing of published content with Revisionary or Post Forking <em>(Pro)</em>", 'capsman-enhanced' );?> |
| 136 | <a href="http://presspermit.com/tutorial/published-content-revision" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li> |
| 137 | |
| 138 | <li> |
| 139 | <?php _e( "Grant Spectator, Participant or Moderator access to specific bbPress forums <em>(Pro)</em>", 'capsman-enhanced' );?> |
| 140 | <a href="http://presspermit.com/tutorial/bbpress-exceptions" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li> |
| 141 | |
| 142 | <li> |
| 143 | <?php _e( "Grant supplemental content permissions to a BuddyPress group <em>(Pro)</em>", 'capsman-enhanced' );?> |
| 144 | <a href="http://presspermit.com/tutorial/buddypress-content-permissions" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li> |
| 145 | |
| 146 | <li> |
| 147 | <?php _e( "WPML integration to mirror permissions to translations <em>(Pro)</em>", 'capsman-enhanced' );?> |
| 148 | </li> |
| 149 | |
| 150 | <li> |
| 151 | <?php _e( "Member support forum", 'capsman-enhanced' );?> |
| 152 | </li> |
| 153 | |
| 154 | </ul></div> |
| 155 | <?php |
| 156 | echo '<div>'; |
| 157 | printf( __('%1$sgrab%2$s %3$s', 'capsman-enhanced'), '<strong>', '</strong>', '<span class="plugins update-message"><a href="' . cme_plugin_info_url('press-permit-core') . '" class="thickbox" title="' . sprintf( __('%s (free install)', 'capsman-enhanced'), 'Press Permit Core' ) . '">Press Permit Core</a></span>' ); |
| 158 | echo ' • '; |
| 159 | printf( __('%1$sbuy%2$s %3$s', 'capsman-enhanced'), '<strong>', '</strong>', '<a href="http://presspermit.com" target="_blank" title="' . sprintf( __('%s info/purchase', 'capsman-enhanced'), 'Press Permit Pro' ) . '">Press Permit Pro</a>' ); |
| 160 | echo ' • '; |
| 161 | echo '<a href="#pp-hide">hide</a>'; |
| 162 | echo '</div></div>'; |
| 163 | } |
| 164 | |
| 165 | if ( MULTISITE ) { |
| 166 | global $wp_roles; |
| 167 | global $wpdb; |
| 168 | |
| 169 | if ( ! empty($_REQUEST['cme_net_sync_role'] ) ) { |
| 170 | switch_to_blog(1); |
| 171 | wp_cache_delete( $wpdb->prefix . 'user_roles', 'options' ); |
| 172 | } |
| 173 | |
| 174 | ( method_exists( $wp_roles, 'for_site' ) ) ? $wp_roles->for_site() : $wp_roles->reinit(); |
| 175 | } |
| 176 | |
| 177 | global $capsman; |
| 178 | $capsman->reinstate_db_roles(); |
| 179 | |
| 180 | $current = get_role($default); |
| 181 | |
| 182 | //print_r($current); |
| 183 | |
| 184 | $rcaps = $current->capabilities; |
| 185 | |
| 186 | // ========= Begin Kevin B mod =========== |
| 187 | $is_administrator = current_user_can( 'administrator' ); |
| 188 | |
| 189 | $custom_types = get_post_types( array( '_builtin' => false ), 'names' ); |
| 190 | $custom_tax = get_taxonomies( array( '_builtin' => false ), 'names' ); |
| 191 | |
| 192 | $defined = array(); |
| 193 | $defined['type'] = get_post_types( array( 'public' => true ), 'object' ); |
| 194 | $defined['taxonomy'] = get_taxonomies( array( 'public' => true ), 'object' ); |
| 195 | |
| 196 | $unfiltered['type'] = apply_filters( 'pp_unfiltered_post_types', array('forum','topic','reply') ); // bbPress' dynamic role def requires additional code to enforce stored caps |
| 197 | $unfiltered['taxonomy'] = apply_filters( 'pp_unfiltered_taxonomies', array( 'post_status', 'topic-tag' ) ); // avoid confusion with Edit Flow administrative taxonomy |
| 198 | /* |
| 199 | if ( ( count($custom_types) || count($custom_tax) ) && ( $is_administrator || current_user_can( 'manage_pp_settings' ) ) ) { |
| 200 | $cap_properties[''] = array(); |
| 201 | $force_distinct_ui = true; |
| 202 | } |
| 203 | */ |
| 204 | |
| 205 | $cap_properties['edit']['type'] = array( 'edit_posts' ); |
| 206 | |
| 207 | foreach( $defined['type'] as $type_obj ) { |
| 208 | if ( 'attachment' != $type_obj->name ) { |
| 209 | if ( isset( $type_obj->cap->create_posts ) && ( $type_obj->cap->create_posts != $type_obj->cap->edit_posts ) ) { |
| 210 | $cap_properties['edit']['type'][]= 'create_posts'; |
| 211 | break; |
| 212 | } |
| 213 | } |
| 214 | } |
| 215 | |
| 216 | $cap_properties['edit']['type'][]= 'edit_others_posts'; |
| 217 | $cap_properties['edit']['type'] = array_merge( $cap_properties['edit']['type'], array( 'publish_posts', 'edit_published_posts', 'edit_private_posts' ) ); |
| 218 | |
| 219 | $cap_properties['edit']['taxonomy'] = array( 'manage_terms' ); |
| 220 | |
| 221 | if ( ! defined( 'PP_ACTIVE' ) ) |
| 222 | $cap_properties['edit']['taxonomy'] = array_merge( $cap_properties['edit']['taxonomy'], array( 'edit_terms', 'assign_terms' ) ); |
| 223 | |
| 224 | $cap_properties['delete']['type'] = array( 'delete_posts', 'delete_others_posts' ); |
| 225 | $cap_properties['delete']['type'] = array_merge( $cap_properties['delete']['type'], array( 'delete_published_posts', 'delete_private_posts' ) ); |
| 226 | |
| 227 | if ( ! defined( 'PP_ACTIVE' ) ) |
| 228 | $cap_properties['delete']['taxonomy'] = array( 'delete_terms' ); |
| 229 | else |
| 230 | $cap_properties['delete']['taxonomy'] = array(); |
| 231 | |
| 232 | $cap_properties['read']['type'] = array( 'read_private_posts' ); |
| 233 | $cap_properties['read']['taxonomy'] = array(); |
| 234 | |
| 235 | $stati = get_post_stati( array( 'internal' => false ) ); |
| 236 | |
| 237 | //if ( count($stati) > 5 ) { |
| 238 | $cap_type_names = array( |
| 239 | '' => __( ' ', 'capsman-enhanced' ), |
| 240 | 'read' => __( 'Reading', 'capsman-enhanced' ), |
| 241 | 'edit' => __( 'Editing Capabilities', 'capsman-enhanced' ), |
| 242 | 'delete' => __( 'Deletion Capabilities', 'capsman-enhanced' ) |
| 243 | ); |
| 244 | |
| 245 | //} else { |
| 246 | |
| 247 | //} |
| 248 | |
| 249 | $cap_tips = array( |
| 250 | 'read_private' => __( 'can read posts which are currently published with private visibility', 'capsman-enhanced' ), |
| 251 | 'edit' => __( 'has basic editing capability (but may need other capabilities based on post status and ownership)', 'capsman-enhanced' ), |
| 252 | 'edit_others' => __( 'can edit posts which were created by other users', 'capsman-enhanced' ), |
| 253 | 'edit_published' => __( 'can edit posts which are currently published', 'capsman-enhanced' ), |
| 254 | 'edit_private' => __( 'can edit posts which are currently published with private visibility', 'capsman-enhanced' ), |
| 255 | 'publish' => __( 'can make a post publicly visible', 'capsman-enhanced' ), |
| 256 | 'delete' => __( 'has basic deletion capability (but may need other capabilities based on post status and ownership)', 'capsman-enhanced' ), |
| 257 | 'delete_others' => __( 'can delete posts which were created by other users', 'capsman-enhanced' ), |
| 258 | 'delete_published' => __( 'can delete posts which are currently published', 'capsman-enhanced' ), |
| 259 | 'delete_private' => __( 'can delete posts which are currently published with private visibility', 'capsman-enhanced' ), |
| 260 | ); |
| 261 | |
| 262 | $default_caps = array( 'read_private_posts', 'edit_posts', 'edit_others_posts', 'edit_published_posts', 'edit_private_posts', 'publish_posts', 'delete_posts', 'delete_others_posts', 'delete_published_posts', 'delete_private_posts', |
| 263 | 'read_private_pages', 'edit_pages', 'edit_others_pages', 'edit_published_pages', 'edit_private_pages', 'publish_pages', 'delete_pages', 'delete_others_pages', 'delete_published_pages', 'delete_private_pages', |
| 264 | 'manage_categories' |
| 265 | ); |
| 266 | $type_caps = array(); |
| 267 | |
| 268 | // Role Scoper and PP1 adjust attachment access based only on user's capabilities for the parent post |
| 269 | if ( defined('SCOPER_VERSION') || ( defined( 'PP_ACTIVE' ) && ! defined( 'PPC_VERSION' ) ) ) |
| 270 | unset( $defined['type']['attachment'] ); |
| 271 | |
| 272 | echo '<ul class="cme-listhoriz">'; |
| 273 | |
| 274 | // cap_types: read, edit, deletion |
| 275 | foreach( array_keys($cap_properties) as $cap_type ) { |
| 276 | echo '<li>'; |
| 277 | echo '<h3>' . $cap_type_names[$cap_type] . '</h3>'; |
| 278 | echo '<table class="cme-typecaps">'; |
| 279 | |
| 280 | foreach( array_keys($defined) as $item_type ) { |
| 281 | if ( ( 'delete' == $cap_type ) && ( 'taxonomy' == $item_type ) ) { |
| 282 | if ( defined('SCOPER_VERSION') || defined('PP_ACTIVE') ) |
| 283 | continue; |
| 284 | |
| 285 | $any_term_deletion_caps = false; |
| 286 | foreach( array_keys($defined['taxonomy']) as $_tax ) { |
| 287 | if ( isset( $defined['taxonomy'][$_tax]->cap->delete_terms ) && ( 'manage_categories' != $defined['taxonomy'][$_tax]->cap->delete_terms ) && ! in_array( $_tax, $unfiltered['taxonomy'] ) ) { |
| 288 | $any_term_deletion_caps = true; |
| 289 | break; |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | if ( ! $any_term_deletion_caps ) |
| 294 | continue; |
| 295 | } |
| 296 | |
| 297 | //if ( ! $cap_type ) { |
| 298 | |
| 299 | //} else { |
| 300 | echo '<th></th>'; |
| 301 | |
| 302 | if ( ! count( $cap_properties[$cap_type][$item_type] ) ) |
| 303 | continue; |
| 304 | |
| 305 | // label cap properties |
| 306 | foreach( $cap_properties[$cap_type][$item_type] as $prop ) { |
| 307 | $prop = str_replace( '_posts', '', $prop ); |
| 308 | $prop = str_replace( '_pages', '', $prop ); |
| 309 | $prop = str_replace( '_terms', '', $prop ); |
| 310 | $tip = ( isset( $cap_tips[$prop] ) ) ? "title='{$cap_tips[$prop]}'" : ''; |
| 311 | $prop = str_replace( '_', '<br />', $prop ); |
| 312 | $th_class = ( 'taxonomy' == $item_type ) ? ' class="term-cap"' : ' class="post-cap"'; |
| 313 | echo "<th $tip{$th_class}>"; |
| 314 | echo ucwords($prop); |
| 315 | echo '</th>'; |
| 316 | } |
| 317 | |
| 318 | foreach( $defined[$item_type] as $key => $type_obj ) { |
| 319 | if ( in_array( $key, $unfiltered[$item_type] ) ) |
| 320 | continue; |
| 321 | |
| 322 | $row = "<tr class='cme_type_{$key}'>"; |
| 323 | |
| 324 | if ( $cap_type ) { |
| 325 | if ( empty($force_distinct_ui) && empty( $cap_properties[$cap_type][$item_type] ) ) |
| 326 | continue; |
| 327 | |
| 328 | $row .= "<td><a class='cap_type' href='#toggle_type_caps'>" . $type_obj->labels->name . '</a>'; |
| 329 | $row .= '<a href="#" class="neg-type-caps"> x </a>'; |
| 330 | $row .= '</td>'; |
| 331 | |
| 332 | $display_row = ! empty($force_distinct_ui); |
| 333 | |
| 334 | foreach( $cap_properties[$cap_type][$item_type] as $prop ) { |
| 335 | $td_classes = array(); |
| 336 | $checkbox = ''; |
| 337 | |
| 338 | if ( ! empty($type_obj->cap->$prop) && ( in_array( $type_obj->name, array( 'post', 'page' ) ) |
| 339 | || ! in_array( $type_obj->cap->$prop, $default_caps ) |
| 340 | || ( ( 'manage_categories' == $type_obj->cap->$prop ) && ( 'manage_terms' == $prop ) && ( 'category' == $type_obj->name ) ) ) ) { |
| 341 | |
| 342 | // if edit_published or edit_private cap is same as edit_posts cap, don't display a checkbox for it |
| 343 | if ( ( ! in_array( $prop, array( 'edit_published_posts', 'edit_private_posts', 'create_posts' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->edit_posts ) ) |
| 344 | && ( ! in_array( $prop, array( 'delete_published_posts', 'delete_private_posts' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->delete_posts ) ) |
| 345 | ) { |
| 346 | $cap_name = $type_obj->cap->$prop; |
| 347 | |
| 348 | if ( 'taxonomy' == $item_type ) |
| 349 | $td_classes []= "term-cap"; |
| 350 | else |
| 351 | $td_classes []= "post-cap"; |
| 352 | |
| 353 | if ( ! empty($pp_metagroup_caps[$cap_name]) ) |
| 354 | $td_classes []='cm-has-via-pp'; |
| 355 | |
| 356 | if ( $is_administrator || current_user_can($cap_name) ) { |
| 357 | if ( ! empty($pp_metagroup_caps[$cap_name]) ) { |
| 358 | $title_text = sprintf( __( '%s: assigned by Permission Group', 'capsman-enhanced' ), $cap_name ); |
| 359 | } else { |
| 360 | $title_text = $cap_name; |
| 361 | } |
| 362 | |
| 363 | $disabled = ''; |
| 364 | $checked = checked(1, ! empty($rcaps[$cap_name]), false ); |
| 365 | |
| 366 | $checkbox = '<input id=caps[' . $cap_name . '] type="checkbox" title="' . $title_text . '" name="caps[' . $cap_name . ']" value="1" ' . $checked . $disabled . ' />'; |
| 367 | $type_caps [$cap_name] = true; |
| 368 | $display_row = true; |
| 369 | } |
| 370 | } else |
| 371 | $td_classes []= "cap-unreg"; |
| 372 | |
| 373 | if ( isset($rcaps[$cap_name]) && empty($rcaps[$cap_name]) ) |
| 374 | $td_classes []= "cap-neg"; |
| 375 | } else |
| 376 | $td_classes []= "cap-unreg"; |
| 377 | |
| 378 | $td_class = ( $td_classes ) ? 'class="' . implode(' ', $td_classes) . '"' : ''; |
| 379 | |
| 380 | $row .= "<td $td_class><span class='cap-x'>X</span>$checkbox"; |
| 381 | |
| 382 | if ( false !== strpos( $td_class, 'cap-neg' ) ) |
| 383 | $row .= '<input type="hidden" class="cme-negation-input" name="caps[' . $cap_name . ']" value="" />'; |
| 384 | |
| 385 | $row .= "</td>"; |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | if ( $display_row ) { |
| 390 | $row .= '</tr>'; |
| 391 | echo $row; |
| 392 | } |
| 393 | } |
| 394 | //} // endif this iteration is for type caps checkbox display |
| 395 | |
| 396 | } // end foreach item type |
| 397 | |
| 398 | echo '</table>'; |
| 399 | |
| 400 | echo '</li>'; |
| 401 | } |
| 402 | |
| 403 | echo '</ul>'; |
| 404 | |
| 405 | // clicking on post type name toggles corresponding checkbox selections |
| 406 | ?> |
| 407 | <script type="text/javascript"> |
| 408 | /* <![CDATA[ */ |
| 409 | jQuery(document).ready( function($) { |
| 410 | $('a[href="#toggle_type_caps"]').click( function() { |
| 411 | var chks = $(this).closest('tr').find('input'); |
| 412 | $(chks).prop( 'checked', ! $(chks).first().is(':checked') ); |
| 413 | return false; |
| 414 | }); |
| 415 | }); |
| 416 | /* ]]> */ |
| 417 | </script> |
| 418 | <?php |
| 419 | |
| 420 | $core_caps = array_fill_keys( array( 'switch_themes', 'edit_themes', 'activate_plugins', 'edit_plugins', 'edit_users', 'edit_files', 'manage_options', 'moderate_comments', |
| 421 | 'manage_links', 'upload_files', 'import', 'unfiltered_html', 'read', 'delete_users', 'create_users', 'unfiltered_upload', 'edit_dashboard', |
| 422 | 'update_plugins', 'delete_plugins', 'install_plugins', 'update_themes', 'install_themes', |
| 423 | 'update_core', 'list_users', 'remove_users', 'add_users', 'promote_users', 'edit_theme_options', 'delete_themes', 'export' ), true ); |
| 424 | |
| 425 | ksort( $core_caps ); |
| 426 | |
| 427 | echo '<p> </p><h3>' . __( 'Other WordPress Core Capabilities', 'capsman-enhanced' ) . '</h3>'; |
| 428 | echo '<table width="100%" class="form-table cme-checklist"><tr>'; |
| 429 | |
| 430 | |
| 431 | $checks_per_row = get_option( 'cme_form-rows', 5 ); |
| 432 | $i = 0; $first_row = true; |
| 433 | |
| 434 | foreach( array_keys($core_caps) as $cap_name ) { |
| 435 | if ( ! $is_administrator && ! current_user_can($cap_name) ) |
| 436 | continue; |
| 437 | |
| 438 | if ( $i == $checks_per_row ) { |
| 439 | echo '</tr><tr>'; |
| 440 | $i = 0; |
| 441 | } |
| 442 | |
| 443 | if ( ! isset( $rcaps[$cap_name] ) ) |
| 444 | $class = 'cap-no'; |
| 445 | else |
| 446 | $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg'; |
| 447 | |
| 448 | if ( ! empty($pp_metagroup_caps[$cap_name]) ) { |
| 449 | $class .= ' cap-metagroup'; |
| 450 | $title_text = sprintf( __( '%s: assigned by Permission Group', 'capsman-enhanced' ), $cap_name ); |
| 451 | } else { |
| 452 | $title_text = $cap_name; |
| 453 | } |
| 454 | |
| 455 | $disabled = ''; |
| 456 | $checked = checked(1, ! empty($rcaps[$cap_name]), false ); |
| 457 | ?> |
| 458 | <td class="<?php echo $class; ?>"><span class="cap-x">X</span><label for="caps[<?php echo $cap_name; ?>]" title="<?php echo $title_text;?>"><input id=caps[<?php echo $cap_name; ?>] type="checkbox" name="caps[<?php echo $cap_name; ?>]" value="1" <?php echo $checked . $disabled;?> /> |
| 459 | <span> |
| 460 | <?php |
| 461 | echo str_replace( '_', ' ', $cap_name ); |
| 462 | ?> |
| 463 | </span></label><a href="#" class="neg-cap"> x </a> |
| 464 | <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?> |
| 465 | <input type="hidden" class="cme-negation-input" name="caps[<?php echo $cap_name; ?>]" value="" /> |
| 466 | <?php endif; ?> |
| 467 | </td> |
| 468 | |
| 469 | <?php |
| 470 | ++$i; |
| 471 | } |
| 472 | |
| 473 | if ( $i == $checks_per_row ) { |
| 474 | echo '</tr><tr>'; |
| 475 | $i = 0; |
| 476 | } elseif ( ! $first_row ) { |
| 477 | // Now close a wellformed table |
| 478 | for ( $i; $i < $checks_per_row; $i++ ){ |
| 479 | echo '<td> </td>'; |
| 480 | } |
| 481 | echo '</tr>'; |
| 482 | } |
| 483 | ?> |
| 484 | |
| 485 | <tr class="cme-bulk-select"> |
| 486 | <td colspan="<?php echo $checks_per_row;?>"> |
| 487 | <span style="float:right"> |
| 488 | <input type="checkbox" class="cme-check-all" title="<?php _e('check/uncheck all', 'capsman-enhanced');?>"> <a class="cme-neg-all" href="#" title="<?php _e('negate all (storing as disabled capabilities)', 'capsman-enhanced');?>">X</a> <a class="cme-switch-all" href="#" title="<?php _e('negate none (add/remove all capabilities normally)', 'capsman-enhanced');?>">X</a> |
| 489 | </span> |
| 490 | </td></tr> |
| 491 | |
| 492 | </table> |
| 493 | |
| 494 | <?php |
| 495 | echo '<p> </p><h3>' . __( 'Additional Capabilities', 'capsman-enhanced' ) . '</h3>'; |
| 496 | |
| 497 | ?> |
| 498 | <table width='100%' class="form-table cme-checklist"> |
| 499 | <tr> |
| 500 | <?php |
| 501 | $i = 0; $first_row = true; |
| 502 | |
| 503 | $all_capabilities = apply_filters( 'capsman_get_capabilities', array_keys( $this->capabilities ), $this->ID ); |
| 504 | $all_capabilities = apply_filters( 'members_get_capabilities', $all_capabilities ); |
| 505 | |
| 506 | foreach( $all_capabilities as $cap_name ) { |
| 507 | if ( ! isset($this->capabilities[$cap_name]) ) |
| 508 | $this->capabilities[$cap_name] = str_replace( '_', ' ', $cap_name ); |
| 509 | } |
| 510 | |
| 511 | uasort( $this->capabilities, 'strnatcasecmp' ); // sort by array values, but maintain keys ); |
| 512 | |
| 513 | foreach ( $this->capabilities as $cap_name => $cap ) : |
| 514 | if ( isset( $type_caps[$cap_name] ) || isset($core_caps[$cap_name]) ) |
| 515 | continue; |
| 516 | |
| 517 | if ( ! $is_administrator && ! current_user_can($cap_name) ) |
| 518 | continue; |
| 519 | |
| 520 | // ============ End Kevin B mod =============== |
| 521 | |
| 522 | // Levels are not shown. |
| 523 | if ( preg_match( '/^level_(10|[0-9])$/i', $cap_name ) ) { |
| 524 | continue; |
| 525 | } |
| 526 | |
| 527 | if ( $i == $checks_per_row ) { |
| 528 | echo '</tr><tr>'; |
| 529 | $i = 0; $first_row = false; |
| 530 | } |
| 531 | |
| 532 | if ( ! isset( $rcaps[$cap_name] ) ) |
| 533 | $class = 'cap-no'; |
| 534 | else |
| 535 | $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg'; |
| 536 | |
| 537 | if ( ! empty($pp_metagroup_caps[$cap_name]) ) { |
| 538 | $class .= ' cap-metagroup'; |
| 539 | $title_text = sprintf( __( '%s: assigned by Permission Group', 'capsman-enhanced' ), $cap_name ); |
| 540 | } else { |
| 541 | $title_text = $cap_name; |
| 542 | } |
| 543 | |
| 544 | $disabled = ''; |
| 545 | $checked = checked(1, ! empty($rcaps[$cap_name]), false ); |
| 546 | |
| 547 | if ( 'manage_capabilities' == $cap_name ) { |
| 548 | if ( ! current_user_can('administrator') ) { |
| 549 | continue; |
| 550 | } elseif ( 'administrator' == $default ) { |
| 551 | $class .= ' cap-locked'; |
| 552 | $lock_manage_caps_capability = true; |
| 553 | $disabled = 'disabled="disabled"'; |
| 554 | } |
| 555 | } |
| 556 | ?> |
| 557 | <td class="<?php echo $class; ?>"><span class="cap-x">X</span><label for="caps[<?php echo $cap_name; ?>]" title="<?php echo $title_text;?>"><input id=caps[<?php echo $cap_name; ?>] type="checkbox" name="caps[<?php echo $cap_name; ?>]" value="1" <?php echo $checked . $disabled;?> /> |
| 558 | <span> |
| 559 | <?php |
| 560 | echo str_replace( '_', ' ', $cap ); |
| 561 | ?> |
| 562 | </span></label><a href="#" class="neg-cap"> x </a> |
| 563 | <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?> |
| 564 | <input type="hidden" class="cme-negation-input" name="caps[<?php echo $cap_name; ?>]" value="" /> |
| 565 | <?php endif; ?> |
| 566 | </td> |
| 567 | <?php |
| 568 | $i++; |
| 569 | endforeach; |
| 570 | |
| 571 | if ( ! empty($lock_manage_caps_capability) ) { |
| 572 | echo '<input type="hidden" name="caps[manage_capabilities]" value="1" />'; |
| 573 | } |
| 574 | |
| 575 | if ( $i == $checks_per_row ) { |
| 576 | echo '</tr><tr>'; |
| 577 | $i = 0; |
| 578 | } else { |
| 579 | if ( ! $first_row ) { |
| 580 | // Now close a wellformed table |
| 581 | for ( $i; $i < $checks_per_row; $i++ ){ |
| 582 | echo '<td> </td>'; |
| 583 | } |
| 584 | echo '</tr>'; |
| 585 | } |
| 586 | } |
| 587 | ?> |
| 588 | |
| 589 | <tr class="cme-bulk-select"> |
| 590 | <td colspan="<?php echo $checks_per_row;?>"> |
| 591 | <span> |
| 592 | <?php |
| 593 | $level = ak_caps2level($rcaps); |
| 594 | ?> |
| 595 | <?php _e('Level:', 'capsman-enhanced') ;?><select name="level"> |
| 596 | <?php for ( $l = $this->max_level; $l >= 0; $l-- ) {?> |
| 597 | <option value="<?php echo $l; ?>" style="text-align:right;"<?php selected($level, $l); ?>> <?php echo $l; ?> </option> |
| 598 | <?php } |
| 599 | ?> |
| 600 | </select> |
| 601 | </span> |
| 602 | |
| 603 | <span style="float:right"> |
| 604 | <input type="checkbox" class="cme-check-all" title="<?php _e('check/uncheck all', 'capsman-enhanced');?>"> <a class="cme-neg-all" href="#" title="<?php _e('negate all (storing as disabled capabilities)', 'capsman-enhanced');?>">X</a> <a class="cme-switch-all" href="#" title="<?php _e('negate none (add/remove all capabilities normally)', 'capsman-enhanced');?>">X</a> |
| 605 | </span> |
| 606 | </td></tr> |
| 607 | |
| 608 | </table> |
| 609 | |
| 610 | <br /> |
| 611 | <?php if ( ! defined('PP_ACTIVE') || pp_get_option('display_hints') ) :?> |
| 612 | <div class="cme-subtext"> |
| 613 | <?php _e( 'Note: Underscores replace spaces in stored capability name ("edit users" => "edit_users").', 'capsman-enhanced' ); ?> |
| 614 | </div> |
| 615 | <?php endif;?> |
| 616 | </span> |
| 617 | |
| 618 | </dd> |
| 619 | </dl> |
| 620 | |
| 621 | <?php |
| 622 | $support_pp_only_roles = ( defined('PP_ACTIVE') ) ? $pp_ui->pp_only_roles_ui( $default ) : false; |
| 623 | cme_network_role_ui( $default ); |
| 624 | ?> |
| 625 | |
| 626 | <p class="submit"> |
| 627 | <input type="hidden" name="action" value="update" /> |
| 628 | <input type="hidden" name="current" value="<?php echo $default; ?>" /> |
| 629 | <input type="submit" name="SaveRole" value="<?php _e('Save Changes', 'capsman-enhanced') ?>" class="button-primary" /> |
| 630 | |
| 631 | <?php if ( current_user_can('administrator') && 'administrator' != $default ) : ?> |
| 632 | <a class="ak-delete" title="<?php echo esc_attr(__('Delete this role', 'capsman-enhanced')) ?>" href="<?php echo wp_nonce_url("admin.php?page={$this->ID}&action=delete&role={$default}", 'delete-role_' . $default); ?>" onclick="if ( confirm('<?php echo esc_js(sprintf(__("You are about to delete the %s role.\n 'Cancel' to stop, 'OK' to delete.", 'capsman-enhanced'), $roles[$default])); ?>') ) { return true;}return false;"><?php _e('Delete Role', 'capsman-enhanced')?></a> |
| 633 | <?php endif; ?> |
| 634 | </p> |
| 635 | |
| 636 | </td> |
| 637 | <td class="sidebar"> |
| 638 | <dl> |
| 639 | <dt><?php if ( defined('WPLANG') && WPLANG ) _e('Select New Role', 'capsman-enhanced'); else echo('Select Role to View / Edit'); ?></dt> |
| 640 | <dd style="text-align:center;"> |
| 641 | <p><select name="role"> |
| 642 | <?php |
| 643 | foreach ( $roles as $role => $name ) { |
| 644 | echo '<option value="' . $role .'"'; selected($default, $role); echo '> ' . $name . ' </option>'; |
| 645 | } |
| 646 | ?> |
| 647 | </select><span style="margin-left:20px"><input type="submit" name="LoadRole" value="<?php if ( defined('WPLANG') && WPLANG ) _e('Change', 'capsman-enhanced'); else echo('Load'); ?>" class="button" /></span></p> |
| 648 | </dd> |
| 649 | </dl> |
| 650 | |
| 651 | <script type="text/javascript"> |
| 652 | /* <![CDATA[ */ |
| 653 | jQuery(document).ready( function($) { |
| 654 | $('select[name="role"]').val('<?php echo $default;?>'); |
| 655 | }); |
| 656 | /* ]]> */ |
| 657 | </script> |
| 658 | |
| 659 | <dl> |
| 660 | <dt><?php _e('Create New Role', 'capsman-enhanced'); ?></dt> |
| 661 | <dd style="text-align:center;"> |
| 662 | <?php $class = ( $support_pp_only_roles ) ? 'tight-text' : 'regular-text'; ?> |
| 663 | <p><input type="text" name="create-name"" class="<?php echo $class;?>" placeholder="<?php _e('Name of new role', 'capsman-enhanced') ?>" /> |
| 664 | |
| 665 | <?php if( $support_pp_only_roles ) : ?> |
| 666 | <label for="new_role_pp_only" title="<?php _e('Make role available for supplemental assignment to Permission Groups only', 'capsman-enhanced');?>"> <input type="checkbox" name="new_role_pp_only" id="new_role_pp_only" value="1"> <?php _e('hidden', 'capsman-enhanced'); ?> </label> |
| 667 | <?php endif; ?> |
| 668 | |
| 669 | <br /> |
| 670 | <input type="submit" name="CreateRole" value="<?php _e('Create', 'capsman-enhanced') ?>" class="button" /> |
| 671 | </p> |
| 672 | </dd> |
| 673 | </dl> |
| 674 | |
| 675 | <dl> |
| 676 | <dt><?php defined('WPLANG') && WPLANG ? _e('Copy this role to', 'capsman-enhanced') : printf( 'Copy %s Role', $roles[$default] ); ?></dt> |
| 677 | <dd style="text-align:center;"> |
| 678 | <?php $class = ( $support_pp_only_roles ) ? 'tight-text' : 'regular-text'; ?> |
| 679 | <p><input type="text" name="copy-name" class="<?php echo $class;?>" placeholder="<?php _e('Name of copied role', 'capsman-enhanced') ?>" /> |
| 680 | |
| 681 | <?php if( $support_pp_only_roles ) : ?> |
| 682 | <label for="copy_role_pp_only" title="<?php _e('Make role available for supplemental assignment to Permission Groups only', 'capsman-enhanced');?>"> <input type="checkbox" name="copy_role_pp_only" id="copy_role_pp_only" value="1"> <?php _e('hidden', 'capsman-enhanced'); ?> </label> |
| 683 | <?php endif; ?> |
| 684 | |
| 685 | <br /> |
| 686 | <input type="submit" name="CopyRole" value="<?php _e('Copy', 'capsman-enhanced') ?>" class="button" /> |
| 687 | </p> |
| 688 | </dd> |
| 689 | </dl> |
| 690 | |
| 691 | <dl> |
| 692 | <dt><?php _e('Add Capability', 'capsman-enhanced'); ?></dt> |
| 693 | <dd style="text-align:center;"> |
| 694 | <p><input type="text" name="capability-name" class="regular-text" placeholder="<?php _e('capability name', 'capsman-enhanced') ?>" /><br /> |
| 695 | <input type="submit" name="AddCap" value="<?php _e('Add to role', 'capsman-enhanced') ?>" class="button" /></p> |
| 696 | </dd> |
| 697 | </dl> |
| 698 | |
| 699 | <dl> |
| 700 | <dt><?php _e('Backup Tool', 'capsman-enhanced'); ?></dt> |
| 701 | <dd style="text-align:center;"> |
| 702 | <p><a href="tools.php?page=capsman-tool"><?php _e('Backup / Restore Roles', 'capsman-enhanced');?></a></p> |
| 703 | </dd> |
| 704 | </dl> |
| 705 | |
| 706 | <dl> |
| 707 | <dt><?php _e('Related Permissions Plugins', 'capsman-enhanced'); ?></dt> |
| 708 | <ul> |
| 709 | <li><a href="https://wordpress.org/plugins/publishpress" target="_blank"><?php _e('PublishPress', 'capsman-enhanced');?></a></li> |
| 710 | <li><a href="https://wordpress.org/plugins/press-permit-core" target="_blank"><?php _e('Press Permit', 'capsman-enhanced');?></a></li> |
| 711 | <li><a href="https://wordpress.org/plugins/revisionary" target="_blank"><?php _e('Revisionary', 'capsman-enhanced');?></a></li> |
| 712 | </ul> |
| 713 | </dl> |
| 714 | |
| 715 | <?php if ( defined('PP_ACTIVE') ) |
| 716 | $pp_ui->pp_types_ui( $defined ); |
| 717 | ?> |
| 718 | </td> |
| 719 | </tr> |
| 720 | </table> |
| 721 | </fieldset> |
| 722 | </form> |
| 723 | </div> |
| 724 | |
| 725 | <?php |
| 726 | function cme_network_role_ui( $default ) { |
| 727 | if ( ! is_multisite() || ! is_super_admin() || ( 1 != get_current_blog_id() ) ) |
| 728 | return false; |
| 729 | ?> |
| 730 | |
| 731 | <div style="float:right;margin-left:10px;margin-right:10px"> |
| 732 | <?php |
| 733 | if ( ! $autocreate_roles = get_site_option( 'cme_autocreate_roles' ) ) |
| 734 | $autocreate_roles = array(); |
| 735 | |
| 736 | $checked = ( in_array( $default, $autocreate_roles ) ) ? 'checked="checked"': ''; |
| 737 | ?> |
| 738 | <div style="margin-bottom: 5px"> |
| 739 | <label for="cme_autocreate_role" title="<?php _e('Create this role definition in new (future) sites', 'capsman-enhanced');?>"><input type="checkbox" name="cme_autocreate_role" id="cme_autocreate_role" value="1" <?php echo $checked;?>> <?php _e('include in new sites', 'capsman-enhanced'); ?> </label> |
| 740 | </div> |
| 741 | <div> |
| 742 | <label for="cme_net_sync_role" title="<?php echo esc_attr(__('Copy / update this role definition to all sites now', 'capsman-enhanced'));?>"><input type="checkbox" name="cme_net_sync_role" id="cme_net_sync_role" value="1"> <?php _e('sync role to all sites now', 'capsman-enhanced'); ?> </label> |
| 743 | </div> |
| 744 | </div> |
| 745 | <?php |
| 746 | return true; |
| 747 | } |
| 748 | |
| 749 | function cme_plugin_info_url( $plugin_slug ) { |
| 750 | return self_admin_url( "plugin-install.php?tab=plugin-information&plugin=$plugin_slug&TB_iframe=true&width=640&height=678" ); |
| 751 | } |