function act_wp_user_query(&$query_obj)
 {
     // filter Author dropdown on post edit form
     if (in_array($GLOBALS['pagenow'], array('post.php', 'post-new.php')) && 'authors' == $query_obj->query_vars['who']) {
         global $current_user, $scoper, $wpdb;
         $object_type = cr_find_post_type();
         $object_id = scoper_get_object_id('post');
         $post_type_obj = get_post_type_object($object_type);
         if ($object_id > 0) {
             if ($current_author = $scoper->data_sources->get_from_db('owner', 'post', $object_id)) {
                 $force_user_id = $current_author;
             }
         } else {
             global $current_user;
             $force_user_id = $current_user->ID;
         }
         if (cr_user_can($post_type_obj->cap->edit_others_posts, $object_id, 0, array('omit_owner_clause' => true))) {
             $args = array();
             if ($force_user_id) {
                 $args['include_user_ids'] = $force_user_id;
             }
             $args['preserve_or_clause'] = " uro.user_id = '{$force_user_id}'";
             $users = $scoper->users_who_can($post_type_obj->cap->edit_posts, COL_ID_RS, 'post', $object_id, $args);
         } else {
             $display_name = $wpdb->get_var("SELECT display_name FROM {$wpdb->users} WHERE ID = '{$force_user_id}'");
             $users = array((object) array('ID' => $force_user_id, 'display_name' => $display_name));
         }
         // for Author dropdown filtering, there should always be at least one user
         if ($users) {
             $query_obj->query_from = "FROM {$wpdb->users}";
             $query_obj->query_where = "WHERE 1=1 AND ID IN ('" . implode("','", $users) . "')";
         }
     }
 }
 function flt_defeat_publish_filter($where)
 {
     $post_type = cr_find_post_type();
     $post_type_obj = get_post_type_object($post_type);
     $object_id = scoper_get_object_id('post', $post_type);
     // don't alter the query if RS query filtering is disabled, or if this maneuver has been disabled via constant
     // note: for non-administrators, QueryInterceptor_RS::flt_objects_where will convert the publish requirement to publish OR private, if the user's blog role or RS-assigned roles grant private access
     if (!is_content_administrator_rs() || defined('SCOPER_RETAIN_PUBLISH_FILTER') || defined('DISABLE_QUERYFILTERS_RS')) {
         return $where;
     }
     global $wp_query;
     if (is_admin() && !empty($wp_query->query['post_status'])) {
         // if a specific status was requested by URI, don't force inclusion of others
         return $where;
     }
     // don't alter the where clause if in wp-admin and not filtering by taxonomy
     if (is_admin()) {
         global $wp_query;
         if (empty($wp_query) && empty($wp_query->is_tax)) {
             return $where;
         }
     }
     global $wpdb, $current_user;
     // don't alter the where clause for anonymous users
     if (empty($current_user->ID)) {
         return $where;
     }
     $where = preg_replace("/{$wpdb->posts}.post_status\\s*=\\s*'publish'/", "({$wpdb->posts}.post_status = 'publish' OR {$wpdb->posts}.post_status = 'private')", $where);
     $where = preg_replace("/p2.post_status\\s*=\\s*'publish'/", "(p2.post_status = 'publish' OR p2.post_status = 'private')", $where);
     $where = preg_replace("/p.post_status\\s*=\\s*'publish'/", "(p.post_status = 'publish' OR p.post_status = 'private')", $where);
     return $where;
 }
 function ui_hide_admin_divs()
 {
     if (!in_array($GLOBALS['pagenow'], array('post.php', 'post-new.php'))) {
         return;
     }
     if (!($object_type = cr_find_post_type())) {
         return;
     }
     // For this data source, is there any html content to hide from non-administrators?
     $option_type = 'page' == $object_type ? 'page' : 'post';
     $css_ids = scoper_get_otype_option('admin_css_ids', 'post', $option_type);
     $css_ids = str_replace(' ', '', $css_ids);
     $css_ids = str_replace(',', ';', $css_ids);
     $css_ids = explode(';', $css_ids);
     // option storage is as semicolon-delimited string
     if (empty($css_ids)) {
         return;
     }
     $object_id = scoper_get_object_id('post');
     $can_edit_blogwide = $this->scoper->user_can_edit_blogwide('post', $object_type);
     $blogwide_requirement = scoper_get_option('hide_non_editor_admin_divs');
     if ('admin_option' == $blogwide_requirement) {
         $blogwide_requirement_met = is_option_administrator_rs();
     } elseif ('admin_user' == $blogwide_requirement) {
         $blogwide_requirement_met = is_user_administrator_rs();
     } elseif ('admin_content' == $blogwide_requirement) {
         $blogwide_requirement_met = is_content_administrator_rs();
     } elseif ('editor' == $blogwide_requirement) {
         $blogwide_requirement_met = $this->scoper->user_can_edit_blogwide('post', $object_type, array('status' => 'publish', 'require_others_cap' => true));
     } elseif ('author' == $blogwide_requirement) {
         $blogwide_requirement_met = $this->scoper->user_can_edit_blogwide('post', $object_type, array('status' => 'publish'));
     } elseif ($blogwide_requirement) {
         $blogwide_requirement_met = $can_edit_blogwide;
     } else {
         $blogwide_requirement_met = true;
     }
     if ($can_edit_blogwide && $blogwide_requirement_met) {
         // don't hide anything if a user with sufficient blog-wide role is creating a new object
         if (!$object_id) {
             return;
         }
         if (!($object = $this->scoper->data_sources->get_object('post', $object_id))) {
             return;
         }
         if (empty($object->post_date)) {
             // don't prevent the full editing of new posts/pages
             return;
         }
         // don't hide anything if a user with sufficient blog-wide role is editing their own object
         /*
         global $current_user;
         if ( empty($object->post_author) || ( $object->post_author == $current_user->ID) )
         	return;
         */
     }
     if ($blogwide_requirement && !$blogwide_requirement_met || !$this->scoper_admin->user_can_admin_object('post', $object_type, $object_id, '', '', true)) {
         echo "\n<style type='text/css'>\n<!--\n";
         $removeable_metaboxes = apply_filters('scoper_removeable_metaboxes', array('categorydiv', 'tagsdiv-post_tag', 'postcustom', 'pagecustomdiv', 'authordiv', 'pageauthordiv', 'trackbacksdiv', 'revisionsdiv', 'pending_revisions_div', 'future_revisionsdiv'));
         foreach ($css_ids as $id) {
             if (in_array($id, $removeable_metaboxes)) {
                 // thanks to piemanek for tip on using remove_meta_box for any core admin div
                 remove_meta_box($id, $object_type, 'normal');
                 remove_meta_box($id, $object_type, 'advanced');
             } else {
                 // hide via CSS if the element is not a removeable metabox
                 echo "#{$id} { display: none !important; }\n";
                 // this line adapted from Clutter Free plugin by Mark Jaquith
             }
         }
         echo "-->\n</style>\n";
     }
 }
