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