Example #1
0
 function get_usergroups_clause($table_alias, $args = array())
 {
     $table_alias = $table_alias ? "{$table_alias}." : '';
     $arr = array();
     $arr[] = "{$table_alias}agent_type = 'user' AND {$table_alias}agent_id = '{$this->ID}'";
     foreach (pp_get_group_types(array(), 'names') as $agent_type) {
         $apply_groups = $this->groups[$agent_type];
         if ('pp_group' == $agent_type && pp_get_option('netwide_groups')) {
             foreach (array_keys($apply_groups) as $k) {
                 if (empty($apply_groups[$k]->metagroup_type)) {
                     unset($apply_groups[$k]);
                 }
             }
         }
         if (!empty($apply_groups)) {
             $arr[] = "{$table_alias}agent_type = '{$agent_type}' AND {$table_alias}agent_id IN ('" . implode("', '", array_keys($apply_groups)) . "')";
         }
     }
     if (!empty($args['user_clause'])) {
         $arr[] = "{$table_alias}agent_type = 'user' AND {$table_alias}agent_id = '{$this->ID}'";
     }
     $clause = pp_implode(' OR ', $arr);
     if (count($arr) > 1) {
         $clause = "( {$clause} )";
     }
     if ($clause) {
         return " AND {$clause}";
     } else {
         return ' AND 1=2';
     }
 }
Example #2
0
 public static function remove_user_groups($user_id, $omit_group_ids = array())
 {
     $group_types = pp_get_group_types(array('editable' => true));
     foreach (pp_get_group_types(array('editable' => true)) as $agent_type) {
         if ('pp_group' == $agent_type && in_array('pp_net_group', $group_types)) {
             continue;
         }
         $posted_groups = isset($_POST[$agent_type]) ? array_map('intval', $_POST[$agent_type]) : array();
         $stored_groups = array_keys(pp_get_groups_for_user($user_id, $agent_type, array('cols' => 'id')));
         if ($omit_group_ids) {
             $stored_groups = array_diff($stored_groups, $omit_group_ids);
         }
         $delete_groups = array_diff($stored_groups, $posted_groups);
         foreach ($delete_groups as $group_id) {
             if (pp_has_group_cap('pp_manage_members', $group_id, $agent_type)) {
                 pp_remove_group_user($group_id, $user_id, compact('agent_type'));
             }
         }
     }
 }
Example #3
0
 function flt_manage_posts_columns($columns)
 {
     if (current_user_can('pp_assign_roles')) {
         if (!isset($this->exceptions)) {
             global $wpdb, $pp, $typenow;
             $this->exceptions = array();
             if (!empty($pp->listed_ids[$typenow])) {
                 $agent_type_csv = implode("','", array_merge(array('user'), pp_get_group_types()));
                 $id_csv = implode("','", array_keys($pp->listed_ids[$typenow]));
                 $results = $wpdb->get_results("SELECT DISTINCT i.item_id, e.operation FROM {$wpdb->ppc_exceptions} AS e INNER JOIN {$wpdb->ppc_exception_items} AS i ON e.exception_id = i.exception_id WHERE e.for_item_source = 'post' AND e.via_item_source = 'post' AND e.agent_type IN ('{$agent_type_csv}') AND i.item_id IN ('{$id_csv}')");
                 foreach ($results as $row) {
                     if (!isset($this->exceptions[$row->item_id])) {
                         $this->exceptions[$row->item_id] = array();
                     }
                     $this->exceptions[$row->item_id][] = $row->operation;
                 }
             }
         }
         if ($this->exceptions) {
             $columns['pp_exceptions'] = __('Exceptions', 'pp');
         }
     }
     return $columns;
 }
