You are here

function gauth_user_services_edit_form in Google Auth 7

Same name and namespace in other branches
  1. 7.2 gauth_user/gauth_user.admin.inc \gauth_user_services_edit_form()

Form builder; Edit an services account.

Parameters

array $form_state: An associative array containing the current state of the form.

int $id: An id of the account.

See also

gauth_user_services_edit_form_submit()

gauth_user_services_edit_form_validate()

1 string reference to 'gauth_user_services_edit_form'
gauth_user_menu in gauth_user/gauth_user.module
Implements hook_menu().

File

gauth_user/gauth_user.admin.inc, line 87
Administration pages for Google Auth User Services.

Code

function gauth_user_services_edit_form($form, &$form_state, $id = NULL) {
  $account = array();
  if ($id) {
    $account = gauth_user_services_load($id, FALSE);
    $form['is_new'] = array(
      '#type' => 'value',
      '#value' => FALSE,
    );
  }
  else {
    $form['is_new'] = array(
      '#type' => 'value',
      '#value' => TRUE,
    );
  }
  $form['name'] = array(
    '#type' => 'textfield',
    '#title' => t('Account Name'),
    '#description' => t('The unique name for this account.'),
    '#default_value' => isset($account['name']) ? $account['name'] : '',
    '#required' => TRUE,
  );

  // Machine-readable type name.
  $form['id'] = array(
    '#type' => 'machine_name',
    '#default_value' => $id ? $id : '',
    '#maxlength' => 32,
    '#machine_name' => array(
      'exists' => 'gauth_user_services_types',
      'source' => array(
        'name',
      ),
    ),
    '#description' => t('A unique machine-readable name for this service account. It must only contain lowercase letters, numbers, and underscores.'),
  );
  $form['developer_key'] = array(
    '#type' => 'textfield',
    '#title' => t('Api Key'),
    '#description' => t('The server api key of the web application.'),
    '#default_value' => isset($account['developer_key']) ? $account['developer_key'] : '',
    '#required' => TRUE,
  );
  $form['client_id'] = array(
    '#type' => 'textfield',
    '#title' => t('Client Id'),
    '#description' => t('The CLIENT ID in the "Client ID for web application" section.'),
    '#default_value' => isset($account['client_id']) ? $account['client_id'] : '',
    '#required' => TRUE,
  );
  $form['client_secret'] = array(
    '#type' => 'textfield',
    '#title' => t('Client Secret Key'),
    '#description' => t('The CLIENT SECRET in the "Client ID for web application" section.'),
    '#default_value' => isset($account['client_secret']) ? $account['client_secret'] : '',
    '#required' => TRUE,
  );
  $options = gauth_google_services_names();
  $form['services'] = array(
    '#type' => 'select',
    '#title' => t('Services'),
    '#description' => t('Services that will be enabled to be used by this account.'),
    '#options' => $options,
    '#multiple' => TRUE,
    '#default_value' => isset($account['services']) ? explode(",", $account['services']) : array(),
    '#required' => TRUE,
  );
  $form['access_type'] = array(
    '#type' => 'radios',
    '#title' => t('Access Type'),
    '#description' => t('The Access Type of the account. Select offline if the site can perform actions even when the user is not online.'),
    '#options' => array(
      'offline' => t('Offline'),
      'online' => t('Online'),
    ),
    '#default_value' => isset($account['access_type']) ? $account['access_type'] : '',
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#suffix' => l(t('Cancel'), 'admin/config/services/gauth_user'),
  );
  return $form;
}