Ejemplo n.º 1
0
 function process_submission()
 {
     if (!current_user_can('pp_manage_settings')) {
         wp_die(__ppw('Cheatin’ uh?'));
     }
     if (!empty($_REQUEST['pp_refresh_updates'])) {
         delete_site_transient('update_plugins');
         pp_get_version_info(true, false, true);
         wp_update_plugins();
         wp_redirect(admin_url('admin.php?page=pp-settings&pp_refresh_done=1'));
         exit;
     }
     if (!empty($_REQUEST['pp_renewal'])) {
         $opt_val = get_option('pp_support_key');
         $renewal_token = !is_array($opt_val) || count($opt_val) < 2 ? '' : substr($opt_val[1], 0, 16);
         $url = site_url('');
         $arr_url = parse_url($url);
         $site = urlencode(str_replace($arr_url['scheme'] . '://', '', $url));
         wp_redirect('http://presspermit.com/renewal/?pkg=press-permit-pro&site=' . $site . '&rt=' . $renewal_token);
         exit;
     }
     if (!empty($_REQUEST['pp_upload_config']) || !empty($_REQUEST['pp_support_forum'])) {
         require_once dirname(__FILE__) . '/admin/support_pp.php';
         $args = array();
         if (isset($_REQUEST['post_id'])) {
             $args['post_id'] = (int) $_REQUEST['post_id'];
         }
         if (isset($_REQUEST['term_taxonomy_id'])) {
             $args['term_taxonomy_id'] = (int) $_REQUEST['term_taxonomy_id'];
         }
         if (!empty($_REQUEST['pp_support_forum'])) {
             //$forum = ( ! empty( $_REQUEST['pp_forum'] ) ) ? sanitize_url($_REQUEST['pp_forum']) : 'pp2-technical-issues';
             $url = "http://presspermit.com/forums/";
             if (!empty($_REQUEST['pp_topic'])) {
                 $url = add_query_arg('pp_topic', $_REQUEST['pp_topic'], $url);
             }
             wp_redirect($url);
         }
         $success = _pp_support_upload($args);
         if (empty($_REQUEST['pp_support_forum'])) {
             if (-1 === $success) {
                 $flag = 'pp_config_no_change';
             } elseif ($success) {
                 $flag = 'pp_config_uploaded';
             } else {
                 $flag = 'pp_config_failed';
             }
             wp_redirect(admin_url("admin.php?page=pp-settings&{$flag}=1"));
         }
         exit;
     }
     if (isset($_POST['pp_submit'])) {
         $this->handle_submission('update');
     } elseif (isset($_POST['pp_defaults'])) {
         $this->handle_submission('default');
     } elseif (isset($_POST['pp_role_usage_defaults'])) {
         delete_option('pp_role_usage');
         pp_refresh_options();
     }
 }
Ejemplo n.º 2
0
 function flt_plugin_action_links($links, $file)
 {
     if ($file == PPC_BASENAME) {
         $links[] = "<a href='http://presspermit.com/forums/'>" . __ppw('Support Forums') . "</a>";
         if (!is_network_admin()) {
             $page = 'pp-settings';
             $links[] = "<a href='admin.php?page={$page}'>" . __ppw('Settings') . "</a>";
         }
     }
     return $links;
 }
Ejemplo n.º 3
0
        if ( current_user_can( 'pp_edit_groups' ) ) {
        	if ( PP_MULTISITE && pp_get_option('ms_netwide_groups') )
        		$url = 'users.php';
        	else
        		$url = 'admin.php';
        }
        */
        $url = 'admin.php';
        $group_variant = isset($_REQUEST['group_variant']) ? pp_sanitize_key($_REQUEST['group_variant']) : 'pp_group';
        if (pp_group_type_editable($group_variant) && current_user_can('pp_create_groups')) {
            ?>
	<a href="<?php 
            echo add_query_arg(array('agent_type' => $agent_type, 'page' => 'pp-group-new'), $url);
            ?>
" class="add-new-h2"><?php 
            echo esc_html(__ppw('Add New'));
            ?>
</a>
<?php 
        }
        echo '</h2>';
        if (pp_get_option('display_hints')) {
            echo '<div class="pp-hint">';
            if (defined('PP_GROUPS_HINT')) {
                echo esc_html(PP_GROUPS_HINT);
            } else {
                echo esc_html(__('Permission Groups are sets of users to which you may assign supplemental roles or exceptions. To customize permissions for an individual user instead, click their Role in the Users listing.', 'pp'));
            }
            echo '</div><br />';
        }
        /* if ( current_user_can( 'create_users' ) ) { ?> */
		<td><?php 
        if ($role_group_id = pp_get_metagroup('wp_role', $primary_role, array('cols' => 'id'))) {
            echo "<a href='admin.php?page=pp-edit-permissions&action=edit&agent_type=pp_group&agent_id={$role_group_id}'>{$wp_roles->role_names[$primary_role]}</a>";
        } else {
            echo $wp_roles->role_names[$primary_role];
        }
        ?>
		</td>
		</tr>
	<?php 
    }
} elseif ($agent_id) {
    ?>
<tr>
	<th><label for="description"><?php 
    echo __ppw('Description:', 'pp');
    ?>
</label></th>
	<td><input type="text" name="description" id="description" value="<?php 
    echo esc_attr($agent->group_description);
    ?>
" class="regular-text" <?php 
    echo $disabled;
    ?>
 style="width:95%" /></td>
</tr>
<?php 
}
?>
</table>
</td>
Ejemplo n.º 5
0
    function display($agent_type, $id_suffix, $current_selections = array(), $args = array())
    {
        $defaults = array('agent_id' => 0, 'context' => '', 'label_select' => _x('Select &gt;', 'user', 'pp'), 'label_unselect' => _x('&lt; Unselect', 'user', 'pp'), 'label_selections' => __('Current Selections:', 'pp'), 'display_stored_selections' => true, 'create_dropdowns' => false, 'width' => '', 'width_current' => '', 'label_headline' => true, 'multi_select' => true, 'use_selection_js' => true);
        $args = apply_filters('pp_agents_selection_ui_args', array_merge($defaults, $args), $agent_type, $id_suffix);
        extract($args, EXTR_SKIP);
        $width = $width ? "width:{$width}px;" : '';
        $this->register_ajax_js($agent_type, $id_suffix, $context, $agent_id, $args);
        if (true === $label_headline) {
            $label_headline = 'user' == $agent_type ? __('Select Users', 'pp') : __('Select Groups', 'pp');
        }
        ?>
		<table id="pp-agent-selection_<?php 
        echo $id_suffix;
        ?>
-wrapper" class="pp-agents-selection">
		<tr><td id="pp-agent-selection_<?php 
        echo $id_suffix;
        ?>
">
		<h4><?php 
        echo $label_headline;
        ?>
</h4>
		<input id="agent_search_text_<?php 
        echo $id_suffix;
        ?>
" type="text" size="8" />
		<button type="button" class="pp-agent-search-submit" id="agent_submit_<?php 
        echo $id_suffix;
        ?>
"><?php 
        echo __ppw("Search");
        ?>
</button>
		<img class="waiting" style="display:none;" src="<?php 
        echo esc_url(admin_url('images/wpspin_light.gif'));
        ?>
" alt="" />
		
		<?php 
        if ('user' == $agent_type && pp_get_option('user_search_by_role')) {
            ?>
			<br /><select id="pp_search_role_<?php 
            echo $id_suffix;
            ?>
">
			<option value=""><?php 
            _e('(any WP role)', 'pp');
            ?>
</option>
			<?php 
            wp_dropdown_roles();
            ?>
			</select>
		<?php 
        }
        ?>
		
		</td>
		
		<?php 
        if ($display_stored_selections) {
            ?>
		<td style="vertical-align:bottom" class="pp-members-current"><h4><?php 
            echo $label_selections;
            ?>
</h4></td>
		<?php 
        }
        ?>
		
		</tr>
		
		<tr><td>
		<select id="agent_results_<?php 
        echo $id_suffix;
        ?>
" class="pp_agent_results" <?php 
        if ($multi_select) {
            ?>
multiple="multiple" style="height:160px;<?php 
        } else {
            ?>
style="display:none;<?php 
        }
        echo $width;
        ?>
"></select>
		<span id="agent_msg_<?php 
        echo $id_suffix;
        ?>
"></span>
		</td>

		<?php 
        if ($display_stored_selections) {
            if ($width_current) {
                $width = "width:{$width_current}px;";
            }
            ?>
		<td class="pp-members-current">
		<select id='<?php 
            echo $id_suffix;
            ?>
' name='<?php 
            echo $id_suffix;
            ?>
[]' multiple='multiple' style='height:160px;<?php 
            echo $width;
            ?>
float:right'>
		
<?php 
            $display_property = 'user' == $agent_type ? 'user_login' : 'display_name';
            foreach ($current_selections as $agent) {
                $attribs = isset($agent->display_name) && $agent->user_login != $agent->display_name ? 'title="' . esc_attr($agent->display_name) . '"' : '';
                ?>
		<?php 
                $data = apply_filters('pp_agents_selection_ui_attribs', array('attribs' => $attribs, 'user_caption' => $agent->{$display_property}), $agent_type, $id_suffix, $agent);
                ?>
		<option value="<?php 
                echo $agent->ID;
                ?>
" <?php 
                echo $data['attribs'];
                ?>
><?php 
                echo $data['user_caption'];
                ?>
</option>
<?php 
            }
            ?>

		</select><br />
		</td>
		<?php 
        }
        ?>
		
		</tr>
		
		<?php 
        do_action('_pp_agents_selection_ui_select_pre', $id_suffix);
        ?>
		<tr>
		<?php 
        do_action('pp_agents_selection_ui_select_pre', $id_suffix);
        ?>
		

		<td><button type="button" id="select_agents_<?php 
        echo $id_suffix;
        ?>
" class="pp_add" style="float:right<?php 
        if (!$multi_select) {
            ?>
;display:none;<?php 
        }
        ?>
"><?php 
        echo $label_select;
        ?>
</button></td>
		
		<?php 
        if ($display_stored_selections) {
            ?>
		<td class="pp-members-current"><button type="button" id="unselect_agents_<?php 
            echo $id_suffix;
            ?>
" class="pp_remove"><?php 
            echo $label_unselect;
            ?>
</button></td>
		<?php 
        }
        ?>
		
		</tr>
		</table>	
<?php 
        if (!defined('PPM_VERSION') && pp_get_option('display_extension_hints')) {
            if (0 === validate_plugin("pp-membership/pp-membership.php")) {
                $msg = __('To set date limits on group membership, activate the PP Membership plugin.', 'pp');
            } elseif (true == pp_key_status()) {
                $msg = sprintf(__('To set date limits on group membership, %1$sinstall%2$s the PP Membership plugin.', 'pp'), '<a href="admin.php?page=pp-settings&pp_tab=install">', '</a>');
            } else {
                $msg = sprintf(__('To set date limits on group membership, %1$senter%2$s or %3$spurchase%4$s a support key and install the PP Membership plugin.', 'pp'), '<a href="admin.php?page=pp-settings&pp_tab=install">', '</a>', '<a href="http://presspermit.com/purchase">', '</a>');
            }
            echo "<div class='pp-ext-promo'>{$msg}</div>";
        }
        $csv = $current_selections ? implode(',', array_keys($current_selections)) : '';
        $csv = apply_filters('pp_agents_selection_ui_csv', $csv, $id_suffix, $current_selections);
        ?>
		<input type="hidden" id="<?php 
        echo $id_suffix;
        ?>
_csv" name="<?php 
        echo $id_suffix;
        ?>
_csv" value="<?php 
        echo $csv;
        ?>
" />
		<?php 
    }
Ejemplo n.º 6
0
 function install_pp_strings($plugin)
 {
     if ($title = pp_pretty_slug($plugin)) {
         $this->strings['no_package'] = __ppw('Install package not available.');
         $this->strings['downloading_package'] = sprintf(__ppw('Downloading install package from <span class="code">%s</span>&#8230;'), untrailingslashit('http://presspermit.com/'));
         $this->strings['unpack_package'] = __ppw('Unpacking the package&#8230;');
         $this->strings['installing_package'] = __ppw('Installing the plugin&#8230;');
         $this->strings['no_files'] = __ppw('The plugin contains no files.');
         $this->strings['process_failed'] = sprintf(__ppw('%s install Failed.', 'pp'), $title);
         $this->strings['process_success'] = sprintf(__ppw('%s installed successfully.', 'pp'), $title);
         $this->strings['remove_old'] = __ppw('Removing the old version of the plugin&#8230;');
     }
 }
