/**
  * Creates an "Add to Group" drop-down list to do bulk actions on the users page
  * @return string HTML
  */
 public static function render_bulk_add_to_group()
 {
     $addtogrp = __('Add to group', 'contexture-page-security') . '…';
     $groups = CTXPS_Queries::get_groups();
     //First, add our default option...
     $html = sprintf('<option value="">%s</option>', $addtogrp);
     //Then, add the rest of our groups as options
     foreach ($groups as $group) {
         if ($group->group_system_id !== 'CPS01') {
             //Dont include Registered Users group
             $html .= CTX_Helper::gen('option', array('value' => $group->ID), $group->group_title);
         }
     }
     //Now, lets wrap that in a select list
     $html = CTX_Helper::gen('select', array('name' => 'psc_group_add', 'id' => 'psc_group_add', 'style' => 'margin-left:5px;margin-right:5px;'), $html);
     //Add a label before the select
     $html = sprintf('<label class="screen-reader-text" for="psc_group_add">%s</label>', $addtogrp) . $html;
     //Add a button after the select
     $html .= sprintf('<input type="button" name="enrollit" id="enrollit" class="button-secondary" value="%s"/>', __('Add', 'contexture-page-security'));
     //Finally, wrap all that in a div and return
     return CTX_Helper::gen('div', array('class' => 'alignleft actions'), $html);
 }
$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 '

$term_groups::::
';
print_r($term_groups);
echo '

$all_groups::::
';
print_r($all_groups);