You are here

function key_get_key_names_as_options in Key 7.3

Gets all key configurations as options, for use in forms.

Parameters

array $filters: An array of filters to apply to the list of options.

bool $reset: A flag to force the configurations to be retrieved from the database.

Return value

array An array of key names, indexed by id.

3 calls to key_get_key_names_as_options()
key_config_features_export_options in includes/key_config.features.inc
Implements hook_features_export_options().
key_encrypt_key_settings_form in modules/key_encrypt/plugins/key_providers/key.inc
Settings form for the Key Module key provider.
_key_process_key_select in ./key.module
Process function to expand the key element.

File

./key.module, line 470
Main Key functionality and hook implementations.

Code

function key_get_key_names_as_options($filters = array(), $reset = FALSE) {
  $options = array();
  $keys = key_get_keys($reset);
  foreach ($filters as $index => $filter) {
    switch ($index) {
      case 'type':
        $keys = array_intersect_key(key_get_keys_by_type($filter, $reset), $keys);
        break;
      case 'provider':
        $keys = array_intersect_key(key_get_keys_by_provider($filter, $reset), $keys);
        break;
      case 'type_group':
        $keys = array_intersect_key(key_get_keys_by_type_group($filter, $reset), $keys);
        break;
    }
  }
  foreach ($keys as $key) {
    $key_id = $key['id'];
    $key_title = $key['label'];
    $options[$key_id] = (string) $key_title;
  }
  return $options;
}