$txt_addgroup = __('Add group...', 'contexture-page-security');
$txt_subtitle_table = __('Groups With Access', 'contexture-page-security');
/**
 * LOGIC
 ******************************************************************************/
//Determined if this term is protected
$protected_status = CTXPS_Queries::get_term_protection($_REQUEST['tag_ID']);
//Determine how protected status alters display
$echo_protcheck = $protected_status ? 'checked="checked"' : '';
$echo_tlist_style = $protected_status ? 'display:block;' : '';
//Get list of all groups
$all_groups = CTXPS_Queries::get_groups();
//Start with an empty array for $term_groups
$term_groups = CTXPS_Queries::get_groups_by_object('term', $_REQUEST['tag_ID']);
//Build $term_groups manually so that the array index uses id (to make it easier to sort)
$term_groups_simple = CTXPS_Queries::process_group_array($term_groups, 'names');
//Set default option
$ddl_group_opts = sprintf('<option value="0">%s</option>', $txt_addgroup);
//Loop through all groups in the db to populate the drop-down list
foreach ($all_groups as $group) {
    //Generate the option HTML, hiding it if it's already in our $currentGroups array
    $ddl_group_opts .= CTX_Helper::gen('option', array('class' => isset($term_groups_simple[$group->ID]) ? 'detach' : '', 'value' => $group->ID), $group->group_title);
}
//Put all those options into the select box
$selectbox = CTX_Helper::gen('select', array('id' => 'ctxps-grouplist-ddl', 'name' => 'ctxps-grouplist-ddl'), $ddl_group_opts);
/*
echo '<pre>
$avail::::
';
print_r($avail_groups);
echo '