PluginProbe ʕ •ᴥ•ʔ
PublishPress Capabilities – User Role Editor, Access Permissions, User Capabilities, Admin Menus / 1.7.4
PublishPress Capabilities – User Role Editor, Access Permissions, User Capabilities, Admin Menus v1.7.4
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 cap-helper.php 7 years ago filters-admin.php 7 years ago filters-woocommerce.php 7 years ago filters.php 7 years ago handler.php 7 years ago inflect-cme.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
823 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 global $capsman, $cme_cap_helper, $current_user;
29
30 $roles = $this->roles;
31 $default = $this->current;
32
33 if ( $block_read_removal = _cme_is_read_removal_blocked( $this->current ) ) {
34 if ( $current = get_role($default) ) {
35 if ( empty( $current->capabilities['read'] ) ) {
36 ak_admin_error( sprintf( __( 'Warning: This role cannot access the dashboard without the read capability. %1$sClick here to fix this now%2$s.', 'capsman-enhanced' ), '<a href="javascript:void(0)" class="cme-fix-read-cap">', '</a>' ) );
37 }
38 }
39 }
40
41 require_once( dirname(__FILE__).'/pp-ui.php' );
42 $pp_ui = new Capsman_PP_UI();
43
44 if( defined('PRESSPERMIT_ACTIVE') ) {
45 $pp_metagroup_caps = $pp_ui->get_metagroup_caps( $default );
46 } else {
47 $pp_metagroup_caps = array();
48 }
49 ?>
50 <div class="wrap">
51 <?php if( defined('PRESSPERMIT_ACTIVE') ) :
52 pp_icon();
53 $style = 'style="height:60px;"';
54 ?>
55 <?php else:
56 $style = '';
57 ?>
58 <div id="icon-capsman-admin" class="icon32"></div>
59 <?php endif; ?>
60
61 <h1 <?php echo $style;?>><?php _e('Roles and Capabilities', 'capsman-enhanced') ?></h1>
62
63 <form method="post" action="admin.php?page=<?php echo $this->ID ?>">
64 <?php wp_nonce_field('capsman-general-manager'); ?>
65 <fieldset>
66 <table id="akmin">
67 <tr>
68 <td class="content">
69 <dl>
70 <dt><?php printf(__('Capabilities for %s', 'capsman-enhanced'), $roles[$default]); ?></dt>
71 <dd>
72 <div style="float:right">
73 <input type="submit" name="SaveRole" value="<?php _e('Save Changes', 'capsman-enhanced') ?>" class="button-primary" /> &nbsp;
74 </div>
75
76 <?php
77 global $capsman;
78 $img_url = $capsman->mod_url . '/images/';
79 ?>
80 <div class="publishpress-headline">
81 <span class="cme-subtext">
82 <?php _e( '<strong>Note:</strong> Capability changes <strong>remain in the database</strong> after plugin deactivation.', 'capsman-enhanced' ); ?>
83 </span>
84 <span class="publishpress-thanks"> <?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>
85 </div>
86
87 <?php
88 if ( defined( 'PRESSPERMIT_ACTIVE' ) ) {
89 $pp_ui->show_capability_hints( $default );
90 }
91 ?>
92
93 <script type="text/javascript">
94 /* <![CDATA[ */
95 jQuery(document).ready( function($) {
96 $('a[href="#pp-more"]').click( function() {
97 $('#pp_features').show();
98 return false;
99 });
100 $('a[href="#pp-hide"]').click( function() {
101 $('#pp_features').hide();
102 return false;
103 });
104 });
105 /* ]]> */
106 </script>
107 <style>
108 #pp_features {display:none;border:1px solid #eee;padding:5px;text-align:center;min-width:600px}
109 div.pp-logo { text-align: center }
110 div.features-wrap { margin-left: auto; margin-right: auto; text-align: center; width: 540px; }
111 ul.pp-features { list-style: none; padding-top:10px; text-align:left; margin-left: auto }
112 ul.pp-features li:before { content: "\2713\0020"; }
113 ul.pp-features li { padding-bottom: 5px }
114 img.cme-play { margin-bottom: -3px; margin-left: 5px;}
115 </style>
116
117 <?php /* play.png icon by Pavel: http://kde-look.org/usermanager/search.php?username=InFeRnODeMoN */ ?>
118
119 <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">
120 <li>
121 <?php _e( "Automatically define type-specific capabilities for your custom post types and taxonomies", 'capsman-enhanced' );?>
122 <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>
123
124 <li>
125 <?php _e( "Assign standard WP roles supplementally for a specific post type", 'capsman-enhanced' );?>
126 <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>
127
128 <li>
129 <?php _e( "Assign custom WP roles supplementally for a specific post type <em>(Pro)</em>", 'capsman-enhanced' );?>
130 <a href="http://presspermit.com/tutorial/custom-role-usage" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
131
132 <li>
133 <?php _e( "Customize reading permissions per-category or per-post", 'capsman-enhanced' );?>
134 <a href="http://presspermit.com/tutorial/category-exceptions" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
135
136 <li>
137 <?php _e( "Customize editing permissions per-category or per-post <em>(Pro)</em>", 'capsman-enhanced' );?>
138 <a href="http://presspermit.com/tutorial/page-editing-exceptions" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
139
140 <li>
141 <?php _e( "Custom Post Visibility statuses, fully implemented throughout wp-admin <em>(Pro)</em>", 'capsman-enhanced' );?>
142 <a href="http://presspermit.com/tutorial/custom-post-visibility" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
143
144 <li>
145 <?php _e( "Custom Moderation statuses for access-controlled, multi-step publishing workflow <em>(Pro)</em>", 'capsman-enhanced' );?>
146 <a href="http://presspermit.com/tutorial/multi-step-moderation" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
147
148 <li>
149 <?php _e( "Regulate permissions for Edit Flow post statuses <em>(Pro)</em>", 'capsman-enhanced' );?>
150 <a href="http://presspermit.com/tutorial/edit-flow-integration" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
151
152 <li>
153 <?php _e( "Customize the moderated editing of published content with Revisionary or Post Forking <em>(Pro)</em>", 'capsman-enhanced' );?>
154 <a href="http://presspermit.com/tutorial/published-content-revision" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
155
156 <li>
157 <?php _e( "Grant Spectator, Participant or Moderator access to specific bbPress forums <em>(Pro)</em>", 'capsman-enhanced' );?>
158 <a href="http://presspermit.com/tutorial/bbpress-exceptions" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
159
160 <li>
161 <?php _e( "Grant supplemental content permissions to a BuddyPress group <em>(Pro)</em>", 'capsman-enhanced' );?>
162 <a href="http://presspermit.com/tutorial/buddypress-content-permissions" target="_blank"><img class="cme-play" src="<?php echo $img_url;?>play.png" /></a></li>
163
164 <li>
165 <?php _e( "WPML integration to mirror permissions to translations <em>(Pro)</em>", 'capsman-enhanced' );?>
166 </li>
167
168 <li>
169 <?php _e( "Member support forum", 'capsman-enhanced' );?>
170 </li>
171
172 </ul></div>
173 <?php
174 echo '<div>';
175 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>' );
176 echo '&nbsp;&nbsp;&bull;&nbsp;&nbsp;';
177 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>' );
178 echo '&nbsp;&nbsp;&bull;&nbsp;&nbsp;';
179 echo '<a href="#pp-hide">hide</a>';
180 echo '</div></div>';
181
182 if ( MULTISITE ) {
183 global $wp_roles;
184 global $wpdb;
185
186 if ( ! empty($_REQUEST['cme_net_sync_role'] ) ) {
187 switch_to_blog(1);
188 wp_cache_delete( $wpdb->prefix . 'user_roles', 'options' );
189 }
190
191 ( method_exists( $wp_roles, 'for_site' ) ) ? $wp_roles->for_site() : $wp_roles->reinit();
192 }
193 $capsman->reinstate_db_roles();
194
195 $current = get_role($default);
196
197 $rcaps = $current->capabilities;
198
199 $is_administrator = current_user_can( 'administrator' );
200
201 $custom_types = get_post_types( array( '_builtin' => false ), 'names' );
202 $custom_tax = get_taxonomies( array( '_builtin' => false ), 'names' );
203
204 $defined = array();
205 $defined['type'] = get_post_types( array( 'public' => true, 'show_ui' => true ), 'object', 'or' );
206 $defined['taxonomy'] = get_taxonomies( array( 'public' => true ), 'object' );
207
208 $unfiltered['type'] = apply_filters( 'pp_unfiltered_post_types', array( 'forum','topic','reply','wp_block' ) ); // bbPress' dynamic role def requires additional code to enforce stored caps
209 $unfiltered['taxonomy'] = apply_filters( 'pp_unfiltered_taxonomies', array( 'post_status', 'topic-tag' ) ); // avoid confusion with Edit Flow administrative taxonomy
210
211 $enabled_taxonomies = cme_get_assisted_taxonomies();
212
213 /*
214 if ( ( count($custom_types) || count($custom_tax) ) && ( $is_administrator || current_user_can( 'manage_pp_settings' ) ) ) {
215 $cap_properties[''] = array();
216 $force_distinct_ui = true;
217 }
218 */
219
220 $cap_properties['edit']['type'] = array( 'edit_posts' );
221
222 foreach( $defined['type'] as $type_obj ) {
223 if ( 'attachment' != $type_obj->name ) {
224 if ( isset( $type_obj->cap->create_posts ) && ( $type_obj->cap->create_posts != $type_obj->cap->edit_posts ) ) {
225 $cap_properties['edit']['type'][]= 'create_posts';
226 break;
227 }
228 }
229 }
230
231 $cap_properties['edit']['type'][]= 'edit_others_posts';
232 $cap_properties['edit']['type'] = array_merge( $cap_properties['edit']['type'], array( 'publish_posts', 'edit_published_posts', 'edit_private_posts' ) );
233
234 $cap_properties['edit']['taxonomy'] = array( 'manage_terms' );
235
236 if ( ! defined( 'OLD_PRESSPERMIT_ACTIVE' ) )
237 $cap_properties['edit']['taxonomy'] = array_merge( $cap_properties['edit']['taxonomy'], array( 'edit_terms', 'assign_terms' ) );
238
239 $cap_properties['delete']['type'] = array( 'delete_posts', 'delete_others_posts' );
240 $cap_properties['delete']['type'] = array_merge( $cap_properties['delete']['type'], array( 'delete_published_posts', 'delete_private_posts' ) );
241
242 if ( ! defined( 'OLD_PRESSPERMIT_ACTIVE' ) )
243 $cap_properties['delete']['taxonomy'] = array( 'delete_terms' );
244 else
245 $cap_properties['delete']['taxonomy'] = array();
246
247 $cap_properties['read']['type'] = array( 'read_private_posts' );
248 $cap_properties['read']['taxonomy'] = array();
249
250 $stati = get_post_stati( array( 'internal' => false ) );
251
252 $cap_type_names = array(
253 '' => __( '&nbsp;', 'capsman-enhanced' ),
254 'read' => __( 'Reading', 'capsman-enhanced' ),
255 'edit' => __( 'Editing Capabilities', 'capsman-enhanced' ),
256 'delete' => __( 'Deletion Capabilities', 'capsman-enhanced' )
257 );
258
259 $cap_tips = array(
260 'read_private' => __( 'can read posts which are currently published with private visibility', 'capsman-enhanced' ),
261 'edit' => __( 'has basic editing capability (but may need other capabilities based on post status and ownership)', 'capsman-enhanced' ),
262 'edit_others' => __( 'can edit posts which were created by other users', 'capsman-enhanced' ),
263 'edit_published' => __( 'can edit posts which are currently published', 'capsman-enhanced' ),
264 'edit_private' => __( 'can edit posts which are currently published with private visibility', 'capsman-enhanced' ),
265 'publish' => __( 'can make a post publicly visible', 'capsman-enhanced' ),
266 'delete' => __( 'has basic deletion capability (but may need other capabilities based on post status and ownership)', 'capsman-enhanced' ),
267 'delete_others' => __( 'can delete posts which were created by other users', 'capsman-enhanced' ),
268 'delete_published' => __( 'can delete posts which are currently published', 'capsman-enhanced' ),
269 'delete_private' => __( 'can delete posts which are currently published with private visibility', 'capsman-enhanced' ),
270 );
271
272 $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',
273 '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',
274 'manage_categories'
275 );
276 $type_caps = array();
277
278 // Role Scoper and PP1 adjust attachment access based only on user's capabilities for the parent post
279 if ( defined('OLD_PRESSPERMIT_ACTIVE') ) {
280 unset( $defined['type']['attachment'] );
281 }
282
283 echo '<ul class="cme-listhoriz">';
284
285 // cap_types: read, edit, deletion
286 foreach( array_keys($cap_properties) as $cap_type ) {
287 echo '<li>';
288 echo '<h3>' . $cap_type_names[$cap_type] . '</h3>';
289 echo '<table class="cme-typecaps">';
290
291 foreach( array_keys($defined) as $item_type ) {
292 if ( ( 'delete' == $cap_type ) && ( 'taxonomy' == $item_type ) ) {
293 if ( defined('OLD_PRESSPERMIT_ACTIVE') ) {
294 continue;
295 }
296
297 $any_term_deletion_caps = false;
298 foreach( array_keys($defined['taxonomy']) as $_tax ) {
299 if ( isset( $defined['taxonomy'][$_tax]->cap->delete_terms ) && ( 'manage_categories' != $defined['taxonomy'][$_tax]->cap->delete_terms ) && ! in_array( $_tax, $unfiltered['taxonomy'] ) ) {
300 $any_term_deletion_caps = true;
301 break;
302 }
303 }
304
305 if ( ! $any_term_deletion_caps )
306 continue;
307 }
308
309 //if ( ! $cap_type ) {
310
311 //} else {
312 echo '<th></th>';
313
314 if ( ! count( $cap_properties[$cap_type][$item_type] ) )
315 continue;
316
317 // label cap properties
318 foreach( $cap_properties[$cap_type][$item_type] as $prop ) {
319 $prop = str_replace( '_posts', '', $prop );
320 $prop = str_replace( '_pages', '', $prop );
321 $prop = str_replace( '_terms', '', $prop );
322 $tip = ( isset( $cap_tips[$prop] ) ) ? "title='{$cap_tips[$prop]}'" : '';
323 $prop = str_replace( '_', '<br />', $prop );
324 $th_class = ( 'taxonomy' == $item_type ) ? ' class="term-cap"' : ' class="post-cap"';
325 echo "<th $tip{$th_class}>";
326
327 if ( ( 'delete' != $prop ) || ( 'taxonomy' != $item_type ) || cme_get_detailed_taxonomies() ) {
328 echo ucwords($prop);
329 }
330
331 echo '</th>';
332 }
333
334 foreach( $defined[$item_type] as $key => $type_obj ) {
335 if ( in_array( $key, $unfiltered[$item_type] ) )
336 continue;
337
338 $row = "<tr class='cme_type_{$key}'>";
339
340 if ( $cap_type ) {
341 if ( empty($force_distinct_ui) && empty( $cap_properties[$cap_type][$item_type] ) )
342 continue;
343
344 $row .= "<td><a class='cap_type' href='#toggle_type_caps'>" . $type_obj->labels->name . '</a>';
345 $row .= '<a href="#" class="neg-type-caps">&nbsp;x&nbsp;</a>';
346 $row .= '</td>';
347
348 $display_row = ! empty($force_distinct_ui);
349
350 foreach( $cap_properties[$cap_type][$item_type] as $prop ) {
351 $td_classes = array();
352 $checkbox = '';
353 $title = '';
354
355 if ( ! empty($type_obj->cap->$prop) && ( in_array( $type_obj->name, array( 'post', 'page' ) )
356 || ! in_array( $type_obj->cap->$prop, $default_caps )
357 || ( ( 'manage_categories' == $type_obj->cap->$prop ) && ( 'manage_terms' == $prop ) && ( 'category' == $type_obj->name ) ) ) ) {
358
359 // if edit_published or edit_private cap is same as edit_posts cap, don't display a checkbox for it
360 if ( ( ! in_array( $prop, array( 'edit_published_posts', 'edit_private_posts', 'create_posts' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->edit_posts ) )
361 && ( ! in_array( $prop, array( 'delete_published_posts', 'delete_private_posts' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->delete_posts ) )
362 && ( ! in_array( $prop, array( 'edit_terms', 'delete_terms' ) ) || ( $type_obj->cap->$prop != $type_obj->cap->manage_terms ) )
363
364 && ( ! in_array( $prop, array( 'manage_terms', 'edit_terms', 'delete_terms', 'assign_terms' ) )
365 || ( $cme_cap_helper->all_taxonomy_caps[ $type_obj->cap->$prop ] <= 1 )
366 || $type_obj->cap->$prop == str_replace( '_terms', "_{$type_obj->name}s", $prop )
367 || $type_obj->cap->$prop == str_replace( '_terms', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop )
368 )
369
370 && ( in_array( $prop, array( 'manage_terms', 'edit_terms', 'delete_terms', 'assign_terms' ) )
371 || ( $cme_cap_helper->all_type_caps[ $type_obj->cap->$prop ] <= 1 )
372 || $type_obj->cap->$prop == 'upload_files' && 'create_posts' == $prop && 'attachment' == $type_obj->name
373 || $type_obj->cap->$prop == str_replace( '_posts', "_{$type_obj->name}s", $prop )
374 || $type_obj->cap->$prop == str_replace( '_pages', "_{$type_obj->name}s", $prop )
375 || $type_obj->cap->$prop == str_replace( '_posts', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop )
376 || $type_obj->cap->$prop == str_replace( '_pages', "_" . _cme_get_plural($type_obj->name, $type_obj), $prop )
377 )
378 ) {
379 // only present these term caps up top if we are ensuring that they get enforced separately from manage_terms
380 if ( in_array( $prop, array( 'edit_terms', 'delete_terms', 'assign_terms' ) ) && ( ! in_array( $type_obj->name, cme_get_detailed_taxonomies() ) || defined( 'OLD_PRESSPERMIT_ACTIVE' ) ) ) {
381 continue;
382 }
383
384 $cap_name = $type_obj->cap->$prop;
385
386 if ( 'taxonomy' == $item_type )
387 $td_classes []= "term-cap";
388 else
389 $td_classes []= "post-cap";
390
391 if ( ! empty($pp_metagroup_caps[$cap_name]) )
392 $td_classes []='cm-has-via-pp';
393
394 if ( $is_administrator || current_user_can($cap_name) ) {
395 if ( ! empty($pp_metagroup_caps[$cap_name]) ) {
396 $title_text = sprintf( __( '%s: assigned by Permission Group', 'capsman-enhanced' ), $cap_name );
397 } else {
398 $title_text = $cap_name;
399 }
400
401 $disabled = '';
402 $checked = checked(1, ! empty($rcaps[$cap_name]), false );
403
404 $checkbox = '<input id=caps[' . $cap_name . '] type="checkbox" title="' . $title_text . '" name="caps[' . $cap_name . ']" value="1" ' . $checked . $disabled . ' />';
405 $type_caps [$cap_name] = true;
406 $display_row = true;
407 }
408 } else {
409 //$td_classes []= "cap-unreg";
410 $title = 'title="' . sprintf( __( 'shared capability: %s', 'capsman-enhanced' ), esc_attr( $type_obj->cap->$prop ) ) . '"';
411 }
412
413 if ( isset($rcaps[$cap_name]) && empty($rcaps[$cap_name]) ) {
414 $td_classes []= "cap-neg";
415 }
416 } else {
417 $td_classes []= "cap-unreg";
418 }
419
420 $td_class = ( $td_classes ) ? 'class="' . implode(' ', $td_classes) . '"' : '';
421
422 $row .= "<td $td_class $title><span class='cap-x'>X</span>$checkbox";
423
424 if ( false !== strpos( $td_class, 'cap-neg' ) )
425 $row .= '<input type="hidden" class="cme-negation-input" name="caps[' . $cap_name . ']" value="" />';
426
427 $row .= "</td>";
428 }
429 }
430
431 if ( $display_row ) {
432 $row .= '</tr>';
433 echo $row;
434 }
435 }
436 //} // endif this iteration is for type caps checkbox display
437
438 } // end foreach item type
439
440 echo '</table>';
441
442 echo '</li>';
443 }
444
445 echo '</ul>';
446
447 // clicking on post type name toggles corresponding checkbox selections
448 ?>
449 <script type="text/javascript">
450 /* <![CDATA[ */
451 jQuery(document).ready( function($) {
452 $('a[href="#toggle_type_caps"]').click( function() {
453 var chks = $(this).closest('tr').find('input');
454 $(chks).prop( 'checked', ! $(chks).first().is(':checked') );
455 return false;
456 });
457 });
458 /* ]]> */
459 </script>
460 <?php
461
462 echo '<p>&nbsp;</p><h3>' . __( 'Other WordPress Core Capabilities', 'capsman-enhanced' ) . '</h3>';
463 echo '<table width="100%" class="form-table cme-checklist"><tr>';
464
465 $checks_per_row = get_option( 'cme_form-rows', 5 );
466 $i = 0; $first_row = true;
467
468 $core_caps = _cme_core_caps();
469 foreach( array_keys($core_caps) as $cap_name ) {
470 if ( ! $is_administrator && ! current_user_can($cap_name) )
471 continue;
472
473 if ( $i == $checks_per_row ) {
474 echo '</tr><tr>';
475 $i = 0;
476 }
477
478 if ( ! isset( $rcaps[$cap_name] ) )
479 $class = 'cap-no';
480 else
481 $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg';
482
483 if ( ! empty($pp_metagroup_caps[$cap_name]) ) {
484 $class .= ' cap-metagroup';
485 $title_text = sprintf( __( '%s: assigned by Permission Group', 'capsman-enhanced' ), $cap_name );
486 } else {
487 $title_text = $cap_name;
488 }
489
490 $disabled = '';
491 $checked = checked(1, ! empty($rcaps[$cap_name]), false );
492 $lock_capability = false;
493 $title = $title_text;
494
495 if ( 'read' == $cap_name ) {
496 if ( ! empty( $block_read_removal ) ) {
497 // prevent the read capability from being removed from a core role, but don't force it to be added
498 if ( $checked || apply_filters( 'pp_caps_force_capability_storage', false, 'read', $default ) ) {
499 if ( apply_filters( 'pp_caps_lock_capability', true, 'read', $default ) ) {
500 $lock_capability = true;
501 $class .= ' cap-locked';
502 $disabled = 'disabled="disabled"';
503 if ( 'administrator' != $this->current ) {
504 $title = esc_attr( __('Lockout Prevention: To remove read capability, first remove WordPress admin / editing capabilities, or add "dashboard_lockout_ok" capability', 'capsman-enhanced' ) );
505 }
506 }
507 }
508 }
509 }
510
511 ?>
512 <td class="<?php echo $class; ?>"><span class="cap-x">X</span><label for="caps[<?php echo $cap_name; ?>]" title="<?php echo $title;?>"><input id=caps[<?php echo $cap_name; ?>] type="checkbox" name="caps[<?php echo $cap_name; ?>]" value="1" <?php echo $checked . $disabled;?> />
513 <span>
514 <?php
515 echo str_replace( '_', ' ', $cap_name );
516 ?>
517 </span></label><a href="#" class="neg-cap">&nbsp;x&nbsp;</a>
518 <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?>
519 <input type="hidden" class="cme-negation-input" name="caps[<?php echo $cap_name; ?>]" value="" />
520 <?php endif; ?>
521 </td>
522
523 <?php
524
525 if ( $lock_capability ) {
526 echo '<input type="hidden" name="caps[' . $cap_name . ']" value="1" />';
527 }
528
529 ++$i;
530 }
531
532 if ( $i == $checks_per_row ) {
533 echo '</tr><tr>';
534 $i = 0;
535 } elseif ( ! $first_row ) {
536 // Now close a wellformed table
537 for ( $i; $i < $checks_per_row; $i++ ){
538 echo '<td>&nbsp;</td>';
539 }
540 echo '</tr>';
541 }
542 ?>
543
544 <tr class="cme-bulk-select">
545 <td colspan="<?php echo $checks_per_row;?>">
546 <span style="float:right">
547 <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>
548 </span>
549 </td></tr>
550
551 </table>
552
553 <?php
554 echo '<p>&nbsp;</p><h3>' . __( 'Additional Capabilities', 'capsman-enhanced' ) . '</h3>';
555
556 ?>
557 <table width='100%' class="form-table cme-checklist">
558 <tr>
559 <?php
560 $i = 0; $first_row = true;
561
562 $all_capabilities = apply_filters( 'capsman_get_capabilities', array_keys( $this->capabilities ), $this->ID );
563 $all_capabilities = apply_filters( 'members_get_capabilities', $all_capabilities );
564
565 foreach( $all_capabilities as $cap_name ) {
566 if ( ! isset($this->capabilities[$cap_name]) )
567 $this->capabilities[$cap_name] = str_replace( '_', ' ', $cap_name );
568 }
569
570 uasort( $this->capabilities, 'strnatcasecmp' ); // sort by array values, but maintain keys );
571
572 foreach ( $this->capabilities as $cap_name => $cap ) :
573 if ( isset( $type_caps[$cap_name] ) || isset($core_caps[$cap_name]) )
574 continue;
575
576 if ( ! $is_administrator && empty( $current_user->allcaps[$cap_name] ) ) {
577 continue;
578 }
579
580 // ============ End Kevin B mod ===============
581
582 // Levels are not shown.
583 if ( preg_match( '/^level_(10|[0-9])$/i', $cap_name ) ) {
584 continue;
585 }
586
587 if ( $i == $checks_per_row ) {
588 echo '</tr><tr>';
589 $i = 0; $first_row = false;
590 }
591
592 if ( ! isset( $rcaps[$cap_name] ) )
593 $class = 'cap-no';
594 else
595 $class = ( $rcaps[$cap_name] ) ? 'cap-yes' : 'cap-neg';
596
597 if ( ! empty($pp_metagroup_caps[$cap_name]) ) {
598 $class .= ' cap-metagroup';
599 $title_text = sprintf( __( '%s: assigned by Permission Group', 'capsman-enhanced' ), $cap_name );
600 } else {
601 $title_text = $cap_name;
602 }
603
604 $disabled = '';
605 $checked = checked(1, ! empty($rcaps[$cap_name]), false );
606
607 if ( 'manage_capabilities' == $cap_name ) {
608 if ( ! current_user_can('administrator') ) {
609 continue;
610 } elseif ( 'administrator' == $default ) {
611 $class .= ' cap-locked';
612 $lock_manage_caps_capability = true;
613 $disabled = 'disabled="disabled"';
614 }
615 }
616 ?>
617 <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;?> />
618 <span>
619 <?php
620 echo str_replace( '_', ' ', $cap );
621 ?>
622 </span></label><a href="#" class="neg-cap">&nbsp;x&nbsp;</a>
623 <?php if ( false !== strpos( $class, 'cap-neg' ) ) :?>
624 <input type="hidden" class="cme-negation-input" name="caps[<?php echo $cap_name; ?>]" value="" />
625 <?php endif; ?>
626 </td>
627 <?php
628 $i++;
629 endforeach;
630
631 if ( ! empty($lock_manage_caps_capability) ) {
632 echo '<input type="hidden" name="caps[manage_capabilities]" value="1" />';
633 }
634
635 if ( $i == $checks_per_row ) {
636 echo '</tr><tr>';
637 $i = 0;
638 } else {
639 if ( ! $first_row ) {
640 // Now close a wellformed table
641 for ( $i; $i < $checks_per_row; $i++ ){
642 echo '<td>&nbsp;</td>';
643 }
644 echo '</tr>';
645 }
646 }
647 ?>
648
649 <tr class="cme-bulk-select">
650 <td colspan="<?php echo $checks_per_row;?>">
651 <span>
652 <?php
653 $level = ak_caps2level($rcaps);
654 ?>
655 <?php _e('Level:', 'capsman-enhanced') ;?><select name="level">
656 <?php for ( $l = $this->max_level; $l >= 0; $l-- ) {?>
657 <option value="<?php echo $l; ?>" style="text-align:right;"<?php selected($level, $l); ?>>&nbsp;<?php echo $l; ?>&nbsp;</option>
658 <?php }
659 ?>
660 </select>
661 </span>
662
663 <span style="float:right">
664 <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>
665 </span>
666 </td></tr>
667
668 </table>
669
670 <br />
671 <?php if ( ! defined('PRESSPERMIT_ACTIVE') || capsman_get_pp_option('display_hints') ) :?>
672 <div class="cme-subtext">
673 <?php _e( 'Note: Underscores replace spaces in stored capability name ("edit users" => "edit_users").', 'capsman-enhanced' ); ?>
674 </div>
675 <?php endif;?>
676 </span>
677
678 </dd>
679 </dl>
680
681 <?php
682 $support_pp_only_roles = ( defined('PRESSPERMIT_ACTIVE') ) ? $pp_ui->pp_only_roles_ui( $default ) : false;
683 cme_network_role_ui( $default );
684 ?>
685
686 <p class="submit">
687 <input type="hidden" name="action" value="update" />
688 <input type="hidden" name="current" value="<?php echo $default; ?>" />
689 <input type="submit" name="SaveRole" value="<?php _e('Save Changes', 'capsman-enhanced') ?>" class="button-primary" /> &nbsp;
690
691 <?php if ( current_user_can('administrator') && 'administrator' != $default ) : ?>
692 <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\n 'Cancel' to stop, 'OK' to delete.", 'capsman-enhanced'), $roles[$default])); ?>') ) { return true;}return false;"><?php _e('Delete Role', 'capsman-enhanced')?></a>
693 <?php endif; ?>
694 </p>
695
696 </td>
697 <td class="sidebar">
698 <dl>
699 <dt><?php if ( defined('WPLANG') && WPLANG ) _e('Select New Role', 'capsman-enhanced'); else echo('Select Role to View / Edit'); ?></dt>
700 <dd style="text-align:center;">
701 <p><select name="role">
702 <?php
703 foreach ( $roles as $role => $name ) {
704 echo '<option value="' . $role .'"'; selected($default, $role); echo '> ' . $name . ' &nbsp;</option>';
705 }
706 ?>
707 </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>
708 </dd>
709 </dl>
710
711 <script type="text/javascript">
712 /* <![CDATA[ */
713 jQuery(document).ready( function($) {
714 $('select[name="role"]').val('<?php echo $default;?>');
715 });
716 /* ]]> */
717 </script>
718
719 <dl>
720 <dt><?php _e('Create New Role', 'capsman-enhanced'); ?></dt>
721 <dd style="text-align:center;">
722 <?php $class = ( $support_pp_only_roles ) ? 'tight-text' : 'regular-text'; ?>
723 <p><input type="text" name="create-name"" class="<?php echo $class;?>" placeholder="<?php _e('Role Name', 'capsman-enhanced') ?>" />
724
725 <?php if( $support_pp_only_roles ) : ?>
726 <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>
727 <?php endif; ?>
728
729 <br />
730 <input type="submit" name="CreateRole" value="<?php _e('Create', 'capsman-enhanced') ?>" class="button" />
731 </p>
732 </dd>
733 </dl>
734
735 <dl>
736 <dt><?php defined('WPLANG') && WPLANG ? _e('Copy this role to', 'capsman-enhanced') : printf( 'Copy %s Role', $roles[$default] ); ?></dt>
737 <dd style="text-align:center;">
738 <?php $class = ( $support_pp_only_roles ) ? 'tight-text' : 'regular-text'; ?>
739 <p><input type="text" name="copy-name" class="<?php echo $class;?>" placeholder="<?php _e('Role Name', 'capsman-enhanced') ?>" />
740
741 <?php if( $support_pp_only_roles ) : ?>
742 <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>
743 <?php endif; ?>
744
745 <br />
746 <input type="submit" name="CopyRole" value="<?php _e('Copy', 'capsman-enhanced') ?>" class="button" />
747 </p>
748 </dd>
749 </dl>
750
751 <dl>
752 <dt><?php _e('Add Capability', 'capsman-enhanced'); ?></dt>
753 <dd style="text-align:center;">
754 <p><input type="text" name="capability-name" class="regular-text" placeholder="<?php echo 'capability_name';?>" /><br />
755 <input type="submit" name="AddCap" value="<?php _e('Add to role', 'capsman-enhanced') ?>" class="button" /></p>
756 </dd>
757 </dl>
758
759 <dl class="cme-backup-tool">
760 <dt><?php _e('Backup Tool', 'capsman-enhanced'); ?></dt>
761 <dd style="text-align:center;">
762 <p><a href="tools.php?page=capsman-tool"><?php _e('Backup / Restore Roles', 'capsman-enhanced');?></a></p>
763 </dd>
764 </dl>
765
766 <dl>
767 <dt><?php _e('Related Permissions Plugins', 'capsman-enhanced'); ?></dt>
768 <ul>
769 <?php $_url = "plugin-install.php?tab=plugin-information&plugin=publishpress&TB_iframe=true&width=640&height=678";
770 $url = ( is_multisite() ) ? network_admin_url($_url) : admin_url($_url);
771 ?>
772 <li><a class="thickbox" href="<?php echo $url;?>"><?php _e('PublishPress', 'capsman-enhanced');?></a></li>
773
774 <li><a href="#pp-more"><?php _e('Press Permit', 'capsman-enhanced');?></a>
775 </li>
776
777 <?php $_url = "plugin-install.php?tab=plugin-information&plugin=revisionary&TB_iframe=true&width=640&height=678";
778 $url = ( is_multisite() ) ? network_admin_url($_url) : admin_url($_url);
779 ?>
780 <li><a class="thickbox" href="<?php echo $url;?>"><?php _e('Revisionary', 'capsman-enhanced');?></a></li>
781 <li class="publishpress-contact"><a href="https://publishpress.com/contact" target="_blank"><?php _e('Help / Contact Form', 'capsman-enhanced');?></a></li>
782 </ul>
783 </dl>
784
785 <?php
786 $pp_ui->pp_types_ui( $defined['type'] );
787 $pp_ui->pp_taxonomies_ui( $defined['taxonomy'] );
788 ?>
789 </td>
790 </tr>
791 </table>
792 </fieldset>
793 </form>
794 </div>
795
796 <?php
797 function cme_network_role_ui( $default ) {
798 if ( ! is_multisite() || ! is_super_admin() || ( 1 != get_current_blog_id() ) )
799 return false;
800 ?>
801
802 <div style="float:right;margin-left:10px;margin-right:10px">
803 <?php
804 if ( ! $autocreate_roles = get_site_option( 'cme_autocreate_roles' ) )
805 $autocreate_roles = array();
806
807 $checked = ( in_array( $default, $autocreate_roles ) ) ? 'checked="checked"': '';
808 ?>
809 <div style="margin-bottom: 5px">
810 <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>
811 </div>
812 <div>
813 <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>
814 </div>
815 </div>
816 <?php
817 return true;
818 }
819
820 function cme_plugin_info_url( $plugin_slug ) {
821 $_url = "plugin-install.php?tab=plugin-information&plugin=$plugin_slug&TB_iframe=true&width=640&height=678";
822 return ( is_multisite() ) ? network_admin_url($_url) : admin_url($_url);
823 }