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