Ejemplo n.º 7
0
function pp_options($args = array())
{
    if (!current_user_can('pp_manage_settings')) {
        wp_die(__ppw('Cheatin&#8217; uh?'));
    }
    do_action('pp_options_ui');
    global $pp, $pp_admin, $pp_options_ui;
    $pp->load_config();
    //$pp->load_user_config();
    $pp_options_ui = new PP_OptionsUI($args);
    $ui = $pp_options_ui;
    // shorten syntax
    $ui->all_options = array();
    $ui->tab_captions = apply_filters('pp_option_tabs', array());
    $ui->section_captions = apply_filters('pp_section_captions', array());
    $ui->option_captions = apply_filters('pp_option_captions', array());
    $ui->form_options = apply_filters('pp_option_sections', array());
    $ui->display_hints = pp_get_option('display_hints');
    if ($_hidden = apply_filters('pp_hide_options', array())) {
        $hidden = array();
        foreach (array_keys($_hidden) as $option_name) {
            if (!is_array($_hidden[$option_name]) && strlen($option_name) > 3) {
                $hidden[] = substr($option_name, 3);
            }
        }
        foreach (array_keys($ui->form_options) as $tab) {
            foreach (array_keys($ui->form_options[$tab]) as $section) {
                $ui->form_options[$tab][$section] = array_diff($ui->form_options[$tab][$section], $hidden);
            }
        }
    }
    ?>
	<div class='wrap'>
	<?php 
    echo '<form id="pp_settings_form" action="" method="post">';
    wp_nonce_field('pp-update-options');
    do_action('pp_options_form');
    ?>
	<?php 
    pp_icon();
    ?>

	<div class="submit pp-submit" style="border:none;position:absolute;right:20px;top:25px;">
	<input type="submit" name="pp_submit" class="button-primary" value="<?php 
    _e('Save Changes', 'pp');
    ?>
" />
	</div>
	<h2>
	<?php 
    $title = apply_filters('pp_options_form_title', _e('Press Permit Settings', 'pp'));
    _e($title);
    ?>
	</h2>
	
	<?php 
    if ($subheading = apply_filters('pp_options_form_subheading', '')) {
        echo $subheading;
    }
    $color_class = apply_filters('pp_options_form_color_class', 'pp-backtan');
    $class_selected = "agp-selected_agent agp-agent {$color_class}";
    $class_unselected = "agp-unselected_agent agp-agent";
    ?>
	<script type="text/javascript">
	/* <![CDATA[ */
	jQuery(document).ready( function($) {
		$('li.agp-agent a').click(function() {
			$('li.agp-agent').removeClass( 'agp-selected_agent <?php 
    echo $color_class;
    ?>
' );
			$('li.agp-agent').addClass( 'agp-unselected_agent' );
			$(this).parent().addClass( 'agp-selected_agent <?php 
    echo $color_class;
    ?>
' );
			$('.pp-options-wrapper > div').hide();
			$('#' + $(this).attr('class') ).show();
		});
	});
	/* ]]> */
	</script>
	<?php 
    $default_tab = isset($_REQUEST['pp_tab']) && isset($ui->tab_captions[$_REQUEST['pp_tab']]) ? $_REQUEST['pp_tab'] : 'install';
    $default_tab = apply_filters('pp_options_default_tab', $default_tab);
    // @todo: prevent line breaks in these links
    echo "<ul class='pp-list_horiz' style='margin-bottom:-0.1em'>";
    foreach ($ui->tab_captions as $tab => $caption) {
        if (!empty($ui->form_options[$tab])) {
            $class = $default_tab == $tab ? $class_selected : $class_unselected;
            // @todo: return to last tab
            echo "<li class='{$class}'><a class='pp-{$tab}' href='javascript:void(0)'>" . $ui->tab_captions[$tab] . '</a></li>';
        }
    }
    echo '</ul>';
    echo '<div class="pp-options-wrapper">';
    $table_class = 'form-table pp-form-table pp-options-table';
    if (isset($_REQUEST['pp_submit'])) {
        ?>
		<div id="message" class="updated"><p>
		<strong><?php 
        _e('Settings were updated.', 'pp');
        ?>
&nbsp;</strong>
		</p></div>
	<?php 
    } elseif (isset($_REQUEST['pp_defaults'])) {
        ?>
		<div id="message" class="updated"><p>
		<strong><?php 
        _e('Settings were reset to defaults.', 'pp');
        ?>
&nbsp;</strong>
		</p></div>
	<?php 
    }
    foreach (array_keys($ui->tab_captions) as $tab) {
        $display = $default_tab == $tab ? '' : 'display:none';
        echo "<div id='pp-{$tab}' style='clear:both;margin:0;{$display}' class='pp-options {$color_class}'>";
        do_action("pp_{$tab}_options_pre_ui");
        echo "<table class='{$table_class}' id='pp-{$tab}_table'>";
        do_action("pp_{$tab}_options_ui");
        echo '</table></div>';
    }
    echo '</div>';
    // pp-options-wrapper
    $pp_options_ui->filter_network_options();
    echo "<input type='hidden' name='all_options' value='" . implode(',', $ui->all_options) . "' />";
    echo "<input type='hidden' name='all_otype_options' value='" . implode(',', $ui->all_otype_options) . "' />";
    echo "<input type='hidden' name='pp_submission_topic' value='options' />";
    ?>

	<p class="submit pp-submit" style="border:none;">
	<input type="submit" name="pp_submit" class="button-primary" value="<?php 
    _e('Save Changes', 'pp');
    ?>
" />
	</p>

	<?php 
    $msg = __("All settings in this form (including those on undisplayed tabs) will be reset to DEFAULTS.  Are you sure?", 'pp');
    $js_call = "javascript:if (confirm('{$msg}')) {return true;} else {return false;}";
    ?>
	<p class="submit pp-submit-alternate" style="border:none;float:left">
	<input type="submit" name="pp_defaults" value="<?php 
    _e('Revert to Defaults', 'pp');
    ?>
" onclick="<?php 
    echo $js_call;
    ?>
" />
	</p>
	</form>
	<p style='clear:both'>
	</p>
	</div>

	<?php 
}
Ejemplo n.º 8
0
 /**
  * Reports on the availability of new updates and the update key
  *
  * @author Jonathan Davis
  * @author Kevin Behrens
  *
  * @return void
  **/
 public static function status($plugin_file, $plugin_data, $status)
 {
     $updates = self::get_version_info();
     $key = pp_get_option('support_key');
     $activated = isset($key[0]) ? $key[0] == '1' : false;
     global $pp_extensions;
     $slug = '';
     foreach ($pp_extensions as $_slug => $ext) {
         if ($plugin_file == $ext->basename) {
             $slug = $_slug;
             $current_version = $ext->version;
             break;
         }
     }
     if (!$slug) {
         return;
     }
     $version_info = isset($updates->response[$plugin_file]) ? $updates->response[$plugin_file] : false;
     if (!empty($version_info) && isset($version_info->new_version)) {
         // Core update available
         if (version_compare($version_info->new_version, $current_version, '>') || !pp_get_option('beta_updates') && preg_match("/dev|alpha|beta|rc/i", $current_version)) {
             $network = is_network_admin() ? 'network/' : '';
             $details_url = admin_url("{$network}plugin-install.php?tab=plugin-information&plugin={$slug}&TB_iframe=true&width=600&height=800");
             $update_url = wp_nonce_url("update.php?action={$slug}&plugin=" . $plugin_file, 'upgrade-plugin_' . $slug);
             if (!$activated) {
                 // Key not active for extension update
                 $update_url = 'http://presspermit.com/' . 'purchase/';
                 $message = sprintf(__('There is a new version of %1$s, but <a href="%2$s">your support key</a> is not activated. No automatic update available. <a href="%3$s">Purchase a Press Permit Pro support key</a> for one-click updates and support resources. <a href="%4$s" class="thickbox" title="%5$s">View version %6$s details</a>.', 'pp'), $plugin_data['Name'], admin_url('admin.php?page=pp-settings&pp_tab=install'), 'http://presspermit.com/' . 'purchase/', $details_url, esc_attr($plugin_data['Name']), $version_info->new_version);
                 set_site_transient('ppc_update_info', false);
             } else {
                 $message = sprintf(__ppw('There is a new version of %1$s available. <a href="%2$s" class="thickbox" title="%3$s">View version %4$s details</a> or <a href="%5$s">upgrade automatically</a>.'), $plugin_data['Name'], $details_url, esc_attr($plugin_data['Name']), $version_info->new_version, $update_url);
             }
             echo '<tr class="plugin-update-tr"><td colspan="3" class="plugin-update"><div class="update-message">' . $message . '</div></td></tr>';
             return;
         }
     }
     if (!$activated) {
         // No update availableKey not active
         $message = sprintf(__('Activate your <a href="%1$s">support key</a> for Press Permit Pro extensions and support resources.', 'pp'), admin_url('admin.php?page=pp-settings&pp_tab=install'), 'http://presspermit.com/' . "purchase/");
         echo '<tr class="plugin-update-tr"><td colspan="3" class="plugin-update"><div class="update-message">' . $message . '</div></td></tr>';
         set_site_transient('ppc_update_info', false);
         return;
     }
 }
Ejemplo n.º 9
0
 function ui_admin_footer()
 {
     if (false !== strpos($_SERVER['HTTP_USER_AGENT'], 'msie 7')) {
         echo '<span style="float:right; margin-left: 2em"><a href="http://presspermit.com/">' . __('Press Permit', 'pp') . '</a> ' . PPC_VERSION . ' | ' . '<a href="http://presspermit.com/forums/">' . __ppw('Support Forums', 'pp') . '</a>&nbsp;</span>';
     }
 }
Ejemplo n.º 10
0
    function display($agent_type, $id_suffix, $current_selections = array(), $args = array())
    {
        $defaults = array('agent_id' => 0, 'context' => '', 'label_select' => _x('Select &gt;', 'user', 'pp'), 'label_unselect' => _x('&lt; Unselect', 'user', 'pp'), 'label_selections' => __('Current Selections:', 'pp'), 'display_stored_selections' => true, 'create_dropdowns' => false, 'width' => '', 'width_current' => '', 'label_headline' => true, 'multi_select' => true, 'use_selection_js' => true);
        $args = apply_filters('pp_agents_selection_ui_args', array_merge($defaults, $args), $agent_type, $id_suffix);
        extract($args, EXTR_SKIP);
        $width = $width ? "width:{$width}px;" : '';
        $this->register_ajax_js($agent_type, $id_suffix, $context, $agent_id, $args);
        if ('user' == $agent_type) {
            if (defined('PP_USER_LASTNAME_SEARCH') && !defined('PP_USER_SEARCH_FIELD')) {
                $default_search_field = 'last_name';
            } elseif (defined('PP_USER_SEARCH_FIELD')) {
                $default_search_field = PP_USER_SEARCH_FIELD;
            } else {
                $default_search_field = '';
            }
        }
        if (true === $label_headline) {
            if ('user' == $agent_type) {
                if ($default_search_field) {
                    $search_caption = __(ucwords(str_replace('_', ' ', $default_search_field)), 'pp');
                    $label_headline = sprintf(__('Find Users by %s', 'pp'), $search_caption);
                } else {
                    $label_headline = __('Find Users', 'pp');
                }
            } else {
                $label_headline = __('Select Groups', 'pp');
            }
        }
        ?>
		<table id="pp-agent-selection_<?php 
        echo $id_suffix;
        ?>
-wrapper" class="pp-agents-selection">
		<tr><td id="pp-agent-selection_<?php 
        echo $id_suffix;
        ?>
 " style="vertical-align:top">
		<h4><?php 
        echo $label_headline;
        ?>
</h4>
		<input id="agent_search_text_<?php 
        echo $id_suffix;
        ?>
" type="text" size="8" />
		<button type="button" class="pp-agent-search-submit" id="agent_submit_<?php 
        echo $id_suffix;
        ?>
"><?php 
        echo __ppw("Search");
        ?>
</button>
		
		<?php 
        if ('user' == $agent_type) {
            ?>
			<br />
			<?php 
            $title = !defined('PP_USER_SEARCH_META_FIELDS') && pp_is_user_administrator() && pp_get_option('advanced_options') && pp_get_option('display_hints') ? __('For additional fields, define constant PP_USER_SEARCH_META_FIELDS', 'pp') : '';
            $fields = array('first_name' => __('First Name', 'pp'), 'last_name' => __('Last Name', 'pp'), 'nickname' => __('Nickname', 'pp'));
            if (defined('PP_USER_SEARCH_META_FIELDS')) {
                $custom_fields = str_replace(' ', '', PP_USER_SEARCH_META_FIELDS);
                $custom_fields = explode(',', $custom_fields);
                foreach ($custom_fields as $cfield) {
                    $fields[$cfield] = __(ucwords(str_replace('_', ' ', $cfield)), 'pp');
                }
            }
            if (isset($fields[$default_search_field])) {
                unset($fields[$default_search_field]);
            }
            $ilim = defined('PP_USER_SEARCH_META_FIELDS') ? 6 : 3;
            for ($i = 0; $i < $ilim; $i++) {
                ?>
				<div class="pp-user-meta-search" <?php 
                if ($i > 0 && empty($_GET["pp_search_user_meta_key_{$i}_{$id_suffix}"])) {
                    echo ' style="display:none;"';
                }
                ?>
>
				<select id="pp_search_user_meta_key_<?php 
                echo $i;
                ?>
_<?php 
                echo $id_suffix;
                ?>
">
				<option value=""><?php 
                _e('(user field)', 'pp');
                ?>
</option>
				<?php 
                foreach ($fields as $field => $lbl) {
                    ?>
					<option value="<?php 
                    echo $field;
                    ?>
"><?php 
                    echo $lbl;
                    ?>
</option>
				<?php 
                }
                ?>
				</select>
				&nbsp;
				<input id="pp_search_user_meta_val_<?php 
                echo $i;
                ?>
_<?php 
                echo $id_suffix;
                ?>
" type="text" <?php 
                if (empty($_GET["pp_search_user_meta_key_{$i}_{$id_suffix}"])) {
                    echo 'style="display:none"';
                }
                ?>
 title="<?php 
                echo $title;
                ?>
" size="8" />
				<?php 
                if ($i < $ilim - 1) {
                    ?>
				&nbsp;<span class="pp-usermeta-field-more" <?php 
                    if (empty($_GET["pp_search_user_meta_key_{$i}_{$id_suffix}"])) {
                        echo 'style="display:none"';
                    }
                    ?>
>+</span>
				<?php 
                }
                ?>
				</div>
			<?php 
            }
            ?>
		<?php 
        }
        ?>
		
		<?php 
        if ('user' == $agent_type && pp_get_option('user_search_by_role')) {
            ?>
			<select id="pp_search_role_<?php 
            echo $id_suffix;
            ?>
" class="pp-search-role">
			<option value=""><?php 
            _e('(any WP role)', 'pp');
            ?>
</option>
			<?php 
            wp_dropdown_roles();
            ?>
			</select>
		<?php 
        }
        ?>
		</td>
		
		<?php 
        if ($display_stored_selections) {
            ?>
			<td style="vertical-align:top" class="pp-members-current">
			</td>
		<?php 
        }
        ?>
		
		</tr>
		
		<tr><td>
		<h4><?php 
        _e('Search Results:', 'pp');
        ?>
<img class="waiting" style="display:none;float:right" src="<?php 
        echo esc_url(admin_url('images/wpspin_light.gif'));
        ?>
" alt="" /></h4>
		
		<select id="agent_results_<?php 
        echo $id_suffix;
        ?>
" class="pp_agent_results" <?php 
        if ($multi_select) {
            ?>
multiple="multiple" style="height:160px;<?php 
        } else {
            ?>
style="display:none;<?php 
        }
        echo $width;
        ?>
"></select>
		<span id="agent_msg_<?php 
        echo $id_suffix;
        ?>
"></span>
		</td>

		<?php 
        if ($display_stored_selections) {
            if ($width_current) {
                $width = "width:{$width_current}px;";
            }
            ?>
		<td class="pp-members-current">
		<h4><?php 
            echo $label_selections;
            ?>
</h4>
		
		<select id='<?php 
            echo $id_suffix;
            ?>
' name='<?php 
            echo $id_suffix;
            ?>
[]' multiple='multiple' style='height:160px;<?php 
            echo $width;
            ?>
'>
		
<?php 
            if ('user' == $agent_type) {
                $display_property = defined('PP_USER_RESULTS_DISPLAY_NAME') ? 'display_name' : 'user_login';
            } else {
                $display_property = 'display_name';
            }
            foreach ($current_selections as $agent) {
                $attribs = isset($agent->display_name) && $agent->user_login != $agent->display_name ? 'title="' . esc_attr($agent->display_name) . '"' : '';
                ?>
		<?php 
                $data = apply_filters('pp_agents_selection_ui_attribs', array('attribs' => $attribs, 'user_caption' => $agent->{$display_property}), $agent_type, $id_suffix, $agent);
                ?>
		<option value="<?php 
                echo $agent->ID;
                ?>
" <?php 
                echo $data['attribs'];
                ?>
><?php 
                echo $data['user_caption'];
                ?>
</option>
<?php 
            }
            ?>

		</select><br />
		</td>
		<?php 
        }
        ?>
		
		</tr>
		
		<?php 
        do_action('_pp_agents_selection_ui_select_pre', $id_suffix);
        ?>
		<tr>
		<?php 
        do_action('pp_agents_selection_ui_select_pre', $id_suffix);
        ?>
		

		<td><button type="button" id="select_agents_<?php 
        echo $id_suffix;
        ?>
" class="pp_add" style="float:right<?php 
        if (!$multi_select) {
            ?>
;display:none;<?php 
        }
        ?>
"><?php 
        echo $label_select;
        ?>
</button></td>
		
		<?php 
        if ($display_stored_selections) {
            ?>
		<td class="pp-members-current"><button type="button" id="unselect_agents_<?php 
            echo $id_suffix;
            ?>
" class="pp_remove"><?php 
            echo $label_unselect;
            ?>
</button></td>
		<?php 
        }
        ?>
		
		</tr>
		</table>	
<?php 
        if (!defined('PPM_VERSION') && pp_get_option('display_extension_hints')) {
            if (0 === validate_plugin("pp-membership/pp-membership.php")) {
                $msg = __('To set date limits on group membership, activate the PP Membership plugin.', 'pp');
            } elseif (true == pp_key_status()) {
                $msg = sprintf(__('To set date limits on group membership, %1$sinstall%2$s the PP Membership plugin.', 'pp'), '<a href="admin.php?page=pp-settings&pp_tab=install">', '</a>');
            } else {
                $msg = sprintf(__('To set date limits on group membership, %1$senter%2$s or %3$spurchase%4$s a support key and install the PP Membership plugin.', 'pp'), '<a href="admin.php?page=pp-settings&pp_tab=install">', '</a>', '<a href="http://presspermit.com/purchase">', '</a>');
            }
            echo "<div class='pp-ext-promo'>{$msg}</div>";
        }
        $csv = $current_selections ? implode(',', array_keys($current_selections)) : '';
        $csv = apply_filters('pp_agents_selection_ui_csv', $csv, $id_suffix, $current_selections);
        ?>
		<input type="hidden" id="<?php 
        echo $id_suffix;
        ?>
_csv" name="<?php 
        echo $id_suffix;
        ?>
_csv" value="<?php 
        echo $csv;
        ?>
" />
		<?php 
    }
    function options_ui()
    {
        global $pp_options_ui;
        $ui = $pp_options_ui;
        // shorten syntax
        $tab = 'install';
        $ppcom_connect = pp_update_info_enabled();
        $use_network_admin = pp_use_network_updates();
        $suppress_updates = $use_network_admin && !is_super_admin();
        $section = 'key';
        // --- UPDATE KEY SECTION ---
        if (!empty($ui->form_options[$tab][$section]) && !$suppress_updates) {
            ?>
			<tr><td scope="row" colspan="2"><span style="font-weight:bold;vertical-align:top"><?php 
            echo $ui->section_captions[$tab][$section];
            ?>
</span>
			<?php 
            global $activated;
            if ($ppcom_connect) {
                require_once dirname(__FILE__) . '/plugin_pp.php';
                PP_Plugin_Status::get_version_info();
            }
            $id = 'support_key';
            $opt_val = pp_get_option($id);
            if (!is_array($opt_val) || count($opt_val) < 2) {
                $activated = false;
                $expired = false;
                $key = '';
            } else {
                $activated = 1 == $opt_val[0];
                $expired = -1 == $opt_val[0];
                $key = $opt_val[1];
            }
            if (isset($opt_val['expire_date_gmt'])) {
                $expire_days = intval((strtotime($opt_val['expire_date_gmt']) - time()) / 86400);
            }
            if ($expired) {
                $class = 'activating';
                $is_err = true;
                $msg = sprintf(__('Your support key has expired. For information on renewal at a discounted rate, <a href="%s">click here</a>.', 'pp'), 'admin.php?page=pp-settings&amp;pp_renewal=1');
            } elseif (!empty($opt_val['expire_date_gmt'])) {
                $class = 'activating';
                if ($expire_days < 30) {
                    $is_err = true;
                }
                if ($expire_days < 1) {
                    $msg = sprintf(__('Your support key (for plugin updates) will expire today. For information on renewal at a discounted rate, <a href="%2$s">click here</a>.', 'pp'), $expire_days, 'admin.php?page=pp-settings&amp;pp_renewal=1');
                } elseif ($expire_days < 30) {
                    $msg = sprintf(__('Your support key (for plugin updates) will expire in %1$s days. For information on renewal at a discounted rate, <a href="%2$s">click here</a>.', 'pp'), $expire_days, 'admin.php?page=pp-settings&amp;pp_renewal=1');
                } else {
                    $class = "activating hidden";
                }
            } elseif (!$activated) {
                $class = 'activating';
                $msg = sprintf(__('Activate your support key to install Pro extensions and access the member support forums. Available at <a href="%s">presspermit.com</a>.', 'pp'), 'http://presspermit.com/' . 'purchase/');
            } else {
                $class = "activating hidden";
                $msg = '';
            }
            ?>
				
				<span style="margin-left:145px;">
					<?php 
            if ($expired && !empty($key)) {
                ?>
						<span class="pp-key-exired"><?php 
                _e("Key Expired", 'pp');
                ?>
</span>
						<button type="button" id="activation-button" name="activation-button" class="button-secondary"><?php 
                _e('Deactivate Key', 'pp');
                ?>
</button>
						<span class="pp-key-exired pp-key-warning"> <?php 
                _e('note: Renewal does not require deactivation. If you do deactivate, re-entry of the support key will be required.', 'pp');
                ?>
</span>
					<?php 
            } else {
                ?>
						<?php 
                if ($activated) {
                    ?>
						<span class="pp-key-active"><?php 
                    _e("Key Activated", 'pp');
                    ?>
</span>
						<?php 
                }
                ?>
						<input name="<?php 
                echo $id;
                ?>
" type="text" id="<?php 
                echo $id;
                ?>
" <?php 
                echo $activated ? ' style="display:none"' : '';
                ?>
 />
						<button type="button" id="activation-button" name="activation-button" class="button-secondary"><?php 
                echo !$activated ? __('Activate Key', 'pp') : __('Deactivate Key', 'pp');
                ?>
</button>
					<?php 
            }
            ?>
					
					<img id="pp_support_waiting" class="waiting" style="display:none;position:relative" src="<?php 
            echo esc_url(admin_url('images/wpspin_light.gif'));
            ?>
" alt="" />
				</span>

				<br />
				
				<span style="margin-left:217px">
					<?php 
            if ($activated) {
                ?>
					<span class="pp-key-active pp-key-warning"> <?php 
                _e('note: If you deactive, re-entry of the support key will be required for re-activation.', 'pp');
                ?>
</span>
					<?php 
            } elseif (!$expired) {
                ?>
					<span class="pp-subtext"> <?php 
                _e('note: Your site URL and version info will be sent to presspermit.com', 'pp');
                ?>
</span>
					<?php 
            }
            ?>
				</span>
				
				<br /><div id="activation-status" class="<?php 
            echo $class;
            ?>
"><?php 
            echo $msg;
            ?>
</div><div id="activation-reload" style="display:none;margin-top:10px"><a href="<?php 
            echo admin_url('admin.php?page=pp-settings');
            ?>
"><?php 
            _e('reload extension links', 'pp');
            ?>
</a></div>
				
				<?php 
            if (!empty($is_err)) {
                ?>
				<div id="activation-error" class="error" style="margin-top:35px"><?php 
                echo $msg;
                ?>
</div>
				<?php 
            }
            ?>
				
				<?php 
            if (!$activated || $expired) {
                require_once dirname(__FILE__) . '/pro-promo_pp.php';
            }
            ?>
			</td></tr>
		<?php 
            do_action('pp_support_key_ui');
            self::footer_js($activated);
        }
        // any options accessable in this section
        $section = 'version';
        // --- VERSION SECTION ---
        if (!empty($ui->form_options[$tab][$section])) {
            ?>
			<tr>
			<th scope="row"><?php 
            echo $ui->section_captions[$tab][$section];
            ?>
</th>
			<td>
			
			<?php 
            if ($ppcom_connect) {
                $update_info = pp_get_all_updates_info(!empty($_REQUEST['pp_refresh_updates']));
            } else {
                $update_info = array();
            }
            //dump($update_info);
            $info_link = '';
            $update_link = '';
            $alert = '';
            if (!$suppress_updates) {
                $wp_plugin_updates = get_site_transient('update_plugins');
                if ($wp_plugin_updates && isset($wp_plugin_updates->response[PPC_BASENAME]) && !empty($wp_plugin_updates->response[PPC_BASENAME]->new_version) && version_compare($wp_plugin_updates->response[PPC_BASENAME]->new_version, PPC_VERSION, '>')) {
                    $slug = 'press-permit-core';
                    $_url = "plugin-install.php?tab=plugin-information&plugin={$slug}&section=changelog&TB_iframe=true&width=600&height=800";
                    $info_url = $use_network_admin ? network_admin_url($_url) : admin_url($_url);
                    $info_link = "<span class='update-message'> &bull; <a href='{$info_url}' class='thickbox'>" . sprintf(__ppw('%s&nbsp;details', 'pp'), $update_info[$slug]['new_version']) . '</a></span>';
                }
            }
            printf(__('Press Permit Core Version: %1$s %2$s', 'pp'), PPC_VERSION, $info_link . $update_link . $alert);
            ?>
			<br />
			<?php 
            printf(__("Database Schema Version: %s", 'pp'), PPC_DB_VERSION);
            ?>
			<br />
			<?php 
            global $wp_version;
            printf(__("WordPress Version: %s", 'pp'), $wp_version);
            ?>
			<br />
			<?php 
            printf(__("PHP Version: %s", 'pp'), phpversion());
            ?>
			<br />
			<?php 
            if (empty($activated) && empty($expired) && !defined('PP_FORCE_PPCOM_INFO')) {
                ?>
				<div style="margin-top:10px">
				<?php 
                $hint = __('Periodically query presspermit.com for available extensions. Your version info will be sent.', 'pp');
                $ui->option_checkbox('ppcom_update_info', $tab, $section, $hint);
                ?>
				</div>
			<?php 
            }
            ?>
			
			</td></tr>
		<?php 
        }
        // any options accessable in this section
        $section = 'extensions';
        // --- EXTENSIONS SECTION ---
        if (!empty($ui->form_options[$tab][$section])) {
            ?>
			<tr><th scope="row"><?php 
            echo $ui->section_captions[$tab][$section];
            if ($ppcom_connect) {
                echo '&nbsp;&nbsp;&bull;&nbsp;&nbsp;<a href="admin.php?page=pp-settings&amp;pp_refresh_updates=1">' . __('refresh', 'pp') . '</a>';
            }
            ?>
</th><td>
			<?php 
            global $pp_extensions;
            $missing = $inactive = array();
            if (pp_get_option('display_hints') && $ppcom_connect) {
                $ext_info = pp_get_extension_info(!empty($_REQUEST['pp_refresh_done']));
                $ext_info->blurb['capability-manager-enhanced'] = __('Create your own WP roles or modify the capabilities defined for any WP Role.', 'pp');
                $ext_info->descript['capability-manager-enhanced'] = __('Create your own WP roles or modify the capabilities defined for any WP Role. Not necessary for all installations, but PP interop is particularly important for bbPress and BuddyPress installations.', 'pp');
            }
            if (!empty($ext_info) && (empty($ext_info->blurb) || empty($ext_info->descript))) {
                unset($ext_info);
            }
            if ($missing = array_diff_key($update_info, $pp_extensions)) {
                unset($missing['press-permit-core']);
                foreach (array_keys($missing) as $slug) {
                    if (0 === validate_plugin("{$slug}/{$slug}.php")) {
                        unset($missing[$slug]);
                        $inactive[$slug] = true;
                    }
                }
            }
            ksort($pp_extensions);
            if ($pp_extensions) {
                $change_log_caption = __('<strong>Change Log</strong> (since your current version)', 'pp');
                ?>
				<h4 style="margin-bottom:2px;margin-top:0"><?php 
                _e('Active Extensions:', 'pp');
                ?>
</h4>
				<table class="pp-extensions">
				<?php 
                foreach ($pp_extensions as $slug => $plugin_info) {
                    $info_link = '';
                    $update_link = '';
                    $alert = '';
                    if (isset($update_info[$slug]) && version_compare($update_info[$slug]['new_version'], $plugin_info->version, '>')) {
                        $_url = "plugin-install.php?tab=plugin-information&plugin={$slug}&TB_iframe=true&width=600&height=800";
                        $info_url = $use_network_admin ? network_admin_url($_url) : admin_url($_url);
                        $info_link = "<span class='update-message'> &bull; <a href='{$info_url}' class='thickbox' title='{$change_log_caption}'>" . sprintf(__ppw('%s&nbsp;details', 'pp'), $update_info[$slug]['new_version']) . '</a></span>';
                        if (!$suppress_updates) {
                            $style = $activated ? '' : "style='display:none'";
                            $url = pp_plugin_update_url($plugin_info->basename, $slug) . '&pp_install=1&TB_iframe=true&height=400';
                            $update_link = "<span class='pp-update-link' {$style}> &bull; <a href='{$url}' class='thickbox' target='_blank'>" . __ppw('update&nbsp;now', 'pp') . '</a></span>';
                            $alert = !empty($update_info[$slug]['alert']) ? " &bull; <span class='pp-red'>{$update_info[$slug]['alert']}</span>" : '';
                        }
                    }
                    ?>
				<tr>
				<td <?php 
                    if ($alert) {
                        echo 'colspan="2"';
                    }
                    ?>
><?php 
                    echo __($plugin_info->label) . ' <span class="pp-gray">' . $plugin_info->version . "</span> {$info_link} {$update_link} {$alert}";
                    ?>
</td>
				<?php 
                    if (!empty($ext_info) && !$alert) {
                        ?>
				<td>
					<?php 
                        if (isset($ext_info->blurb[$slug])) {
                            ?>
					<span class="pp-ext-info" title="<?php 
                            if (isset($ext_info->descript[$slug])) {
                                echo esc_attr($ext_info->descript[$slug]);
                            }
                            ?>
"><?php 
                            echo $ext_info->blurb[$slug];
                            ?>
</span>
					<?php 
                        }
                        ?>
				</td>
				<?php 
                    }
                    ?>
				</tr>
				<?php 
                }
                ?>
				</table>
			<?php 
            }
            if (!defined('CAPSMAN_ENH_VERSION')) {
                if (0 === validate_plugin('capability-manager-enhanced/capsman-enhanced.php') || 0 === validate_plugin('capsman-enhanced/capsman-enhanced.php')) {
                    $inactive['capability-manager-enhanced'] = true;
                } else {
                    $missing['capability-manager-enhanced'] = true;
                }
            }
            ksort($inactive);
            if ($inactive) {
                ?>
			<h4 style="margin-bottom:2px"><?php 
                $url = PP_MULTISITE ? 'network/plugins.php/' : 'plugins.php';
                printf(__('%1$sInactive Extensions%2$s:', 'pp'), "<a href='{$url}'>", '</a>');
                ?>
</h4>
			<table class="pp-extensions">
			<?php 
                foreach (array_keys($inactive) as $slug) {
                    ?>
			<tr>
			<td><?php 
                    echo pp_pretty_slug($slug);
                    ?>
</td>
			<?php 
                    if (!empty($ext_info)) {
                        ?>
				<td>
					<?php 
                        if (isset($ext_info->blurb[$slug])) {
                            ?>
					<span class="pp-ext-info" title="<?php 
                            if (isset($ext_info->descript[$slug])) {
                                echo esc_attr($ext_info->descript[$slug]);
                            }
                            ?>
"><?php 
                            echo $ext_info->blurb[$slug];
                            ?>
</span>
					<?php 
                        }
                        ?>
				</td>
			<?php 
                    }
                    ?>
			</tr>
			<?php 
                }
                ?>
			</table>
			<?php 
            }
            ksort($missing);
            if ($missing) {
                ?>
			<h4 style="margin-bottom:2px"><?php 
                _e('Available Pro Extensions:', 'pp');
                ?>
</h4>
			<table class="pp-extensions">
			<?php 
                foreach (array_keys($missing) as $slug) {
                    if ($need_supplemental_key = isset($update_info[$slug]['key_type']) && 'pp' != $update_info[$slug]['key_type']) {
                        $any_supplemental_key = true;
                    }
                    if ($activated && isset($update_info[$slug]) && !$need_supplemental_key && !$suppress_updates) {
                        $_url = "update.php?action={$slug}&amp;plugin={$slug}&pp_install=1&TB_iframe=true&height=400";
                        $install_url = $use_network_admin ? network_admin_url($_url) : admin_url($_url);
                        $url = wp_nonce_url($install_url, "{$slug}_{$slug}");
                        $install_link = "<span> &bull; <a href='{$url}' class='thickbox' target='_blank'>" . __ppw('install', 'pp') . '</a></span>';
                    } else {
                        $install_link = '';
                    }
                    ?>
			<tr>
			<td><?php 
                    if (!empty($update_info[$slug])) {
                        echo "<a href='http://presspermit.com/extensions/{$slug}'>" . pp_pretty_slug($slug) . '</a>' . $install_link;
                    } else {
                        $caption = ucwords(str_replace('-', ' ', $slug));
                        echo '<span class="plugins update-message"><a href="' . pp_plugin_info_url($slug) . '" class="thickbox" title=" ' . $caption . '">' . str_replace(' ', '&nbsp;', $caption) . '</a></span>';
                    }
                    ?>
</td>
			<?php 
                    if (!empty($ext_info)) {
                        ?>
				<td>
					<?php 
                        if (isset($ext_info->blurb[$slug])) {
                            ?>
					<span class="pp-ext-info" title="<?php 
                            if (isset($ext_info->descript[$slug])) {
                                echo esc_attr($ext_info->descript[$slug]);
                            }
                            ?>
"><?php 
                            echo $ext_info->blurb[$slug];
                            ?>
</span>
					<?php 
                        }
                        ?>
				</td>
			<?php 
                    }
                    ?>
			</tr>
			<?php 
                }
                ?>
			</table>
			<p style="padding-left:15px;">
			<?php 
                if (!$activated) {
                    echo '<span class="pp-red">' . __('To enable one-click installation and update of extensions, please activate your Press Permit Pro support key above.', 'pp') . '<span>';
                } elseif (!empty($any_supplemental_key)) {
                    printf(__('Visit %1$spresspermit.com%2$s for further information on obtaining and installing extensions.', 'pp'), '<a href="http://presspermit.com">', '</a>');
                }
                ?>
			</p>
			
			<?php 
            } elseif (!pp_update_info_enabled()) {
                ?>
				<p style="margin-top:20px"><strong><?php 
                _e('Press Permit Pro extensions supply:', 'pp');
                ?>
</strong></p>
				<ul class="pp-bullet-list">
				<li><?php 
                printf(__('%1$sContent-specific editing permissions, with Edit Flow, Revisionary and Post Forking support%2$s', 'pp'), '<a href="http://presspermit.com/extensions/pp-collaborative-editing">', '</a>');
                ?>
</li>
				<li><?php 
                printf(__('%1$sCustom Post Statuses (for visibility or moderation)%2$s', 'pp'), '<a href="http://presspermit.com/extensions/pp-custom-post-statuses">', '</a>');
                ?>
</li>
				<li><?php 
                printf(__('%1$sCustomize bbPress forum access%2$s', 'pp'), '<a href="http://presspermit.com/extensions/pp-compatibility">', '</a>');
                ?>
</li>
				<li><?php 
                printf(__('%1$sFile URL filtering%2$s', 'pp'), '<a href="http://presspermit.com/extensions/pp-file-url-filter">', '</a>');
                ?>
</li>
				<li><?php 
                printf(__('%1$sRole Scoper import script%2$s', 'pp'), '<a href="http://presspermit.com/extensions/pp-import">', '</a>');
                ?>
</li>
				<li><?php 
                printf(__('%1$s...and more%2$s', 'pp'), '<a href="http://presspermit.com/extensions/">', '</a>');
                ?>
</li>
				</ul>
				<p>
				<?php 
                printf(__('For updated availability, enable the "update info" option above or visit %1$spresspermit.com%2$s.', 'pp'), '<a href="http://presspermit.com/extensions/">', '</a>');
                ?>
</p>
			<?php 
            }
            ?>
			<?php 
            if (!empty($ext_info) && pp_get_option('display_hints')) {
                ?>
			<p><span class="pp-subtext">
			<?php 
                _e('Note: Hover over descriptions for more detail. Press Permit extensions can also be maintained on the Plugins screen.', 'pp');
                ?>
			</span></p>
			<?php 
            }
            ?>
			
			<?php 
            ?>
			</td></tr>
			<?php 
        }
        // any options accessable in this section
        $section = 'help';
        // --- HELP SECTION ---
        if (!empty($ui->form_options[$tab][$section])) {
            ?>
			<tr><th scope="row"><?php 
            echo $ui->section_captions[$tab][$section];
            ?>
</th><td>
			<?php 
            if ($activated) {
                ?>
				<ul class="pp-support-list">
				<li><a href='http://presspermit.com/docs/' target='pp_doc'><?php 
                _e('Press Permit Documentation', 'pp');
                ?>
</a></li>

				<li class="pp-support-forum"><a href="admin.php?page=pp-settings&amp;pp_support_forum=1" target="pp_forum"><?php 
                _e('Press Permit Support Forums', 'pp');
                ?>
</a> <strong>*</strong></li>

				<li class="upload-config"><a href="admin.php?page=pp-settings&amp;pp_upload_config=1"><?php 
                _e('Upload site configuration to presspermit.com now', 'pp');
                ?>
</a> <strong>*</strong> 
				<img id="pp_upload_waiting" class="waiting" style="display:none;position:relative" src="<?php 
                echo esc_url(admin_url('images/wpspin_light.gif'));
                ?>
" alt="" />
				</li>
				</ul>
				
				<div style="text-indent: -10px;padding-left: 10px;margin-top:15px;margin-left:10px"><strong>
				<?php 
                printf(__('%s Site configuration data selected below will be uploaded to presspermit.com:', 'pp'), '<strong>* </strong>');
                ?>
				</strong></div>
				
				<div style="padding-left:22px">
				<?php 
                $ok = (array) pp_get_option('support_data');
                $ok['ver'] = 1;
                $ui->all_options[] = 'support_data';
                $avail = array('ver' => __('Version info for server, WP, bbPress, BuddyPress, PP and all extensions', 'pp'), 'pp_options' => __('PP Settings and related WP Settings', 'pp'), 'theme' => __('Theme name, version and status', 'pp'), 'active_plugins' => __('Activated plugins list', 'pp'), 'installed_plugins' => __('Inactive plugins list', 'pp'), 'wp_roles_types' => __('WordPress Roles, Capabilities, Post Types, Taxonomies and Post Statuses', 'pp'), 'pp_permissions' => __('Role Assignments and Exceptions', 'pp'), 'pp_groups' => __('Group definitions', 'pp'), 'pp_group_members' => __('Group Membership (id only)', 'pp'), 'pp_imports' => __('Role Scoper / PP 1.x Configuration and PP Import Results', 'pp'), 'post_data' => __('Post id, status, author id, parent id, and term ids and taxonomy name (when support accessed from post or term edit form)', 'pp'), 'error_log' => __('PHP Error Log (recent entries, no absolute paths)', 'pp'));
                $ok['ver'] = true;
                $ok['pp_options'] = true;
                ?>
				<div class="support_data">
				<?php 
                foreach ($avail as $key => $caption) {
                    $id = 'support_data_' . $key;
                    $disabled = in_array($key, array('ver', 'pp_options')) ? 'disabled="disabled"' : '';
                    ?>
					<div>
					<label for="<?php 
                    echo $id;
                    ?>
"><input type="checkbox" id="<?php 
                    echo $id;
                    ?>
" name="support_data[<?php 
                    echo $key;
                    ?>
]" value="1" <?php 
                    echo $disabled;
                    checked('1', !empty($ok[$key]), true);
                    ?>
 /> <?php 
                    echo $caption;
                    ?>
</label>
					</div>
				<?php 
                }
                ?>
				</div>
				
				<div>
				<label for="pp_support_data_all"><input type="checkbox" id="pp_support_data_all" value="1" /> <?php 
                _e('(all)', 'pp');
                ?>
</label>
				</div>
				
				<div style="margin-top:10px">
				<?php 
                _e('<strong>note:</strong> user data, absolute paths, database prefix, post title, post content and post excerpt are <strong>never</strong> uploaded', 'pp');
                ?>
				</div>
				
				</div>
				<?php 
            } else {
                ?>
				<div>
				<?php 
                _e('Purchase of a support key enables access to the following resources:', 'pp');
                ?>
				</div>
	
				<ul class="pp-support-list pp-bullet-list">
				<!-- <li><a href='http://presspermit.com/docs/' target='pp_doc'><?php 
                _e('Pro Documentation on presspermit.com', 'pp');
                ?>
</a></li> -->
				<li><a href='http://presspermit.com/forums/' target='pp_forum'><?php 
                _e('Pro Support Forums on presspermit.com', 'pp');
                ?>
</a></li>
				<li><?php 
                _e('Optional uploading of your site configuration to assist troubleshooting', 'pp');
                ?>
</li>
				</ul>
				<?php 
            }
            if (version_compare(PPC_VERSION, '1.0', '<')) {
                echo '<div>';
                _e('Note that these resources may be unavailable or incomplete during the project\'s initial beta phase.', 'pp');
                echo '</div>';
            }
            ?>
			</td></tr>
		<?php 
        }
        // any options accessable in this section
        if (!empty($activated)) {
            $section = 'beta_updates';
            // --- BETA UPDATES SECTION ---
            if (!empty($ui->form_options[$tab][$section]) && !$suppress_updates && $ppcom_connect) {
                ?>
				<tr><th scope="row"><?php 
                echo $ui->section_captions[$tab][$section];
                ?>
</th><td>
				<?php 
                if (preg_match("/dev|alpha|beta|rc/i", PPC_VERSION) && version_compare(PPC_VERSION, '0.9', '>')) {
                    $hint = __('If you have already received a beta update and want to switch back to the current production version, switch off this option and click Update. Then look for an update prompt in the Plugins list.', 'pp');
                } else {
                    $hint = '';
                }
                $ui->option_checkbox('beta_updates', $tab, $section, $hint);
                ?>
				</td></tr>
				<?php 
            }
            // any options accessable in this section
        }
    }
Ejemplo n.º 12
0
    function options_ui()
    {
        global $pp_options_ui;
        $ui = $pp_options_ui;
        // shorten syntax
        $tab = 'advanced';
        $section = 'enable';
        // --- ENABLE SECTION ---
        if (!empty($ui->form_options[$tab][$section])) {
            ?>
			<tr><th scope="row"><?php 
            echo $ui->section_captions[$tab][$section];
            ?>
</th><td>
			<?php 
            $hint = '';
            $ui->option_checkbox('advanced_options', $tab, $section, $hint);
            ?>
			</td></tr>
		<?php 
        }
        // any options accessable in this section
        $section = 'file_filtering';
        if ($this->enabled || true || PP_MULTISITE) {
            ?>
		<tr><th scope="row"><?php 
            echo $ui->section_captions[$tab][$section];
            ?>
</th><td>
		<?php 
            if (defined('PPFF_VERSION')) {
                do_action('ppff_pp_option_hint');
            } else {
                _e('To filter access to attached files, install the Press Permit File URL Filter extension.', 'pp');
                echo '<br />';
            }
            ?>
		</td></tr>
		<?php 
        }
        if ($this->enabled) {
            $section = 'anonymous';
            // --- ANONYMOUS USERS SECTION ---
            if (!empty($ui->form_options[$tab][$section])) {
                ?>
				<tr><th scope="row"><?php 
                echo $ui->section_captions[$tab][$section];
                ?>
</th><td>
				<?php 
                $hint = sprintf(__('Disable PP filtering for users who are not logged in. %1$sNote that this performance enhancement will make reading exceptions ineffective%2$s.', 'pp'), '<span class="pp-warning"><strong>', '</strong></span>');
                $ui->option_checkbox('anonymous_unfiltered', $tab, $section, $hint);
                $hint = __('If checked, pages blocked from the "All" or "Authenticated" groups will still be listed to Administrators.', 'pp');
                $ui->option_checkbox('suppress_administrator_metagroups', $tab, $section, $hint);
                do_action('pp_options_ui_insertion', $tab, $section);
                ?>
				</td></tr>
			<?php 
            }
            // any options accessable in this section
            $section = 'custom_statuses';
            // --- CUSTOM POST STATUSES SECTION ---
            if (!empty($ui->form_options[$tab][$section])) {
                ?>
				<tr><th scope="row"><?php 
                echo $ui->section_captions[$tab][$section];
                ?>
</th><td>
				<?php 
                do_action('pp_options_ui_insertion', $tab, $section);
                ?>
				</td></tr>
			<?php 
            }
            // any options accessable in this section
            $section = 'permissions_admin';
            // --- PERMISSIONS ADMIN SECTION ---
            if (!empty($ui->form_options[$tab][$section])) {
                ?>
				<tr><th scope="row"><?php 
                echo $ui->section_captions[$tab][$section];
                ?>
</th><td>
				<?php 
                $hint = __('If enabled, users with the pp_set_read_exceptions capability in the WP role can set reading exceptions for their editable posts.', 'pp');
                $ui->option_checkbox('non_admins_set_read_exceptions', $tab, $section, $hint);
                do_action('pp_options_ui_insertion', $tab, $section);
                ?>
				</td></tr>
			<?php 
            }
            // any options accessable in this section
            $section = 'capabilities';
            // --- PP CAPABILITIES SECTION ---
            ?>
				<tr><td scope="row" colspan="2"><span style="font-weight:bold"><?php 
            echo $ui->section_captions[$tab][$section];
            ?>
</span>
				<span style="margin-left:125px">
				<?php 
            if (pp_get_option('display_hints')) {
                ?>
					<span class="pp-subtext">
					<?php 
                if (ppc_is_plugin_active('capsman-enhanced')) {
                    $url = 'admin.php?page=capsman';
                    printf(__('You can customize Press Permit administration capabilities %1$s for any WP role%2$s:', 'pp'), '<a href="' . $url . '">', '</a>');
                } else {
                    printf(__('You can customize Press Permit administration capabilities by using a WP role editor such as %1$s:', 'pp'), '<span class="plugins update-message"><a href="' . pp_plugin_info_url('capability-manager-enhanced') . '" class="thickbox" title=" Capability Manager Enhanced">Capability&nbsp;Manager&nbsp;Enhanced</a></span>');
                }
                ?>
					</span>
				<?php 
            }
            ?>
				</span>
				
	
				<table id="pp_cap_descripts">
				<thead>
				<tr>
				<th class="cap-name"><?php 
            _e('Capability Name', 'pp');
            ?>
</th>
				<th><?php 
            echo __ppw('Description', 'pp');
            ?>
</th>
				</tr>
				</thead>
				<tbody>
				
				<?php 
            $pp_caps = array('pp_manage_settings' => __('Modify these Press Permit settings', 'pp'), 'pp_unfiltered' => __('Press Permit does not apply any supplemental roles or exceptions to limit or expand viewing or editing access', 'pp'), 'pp_administer_content' => __('PP implicitly grants capabilities for all post types and statuses, but does not apply exceptions', 'pp'), 'pp_create_groups' => __('Can create Permission Groups', 'pp'), 'pp_edit_groups' => __('Can edit all Permission Groups (barring Exceptions)', 'pp'), 'pp_delete_groups' => __('Can delete Permission Groups', 'pp'), 'pp_manage_members' => __('If group editing is allowed, can also modify group membership', 'pp'), 'pp_assign_roles' => __('Assign supplemental Roles or Exceptions. Other capabilities may also be required.', 'pp'), 'pp_set_read_exceptions' => __('Set Reading Exceptions for editable posts on Edit Post/Term screen (for non-Administrators lacking edit_users capability; may be disabled by PP option)', 'pp'));
            if (!defined('PPCE_VERSION') && !pp_key_active()) {
                if (class_exists('Fork')) {
                    $pp_caps['pp_set_fork_exceptions'] = __('(PP Pro capability)', 'pp');
                }
                if (defined('RVY_VERSION')) {
                    $pp_caps['pp_set_revise_exceptions'] = __('(PP Pro capability)', 'pp');
                }
                $pp_caps = array_merge($pp_caps, array('pp_set_edit_exceptions' => __('(PP Pro capability)', 'pp'), 'pp_set_associate_exceptions' => __('(PP Pro capability)', 'pp'), 'pp_set_term_assign_exceptions' => __('(PP Pro capability)', 'pp'), 'pp_set_term_manage_exceptions' => __('(PP Pro capability)', 'pp'), 'pp_set_term_associate_exceptions' => __('(PP Pro capability)', 'pp'), 'list_others_unattached_files' => __('(PP Pro capability)', 'pp'), 'edit_own_attachments' => __('(PP Pro capability)', 'pp')));
            }
            if (!defined('PPS_VERSION') && !pp_key_active()) {
                $pp_caps = array_merge($pp_caps, array('pp_define_post_status' => __('(PP Pro capability)', 'pp'), 'pp_define_moderation' => __('(PP Pro capability)', 'pp'), 'pp_define_privacy' => __('(PP Pro capability)', 'pp'), 'set_posts_status' => __('(PP Pro capability)', 'pp'), 'pp_moderate_any' => __('(PP Pro capability)', 'pp')));
            }
            $pp_caps = apply_filters('pp_cap_descriptions', $pp_caps);
            foreach ($pp_caps as $cap_name => $descript) {
                ?>
				<tr>
				<td class="cap-name"><?php 
                echo $cap_name;
                ?>
</td>
				<td><?php 
                echo $descript;
                ?>
</td>
				</tr>
				<?php 
            }
            ?>
				</tbody>
				</table>

	
				</td></tr>
			<?php 
            $section = 'misc';
            // --- MISC SECTION ---
            if (!empty($ui->form_options[$tab][$section])) {
                ?>
				<tr><th scope="row"><?php 
                echo $ui->section_captions[$tab][$section];
                ?>
</th><td>
				<?php 
                $hint = __('Display a role dropdown alongside the user search input box to narrow results.', 'pp');
                $ui->option_checkbox('user_search_by_role', $tab, $section, $hint);
                $hint = __('Display additional descriptions in role assignment and options UI.', 'pp');
                $ui->option_checkbox('display_hints', $tab, $section, $hint);
                $hint = __('Display descriptive captions for additional functionality provided by missing or deactivated extension plugins (Press Permit Pro package).', 'pp');
                $ui->option_checkbox('display_extension_hints', $tab, $section, $hint);
                ?>
				</td></tr>
			<?php 
            }
            // any options accessable in this section
            $section = 'role_integration';
            // --- ROLE INTEGRATION SECTION ---
            if (!empty($ui->form_options[$tab][$section])) {
                ?>
				<tr><th scope="row"><?php 
                echo $ui->section_captions[$tab][$section];
                ?>
</th><td>
				<?php 
                $hint = __('Detect user roles which are appended dynamically but not stored to the WP database. May be useful for sites that sync with Active Directory or other external user registration systems.', 'pp');
                $args = defined('PP_FORCE_DYNAMIC_ROLES') ? array('val' => 1, 'no_storage' => true, 'disabled' => true) : array();
                $ui->option_checkbox('dynamic_wp_roles', $tab, $section, $hint, '', $args);
                ?>
				</td></tr>
			<?php 
            }
            // any options accessable in this section
        }
        // endif advanced options enabled
        if (PP_MULTISITE) {
            $section = 'network';
            ?>
			<tr><th scope="row"><?php 
            echo $ui->section_captions[$tab][$section];
            ?>
</th><td>

			<div id="pp_modify_default_settings" style="max-width:700px">
			<?php 
            _e('To modify one or more default settings network-wide, <strong>copy</strong> the following code into your theme&apos;s <strong>functions.php</strong> file (or some other file which is always executed and not auto-updated) and modify as desired:', 'pp');
            ?>
			<textarea rows='10' cols='150' readonly='readonly' style="margin-top:5px">
// Use this filter if you want to change the default, but still allow manual setting
add_filter( 'pp_default_options', 'my_pp_default_options', 99 );

function my_pp_default_options( $def_options ) {
	// Array key corresponds to name attributes of checkboxes, dropdowns and input boxes. Modify for desired default settings.

	$def_options['new_user_groups_ui'] = 0;
	
	return $def_options;
}
			</textarea>
			</div>
			<br />
			
			<div id="pp_force_settings" style="max-width:700px">
			<?php 
            _e('To force the value of one or more settings network-wide, <strong>copy</strong> the following code into your theme&apos;s <strong>functions.php</strong> file (or some other file which is always executed and not auto-updated) and modify as desired:', 'pp');
            ?>
			<textarea rows='13' cols='150' readonly='readonly' style="margin-top:5px">
// Use this filter if you want to force an option, blocking/disregarding manual setting
add_filter( 'pp_options', 'my_pp_options', 99 );

// Use this filter if you also want to hide an option from the PP settings screen (works for most options)
add_filter( 'pp_hide_options', 'my_pp_options', 99 );

function my_pp_options( $options ) {
	// Array key corresponds to pp_prefixed name attributes of checkboxes, dropdowns and input boxes. Modify for desired settings.

	$options['pp_new_user_groups_ui'] = 1;
	$options['pp_display_hints'] = 0;	// note: advanced options can be forced here even if advanced settings are disabled
	
	return $options;
}
			</textarea>
			</div>
			
			</td></tr>
		<?php 
        }
        // endif multisite
    }
Ejemplo n.º 13
0
 /**
  * Generate HTML for a single row on the PP Role Groups admin panel.
  *
  * @param object $user_object
  * @param string $style Optional. Attributes added to the TR element.  Must be sanitized.
  * @param int $num_users Optional. User count to display for this group.
  * @return string
  */
 function single_row($group_object, $style = '')
 {
     //$group_object = sanitize_user_object( $group_object, 'display' );
     global $pp_admin;
     static $base_url;
     static $members_cap;
     static $is_administrator;
     if (!isset($base_url)) {
         $base_url = apply_filters('pp_groups_base_url', 'admin.php');
         // @todo: filter based on menu usage
         $is_administrator = pp_is_user_administrator();
     }
     /*
     if ( ! $is_administrator ) {
     	$members_cap = apply_filters( 'pp_edit_groups_reqd_caps', array('pp_manage_members'), 'edit-members' );
     }
     */
     $group_id = $group_object->ID;
     if ($group_object->metagroup_id) {
         if ('rvy_notice' == $group_object->metagroup_type && !defined('RVY_VERSION')) {
             return;
         }
         require_once PPC_ABSPATH . '/groups-retrieval_pp.php';
         $group_object->group_name = PP_GroupRetrieval::get_metagroup_name($group_object->metagroup_type, $group_object->metagroup_id, $group_object->group_name);
         $group_object->group_description = PP_GroupRetrieval::get_metagroup_descript($group_object->metagroup_type, $group_object->metagroup_id, $group_object->group_description);
     }
     $group_object->group_name = stripslashes($group_object->group_name);
     $group_object->group_description = stripslashes($group_object->group_description);
     // Set up the hover actions for this user
     $actions = array();
     $checkbox = '';
     $can_manage_group = $is_administrator || pp_has_group_cap('pp_edit_groups', $group_id, $this->agent_type);
     $agent_type_clause = $this->agent_type && 'pp_group' != $this->agent_type ? "&amp;agent_type={$this->agent_type}" : '';
     // Check if the group for this row is editable
     if ($can_manage_group) {
         $edit_link = $base_url . "?page=pp-edit-permissions&amp;action=edit{$agent_type_clause}&amp;agent_id={$group_id}";
         $edit = "<strong><a href=\"{$edit_link}\">{$group_object->group_name}</a></strong><br />";
         $actions['edit'] = '<a href="' . $edit_link . '">' . __ppw('Edit') . '</a>';
     } else {
         $edit_link = '';
         $edit = '<strong>' . $group_object->group_name . '</strong>';
     }
     $can_delete_group = $is_administrator || current_user_can('pp_delete_groups', $group_id);
     if ($can_delete_group && !$group_object->metagroup_id) {
         $actions['delete'] = "<a class='submitdelete' href='" . wp_nonce_url($base_url . "?page=pp-groups&amp;pp_action=delete{$agent_type_clause}&amp;group={$group_id}", 'bulk-groups') . "'>" . __('Delete') . "</a>";
     }
     $actions = apply_filters('pp_group_row_actions', $actions, $group_object);
     $edit .= $this->row_actions($actions);
     // Set up the checkbox ( because the group or group members are editable, otherwise it's empty )
     if ($actions && !$group_object->metagroup_id) {
         $checkbox = "<input type='checkbox' name='groups[]' id='group_{$group_id}' value='{$group_id}' />";
     } else {
         $checkbox = '';
     }
     //$avatar = get_avatar( $user_object->ID, 32 );
     $r = "<tr id='group-{$group_id}'{$style}>";
     list($columns, $hidden) = $this->get_column_info();
     foreach ($columns as $column_name => $column_display_name) {
         $class = "class=\"{$column_name} column-{$column_name}\"";
         $style = '';
         if (in_array($column_name, $hidden)) {
             $style = ' style="display:none;"';
         }
         $attributes = "{$class}{$style}";
         switch ($column_name) {
             case 'cb':
                 $r .= "<th scope='row' class='check-column'>{$checkbox}</th>";
                 break;
             case 'ID':
                 $r .= "<td {$attributes}>{$group_id}</td>";
                 break;
             case 'group_name':
                 $r .= "<td {$attributes}>{$edit}</td>";
                 break;
             case 'num_users':
                 if ('wp_role' == $group_object->metagroup_type) {
                     $num_users = pp_count_role_users($group_object->metagroup_id);
                 } else {
                     $num_users = pp_get_group_members($group_id, $this->agent_type, 'count');
                 }
                 $attributes = 'class="posts column-num_users num"' . $style;
                 $r .= "<td {$attributes}>";
                 /*
                 if ( $members_link )
                 	$r .= "<a href='$members_link'>$num_users</a>";
                 else
                 */
                 if ('wp_role' == $group_object->metagroup_type) {
                     if (in_array($group_object->metagroup_id, array('wp_anon', 'wp_all', 'wp_auth'))) {
                         $r .= '';
                     } else {
                         $user_url = admin_url("users.php?role={$group_object->metagroup_id}");
                         $r .= "<a href='{$user_url}'>{$num_users}</a>";
                     }
                 } else {
                     $r .= $num_users;
                 }
                 $r .= "</td>";
                 break;
             case 'roles':
             case 'exceptions':
                 $r .= $this->single_row_role_column($column_name, $group_id, $can_manage_group, $edit_link, $attributes);
                 break;
             case 'description':
                 $r .= "<td {$attributes}>{$group_object->group_description}</td>";
                 break;
             default:
                 $r .= "<td {$attributes}>";
                 $r .= apply_filters('pp_manage_pp_groups_custom_column', '', $column_name, $group_id);
                 $r .= "</td>";
         }
     }
     $r .= '</tr>';
     return $r;
 }
Ejemplo n.º 14
0
    public static function _current_exceptions_ui($exc_results, $args = array())
    {
        global $pp_admin, $pp_role_defs, $pp_data_sources;
        $defaults = array('read_only' => false, 'class' => 'pp-group-roles', 'item_links' => false, 'caption' => '', 'link' => '', 'agent_type' => '');
        $args = array_merge($defaults, $args);
        extract($args);
        if (!$exc_results) {
            return;
        }
        if (!$caption) {
            $caption = 'user' == $agent_type ? sprintf(__('Exceptions %1$s(for user)%2$s', 'pp'), '<small>', '</small>') : __('Exceptions', 'pp');
        }
        require_once PPC_ABSPATH . '/lib/ancestry_lib_pp.php';
        $can_assign = current_user_can('pp_assign_roles') && pp_bulk_roles_enabled();
        $exceptions = array_fill_keys(array_merge(array('term', 'post'), pp_get_group_types()), array());
        $item_paths = array_fill_keys(array_keys($exceptions), array(__('(none)', 'pp')));
        // support imported include exception with no items included
        $post_types = pp_get_enabled_post_types(array(), 'names');
        $taxonomies = pp_get_enabled_taxonomies(array('object_type' => false), 'names');
        foreach ($exc_results as $row) {
            // object_type not strictly necessary here, included for consistency with term role array
            switch ($row->via_item_source) {
                case 'term':
                    if ($row->item_id) {
                        $taxonomy = '';
                        $term_id = (int) pp_ttid_to_termid($row->item_id, $taxonomy);
                        if ($row->item_id) {
                            $item_paths['term'][$row->item_id] = PP_Ancestry::get_term_path($term_id, $taxonomy);
                        }
                        $via_type = $taxonomy;
                    } else {
                        $via_type = $row->via_item_type;
                    }
                    break;
                case 'post':
                    if ($row->item_id) {
                        $item_paths['post'][$row->item_id] = PP_Ancestry::get_post_path($row->item_id);
                    }
                    // no break
                // no break
                default:
                    if (pp_group_type_exists($row->via_item_source)) {
                        static $groups_by_id;
                        if (!isset($groups_by_id)) {
                            $groups_by_id = array();
                        }
                        if (!isset($groups_by_id[$row->via_item_source])) {
                            $groups_by_id[$row->via_item_source] = array();
                            foreach (pp_get_groups($row->via_item_source, array('skip_meta_types' => 'wp_role')) as $group) {
                                $groups_by_id[$row->via_item_source][$group->ID] = $group->name;
                            }
                        }
                        if (isset($groups_by_id[$row->via_item_source][$row->item_id])) {
                            $item_paths[$row->via_item_source][$row->item_id] = $groups_by_id[$row->via_item_source][$row->item_id];
                        }
                        $via_type = $row->via_item_source;
                    } else {
                        $via_type = $row->via_item_type ? $row->via_item_type : $row->for_item_type;
                    }
            }
            if (!isset($exceptions[$row->via_item_source][$via_type])) {
                $exceptions[$row->via_item_source][$via_type] = array();
            }
            if (!isset($exceptions[$row->via_item_source][$via_type][$row->for_item_type])) {
                $exceptions[$row->via_item_source][$via_type][$row->for_item_type] = array();
            }
            if (!isset($exceptions[$row->via_item_source][$via_type][$row->for_item_type][$row->operation])) {
                $exceptions[$row->via_item_source][$via_type][$row->for_item_type][$row->operation] = array();
            }
            if (!isset($exceptions[$row->via_item_source][$via_type][$row->for_item_type][$row->operation][$row->mod_type])) {
                $exceptions[$row->via_item_source][$via_type][$row->for_item_type][$row->operation][$row->mod_type] = array();
            }
            if (!isset($exceptions[$row->via_item_source][$via_type][$row->for_item_type][$row->operation][$row->mod_type][$row->for_item_status])) {
                $exceptions[$row->via_item_source][$via_type][$row->for_item_type][$row->operation][$row->mod_type][$row->for_item_status] = array();
            }
            if (!isset($exceptions[$row->via_item_source][$via_type][$row->for_item_type][$row->operation][$row->mod_type][$row->for_item_status][$row->item_id])) {
                $exceptions[$row->via_item_source][$via_type][$row->for_item_type][$row->operation][$row->mod_type][$row->for_item_status][$row->item_id] = array();
            }
            $exceptions[$row->via_item_source][$via_type][$row->for_item_type][$row->operation][$row->mod_type][$row->for_item_status][$row->item_id][$row->assign_for] = $row->eitem_id;
            if (!empty($row->inherited_from)) {
                $exceptions[$row->via_item_source][$via_type][$row->for_item_type][$row->operation][$row->mod_type][$row->for_item_status][$row->item_id]['inherited_from'] = $row->inherited_from;
            }
        }
        echo '<div style="clear:both;"></div>' . "<div id='pp_current_exceptions' class='pp-group-box {$class}'>" . '<h3>';
        if ($link) {
            echo "<a href='{$link}'>{$caption}</a>";
        } else {
            echo $caption;
        }
        echo '</h3>';
        echo '<div>';
        echo '<div id="pp_current_exceptions_inner">';
        //ksort( $type_roles );
        if (empty($_REQUEST['all_types']) && !empty($exceptions['post'])) {
            $all_types = array_fill_keys(array_merge($post_types, $taxonomies, array('')), true);
            $all_types = array_diff_key($all_types, array('topic' => true, 'reply' => true));
            // hide topic, reply assignments even if they are somehow saved/imported without inherited_from value
            $exceptions['post'] = array_intersect_key($exceptions['post'], $all_types);
            foreach (array_keys($exceptions['post']) as $key) {
                $exceptions['post'][$key] = array_intersect_key($exceptions['post'][$key], $all_types);
            }
        }
        foreach (array_keys($exceptions) as $via_src) {
            ksort($exceptions[$via_src]);
            foreach (array_keys($exceptions[$via_src]) as $via_type) {
                if ($via_type_obj = pp_get_type_object($via_src, $via_type)) {
                    $via_type_caption = $via_type_obj->labels->singular_name;
                } else {
                    continue;
                }
                $any_redundant = false;
                echo "<div id='pp_current_{$via_src}_{$via_type}_roles' class='pp-current-exceptions'>";
                /*
                if ( 'term' == $via_src )
                	echo '<h4>' . __( 'Per-Term:', 'pp' ) . '</h4>';
                else {
                	if ( $object_type )
                		echo '<h4>' . sprintf( __( 'Per-%s:', 'pp' ), $type_caption ) . '</h4>';
                	else
                		echo '<h4>' . sprintf( __( 'Per-object:', 'pp' ), $type_caption ) . '</h4>';
                }
                
                echo '<h4>' . sprintf( __( '%s Exceptions', 'pp' ), $via_type_caption ) . '</h4>';
                */
                ksort($exceptions[$via_src][$via_type]);
                foreach (array_keys($exceptions[$via_src][$via_type]) as $for_type) {
                    if (pp_group_type_exists($for_type)) {
                        $for_src = $for_type;
                    } else {
                        $for_src = taxonomy_exists($for_type) || !$for_type ? 'term' : 'post';
                    }
                    if (!$for_type) {
                        $for_type_obj = (object) array('labels' => (object) array('singular_name' => __('(all post types)', 'pp')));
                    } elseif (!($for_type_obj = pp_get_type_object($for_src, $for_type))) {
                        continue;
                    }
                    foreach (array_keys($exceptions[$via_src][$via_type][$for_type]) as $operation) {
                        if (!($operation_obj = pp_get_op_object($operation, $for_type))) {
                            continue;
                        }
                        if ('assign' == $operation) {
                            $op_caption = $for_type ? sprintf(__('%1$s (%2$s: %3$s)', 'pp'), $operation_obj->label, $for_type_obj->labels->singular_name, $via_type_caption) : sprintf(__('%1$s %2$s %3$s', 'pp'), $operation_obj->label, $via_type_caption, $for_type_obj->labels->singular_name);
                        } elseif (in_array($operation, array('manage', 'associate'))) {
                            $op_caption = sprintf(__('%1$s %2$s', 'pp'), $operation_obj->label, $via_type_caption);
                        } else {
                            $op_caption = sprintf(__('%1$s %2$s', 'pp'), $operation_obj->label, $for_type_obj->labels->singular_name);
                        }
                        echo "<div class='type-roles-wrapper'>";
                        echo '<h4>' . $op_caption . '</h4>';
                        echo "<div class='pp-current-type-roles'>";
                        echo '<div class="pp-current-roles-tbl-wrapper"><table>';
                        // fill table body (item assignments for each role)
                        echo '<tbody>';
                        foreach (array_keys($exceptions[$via_src][$via_type][$for_type][$operation]) as $mod_type) {
                            if (!($mod_type_obj = pp_get_mod_object($mod_type))) {
                                continue;
                            }
                            foreach (array_keys($exceptions[$via_src][$via_type][$for_type][$operation][$mod_type]) as $status) {
                                if ($status) {
                                    $_status = explode(':', $status);
                                    if (count($_status) > 1) {
                                        $attrib = $_status[0];
                                        $_status = $_status[1];
                                    } else {
                                        $attrib = 'post_status';
                                        $_status = $status;
                                    }
                                    if ('post_status' == $attrib) {
                                        if ($status_obj = get_post_status_object($_status)) {
                                            $status_label = $status_obj->label;
                                        } elseif ('{unpublished}' == $_status) {
                                            // @todo: API
                                            $status_label = __('unpublished', 'pp');
                                        } else {
                                            $status_label = $status;
                                        }
                                    } else {
                                        $status_label = $status;
                                    }
                                    $mod_caption = sprintf(__('%1$s (%2$s)', 'pp'), $mod_type_obj->label, $status_label);
                                } else {
                                    $mod_caption = $mod_type_obj->label;
                                }
                                if ('exclude' == $mod_type && !empty($exceptions[$via_src][$via_type][$for_type][$operation]['include'])) {
                                    $tr_class = ' class="pp_faded"';
                                    $mod_caption = sprintf(__('* %s', 'pp'), $mod_caption);
                                    $any_faded = true;
                                } else {
                                    $tr_class = '';
                                }
                                echo "<tr{$tr_class}><td class='pp_item_role_caption'>{$mod_caption}</td>";
                                echo '<td>';
                                //if ( $item_links ) {
                                //	if ( 'term' != $scope )
                                //		$edit_url_base = $pp_data_sources->member_property( $item_source, '_edit_link' );
                                //}
                                echo "<div class='pp-role-terms-wrapper pp-role-terms-{$via_type}'>";
                                if ('term' == $via_src && !in_array($operation, array('manage', 'associate'))) {
                                    if (taxonomy_exists($via_type)) {
                                        // "Categories:"
                                        $tx_obj = get_taxonomy($via_type);
                                        $tx_caption = $tx_obj->labels->name;
                                    } else {
                                        $tx_caption = '';
                                    }
                                    echo '<div class="pp-taxonomy-caption">' . sprintf(__('%s:', 'pp'), $tx_caption) . '</div>';
                                    //$edit_url_base = ( isset($tx_obj->_edit_link) ) ? $tx_obj->_edit_link : '';
                                }
                                echo '<div class="pp-role-terms">';
                                $tx_item_paths = array_intersect_key($item_paths[$via_src], $exceptions[$via_src][$via_type][$for_type][$operation][$mod_type][$status]);
                                uasort($tx_item_paths, 'strnatcasecmp');
                                // sort by array values, but maintain keys );
                                foreach ($tx_item_paths as $item_id => $item_path) {
                                    //$assignment = $roles[$scope][$role_name][$item_source][$item_type][$item_id];
                                    $assignment = $exceptions[$via_src][$via_type][$for_type][$operation][$mod_type][$status][$item_id];
                                    $classes = array();
                                    if (isset($assignment['children'])) {
                                        if (isset($assignment['item'])) {
                                            $ass_id = $assignment['item'] . ',' . $assignment['children'];
                                            $classes[] = 'role_both';
                                            $any_both = true;
                                        } else {
                                            $ass_id = '0,' . $assignment['children'];
                                            $classes[] = 'role_ch';
                                            $any_child_only = true;
                                        }
                                    } else {
                                        $ass_id = $assignment['item'];
                                    }
                                    $class = $classes ? "class='" . implode(' ', $classes) . "'" : '';
                                    if ($read_only) {
                                        if ($item_links) {
                                            //$item_edit_url = sprintf($edit_url_base, $item_id);
                                            $item_edit_url = '';
                                            echo "<div><a href='{$item_edit_url}' {$class}>{$item_path}</a></div>";
                                        } else {
                                            echo "<div><span {$class}>{$item_path}</span></div>";
                                        }
                                    } else {
                                        $cb_id = 'pp_edit_exception_' . str_replace(',', '_', $ass_id);
                                        if (!empty($assignment['inherited_from'])) {
                                            $classes[] = 'inherited';
                                            $classes[] = "from_{$assignment['inherited_from']}";
                                        }
                                        if ($tr_class) {
                                            // apply fading for redundantly stored exclusions
                                            $classes[] = $tr_class;
                                        }
                                        $lbl_class = $classes ? "class='" . implode(' ', $classes) . "'" : '';
                                        if ('term' == $via_src) {
                                            $edit_url = admin_url("edit-tags.php?taxonomy={$via_type}&action=edit&tag_ID=" . pp_ttid_to_termid($item_id, $via_type) . "&post_type={$for_type}");
                                        } else {
                                            $edit_url = admin_url("post.php?post={$item_id}&action=edit");
                                        }
                                        echo "<div><label for='{$cb_id}' {$lbl_class}><input id='{$cb_id}' type='checkbox' name='pp_edit_exception[]' value='{$ass_id}' {$class}> " . $item_path . '</label><a href="' . $edit_url . '">' . __('edit') . '</a></div>';
                                    }
                                }
                                // end foreach item
                                if (count($tx_item_paths) > 3 && !$read_only) {
                                    $cb_id = "pp_check_all_{$via_src}_{$via_type}_{$for_type}_{$operation}_{$status}";
                                    echo "<div><label for='{$cb_id}'><input type='checkbox' id='{$cb_id}' class='pp_check_all'> " . __('(all)', 'pp') . '</label></div>';
                                }
                                echo '</div></div>';
                                // pp-role-terms, pp-role-terms-wrapper
                                echo '</td></tr>';
                            }
                            // end foreach status
                        }
                        // end foreach mod_type
                        echo '</tbody>';
                        echo '</table></div>';
                        // pp-current-roles-tbl-wrapper
                        echo '<div class="pp-exception-bulk-edit" style="display:none">';
                        echo "<select><option value=''>" . __ppw('Bulk Actions', 'pp') . "</option><option value='remove'>" . __ppw('Remove', 'pp') . '</option>';
                        if ('post' == $via_src && (!$via_type || $via_type_obj->hierarchical)) {
                            echo "<option value='propagate'>" . sprintf(__('Assign for selected and sub-%s', 'pp'), $via_type_obj->labels->name) . '</option>';
                            echo "<option value='unpropagate'>" . sprintf(__('Assign for selected %s only', 'pp'), $via_type_obj->labels->singular_name) . '</option>';
                            echo "<option value='children_only'>" . sprintf(__('Assign for sub-%s only', 'pp'), $via_type_obj->labels->name) . '</option>';
                        } elseif ('term' == $via_src && $via_type_obj->hierarchical) {
                            echo "<option value='propagate'>" . __('Assign for selected and sub-terms', 'pp') . '</option>';
                            echo "<option value='unpropagate'>" . __('Assign for selected term only', 'pp') . '</option>';
                            echo "<option value='children_only'>" . __('Assign for sub-terms only', 'pp') . '</option>';
                        }
                        echo '</select>';
                        //submit_button( __ppw('Apply'), 'button-secondary submit-edit-item-exception', '', false );
                        ?>
						<input type="submit" name="" class="button submit-edit-item-exception" value="<?php 
                        _e('Apply', 'pp');
                        ?>
" />
						<?php 
                        echo '<img class="waiting" style="display:none;" src="' . esc_url(admin_url('images/wpspin_light.gif')) . '" alt="" />';
                        echo '</div>';
                        // pp-exception-bulk-edit
                        echo '</div></div>';
                        // type-roles-wrapper, pp-current-type-roles
                    }
                    // end foreach operation
                }
                // end foreach for_type
                if ($any_redundant) {
                    echo '<div class="pp-current-roles-note">' . __('* = exceptions redundant due to a corresponding &quot;only these&quot; entry', 'pp') . '</div>';
                }
                if (!empty($via_type_obj->hierarchical)) {
                    $_caption = strtolower($via_type_obj->labels->name);
                    if (!empty($any_both) || !empty($any_child_only)) {
                        ?>
						<div class="pp-current-roles-note">

						<?php 
                        if (!empty($any_both)) {
                            echo '<span class="role_both" style="padding-right:20px">' . sprintf(__('... = assigned for %1$s and sub-%1$s', 'pp'), $_caption) . '</span>';
                        }
                        if (!empty($any_child_only)) {
                            echo '<span>' . sprintf(__('* = assigned for sub-%s only', 'pp'), $_caption) . '</span>';
                        }
                        ?>
						</div>
					<?php 
                    }
                    $show_all_url = esc_url(add_query_arg('show_propagated', '1', $_SERVER['REQUEST_URI']));
                    $show_all_link = "&nbsp;&nbsp;<a href='{$show_all_url}'>";
                    if (empty($_REQUEST['show_propagated'])) {
                        if ('term' == $via_src) {
                            echo '<div class="pp-current-roles-note">' . sprintf(__('note: Exceptions inherited from parent %1$s are not displayed. %2$sshow all%3$s', 'pp'), $_caption, $show_all_link, '</a>') . '</div>';
                        } else {
                            echo '<div class="pp-current-roles-note">' . sprintf(__('note: Exceptions inherited from parent %1$s or terms are not displayed. %2$sshow all%3$s', 'pp'), $_caption, $show_all_link, '</a>') . '</div>';
                        }
                    }
                }
                echo '</div>';
                // pp-current-exceptions
            }
            // end foreach via_type
        }
        // end foreach via_src
        echo '</div>';
        // pp_current_exceptions_inner
        echo '</div>';
        // no class
        echo '</div>';
        // pp_current_exceptions
    }
Ejemplo n.º 15
0
 public static function display($agents_subset, $agent_type, $all_agents, $name_attrib, $item_assignments, $args)
 {
     $defaults = array('eligible_ids' => array(), 'locked_ids' => array(), 'add_group_link' => true, 'show_subset_caption' => true, 'hide_checkboxes' => false);
     $args = array_merge($defaults, (array) $args);
     extract($args, EXTR_SKIP);
     $caption_length_limit = defined('PP_AGENTS_CAPTION_LIMIT') ? PP_AGENTS_CAPTION_LIMIT : 20;
     $emsize_threshold = defined('PP_AGENTS_EMSIZE_THRESHOLD') ? PP_AGENTS_EMSIZE_THRESHOLD : 4;
     static $exec_count = 0;
     $exec_count++;
     // support abbreviated checkbox id for label association
     if ('eligible' == $agents_subset) {
         $caption = __('eligible (%d):', 'pp');
         $item_assignments = array_intersect_key($item_assignments, $all_agents);
         if (!($agent_count = count($all_agents) - count($item_assignments))) {
             return;
         }
     } else {
         $caption = __('current (%d):', 'pp');
         $agent_count = count($item_assignments);
     }
     echo "<div>";
     echo "<ul class='pp-list_horiz'><li>";
     if ($show_subset_caption) {
         printf("<div class='pp-agents_caption'><strong>{$caption}</strong></div>", $agent_count);
     }
     echo '</li>';
     echo '</ul>';
     // -------- construct captions and determine required list item width -----------
     $captions = $full_captions = $draw_agents = array();
     global $wp_locale;
     $rtl = isset($wp_locale) && 'rtl' == $wp_locale->text_direction;
     $longest_caption_length = 10;
     foreach ($all_agents as $agent) {
         $id = $agent->ID;
         $skip = false;
         switch ($agents_subset) {
             case 'current':
                 if (!isset($item_assignments[$id])) {
                     $skip = true;
                 }
                 break;
             default:
                 //'eligible'
                 if (isset($item_assignments[$id])) {
                     $skip = true;
                 }
                 if ($eligible_ids && !in_array($id, $eligible_ids)) {
                     $skip = true;
                 }
         }
         if ($skip) {
             unset($all_agents[$id]);
             continue;
         }
         if ('pp_group' == $agent_type && $agent->metagroup_id) {
             $caption = PP_GroupRetrieval::get_metagroup_name($agent->metagroup_type, $agent->metagroup_id, $agent->name);
         } else {
             $caption = $agent->name;
         }
         if (strlen($caption) > $caption_length_limit) {
             $full_captions[$id] = $caption;
             if ($rtl) {
                 $caption = '...' . substr($caption, strlen($caption) - $caption_length_limit);
             } else {
                 $caption = substr($caption, 0, $caption_length_limit) . '...';
             }
         }
         if (strlen($caption) > $longest_caption_length) {
             $longest_caption_length = strlen($caption) >= $caption_length_limit ? $caption_length_limit + 2 : strlen($caption);
         }
         $captions[$id] = $caption;
     }
     //-------- end caption construction --------------
     if ($agent_count > $emsize_threshold) {
         $ems_per_character = defined('PP_UI_EMS_PER_CHARACTER') ? PP_UI_EMS_PER_CHARACTER : 0.85;
         $list_width_ems = $ems_per_character * $longest_caption_length;
         $ul_class = 'pp-agents-list_' . intval($list_width_ems);
         echo "<div id='div_{$agents_subset}_{$name_attrib}' class='pp-{$agent_type} pp-{$agents_subset}'>" . "<div class='pp-agents_emsized'>" . "<ul class='pp-agents-list {$ul_class}' id='list_{$agents_subset}_{$name_attrib}'>";
     } else {
         $ul_class = "pp-agents-list_auto";
         echo "<div class='pp-{$agent_type}'>" . "<ul class='pp-agents-list {$ul_class}' id='list_{$agents_subset}_{$name_attrib}'>";
     }
     if (pp_group_type_editable($agent_type)) {
         $edit_link_base = apply_filters('pp_groups_base_url', 'admin.php') . "?page=pp-edit-permissions&amp;action=edit&amp;agent_type={$agent_type}&amp;agent_id=";
         $edit_title_text = __('view / edit group', 'pp');
         $edit_caption = __ppw('edit', 'pp');
     } else {
         $edit_link_base = '';
     }
     foreach ($all_agents as $agent) {
         $id = $agent->ID;
         if (!empty($agent->metagroup_id)) {
             $display_name = isset($agent->display_name) ? $agent->display_name : '';
             $li_title = "title='" . PP_GroupRetrieval::get_metagroup_descript($agent->metagroup_type, $agent->metagroup_id, $display_name) . "'";
         } elseif (isset($full_captions[$id])) {
             $li_title = "title='{$full_captions[$id]}'";
         } else {
             $li_title = "title='{$captions[$id]}'";
         }
         $checked = isset($item_assignments[$id]) ? ' checked="checked"' : '';
         $disabled = $locked_ids && in_array($id, $locked_ids) ? " disabled='disabled'" : '';
         echo "<li {$li_title}>";
         if ($hide_checkboxes) {
             echo '&bull; ';
         } else {
             echo "<input type='checkbox' name='{$name_attrib}[]'{$disabled}{$checked} value='{$id}' id='r{$exec_count}_{$id}' />";
         }
         echo "<label for='r{$exec_count}_{$id}'>";
         echo ' ' . $captions[$id];
         echo '</label>';
         if ($edit_link_base && pp_has_group_cap('pp_edit_groups', $id, $agent_type)) {
             echo ' <a href=" ' . $edit_link_base . $id . '" style="display:none" target="_blank" title="' . $edit_title_text . '">' . $edit_caption . '</a>';
         }
         echo '</li>';
     }
     //foreach agent
     echo "<li></li></ul>";
     // prevent invalid markup if no other li's
     if ($agent_count > $emsize_threshold) {
         echo '</div>';
     }
     echo '</div></div>';
 }