You are here

key_ui.module in Key 7

File

modules/key_ui/key_ui.module
View source
<?php

define('KEY_MENU_PATH', 'admin/config/system/keys');

/**
 * Implements hook_menu().
 */
function key_ui_menu() {
  $items = array();
  $items[KEY_MENU_PATH] = array(
    'title' => 'Keys',
    'description' => 'Manage keys.',
    'page callback' => 'key_ui_key_configs_list',
    'access arguments' => array(
      'administer keys',
    ),
    'file' => 'includes/key_ui.admin.inc',
    'type' => MENU_NORMAL_ITEM,
  );
  $items[KEY_MENU_PATH . '/list'] = array(
    'title' => 'List keys',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
  );
  $items[KEY_MENU_PATH . '/add'] = array(
    'title' => 'Add key',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'key_ui_key_config_form',
    ),
    'access arguments' => array(
      'administer keys',
    ),
    'file' => 'includes/key_ui.admin.inc',
    'type' => MENU_LOCAL_ACTION,
  );
  $items[KEY_MENU_PATH . '/edit/%key_ui_config'] = array(
    'title' => 'Edit key',
    'title callback' => 'key_ui_config_edit_title',
    'title arguments' => array(
      5,
    ),
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'key_ui_key_config_form',
      5,
    ),
    'access arguments' => array(
      'administer keys',
    ),
    'file' => 'includes/key_ui.admin.inc',
  );
  $items[KEY_MENU_PATH . '/delete/%key_ui_config'] = array(
    'title' => 'Delete key',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'key_ui_key_config_delete_confirm',
      5,
    ),
    'access arguments' => array(
      'administer keys',
    ),
    'file' => 'includes/key_ui.admin.inc',
  );
  $items[KEY_MENU_PATH . '/integration'] = array(
    'title' => 'Integration',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'key_ui_key_integration_form',
    ),
    'access arguments' => array(
      'administer keys',
    ),
    'file' => 'includes/key_ui.admin.inc',
    'type' => MENU_LOCAL_TASK,
  );
  return $items;
}

/**
 * Implements hook_theme().
 */
function key_ui_theme() {
  return array(
    'key_ui_key_configs_list_description' => array(
      'variables' => array(
        'label' => NULL,
        'name' => NULL,
        'description' => NULL,
      ),
      'file' => 'includes/key_ui.admin.inc',
    ),
    'key_ui_key_integrations_fieldset' => array(
      'render element' => 'form',
      'file' => 'includes/key_ui.admin.inc',
    ),
  );
}

/**
 * Title callback for the key configuration edit page.
 *
 * @param string $config_name
 *   The machine-readable name of the configuration being edited.
 *
 * @return string
 *   The human-friendly label of the requested configuration.
 */
function key_ui_key_config_edit_title($config_name) {
  return $config['label'];
}

/**
 * Menu argument loader: loads a key configuration by name.
 *
 * @param string $name
 *   The machine-readable name of an configuration to load,
 *   where '-' is replaced with '_'.
 *
 * @return array
 *   An array representing an key configuration or FALSE if the
 *   configuration does not exist.
 */
function key_ui_config_load($name) {
  return key_get_config(strtr($name, array(
    '-' => '_',
  )));
}

Functions

Namesort descending Description
key_ui_config_load Menu argument loader: loads a key configuration by name.
key_ui_key_config_edit_title Title callback for the key configuration edit page.
key_ui_menu Implements hook_menu().
key_ui_theme Implements hook_theme().

Constants

Namesort descending Description
KEY_MENU_PATH