You are here

function rolereference_potential_references in Role Reference 7

Return a rid->name array of referenceable roles, based on the field settings.

Parameters

{array} $referenceable_roles:

3 calls to rolereference_potential_references()
rolereference_field_prepare_view in ./rolereference.module
Implements hook_field_prepare_view().
rolereference_field_validate in ./rolereference.module
Implements hook_field_validate().
rolereference_options_list in ./rolereference.module
Implements hook_options_list().

File

./rolereference.module, line 250

Code

function rolereference_potential_references($referenceable_roles, $field_name) {
  $roles =& drupal_static('rolereference_' . $field_name, array());
  $user_roles = user_roles();
  if (empty($roles)) {
    foreach ($user_roles as $rid => $role) {
      if (!empty($referenceable_roles[$rid])) {
        $roles[$rid] = $role;
      }
    }
    if (empty($roles)) {
      $roles = $user_roles;
    }
  }
  return $roles;
}