function prepare_items() { global $groupsearch; $groupsearch = isset($_REQUEST['s']) ? sanitize_text_field($_REQUEST['s']) : ''; $groups_per_page = $this->get_items_per_page('groups_per_page'); $paged = $this->get_pagenum(); $args = array('number' => $groups_per_page, 'offset' => ($paged - 1) * $groups_per_page, 'search' => $groupsearch); $args['search'] = '*' . $args['search'] . '*'; if (isset($_REQUEST['orderby'])) { $args['orderby'] = pp_sanitize_word($_REQUEST['orderby']); } if (isset($_REQUEST['order'])) { $args['order'] = pp_sanitize_word($_REQUEST['order']); } // Query the user IDs for this page $args['agent_type'] = $this->agent_type; $pp_group_search = new PP_Group_Query($args); $this->items = $pp_group_search->get_results(); $this->listed_ids = array(); foreach ($this->items as $group) { $this->listed_ids[] = $group->ID; } $this->role_info = ppc_count_assigned_roles($this->agent_type, array('query_agent_ids' => $this->listed_ids)); $this->exception_info = ppc_count_assigned_exceptions($this->agent_type, array('query_agent_ids' => $this->listed_ids)); $this->set_pagination_args(array('total_items' => $pp_group_search->get_total(), 'per_page' => $groups_per_page)); }
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; } }