static function abbreviated_exceptions_ui($agent_type, $agent_id, $args = array()) { $defaults = array('caption' => '', 'edit_url' => '', 'join_groups' => false, 'class' => 'pp-user-roles', 'new_permissions_link' => false, 'maybe_display_note' => true); $args = array_merge($defaults, $args); extract($args, EXTR_SKIP); //static $done = false; //if ( $done ) return; //$done = true; $args['show_link'] = false; $args['force_refresh'] = true; $new_permissions_link = $maybe_display_note && pp_is_user_administrator() && pp_bulk_roles_enabled() && current_user_can('list_users'); if (!($exceptions_ui = ppc_list_agent_exceptions($agent_type, $agent_id, $args))) { if ('user' == $agent_type && $join_groups != 'groups_only' && $new_permissions_link) { ?> <div style="clear:both;"></div> <div id='pp_current_exceptions_ui' class='pp-group-box <?php echo $class; ?> '> <h3> <?php _e('Custom User Permissions', 'pp'); ?> </h3> <p> <?php printf(__('Supplemental roles and exceptions assigned to a user\'s primary role or other Permission Groups are usually the cleanest way to customize permissions. You can also %1$scustomize this user directly%2$s.', 'pp'), "<a href='{$edit_url}'>", '</a>'); ?> </p> </div> <?php } return; } ?> <div style="clear:both;"></div> <div id='pp_current_exceptions_ui' class='pp-group-box <?php echo $class; ?> '> <h3> <?php if ($edit_url) { echo "<a href='{$edit_url}'>{$caption}</a>"; } else { echo $caption; } ?> </h3> <?php echo $exceptions_ui; ?> </div> <?php }
public static function flt_users_custom_column($content = '', $column_name, $id) { switch ($column_name) { case 'pp_groups': global $wp_list_table; //if ( ! $agent_type = apply_filters( 'pp_query_group_type', '' ) ) // $agent_type = 'pp_group'; static $all_groups; static $all_group_types; if (!isset($all_groups)) { $all_groups = array(); $all_group_types = pp_get_group_types(array('editable' => true)); } $all_group_names = array(); foreach ($all_group_types as $agent_type) { if (!isset($all_groups[$agent_type])) { $all_groups[$agent_type] = pp_get_groups($agent_type); } if (empty($all_groups[$agent_type])) { continue; } $group_names = array(); if ($group_ids = pp_get_groups_for_user($id, $agent_type, array('cols' => 'id', 'query_user_ids' => array_keys($wp_list_table->items)))) { foreach (array_keys($group_ids) as $group_id) { if (isset($all_groups[$agent_type][$group_id])) { if (empty($all_groups[$agent_type][$group_id]->metagroup_type) || 'wp_role' != $all_groups[$agent_type][$group_id]->metagroup_type) { $group_names[$all_groups[$agent_type][$group_id]->name] = $group_id; } } } if ($group_names) { uksort($group_names, "strnatcasecmp"); foreach ($group_names as $name => $_id) { if (defined('PP_USERS_UI_GROUP_FILTER_LINK')) { $url = add_query_arg('pp_group', $_id, $_SERVER['REQUEST_URI']); $all_group_names[] = "<a href='{$url}'>{$name}</a>"; } else { $all_group_names[] = "<a href='" . "admin.php?page=pp-edit-permissions&action=edit&agent_type={$agent_type}&agent_id={$_id}'>{$name}</a>"; } } //$group_names = array_merge( $group_names, $this_group_names ); } } } return implode(", ", $all_group_names); break; case 'pp_roles': global $wp_list_table, $wp_roles; static $role_info; $role_str = ''; if (!isset($role_info)) { $role_info = ppc_count_assigned_roles('user', array('query_agent_ids' => array_keys($wp_list_table->items))); } $user_object = new WP_User((int) $id); static $hide_roles; if (!isset($hide_roles)) { $hide_roles = !defined('bbp_get_version') ? array('bbp_participant', 'bbp_moderator', 'bbp_keymaster', 'bbp_blocked', 'bbp_spectator') : array(); $hide_roles = apply_filters('pp_hide_roles', $hide_roles); } $user_object->roles = array_diff($user_object->roles, $hide_roles); $role_titles = array(); foreach ($user_object->roles as $role_name) { if (isset($wp_roles->role_names[$role_name])) { $role_titles[] = $wp_roles->role_names[$role_name]; } } if (isset($role_info[$id]) && isset($role_info[$id]['roles'])) { $role_titles = array_merge($role_titles, array_keys($role_info[$id]['roles'])); } $display_limit = 3; if (count($role_titles) > $display_limit) { $excess = count($role_titles) - $display_limit; $role_titles = array_slice($role_titles, 0, $display_limit); $role_titles[] = sprintf(__('%s more', 'pp'), $excess); } $role_str = '<span class="pp-group-site-roles">' . implode(', ', $role_titles) . '</span>'; if (current_user_can('edit_user', $id) && current_user_can('pp_assign_roles')) { $edit_link = "admin.php?page=pp-edit-permissions&action=edit&agent_id={$id}&agent_type=user"; $role_str = "<a href=\"{$edit_link}\">{$role_str}</a><br />"; } return $role_str; break; case 'pp_exceptions': global $wp_list_table; return ppc_list_agent_exceptions('user', $id, array('query_agent_ids' => array_keys($wp_list_table->items))); break; default: return $content; } }