function scoper_filter_terms_for_status($taxonomy, $selected_terms, &$user_terms, $args = array())
{
    if (defined('DISABLE_QUERYFILTERS_RS') || defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
        return $selected_terms;
    }
    global $scoper;
    $defaults = array('object_id' => 0, 'object_type' => '', 'status' => '');
    $args = array_merge($defaults, $args);
    extract($args);
    if (!($tx = $scoper->taxonomies->get($taxonomy))) {
        return $selected_terms;
    }
    if (!($src = $scoper->data_sources->get($tx->object_source))) {
        return $selected_terms;
    }
    if (!isset($src->statuses) || count($src->statuses) < 2) {
        return $selected_terms;
    }
    if (!$object_id) {
        $object_id = scoper_get_object_id($src->name);
    }
    if (!$status) {
        // determine current post status
        if (defined('XMLRPC_REQUEST') && !empty($GLOBALS['scoper_xmlrpc_post_status'])) {
            $status = $GLOBALS['scoper_xmlrpc_post_status'];
        } else {
            if (!($status = $scoper->data_sources->get_from_http_post('status', $src))) {
                if ($object_id) {
                    $status = $scoper->data_sources->get_from_db('status', $src, $object_id);
                }
            }
        }
    }
    if (!$object_type) {
        if (!($object_type = cr_find_object_type($src->name, $object_id))) {
            if (defined('XMLRPC_REQUEST')) {
                $object_type = 'post';
            } else {
                return $selected_terms;
            }
        }
    }
    if ('auto-draft' == $status) {
        $status = 'draft';
    }
    // make sure _others caps are required only for objects current user doesn't own
    $base_caps_only = true;
    if ($object_id && !empty($src->cols->owner)) {
        $col_owner = $src->cols->owner;
        if ($object = $scoper->data_sources->get_object($src->name, $object_id)) {
            if (!empty($object->{$col_owner}) && $object->{$col_owner} != $GLOBALS['current_user']->ID) {
                $base_caps_only = false;
            }
        }
    }
    if (!($reqd_caps = cr_get_reqd_caps($src->name, OP_EDIT_RS, $object_type, $status, $base_caps_only))) {
        return $selected_terms;
    }
    $qualifying_roles = $scoper->role_defs->qualify_roles($reqd_caps);
    if ($qualifying_term_assigner_roles = $scoper->role_defs->qualify_roles(array("assign_{$taxonomy}"))) {
        $qualifying_roles = array_merge($qualifying_roles, $qualifying_term_assigner_roles);
    }
    $user_terms = $scoper->qualify_terms_daterange($reqd_caps, $taxonomy, $qualifying_roles);
    foreach (array_keys($user_terms) as $date_key) {
        $date_clause = '';
        if ($date_key && is_serialized($date_key)) {
            // Check stored post date against any role date limits associated whith this set of terms (if not stored, check current date)
            $content_date_limits = unserialize($date_key);
            $post_date_gmt = $object_id ? $scoper->data_sources->get_from_db('date', $src, $object_id) : 0;
            if (!$post_date_gmt) {
                $post_date_gmt = agp_time_gmt();
            }
            if ($post_date_gmt < $content_date_limits->content_min_date_gmt || $post_date_gmt > $content_date_limits->content_max_date_gmt) {
                unset($user_terms[$date_key]);
            }
        }
    }
    $user_terms = agp_array_flatten($user_terms);
    $selected_terms = array_intersect($selected_terms, $user_terms);
    return $selected_terms;
}
 function ui_object_roles($src_name, $args = array())
 {
     $defaults = array('object_type' => '');
     $args = array_merge($defaults, (array) $args);
     extract($args);
     if (!($src = $this->scoper->data_sources->get($src_name))) {
         return;
     }
     if (!$object_type) {
         if (!($object_type = cr_find_object_type($src_name))) {
             return;
         }
     }
     $object_id = scoper_get_object_id($src_name, $object_type);
     if (!$this->scoper_admin->user_can_admin_object($src_name, $object_type, $object_id)) {
         return;
     }
     $this->init_item_roles_ui();
     $this->item_roles_ui->single_object_roles_ui($src_name, $object_type, $object_id);
 }
 function flt_wp_dropdown_users($wp_output)
 {
     // just filter Post Author dropdown
     if (!strpos($wp_output, "name='post_author_override'")) {
         return $wp_output;
     }
     // this is meant to filter the post author selection
     if (!is_admin()) {
         return $wp_output;
     }
     // if (even after our blogcap tinkering) the author list is already locked due to insufficient blog-wide caps, don't mess
     if (!($pos = strpos($wp_output, '<option'))) {
         return $wp_output;
     }
     if (!strpos($wp_output, '<option', $pos + 1)) {
         return $wp_output;
     }
     global $wpdb, $scoper;
     $last_query = $wpdb->last_query;
     if (!($object_type = cr_find_post_type())) {
         return $wp_output;
     }
     if (!($post_type_obj = get_post_type_object($object_type))) {
         return $wp_output;
     }
     global $current_user;
     $is_ngg_edit = strpos($_SERVER['REQUEST_URI'], 'nggallery-manage-gallery');
     if (!$is_ngg_edit) {
         $src_name = 'post';
         $object_id = scoper_get_object_id('post', $object_type);
         // only modify the default authors list if current user has Editor role for the current post/page
         $have_cap = cr_user_can($post_type_obj->cap->edit_others_posts, $object_id, 0, array('require_full_object_role' => true));
     } else {
         $src_name = 'ngg_gallery';
         $object_id = $_REQUEST['gid'];
         $have_cap = !empty($current_user->allcaps[$post_type_obj->cap->edit_others_posts]);
         // $post_type_obj defaults to 'post' type on NGG Manage Gallery page
     }
     //if ( ! $have_cap )
     //	return $wp_output;
     $orderpos = strpos($last_query, 'ORDER BY');
     $orderby = $orderpos ? substr($last_query, $orderpos) : '';
     if (!strpos($orderby, 'display_name')) {
         // sanity check in case the last_query buffer gets messed up
         $orderby = '';
     }
     $id_in = $id_not_in = $show_option_all = $show_option_none = '';
     $pos = strpos($last_query, 'AND ID IN(');
     if ($pos) {
         $pos_close = strpos($last_query, ')', $pos);
         if ($pos_close) {
             $id_in = substr($last_query, $pos, $pos_close - $pos + 1);
         }
     }
     $pos = strpos($last_query, 'AND ID NOT IN(');
     if ($pos) {
         $pos_close = strpos($last_query, ')', $pos);
         if ($pos_close) {
             $id_not_in = substr($last_query, $pos, $pos_close - $pos + 1);
         }
     }
     $search = "<option value='0'>";
     $pos = strpos($wp_output, $search . __awp('Any'));
     if ($pos) {
         $pos_close = strpos($wp_output, '</option>', $pos);
         if ($pos_close) {
             $show_option_all = substr($wp_output, $pos + strlen($search), $pos_close - $pos - strlen($search));
         }
     }
     $search = "<option value='-1'>";
     $pos = strpos($wp_output, $search . __awp('None'));
     if ($pos) {
         $pos_close = strpos($wp_output, '</option>', $pos);
         if ($pos_close) {
             $show_option_none = substr($wp_output, $pos + strlen($search), $pos_close - $pos - strlen($search));
         }
     }
     $search = "<select name='";
     $pos = strpos($wp_output, $search);
     if (false !== $pos) {
         $pos_close = strpos($wp_output, "'", $pos + strlen($search));
         if ($pos_close) {
             $name = substr($wp_output, $pos + strlen($search), $pos_close - $pos - strlen($search));
         }
     }
     $search = " id='";
     $multi = !strpos($wp_output, $search);
     // beginning with WP 2.7, some users dropdowns lack id attribute
     $search = " class='";
     $pos = strpos($wp_output, $search);
     if ($pos) {
         $pos_close = strpos($wp_output, "'", $pos + strlen($search));
         if ($pos_close) {
             $class = substr($wp_output, $pos + strlen($search), $pos_close - $pos - strlen($search));
         }
     }
     $search = " selected='selected'";
     $pos = strpos($wp_output, $search);
     if ($pos) {
         $search = "<option value='";
         $str_left = substr($wp_output, 0, $pos);
         $pos = strrpos($str_left, $search);
         //back up to previous option tag
         $pos_close = strpos($wp_output, "'", $pos + strlen($search));
         if ($pos_close) {
             $selected = substr($wp_output, $pos + strlen($search), $pos_close - ($pos + strlen($search)));
         }
     }
     if (empty($selected)) {
         $selected = $current_user->ID;
     }
     // precaution prevents default-selection of non-current user
     // Role Scoper filter application
     $where = "{$id_in} {$id_not_in}";
     $args = array();
     $args['where'] = $where;
     $args['orderby'] = $orderby;
     if ($object_id > 0) {
         if ($current_author = $scoper->data_sources->get_from_db('owner', $src_name, $object_id)) {
             $force_user_id = $current_author;
         }
     } else {
         $force_user_id = $current_user->ID;
     }
     if ($have_cap) {
         if ($force_user_id) {
             $args['preserve_or_clause'] = " uro.user_id = '{$force_user_id}'";
         }
         $users = $scoper->users_who_can($post_type_obj->cap->edit_posts, COLS_ID_DISPLAYNAME_RS, 'post', $object_id, $args);
     } else {
         $display_name = $wpdb->get_var("SELECT display_name FROM {$wpdb->users} WHERE ID = '{$force_user_id}'");
         $users = array((object) array('ID' => $force_user_id, 'display_name' => $display_name));
     }
     if (empty($users)) {
         // sanity check: users_who_can should always return Administrators
         if ($admin_roles = awp_administrator_roles()) {
             $users = scoper_get_results("SELECT DISTINCT ID, display_name FROM {$wpdb->users} INNER JOIN {$wpdb->user2role2object_rs} AS uro ON uro.user_id = {$wpdb->users}.ID AND uro.scope = 'blog' AND uro.role_type = 'wp' AND uro.role_name IN ('" . implode("','", $admin_roles) . "')");
         } else {
             return $wp_output;
         }
         // the user data must be messed up
     }
     $show = 'display_name';
     // no way to back this out
     // ----------- begin wp_dropdown_users code copy (from WP 2.7) -------------
     $id = $multi ? "" : "id='{$name}'";
     $output = "<select name='{$name}' {$id} class='{$class}'>\n";
     if ($show_option_all) {
         $output .= "\t<option value='0'>{$show_option_all}</option>\n";
     }
     if ($show_option_none) {
         $output .= "\t<option value='-1'>{$show_option_none}</option>\n";
     }
     foreach ((array) $users as $user) {
         $user->ID = (int) $user->ID;
         $_selected = $user->ID == $selected ? " selected='selected'" : '';
         $display = !empty($user->{$show}) ? $user->{$show} : '(' . $user->user_login . ')';
         $output .= "\t<option value='{$user->ID}'{$_selected}>" . esc_html($display) . "</option>\n";
     }
     $output .= "</select>";
     // ----------- end wp_dropdown_users code copy (from WP 2.7) -------------
     return $output;
 }
 function draw_object_roles_content($src_name, $object_type, $role_handle, $object_id = '', $skip_user_validation = false, $object = false)
 {
     //log_mem_usage_rs( 'start ItemRolesUI::draw_object_roles_content()' );
     if (!$object_id) {
         $object_id = scoper_get_object_id($src_name, $object_type);
     }
     if (!empty($object) && 'auto-draft' == $object->post_status) {
         $object_id = 0;
     }
     if ($src_name != $this->loaded_src_name || $object_type != $this->loaded_object_type || $object_id != $this->loaded_object_id) {
         $this->load_roles($src_name, $object_type, $object_id);
     }
     if (!($otype_def = $this->scoper->data_sources->member_property($src_name, 'object_types', $object_type))) {
         return;
     }
     if (!$skip_user_validation && !$this->scoper_admin->user_can_admin_role($role_handle, $object_id, $src_name, $object_type)) {
         return;
     }
     // since we may be dumping a lot of hidden user <li> into the page, enumerate role names to shorten html
     $role_code = 'r' . array_search($role_handle, $this->role_handles);
     $role_def = $this->scoper->role_defs->get($role_handle);
     if (!isset($role_def->valid_scopes[OBJECT_SCOPE_RS])) {
         return;
     }
     if (empty($this->drew_objroles_marker)) {
         echo "<input type='hidden' name='rs_object_roles' value='true' />";
         $this->drew_objroles_marker = true;
     }
     // ========== OBJECT RESTRICTION CHECKBOX(ES) ============
     // checkbox to control object role scoping (dictates whether taxonomy and blog role assignments also be honored for operations on this object )
     $checked = empty($this->object_strict_roles[$role_handle]) ? '' : 'checked="checked"';
     $val = $checked ? '1' : '0';
     echo "<input type='hidden' name='last_objscope_{$role_code}' value='{$val}' id='last_objscope_{$role_code}' />";
     echo "\r\n<p style='margin-bottom:0.8em;'>" . "<span class='alignright'><a href='#wphead'>" . __('top', 'scoper') . '</a></span>' . "<label for='objscope_{$role_code}'>" . "<input type='checkbox' class='rs-check' name='objscope_{$role_code}' value='1' id='objscope_{$role_code}' {$checked} /> " . sprintf(__('Restrict for %1$s (<strong>only</strong> selected users/groups are %2$s)', 'scoper'), $otype_def->labels->singular_name, $this->scoper->role_defs->get_abbrev($role_handle, OBJECT_UI_RS)) . '</label></p>';
     if ($this->do_propagation_cboxes) {
         $checked = empty($this->child_strict_roles[$role_handle]) ? '' : 'checked="checked"';
         $val = $checked ? '1' : '0';
         echo "<input type='hidden' name='last_objscope_children_{$role_code}' value='{$val}' id='last_objscope_children_{$role_code}' />";
         echo "<p style='margin-top: 0.5em;'>" . "<label for='objscope_children_{$role_code}'>" . "<input type='checkbox' class='rs-check' name='objscope_children_{$role_code}' value='1' id='objscope_children_{$role_code}' {$checked} /> " . sprintf(__('Restrict for Sub-%1$s', 'scoper'), $otype_def->labels->name) . '</label></p>';
     }
     // ========== OBJECT ROLE ASSIGNMENT CHECKBOX(ES) ============
     // toggle groups / users view if both are enabled
     //echo "<p style='margin: 1em 0 0.2em 0;'><strong>" . sprintf(__('Assign %s Role:', 'scoper'), $display_name ) . '</strong></p>';
     //echo '<br />';
     $toggle_agents = USER_ROLES_RS && GROUP_ROLES_RS && !empty($this->all_groups);
     if ($toggle_agents) {
         if (!empty($this->current_roles[ROLE_BASIS_USER][$role_handle])) {
             $default_role_basis = ROLE_BASIS_USER;
         } else {
             $default_role_basis = ROLE_BASIS_GROUPS;
         }
         $class_selected = 'agp-selected_agent_colorized agp-selected_agent agp-agent';
         $class_unselected = 'agp-unselected_agent_colorized agp-unselected_agent agp-agent';
         $class = ROLE_BASIS_GROUPS == $default_role_basis ? "class='{$class_selected}'" : "class='{$class_unselected}'";
         $js_call = "agp_swap_display('{$role_code}_groups', '{$role_code}_user', '{$role_code}_show_group_roles', '{$role_code}_show_user_roles', '{$class_selected}', '{$class_unselected}')";
         $bottom_margin = !empty($GLOBALS['is_IE']) ? '-0.7em' : 0;
         echo "\r\n" . "<div class='agp_js_show' style='display:none;margin:0 0 {$bottom_margin} 0'>" . "<ul class='rs-list_horiz' style='margin-bottom:-0.1em'><li {$class}>" . "<a href='javascript:void(0)' id='{$role_code}_show_group_roles' onclick=\"{$js_call}\">" . __('Groups', 'scoper') . '</a></li>';
         $class = ROLE_BASIS_USER == $default_role_basis ? "class='{$class_selected}'" : "class='{$class_unselected}'";
         $js_call = "agp_swap_display('{$role_code}_user', '{$role_code}_groups', '{$role_code}_show_user_roles', '{$role_code}_show_group_roles', '{$class_selected}', '{$class_unselected}')";
         echo "\r\n" . "<li {$class}><a href='javascript:void(0)' id='{$role_code}_show_user_roles' onclick=\"{$js_call}\">" . __awp('Users') . '</a></li>' . '</ul></div>';
     }
     $class = "class='rs-agents'";
     //need effective line break here if not IE
     echo "<div style='clear:both;margin:0 0 0.3em 0' {$class}>";
     $role_ops = $this->scoper->cap_defs->get_cap_ops($this->scoper->role_defs->role_caps[$role_handle]);
     $agents_reqd_op = isset($role_ops[OP_EDIT_RS]) ? OP_EDIT_RS : OP_READ_RS;
     $containing_roles = $this->scoper->role_defs->get_containing_roles($role_handle);
     require_once dirname(__FILE__) . '/agents_checklist_rs.php';
     $args = array('suppress_extra_prefix' => true, 'default_hide_threshold' => 20, 'propagation' => $this->do_propagation_cboxes, 'otype_label_singular' => $otype_def->labels->singular_name, 'otype_label' => $otype_def->labels->name, 'object_type' => $object_type, 'object_id' => $object_id);
     $args['via_other_role_ids'] = array();
     // must set this here b/c subsequent for loop is set up for users iteration to recall via_other_role_ids from groups iteration
     foreach ($this->agent_captions as $role_basis => $agent_caption) {
         if (!is_array($this->blog_term_roles[$role_basis][$role_handle])) {
             $this->blog_term_roles[$role_basis][$role_handle] = array();
         }
         // for the purpose of indicating implicit role ownership, we will consider any assignment of a containing role as equivalent
         foreach (array_keys($containing_roles) as $containing_role_handle) {
             if (isset($this->blog_term_roles[$role_basis][$containing_role_handle]) && is_array($this->blog_term_roles[$role_basis][$containing_role_handle])) {
                 $this->blog_term_roles[$role_basis][$role_handle] = array_merge($this->blog_term_roles[$role_basis][$role_handle], $this->blog_term_roles[$role_basis][$containing_role_handle]);
             }
         }
         $this->blog_term_roles[$role_basis][$role_handle] = array_unique($this->blog_term_roles[$role_basis][$role_handle]);
         $hide_class = $toggle_agents && $role_basis != $default_role_basis ? ' class="agp_js_hide"' : '';
         echo "\r\n<div id='{$role_code}_{$role_basis}' {$hide_class}>";
         // also abbreviate "groups" to 'g', 'user' to 'u'
         $id_prefix = $role_code . substr($role_basis, 0, 1);
         if ($this->indicate_blended_roles && $object_id && GROUP_ROLES_RS && ROLE_BASIS_USER == $role_basis) {
             $args['via_other_basis_ids'] = array();
             // note users who are in a group that has this role object-assigned
             if (!empty($this->current_roles[ROLE_BASIS_GROUPS][$role_handle]['assigned'])) {
                 foreach (array_keys($this->current_roles[ROLE_BASIS_GROUPS][$role_handle]['assigned']) as $group_id) {
                     if (!isset($this->group_members[$group_id])) {
                         $this->group_members[$group_id] = ScoperAdminLib::get_group_members($group_id, COL_ID_RS, true);
                     }
                     //arg: maybe WP role metagroup
                     $args['via_other_basis_ids'] = array_merge($args['via_other_basis_ids'], $this->group_members[$group_id]);
                 }
             }
             // note users who are in a group that has this role term-assigned or blog-assigned (and not restricted)
             foreach ($this->blog_term_roles[ROLE_BASIS_GROUPS][$role_handle] as $group_id) {
                 if (!isset($this->group_members[$group_id])) {
                     $this->group_members[$group_id] = ScoperAdminLib::get_group_members($group_id, COL_ID_RS, true);
                 }
                 //arg: maybe WP role metagroup
                 $args['via_other_basis_ids'] = array_merge($args['via_other_basis_ids'], $this->group_members[$group_id]);
             }
             // note users who are in a group that has a containing role object-assigned
             // (note: via_other_role_ids element was set in previous iteration since ROLE_BASIS_GROUPS is first element in agents_caption array
             foreach ($args['via_other_role_ids'] as $group_id) {
                 if (!isset($this->group_members[$group_id])) {
                     $this->group_members[$group_id] = ScoperAdminLib::get_group_members($group_id, COL_ID_RS, true);
                 }
                 //arg: maybe WP role metagroup
                 $args['via_other_basis_ids'] = array_merge($args['via_other_basis_ids'], $this->group_members[$group_id]);
             }
             $args['via_other_basis_ids'] = array_unique($args['via_other_basis_ids']);
         }
         if ($this->indicate_blended_roles) {
             $args['via_other_scope_ids'] = $this->blog_term_roles[$role_basis][$role_handle];
         }
         $args['via_other_role_ids'] = array();
         if ($this->indicate_blended_roles && $containing_roles) {
             foreach (array_keys($containing_roles) as $containing_role_handle) {
                 if (isset($this->current_roles[$role_basis][$containing_role_handle]['assigned'])) {
                     $args['via_other_role_ids'] = array_merge($args['via_other_role_ids'], array_keys($this->current_roles[$role_basis][$containing_role_handle]['assigned']));
                 }
             }
             $args['via_other_role_ids'] = array_unique($args['via_other_role_ids']);
         }
         if ($object_id && $this->do_propagation_cboxes) {
             $args['for_entity_ids'] = isset($this->current_roles[$role_basis][$role_handle]['entity']) ? array_keys($this->current_roles[$role_basis][$role_handle]['entity']) : array();
             $args['for_children_ids'] = isset($this->current_roles[$role_basis][$role_handle]['children']) ? array_keys($this->current_roles[$role_basis][$role_handle]['children']) : '';
         }
         $args['eligible_ids'] = isset($this->eligible_agent_ids[$role_basis][$agents_reqd_op]) ? $this->eligible_agent_ids[$role_basis][$agents_reqd_op] : '';
         if ('post' == $src_name && 'auto-draft' == $object->post_status) {
             $args['suppress_last_agents'] = true;
         }
         if (!empty($this->current_roles[$role_basis][$role_handle]['assigned'])) {
             ScoperAgentsChecklist::agents_checklist($role_basis, $this->all_agents[$role_basis], $id_prefix, $this->current_roles[$role_basis][$role_handle]['assigned'], $args);
         } else {
             ScoperAgentsChecklist::agents_checklist($role_basis, $this->all_agents[$role_basis], $id_prefix, '', $args);
         }
         echo "\r\n</div>";
     }
     // end foreach role basis caption (user or group)
     echo '</div>';
     // class rs-agents
     //log_mem_usage_rs( 'end ItemRolesUI::draw_object_roles_content()' );
 }