Example #4
0
function pp_group_type_editable($agent_type)
{
    return in_array($agent_type, pp_get_group_types(array('editable' => true)));
}
Example #5
0
 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' ) ) { ?> */
 $group_types = array('pp_group' => (object) array('labels' => (object) array('singular_name' => __('Custom Group', 'pp'))));
 if (current_user_can('pp_administer_content')) {
     $group_types['wp_role'] = (object) array('labels' => (object) array('singular_name' => __('WP Role', 'pp')));
 }
 $group_types = apply_filters('pp_list_group_types', array_merge($group_types, pp_get_group_types(array(), 'object')));
 // currently faking WP Role as a "group type", but want it listed before BuddyPress Group
 $links = array();
 foreach ($group_types as $_group_type => $gtype_obj) {
     $agent_type_str = 'wp_role' == $_group_type ? "&agent_type=pp_group" : "&agent_type={$_group_type}";
     $gvar_str = "&group_variant={$_group_type}";
     $class = strpos($agent_type_str, $agent_type) && (!$group_variant || strpos($gvar_str, $group_variant)) ? 'class="current"' : '';
     $links[] = "<li><a href='admin.php?page=pp-groups{$agent_type_str}{$gvar_str}' {$class}>{$gtype_obj->labels->singular_name}</a></li>";
 }
 echo '<ul class="subsubsub">';
 printf(__('%1$sGroup Type:%2$s %3$s', 'pp'), '<li class="pp-gray"><strong>', '</strong></li>', implode('&nbsp;|&nbsp;', $links));
 echo '</ul>';
 if (!empty($groupsearch)) {
     printf('<span class="subtitle">' . __('Search results for &#8220;%s&#8221;') . '</span>', esc_html($groupsearch));
 }
 ?>
