function options_ui()
    {
        global $pp_default_options, $pp_options_ui;
        $ui = $pp_options_ui;
        $tab = 'core';
        $section = 'permissions';
        // --- PERMISSIONS SECTION ---
        if (!empty($ui->form_options[$tab][$section])) {
            ?>
			<tr><th scope="row"><?php 
            echo $ui->section_captions[$tab][$section];
            ?>
</th><td>
			<?php 
            $hint = __('If disabled, manually "blocked" posts can be unblocked by Category / Term Exceptions.  Enabling this setting will provide more intuitive behavior, but may require configuration review and testing on prior installations.', 'pp');
            $ui->option_checkbox('post_blockage_priority', $tab, $section, $hint);
            ?>
			</td></tr>
		<?php 
        }
        // any options accessable in this section
        // --- FILTERED TAXONOMIES / POST TYPES SECTION ---
        foreach (array('object' => 'post_types', 'term' => 'taxonomies') as $scope => $section) {
            if (empty($ui->form_options[$tab][$section])) {
                continue;
            }
            ?>
			<tr><th scope="row"><?php 
            echo $ui->section_captions[$tab][$section];
            ?>
</th><td>
			<?php 
            if ('term' == $scope) {
                $option_name = 'enabled_taxonomies';
                _e('Modify permissions for these Taxonomies:', 'pp');
                echo '<br />';
                $types = get_taxonomies(array('public' => true), 'object');
                if ($omit_types = apply_filters('pp_unfiltered_taxonomies', array('post_status', 'topic-tag'))) {
                    // avoid confusion with Edit Flow administrative taxonomy
                    $types = array_diff_key($types, array_fill_keys((array) $omit_types, true));
                }
                $hidden_types = apply_filters('pp_hidden_taxonomies', array());
                $types = _pp_order_types($types);
            } else {
                $option_name = 'enabled_post_types';
                _e('Modify permissions for these Post Types:', 'pp');
                $types = get_post_types(array('public' => true), 'object');
                if ($omit_types = apply_filters('pp_unfiltered_post_types', array())) {
                    $types = array_diff_key($types, array_fill_keys((array) $omit_types, true));
                }
                $hidden_types = apply_filters('pp_hidden_post_types', array());
                $types = _pp_order_types($types);
            }
            $ui->all_otype_options[] = $option_name;
            if (isset($pp_default_options[$option_name])) {
                if (!($enabled = $ui->get_option($option_name))) {
                    $enabled = array();
                }
                foreach ($types as $key => $obj) {
                    if (!$key) {
                        continue;
                    }
                    $id = $option_name . '-' . $key;
                    $name = $option_name . "[{$key}]";
                    ?>
					
					<?php 
                    if ('nav_menu' == $key) {
                        ?>
						<input name="<?php 
                        echo $name;
                        ?>
" type="hidden" id="<?php 
                        echo $id;
                        ?>
" value="1" />
					<?php 
                    } else {
                        ?>
						<?php 
                        if (isset($hidden_types[$key])) {
                            ?>
							<input name="<?php 
                            echo $name;
                            ?>
" type="hidden" value="<?php 
                            echo $hidden_types[$key];
                            ?>
" />
						<?php 
                        } else {
                            ?>
							<div class="agp-vtight_input">
							<input name="<?php 
                            echo $name;
                            ?>
" type="hidden" value="0" />
							<label for="<?php 
                            echo $id;
                            ?>
" title="<?php 
                            echo $key;
                            ?>
">
							<input name="<?php 
                            echo $name;
                            ?>
" type="checkbox" id="<?php 
                            echo $id;
                            ?>
" value="1" <?php 
                            checked('1', !empty($enabled[$key]));
                            ?>
 />
							
							<?php 
                            if (isset($obj->labels_pp)) {
                                echo $obj->labels_pp->name;
                            } elseif (isset($obj->labels->name)) {
                                echo $obj->labels->name;
                            } else {
                                echo $key;
                            }
                            echo '</label></div>';
                        }
                    }
                    // displaying checkbox UI
                }
                // end foreach src_otype
            }
            // endif default option isset
            if ('object' == $scope) {
                if (pp_get_option('display_hints')) {
                    if ($types = get_post_types(array('public' => true, '_builtin' => false))) {
                        ?>
						<div class="pp-subtext">
						<?php 
                        printf(__('<span class="pp-important">Note</span>: Type-specific capability requirements (i.e. edit_things instead of edit_posts) will be imposed. If PP filters Media or a custom type, non-Administrators <span class="pp-important">will need a corresponding %1$ssupplemental role%2$s for editing</span>. Adding the type-specific capabilities directly to a WP role definition also works.'), "<a href='" . admin_url('?page=pp-groups') . "'>", '</a>');
                        ?>
						</div>
						
						<?php 
                        if (in_array('forum', $types) && !defined('PPP_VERSION') && pp_get_option('display_extension_hints')) {
                            ?>
							<div class="pp-subtext" style="margin-top:10px">
							<?php 
                            if (pp_key_active()) {
                                _e('To customize bbPress forum permissions, activate PP Compatibility Pack.', 'pp');
                            } else {
                                _e('To customize bbPress forum permissions, activate your Press Permit Pro support key.', 'pp');
                            }
                            ?>
							</div>
						<?php 
                        }
                        ?>
					<?php 
                    }
                }
                if (pp_wp_ver('3.5')) {
                    echo '<br /><div>';
                    $hint = __('If enabled, the create_posts, create_pages, etc. capabilities will be enforced for all Filtered Post Types.  <strong>NOTE: You will also need to use a WordPress Role Editor</strong> such as Capability Manager Enhanced to add the create_posts capability to desired roles.', 'pp');
                    $ret = $ui->option_checkbox('define_create_posts_cap', $tab, $section, $hint, '');
                    echo '</div>';
                }
            }
            ?>
			</td></tr>
			<?php 
        }
        // end foreach scope
        $section = 'front_end';
        // --- FRONT END SECTION ---
        if (!empty($ui->form_options[$tab][$section])) {
            ?>
			<tr><th scope="row"><?php 
            echo $ui->section_captions[$tab][$section];
            ?>
</th><td>
			<?php 
            $hint = __('Remove the "Private:" and "Protected" prefix from Post, Page titles', 'pp');
            $ui->option_checkbox('strip_private_caption', $tab, $section, $hint);
            ?>
			</td></tr>
		<?php 
        }
        // any options accessable in this section
        $section = 'admin';
        // --- BACK END SECTION ---
        if (!empty($ui->form_options[$tab][$section])) {
            ?>
			<tr><th scope="row"><?php 
            echo $ui->section_captions[$tab][$section];
            ?>
</th><td>
			<?php 
            $hint = 0 === validate_plugin("pp-collaborative-editing/pp-collaborative-editing.php") ? __('Note: pending further development, uneditable posts will always be hidden if the PP Collaborative Editing extension is active', 'pp') : '';
            if (defined('PPCE_VERSION')) {
                $args = array('val' => 1, 'disabled' => true, 'no_storage' => true);
            }
            $ui->option_checkbox('admin_hide_uneditable_posts', $tab, $section, $hint, '', $args);
            ?>
			</td></tr>
		<?php 
        }
        // any options accessable in this section
        $section = 'user_profile';
        // --- USER PROFILE SECTION ---
        if (!empty($ui->form_options[$tab][$section])) {
            ?>
			<tr><th scope="row"><?php 
            echo $ui->section_captions[$tab][$section];
            ?>
</th><td>
			<?php 
            $hint = '';
            if (!defined('PP_MULTISITE')) {
                $ui->option_checkbox('new_user_groups_ui', $tab, $section, $hint, '<br />');
            }
            $hint = __('note: Groups and Roles are always displayed in "Edit User"', 'pp');
            $ui->option_checkbox('display_user_profile_groups', $tab, $section);
            $ui->option_checkbox('display_user_profile_roles', $tab, $section, $hint);
            ?>
				
			</td></tr>
		<?php 
        }
        // any options accessable in this section
        $section = 'db_maint';
        if (get_option('pp_need_group_index_drop')) {
            ?>
			<tr><th scope="row"><?php 
            echo $ui->section_captions[$tab][$section];
            ?>
</th><td>
			<?php 
            $hint = '';
            $ui->option_checkbox('do_group_index_drop', $tab, $section, $hint, '<br />', array('no_storage' => true));
            ?>

			</td></tr>
		<?php 
        }
    }
