You are here

function key_ui_key_configs_list in Key 7

Menu callback; displays the list of key configurations.

1 string reference to 'key_ui_key_configs_list'
key_ui_menu in modules/key_ui/key_ui.module
Implements hook_menu().

File

modules/key_ui/includes/key_ui.admin.inc, line 11
Administrative functionality for managing key configurations.

Code

function key_ui_key_configs_list() {
  $configs = key_get_configs();
  $header = array(
    t('Name'),
    t('Provider'),
    t('Type'),
    t('Status'),
    array(
      'data' => t('Operations'),
      'colspan' => '2',
    ),
  );
  $rows = array();
  foreach ($configs as $name => $config) {
    $label = $config['label'];
    $name = $config['name'];
    $description = $config['description'];
    $provider = key_get_provider($config['provider']);
    $type = key_get_type($config['type']);

    // Get the function to get the status of the key.
    $status_function = ctools_plugin_get_function($provider, 'status callback');

    // If there are any settings, use them.
    $provider_settings = isset($config['provider_settings']) ? $config['provider_settings'] : array();

    // Get the status of the key.
    $status = call_user_func($status_function, $provider_settings);
    $config_url_string = str_replace('_', '-', $name);
    $variables = array(
      'label' => $label,
      'name' => $name,
      'description' => $description,
    );

    // Set the name column.
    $row = array(
      theme('key_ui_key_configs_list_description', $variables),
    );

    // Set the key provider column.
    $row[] = array(
      'data' => $provider['title'],
    );

    // Set the type column.
    $row[] = array(
      'data' => $type['title'],
    );

    // Set the status column.
    $row[] = array(
      'data' => $status['message'],
    );

    // Set the edit column.
    $row[] = array(
      'data' => l(t('edit'), KEY_MENU_PATH . '/edit/' . $config_url_string),
    );

    // Set the delete column.
    $row[] = array(
      'data' => l(t('delete'), KEY_MENU_PATH . '/delete/' . $config_url_string),
    );
    $rows[] = $row;
  }
  $build['key_ui_configs_list_table'] = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#empty' => t('No keys are available. <a href="@link">Add a key</a>.', array(
      '@link' => url(KEY_MENU_PATH . '/add'),
    )),
  );
  return $build;
}