Example #6
0
function _ppc_count_assigned_exceptions($agent_type, $args = array())
{
    global $wpdb;
    $defaults = array('query_agent_ids' => false, 'join_groups' => true);
    extract(array_merge($defaults, $args), EXTR_SKIP);
    $item_types = array_merge(pp_get_enabled_post_types(), pp_get_enabled_taxonomies(), pp_get_group_types(array('editable' => true)));
    $type_clause = "AND e.for_item_type IN ('','" . implode("','", $item_types) . "')";
    $type_clause .= " AND e.via_item_type IN ('','" . implode("','", $item_types) . "')";
    $ops_clause = "AND operation IN ('" . implode("','", pp_get_operations()) . "')";
    $count = array();
    $agent_type = pp_sanitize_key($agent_type);
    if ('user' == $agent_type && $join_groups) {
        $results = array();
        foreach (pp_get_group_types(array(), 'object') as $group_type => $gtype_obj) {
            global $wpdb;
            if (!empty($gtype_obj->schema['members'])) {
                extract($gtype_obj->schema['members']);
                // members_table, col_group, col_user
            } else {
                $members_table = $wpdb->pp_group_members;
                $col_member_group = 'group_id';
                $col_member_user = '******';
            }
            $agent_clause = $query_agent_ids ? "AND gm.{$col_member_user} IN ('" . implode("','", (array) $query_agent_ids) . "')" : '';
            if ('groups_only' === $join_groups || 'pp_group' != $group_type) {
                $agent_type_clause = "( e.agent_type = '{$group_type}' AND gm.{$col_member_group} = e.agent_id )";
            } else {
                $agent_type_clause = "( e.agent_type = 'user' AND gm.user_id = e.agent_id ) OR ( e.agent_type = 'pp_group' AND gm.group_id = e.agent_id )";
            }
            $_results = $wpdb->get_results("SELECT gm.{$col_member_user} as qry_agent_id, e.exception_id, e.for_item_source, e.for_item_type, e.via_item_type, e.operation, COUNT(DISTINCT i.exception_id, i.item_id) AS exc_count FROM {$wpdb->ppc_exception_items} AS i INNER JOIN {$wpdb->ppc_exceptions} AS e ON i.exception_id = e.exception_id INNER JOIN {$members_table} AS gm ON ( {$agent_type_clause} ) WHERE i.inherited_from = '0' {$ops_clause} {$type_clause} {$agent_clause} GROUP BY qry_agent_id, e.for_item_source, e.for_item_type, e.operation");
            $results = array_merge($results, $_results);
        }
    } else {
        $agent_clause = $query_agent_ids ? "AND e.agent_id IN ('" . implode("','", (array) $query_agent_ids) . "')" : '';
        $results = $wpdb->get_results("SELECT e.agent_id AS qry_agent_id, e.exception_id, e.for_item_source, e.for_item_type, e.operation, e.via_item_type, COUNT(DISTINCT i.exception_id, i.item_id) AS exc_count FROM {$wpdb->ppc_exception_items} AS i INNER JOIN {$wpdb->ppc_exceptions} AS e ON i.exception_id = e.exception_id WHERE i.inherited_from = '0' AND e.agent_type = '{$agent_type}' {$ops_clause} {$type_clause} {$agent_clause} GROUP BY qry_agent_id, e.for_item_source, e.for_item_type, e.operation");
    }
    foreach ($results as $row) {
        if (!$row->for_item_type) {
            $type_label = '';
        } else {
            if (!($type_obj = pp_get_type_object($row->for_item_source, $row->for_item_type))) {
                continue;
            }
            $type_label = $type_obj->labels->singular_name;
        }
        if ($op_obj = pp_get_op_object($row->operation, $row->for_item_type)) {
            if ('assign' == $row->operation) {
                if ($tx_obj = get_taxonomy($row->via_item_type)) {
                    $lbl = str_replace('Term', $tx_obj->labels->singular_name, $op_obj->label);
                } else {
                    $lbl = $op_obj->label;
                }
                //$lbl = sprintf( __('%2$s: %1$s', 'pp'), $op_lbl, $type_label );
            } elseif (isset($op_obj->abbrev)) {
                $lbl = $op_obj->abbrev;
            } else {
                $lbl = sprintf(__('%1$s %2$s', 'pp'), $op_obj->label, $type_label);
            }
        } else {
            $lbl = $type_label;
        }
        if (!isset($count[$row->qry_agent_id]['exceptions'][$lbl])) {
            $count[$row->qry_agent_id]['exceptions'][$lbl] = 0;
        }
        $count[$row->qry_agent_id]['exceptions'][$lbl] += $row->exc_count;
        if (!isset($count[$row->qry_agent_id]['exc_count'])) {
            $count[$row->qry_agent_id]['exc_count'] = 0;
        }
        $count[$row->qry_agent_id]['exc_count'] += $row->exc_count;
    }
    return $count;
}
    function draw_exceptions_ui($box, $args)
    {
        if (!isset($box['args'])) {
            return;
        }
        extract($box['args'], EXTR_SKIP);
        // $op
        extract($args, EXTR_SKIP);
        // $for_item_source, for_item_type, via_item_source
        global $wp_roles, $pp_current_user;
        $is_draft_post = false;
        if ('post' == $via_item_source) {
            if ('read' == $op) {
                global $post;
                $status_obj = get_post_status_object($post->post_status);
                if (!$status_obj || !$status_obj->public && !$status_obj->private) {
                    $is_draft_post = true;
                }
            }
            $hierarchical = is_post_type_hierarchical($via_item_type);
        } else {
            $hierarchical = is_taxonomy_hierarchical($via_item_type);
        }
        if ($hierarchical = apply_filters('pp_do_assign_for_children_ui', $hierarchical, $via_item_type, $args)) {
            $type_obj = 'post' == $via_item_source ? get_post_type_object($via_item_type) : get_taxonomy($via_item_type);
        }
        $agent_types['wp_role'] = (object) array('labels' => (object) array('name' => __('WP Roles', 'pp'), 'singular_name' => __('WP Role', 'pp')));
        $agent_types = apply_filters('pp_list_group_types', array_merge($agent_types, pp_get_group_types(array(), 'object')));
        $agent_types['user'] = (object) array('labels' => (object) array('name' => __('Users'), 'singular_name' => __('User')));
        //if ( ! $skip_user_validation && ! $pp_admin->user_can_admin_role($role_name, $item_id, $src_name, $object_type) )
        //	return;
        static $drew_itemroles_marker;
        if (empty($drew_itemroles_marker)) {
            echo "<input type='hidden' name='pp_post_exceptions' value='true' />";
            $drew_itemroles_marker = true;
        }
        $current_exceptions = isset($this->data->current_exceptions[$for_item_type]) ? $this->data->current_exceptions[$for_item_type] : array();
        // ========== OBJECT / TERM EXCEPTION DROPDOWNS ============
        $toggle_agents = count($agent_types) > 1;
        if ($toggle_agents) {
            global $is_ID;
            $class_selected = 'agp-selected_agent agp-agent';
            $class_unselected = 'agp-unselected_agent agp-agent';
            $bottom_margin = !empty($is_IE) ? '-0.7em' : 0;
            $default_agent_type = 'wp_role';
            echo "<div class='hide-if-not-js' style='margin:0 0 {$bottom_margin} 0'>" . "<ul class='pp-list_horiz' style='margin-bottom:-0.1em'>";
            foreach ($agent_types as $agent_type => $gtype_obj) {
                $label = !empty($current_exceptions[$op][$agent_type]) ? sprintf(__('%1$s (%2$s)', 'pp'), $gtype_obj->labels->name, count($current_exceptions[$op][$agent_type])) : $gtype_obj->labels->name;
                $class = $default_agent_type == $agent_type ? "class='{$class_selected}'" : "class='{$class_unselected}'";
                echo "<li {$class}><a href='javascript:void(0)' class='{$op}-{$for_item_type}-{$agent_type}'>" . $label . '</a></li>';
            }
            echo '</ul></div>';
        }
        $class = "class='pp-agents pp-exceptions'";
        //need effective line break here if not IE
        echo "<div style='clear:both;margin:0 0 0.3em 0' {$class}>";
        $pp_agents_ui = pp_init_agents_ui();
        foreach (array_keys($agent_types) as $agent_type) {
            $hide_class = $toggle_agents && $agent_type != $default_agent_type ? ' class="hide-if-js"' : '';
            echo "\r\n<div id='{$op}-{$for_item_type}-{$agent_type}' {$hide_class} style='overflow-x:auto'>";
            $this->render->set_options($agent_type);
            // list all WP roles
            if ('wp_role' == $agent_type) {
                if (!isset($current_exceptions[$op][$agent_type])) {
                    $current_exceptions[$op][$agent_type] = array();
                }
                foreach ($this->data->agent_info['wp_role'] as $agent_id => $role) {
                    if (in_array($role->metagroup_id, array('wp_anon', 'wp_all')) && !defined('PP_ALL_ANON_FULL_EXCEPTIONS') && ('read' != $op || pp_get_option('anonymous_unfiltered'))) {
                        continue;
                    }
                    if (!isset($current_exceptions[$op][$agent_type][$agent_id])) {
                        $current_exceptions[$op][$agent_type][$agent_id] = array();
                    }
                }
                if (!$is_draft_post && 'post' == $via_item_source && 'attachment' != $via_item_type && in_array($op, array('read', 'edit', 'delete'))) {
                    $reqd_caps = map_meta_cap("{$op}_post", 0, $item_id);
                } else {
                    $reqd_caps = false;
                }
            }
            global $wp_roles;
            ?>
			
			<table class="pp-item-exceptions-ui pp-exc-<?php 
            echo $agent_type;
            ?>
" style="width:100%"><tr>
			<?php 
            if ('wp_role' != $agent_type) {
                ?>
				<td class="pp-select-exception-agents" style="display:none;">
				<?php 
                // Select Groups / Users UI
                echo '<div>';
                echo '<div class="pp-agent-select">';
                $args = array_merge($args, array('suppress_extra_prefix' => true, 'ajax_selection' => true, 'display_stored_selections' => false, 'create_dropdowns' => true, 'op' => $op, 'via_item_type' => $via_item_type));
                $pp_agents_ui = pp_init_agents_ui();
                $pp_agents_ui->agents_ui($agent_type, array(), "{$op}:{$for_item_type}:{$agent_type}", array(), $args);
                echo '</div>';
                echo '</div>';
                $colspan = 'colspan="2"';
                ?>
				</td>
			<?php 
            } else {
                $colspan = '';
                // for html5 compliance
            }
            ?>
			
			<?php 
            $any_stored = empty($current_exceptions[$op][$agent_type]) ? 0 : count($current_exceptions[$op][$agent_type]);
            ?>
			<td class="pp-current-item-exceptions" style="width:100%">
				<div style="overflow:auto;max-height:325px">
				<table <?php 
            if (!$any_stored) {
                echo 'style="display:none"';
            }
            ?>
>
				<?php 
            if ($hierarchical) {
                ?>
					<thead>
					<tr>
					<th></th>
					<th><?php 
                printf(__('This %s', 'pp'), $type_obj->labels->singular_name);
                ?>
</th>
					<th><?php 
                if ($caption = apply_filters('pp_item_assign_for_children_caption', '', $via_item_type)) {
                    printf($caption);
                } else {
                    printf(__('Sub-%s', 'pp'), $type_obj->labels->name);
                }
                ?>
</th>
					</tr>
					</thead>
				<?php 
            }
            ?>
					<tbody>
					<?php 
            // @todo: why is agent_id=0 in current_exceptions array?
            if ($any_stored) {
                if ('wp_role' == $agent_type) {
                    foreach ($current_exceptions[$op][$agent_type] as $agent_id => $agent_exceptions) {
                        if ($agent_id && isset($this->data->agent_info[$agent_type][$agent_id])) {
                            $this->render->draw_row($agent_type, $agent_id, $current_exceptions[$op][$agent_type][$agent_id], $this->data->inclusions_active, $this->data->agent_info[$agent_type][$agent_id], compact('for_item_type', 'op', 'reqd_caps', 'hierarchical'));
                        }
                    }
                } else {
                    foreach (array_keys($this->data->agent_info[$agent_type]) as $agent_id) {
                        // order by agent name
                        if ($agent_id && isset($current_exceptions[$op][$agent_type][$agent_id])) {
                            $this->render->draw_row($agent_type, $agent_id, $current_exceptions[$op][$agent_type][$agent_id], $this->data->inclusions_active, $this->data->agent_info[$agent_type][$agent_id], compact('for_item_type', 'op', 'reqd_caps', 'hierarchical'));
                        }
                    }
                }
            }
            ?>
					</tbody>
					
					<tfoot<?php 
            if ($any_stored < 2) {
                echo ' style="display:none;"';
            }
            ?>
>
					<?php 
            $link_caption = 'wp_role' == $agent_type ? __('default all', 'pp') : __('clear all', 'pp');
            ?>
						<tr>
						<td></td><td style="text-align:center"><a href="#clear-item-exc"><?php 
            echo $link_caption;
            ?>
</a></td>
						<?php 
            if ($hierarchical) {
                ?>
						<td style="text-align:center"><a href="#clear-sub-exc"><?php 
                echo $link_caption;
                ?>
</a></td>
						<?php 
            }
            ?>
						</tr>
					</tfoot>
				
				</table>
				
				</div>
				
				<?php 
            if (!$any_stored) {
                ?>
				<div class="pp-no-exceptions"><?php 
                _e('No access customizations stored.', 'pp');
                ?>
</div>
				<?php 
            }
            ?>
			</td>
			</tr>
			
			<tr>
			<td class="pp-exception-actions" <?php 
            echo $colspan;
            ?>
>
			<?php 
            if ('wp_role' != $agent_type) {
                ?>
				<a class="pp-select-exception-agents" href="#"><?php 
                'user' == $agent_type ? _e('select users', 'pp') : _e('select groups', 'pp');
                ?>
</a>
				<a class="pp-close-select-exception-agents" href="#" style="display:none;"><?php 
                _e('close', 'pp');
                ?>
</a>
			<?php 
            }
            if (pp_group_type_editable($agent_type) && pp_has_group_cap('pp_create_groups', 0, $agent_type)) {
                ?>
				&nbsp;&bull;&nbsp;<a class="pp-create-exception-agent" href="admin.php?page=pp-group-new" target="_blank"><?php 
                _e('create group', 'pp');
                ?>
</a>
			<?php 
            }
            ?>
			</td>
			</tr>
			</table>
			
			</div>
			<?php 
        }
        // end foreach group type caption
        echo '</div>';
        // class pp-agents
        if ('read' == $op && pp_get_option('display_extension_hints') && ('attachment' == $for_item_type && !defined('PPFF_VERSION') || !defined('PPCE_VERSION'))) {
            require_once dirname(__FILE__) . '/item-exceptions-ui-hints_pp.php';
            _ppc_item_ui_hints($for_item_type);
        }
        if ('term' == $via_item_source && in_array($op, array('read', 'edit'))) {
            $msg = __('To customize <strong>for a specific post status</strong>, edit the desired role / group / user permissions directly (Permissions > Groups or Users)', 'pp');
            echo "<div class='pp-exc-notes'>{$msg}</div>";
        }
    }
