You are here

function _get_role_choices in Ubercart 5

Function gets available roles for granting on product purcahse

@return: An assoc array with key = rid and value = role name

Parameters

$exclude: A list of role ids to exclude from the list

4 calls to _get_role_choices()
uc_roles_feature_form in uc_roles/uc_roles.module
Form builder for hook_product_feature
uc_roles_feature_settings in uc_roles/uc_roles.module
Form builder for role settings
uc_roles_store_status in uc_roles/uc_roles.module
Implementation of hook_store_status().
uc_roles_user in uc_roles/uc_roles.module
Implementation of hook_user().

File

uc_roles/uc_roles.module, line 1059
Grants roles upon accepted payment of products

Code

function _get_role_choices($exclude = array()) {
  $output = array();
  $roles = user_roles(TRUE);
  unset($roles[DRUPAL_AUTHENTICATED_RID]);
  $selected = variable_get('uc_roles_default_role_choices', array());
  $default = empty($selected);
  foreach ($roles as $rid => $name) {
    if ($default || !empty($selected[$rid]) && !in_array($rid, $exclude)) {
      $output[$rid] = $roles[$rid];
    }
  }
  return $output;
}