You are here

function gauth_account_edit_form in Google Auth 7

Same name and namespace in other branches
  1. 7.2 gauth.admin.inc \gauth_account_edit_form()

Form builder; Edit an 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_account_edit_form_submit()

gauth_account_edit_form_validate()

1 string reference to 'gauth_account_edit_form'
gauth_menu in ./gauth.module
Implements hook_menu().

File

./gauth.admin.inc, line 93
Administration pages for Google OAuth settings.

Code

function gauth_account_edit_form($form, &$form_state, $id = NULL) {
  $form['id'] = array(
    '#type' => 'value',
    '#value' => $id,
  );
  $account = array();
  if ($id) {
    $account = gauth_account_load($id, FALSE);
  }
  $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,
  );
  $form['developer_key'] = array(
    '#type' => 'textfield',
    '#title' => t('Api Key'),
    '#description' => t('The server api key of 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'] : 'offline',
  );
  $form['callback_url'] = array(
    '#type' => 'textfield',
    '#title' => t('Redirect Url'),
    '#description' => t('Copy this url and paste it in google project as a authorized redirect url.'),
    '#default_value' => gauth_callback_url(),
    '#attributes' => array(
      'disabled' => 'disabled',
    ),
  );
  $form['uid'] = array(
    '#type' => 'value',
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Save'),
    '#suffix' => l(t('Cancel'), 'admin/config/services/gauth_account'),
  );
  return $form;
}