Example #8
0
 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&amp;action=edit&amp;agent_type={$agent_type}&amp;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&nbsp;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&amp;action=edit&amp;agent_id={$id}&amp;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;
     }
 }
Example #9
0
 function log_term_data()
 {
     global $wp_object_cache, $wpdb, $pp, $typenow;
     $taxonomy = pp_sanitize_key($_REQUEST['taxonomy']);
     if (!empty($wp_object_cache->cache[$taxonomy])) {
         if (isset($wp_object_cache->cache[$taxonomy])) {
             // Note: As of WP 3.5, array is keyed "blog_id:term_id" on Multisite installs
             $listed_term_ids = array();
             foreach ($wp_object_cache->cache[$taxonomy] as $term) {
                 $listed_tt_ids[] = $term->term_taxonomy_id;
             }
         }
         if (empty($_REQUEST['paged'])) {
             $listed_tt_ids[] = 0;
         }
     } else {
         return;
     }
     if (!empty($_REQUEST['pp_universal'])) {
         $typenow = '';
     } elseif (empty($typenow)) {
         $typenow = isset($_REQUEST['post_type']) ? pp_sanitize_key($_REQUEST['post_type']) : '';
     }
     $this->exceptions = array();
     if (!empty($listed_tt_ids)) {
         $agent_type_csv = implode("','", array_merge(array('user'), pp_get_group_types()));
         $id_csv = implode("','", $listed_tt_ids);
         $post_type = !empty($_REQUEST['pp_universal']) ? '' : $typenow;
         $for_type_csv = $typenow ? "'{$post_type}'" : "'', '{$taxonomy}'";
         $results = $wpdb->get_results("SELECT DISTINCT i.item_id, e.operation FROM {$wpdb->ppc_exceptions} AS e INNER JOIN {$wpdb->ppc_exception_items} AS i ON e.exception_id = i.exception_id WHERE e.for_item_type IN ({$for_type_csv}) AND e.via_item_source = 'term' AND e.via_item_type = '{$taxonomy}' AND e.agent_type IN ('{$agent_type_csv}') AND i.item_id IN ('{$id_csv}')");
         foreach ($results as $row) {
             if (!isset($this->exceptions[$row->item_id])) {
                 $this->exceptions[$row->item_id] = array();
             }
             $this->exceptions[$row->item_id][] = $row->operation;
         }
     }
 }