Beispiel #2
0
    public static function _draw_group_permissions($agent_id, $agent_type, $url, $wp_http_referer = '', $args = array())
    {
        global $current_user;
        //$defaults = array( 'agent' => (object) array() );
        $post_types = _pp_order_types(pp_get_enabled_post_types(array(), 'object'));
        $taxonomies = _pp_order_types(pp_get_enabled_taxonomies(array('object_type' => false), 'object'));
        //$taxonomies ['link_category'] = (object) array( 'name' => 'link_category', 'labels' => (object) array( 'name' => __ppw('Link Categories'), 'singular_name' => __ppw('Link Categories') ) );
        $perms = array();
        if ('pp_group' == $agent_type && ($group = pp_get_group($agent_id))) {
            $is_wp_role = 'wp_role' == $group->metagroup_type;
        }
        if (empty($group) || !in_array($group->metagroup_id, array('wp_anon', 'wp_all')) || defined('PP_ALL_ANON_ROLES')) {
            $perms['roles'] = __('Add Supplemental Roles', 'pp');
        }
        $perms['exceptions'] = __('Add Exceptions', 'pp');
        if (!isset($perms['roles'])) {
            $current_tab = 'pp-add-exceptions';
        } elseif (!isset($perms['roles'])) {
            $current_tab = 'pp-add-roles';
        } elseif (!($current_tab = get_user_option('pp-permissions-tab'))) {
            $current_tab = isset($perms['roles']) ? 'pp-add-roles' : 'pp-add-exceptions';
        }
        if ($args['agent']->metagroup_type == 'wp_role' && !in_array($args['agent']->metagroup_id, array('wp_anon', 'wp_all'))) {
            $perms['clone'] = __('Clone', 'pp');
        }
        // --- add permission tabs ---
        echo "<ul id='pp_add_permission_tabs' class='pp-list_horiz' style='margin-bottom:-3px'>";
        foreach ($perms as $perm_type => $_caption) {
            $class = "pp-add-{$perm_type}" == $current_tab ? 'agp-selected_agent' : 'agp-unselected_agent';
            echo "<li class='agp-agent pp-add-{$perm_type} pp-add-permissions {$class}'><a class='pp-add-{$perm_type}' href='javascript:void(0)'>" . $_caption . '</a></li>';
        }
        echo '</ul>';
        // --- divs for add Roles / Exceptions ---
        $arr = array_keys($perms);
        $first_perm_type = reset($arr);
        foreach (array_keys($perms) as $perm_type) {
            $display_style = "pp-add-{$perm_type}" == $current_tab ? '' : ';display:none';
            echo "<div class='pp-group-box pp-add-permissions pp-add-{$perm_type}' style='clear:both{$display_style}'>";
            echo '<div>';
            if ('roles' == $perm_type) {
                // temp workaround for bbPress
                self::_select_roles_ui(array_diff_key($post_types, array_fill_keys(array('topic', 'reply'), true)), $taxonomies);
            } elseif ('exceptions' == $perm_type) {
                if (!isset($args['external'])) {
                    $args['external'] = array();
                }
                self::_select_exceptions_ui(array_diff_key($post_types, array_fill_keys(array('topic', 'reply'), true)), $taxonomies, $args);
            }
            ?>
			<form id="group-<?php 
            echo $perm_type;
            ?>
-selections" action="<?php 
            echo esc_url($url);
            ?>
" method="post"<?php 
            do_action('pp_group_edit_form_tag');
            ?>
>
			<?php 
            wp_nonce_field("pp-update-{$perm_type}_" . $agent_id, "_pp_nonce_{$perm_type}");
            ?>
			
			<?php 
            if ('clone' == $perm_type) {
                self::_select_clone_ui($args['agent']);
            }
            ?>
			<?php 
            if ($wp_http_referer) {
                ?>
				<input type="hidden" name="wp_http_referer" value="<?php 
                echo esc_url($wp_http_referer);
                ?>
" />
			<?php 
            }
            ?>
			<input type="hidden" name="action" value="pp_update<?php 
            echo $perm_type;
            ?>
" />
			<input type="hidden" name="agent_id" value="<?php 
            echo esc_attr($agent_id);
            ?>
" />
			<input type="hidden" name="agent_type" value="<?php 
            echo esc_attr($agent_type);
            ?>
" />
			<input type="hidden" name="member_csv" value="-1" />
			<input type="hidden" name="group_name" value="-1" />
			<input type="hidden" name="description" value="-1" />
			<?php 
            if ('roles' == $perm_type) {
                self::_selected_roles_ui();
            } elseif ('exceptions' == $perm_type) {
                self::_selected_exceptions_ui();
            }
            ?>
			</form>
			<?php 
            echo '</div></div>';
        }
        // end foreach perm_type (roles, exceptions)
        $args['agent_type'] = $agent_type;
        $roles = ppc_get_roles($agent_type, $agent_id, compact($post_types, $taxonomies));
        $args['class'] = 'user' == $agent_type ? 'pp-user-roles' : 'pp-group-roles';
        $args['agent_type'] = $agent_type;
        self::_current_roles_ui($roles, $args);
        $post_types[''] = '';
        // also retrieve exceptions for (all) post type
        $_args = array('assign_for' => '', 'extra_cols' => array('i.assign_for', 'i.eitem_id'), 'agent_type' => $agent_type, 'agent_id' => $agent_id, 'post_types' => array_keys($post_types), 'taxonomies' => array_keys($taxonomies), 'return_raw_results' => true);
        if (empty($_REQUEST['show_propagated'])) {
            $_args['inherited_from'] = 0;
        } else {
            $_args['extra_cols'][] = 'i.inherited_from';
        }
        $exc = ppc_get_exceptions($_args);
        $args['class'] = 'user' == $agent_type ? 'pp-user-roles' : 'pp-group-roles';
        self::_current_exceptions_ui($exc, $args);
        do_action('pp_group_roles_ui', $agent_type, $agent_id);
    }