You are here

function encrypt_configs_list in Encrypt 7.3

Same name and namespace in other branches
  1. 7.2 includes/encrypt.admin.inc \encrypt_configs_list()

Menu callback; displays the list of configurations.

1 string reference to 'encrypt_configs_list'
encrypt_menu in ./encrypt.module
Implements hook_menu().

File

includes/encrypt.admin.inc, line 13
This file holds the functions for the Encrypt admin settings.

Code

function encrypt_configs_list() {
  $configs = encrypt_get_configs();
  $methods = encrypt_get_encryption_methods();
  $providers = encrypt_get_key_providers();
  $default_config = variable_get('encrypt_default_config', NULL);
  $header = array(
    t('Name'),
    t('Encryption Method'),
    t('Key Provider'),
    t('Created'),
    t('Status'),
    array(
      'data' => t('Operations'),
      'colspan' => '3',
    ),
  );
  $rows = array();
  foreach ($configs as $key => $config) {
    $label = $config['label'];
    $name = $config['name'];
    $description = $config['description'];
    $method = $config['method'];
    $provider = $config['provider'];
    $created = format_date($config['created'], 'short');
    $config_url_str = str_replace('_', '-', $name);
    $variables = array(
      'label' => $label,
      'name' => $name,
      'description' => $description,
    );

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

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

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

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

    // Set the status column.
    $status = array();
    $status[] = $config['enabled'] ? t('Enabled') : t('Disabled');
    if ($default_config == $config['name']) {
      $status[] = t('Default');
    }
    $row[] = array(
      'data' => implode(', ', $status),
    );

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

    // Set the delete column.
    $row[] = array(
      'data' => l(t('delete'), ENCRYPT_MENU_PATH . '/delete/' . $config_url_str),
    );

    // Set the make default column if this is not already the default.
    if ($default_config != $name) {
      $row[] = array(
        'data' => l(t('make default'), ENCRYPT_MENU_PATH . '/default/' . $config_url_str),
      );
    }
    else {
      $row[] = array(
        'data' => '',
      );
    }
    $rows[] = $row;
  }
  $build['encrypt_configs_list_table'] = array(
    '#theme' => 'table',
    '#header' => $header,
    '#rows' => $rows,
    '#empty' => t('No encryption configurations are available. <a href="@link">Add a configuration</a>.', array(
      '@link' => url(ENCRYPT_MENU_PATH . '/add'),
    )),
  );
  return $build;
}