Example #10
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
    }
Example #11
0
    public static function display_ui_user_groups($include_role_metagroups = false, $args = array())
    {
        $defaults = array('initial_hide' => false, 'selected_only' => false, 'hide_checkboxes' => false, 'force_display' => false, 'edit_membership_link' => false, 'user_id' => false);
        extract(array_merge($defaults, $args), EXTR_SKIP);
        require_once dirname(__FILE__) . '/permissions-ui_pp.php';
        if (!is_numeric($user_id)) {
            global $profileuser;
            $user_id = !empty($profileuser) ? $profileuser->ID : 0;
        }
        $group_types = pp_get_group_types(array('editable' => true));
        foreach ($group_types as $agent_type) {
            //if ( ! $agent_type = apply_filters( 'pp_query_group_type', '' ) )
            //	$agent_type = 'pp_group';
            if ('pp_group' == $agent_type && in_array('pp_net_group', $group_types)) {
                continue;
            }
            if (!pp_has_group_cap('pp_manage_members', 0, $agent_type)) {
                continue;
            }
            if (!($all_groups = pp_get_groups($agent_type))) {
                continue;
            }
            $reqd_caps = (array) apply_filters('pp_edit_groups_reqd_caps', array('pp_edit_groups'));
            // @todo: reinstate?
            //$editable_ids = pp_get_groups( 'pp_group', FILTERED_PP, 'id', compact('reqd_caps') );
            if (current_user_can('pp_manage_members')) {
                $editable_ids = array_keys($all_groups);
            } else {
                $editable_ids = array();
            }
            $stored_groups = pp_get_groups_for_user($user_id, $agent_type, array('cols' => 'id'));
            //$addable_ids = array_diff( $editable_ids, array_keys($stored_groups) );
            $locked_ids = array_diff(array_keys($stored_groups), $editable_ids);
            // can't manually edit membership of WP Roles groups or other metagroups lacking _ed_ suffix
            $all_ids = array();
            foreach ($all_groups as $key => $group) {
                if ($selected_only && !isset($stored_groups[$group->ID])) {
                    unset($all_groups[$key]);
                    continue;
                }
                $all_ids[] = $group->ID;
                if (!$include_role_metagroups && !empty($group->metagroup_id) && 'wp_role' == $group->metagroup_type) {
                    $editable_ids = array_diff($editable_ids, array($group->ID));
                    unset($stored_groups[$group->ID]);
                    unset($all_groups[$key]);
                } elseif (!in_array($group->ID, $editable_ids) && !in_array($group->ID, $locked_ids)) {
                    unset($all_groups[$key]);
                }
            }
            $locked_ids = array_diff(array_keys($stored_groups), $editable_ids);
            // avoid incorrect eligible count if orphaned group roles are included in editable_ids
            $editable_ids = array_intersect($editable_ids, $all_ids);
            if (!$all_groups && !$force_display) {
                continue;
            }
            $style = $initial_hide ? "style='display:none'" : '';
            echo "<div id='userprofile_groupsdiv_pp' class='pp-group-box pp-group_members' {$style}>";
            echo "<h3>";
            if ('pp_group' == $agent_type) {
                if (defined('GROUPS_CAPTION_RS')) {
                    echo GROUPS_CAPTION_RS;
                } else {
                    _e('Permission Groups', 'pp');
                }
            } else {
                $group_type_obj = pp_get_group_type_object($agent_type);
                echo $group_type_obj->labels->name;
            }
            echo "</h3>";
            $css_id = $agent_type;
            $args = array('eligible_ids' => $editable_ids, 'locked_ids' => $locked_ids, 'show_subset_caption' => false, 'hide_checkboxes' => $hide_checkboxes);
            require_once dirname(__FILE__) . '/agents_ui_pp.php';
            $pp_agents_ui = pp_init_agents_ui();
            $pp_agents_ui->agents_ui($agent_type, $all_groups, $css_id, $stored_groups, $args);
            if ($edit_membership_link || !$all_groups && $force_display) {
                ?>
				<p>
				<?php 
                if (!$all_groups && $force_display) {
                    _e('This user is not a member of any Permission Groups.', 'pp');
                    ?>
&nbsp;&bull;&nbsp;
				<?php 
                }
                ?>
				<a href='user-edit.php?user_id=<?php 
                echo $user_id;
                ?>
#userprofile_groupsdiv_pp' title='<?php 
                echo esc_attr(__('Edit this user&apos;s group membership', 'pp'));
                ?>
'><?php 
                _e('add / edit membership');
                ?>
</a>
				&nbsp;&nbsp;
				<span class="pp-subtext">
				<?php 
                $note = apply_filters('pp_user_profile_groups_note', defined('BP_VERSION') ? __('note: BuddyPress Groups and other externally defined groups are not listed here, even if they modify permissions', 'pp') : '', $user_id, $args);
                echo $note;
                ?>
				</span>
				</p>
			<?php 
            }
            echo '</div>';
        }
        // end foreach agent_type
        echo "<input type='hidden' name='pp_editing_user_groups' value='1' />";
    }