You are here

function key_ui_key_integration_form in Key 7

Menu callback; displays the list of key integrations.

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

File

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

Code

function key_ui_key_integration_form($form, &$form_state) {

  // Clear the plugin cache on the first page load, but not on AJAX refreshes.
  if (!isset($form_state['values'])) {
    _key_clear_plugin_cache('key_integration');
  }
  $integrations = key_get_integrations();
  $modules = system_rebuild_module_data();
  $form['#tree'] = TRUE;
  $form['integrations'] = array();
  foreach ($integrations as $name => $integration) {
    $type_label = !empty($integration['type']) ? $integration['type'] : t('Other');
    $form['integrations'][$type_label][$name] = array(
      'enabled' => array(
        '#type' => 'checkbox',
        '#title' => t('Enabled'),
        '#default_value' => $integration['enabled'],
      ),
      'name' => array(
        '#markup' => $integration['title'],
      ),
      'description' => array(
        '#markup' => $integration['description'],
      ),
      'module' => array(
        '#markup' => $modules[$integration['module']]->info['name'],
      ),
    );
    if (isset($integration['locked']) && $integration['locked'] == TRUE) {
      $form['integrations'][$type_label][$name]['enabled']['#disabled'] = TRUE;
    }
  }

  // Create the fieldsets for each integration type.
  foreach (element_children($form['integrations']) as $type) {
    $form['integrations'][$type] += array(
      '#type' => 'fieldset',
      '#title' => $type,
      '#collapsible' => TRUE,
      '#theme' => 'key_ui_key_integrations_fieldset',
      '#header' => array(
        array(
          'data' => t('Enabled'),
          'class' => array(
            'checkbox',
          ),
        ),
        t('Name'),
        t('Description'),
        t('Module'),
      ),
    );
  }

  // Sort the fieldsets by title.
  uasort($form['integrations'], 'element_sort_by_title');

  // Add the submit button.
  $form['actions'] = array(
    '#type' => 'actions',
  );
  $form['actions']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save integrations'),
  );
  return $form;
}