You are here

function hubspot_admin_settings in HubSpot 6.2

Same name and namespace in other branches
  1. 6 hubspot.admin.inc \hubspot_admin_settings()
  2. 7.3 hubspot.admin.inc \hubspot_admin_settings()
  3. 7 hubspot.admin.inc \hubspot_admin_settings()
  4. 7.2 hubspot.admin.inc \hubspot_admin_settings()

@file Provides admin settings page to adjust HubSpot API key, debugging settings, and JavaScript embedding.

1 string reference to 'hubspot_admin_settings'
hubspot_menu in ./hubspot.module
Implements hook_menu() to get the config page listed

File

./hubspot.admin.inc, line 8
Provides admin settings page to adjust HubSpot API key, debugging settings, and JavaScript embedding.

Code

function hubspot_admin_settings() {
  $form = array();
  $hubspot_access_token = $_GET['access_token'];
  if (!empty($hubspot_access_token)) {
    variable_set('hubspot_access_token', $hubspot_access_token);
  }
  $hubspot_refresh_token = $_GET['refresh_token'];
  if (!empty($hubspot_refresh_token)) {
    variable_set('hubspot_refresh_token', $hubspot_refresh_token);
  }
  $hubspot_expires_in = $_GET['expires_in'];
  if (!empty($hubspot_expires_in)) {
    variable_set('hubspot_expires_in', $hubspot_expires_in);
  }
  $hubspot_error = $_GET['error'];
  if ($hubspot_error == "access_denied") {
    drupal_set_message(t('You denied the request for authentication with Hubspot. Please click the button again and choose the AUTHORIZE option.'), 'error', FALSE);
  }
  $form['settings'] = array(
    '#title' => t('HubSpot Settings'),
    '#type' => 'fieldset',
  );
  $form['settings']['hubspot_portalid'] = array(
    '#title' => t('HubSpot Portal ID'),
    '#type' => 'textfield',
    '#default_value' => variable_get('hubspot_portalid', ''),
    '#description' => t('Enter the Hubspot Portal ID for this site.  It can be found by <a href="https://login.hubspot.com/login" target="_blank">logging into HubSpot</a> going to the Dashboard and examining the url. Example: "https://app.hubspot.com/dashboard-plus/12345/dash/".  The number after "dashboard-plus" is your Portal ID.'),
  );
  if (variable_get('hubspot_portalid', '')) {
    $form['settings']['hubspot_authentication'] = array(
      '#value' => t('Connect Hubspot Account'),
      '#type' => 'submit',
      '#validate' => array(),
      '#submit' => array(
        'hubspot_oauth_submit',
      ),
    );
    if (variable_get('hubspot_refresh_token', '')) {
      $form['settings']['hubspot_authentication']['#suffix'] = t('Your Hubspot account is connected.');
      $form['settings']['hubspot_authentication']['#value'] = t('Disconnect Hubspot Account');
      $form['settings']['hubspot_authentication']['#submit'] = array(
        'hubspot_oauth_disconnect',
      );
    }
  }
  $form['settings']['hubspot_log_code'] = array(
    '#title' => t('HubSpot Traffic Logging Code'),
    '#type' => 'textarea',
    '#default_value' => variable_get('hubspot_log_code', ''),
    '#description' => t('To enable HubSpot traffic logging on your site, paste the External Site Traffic Logging code here.'),
  );
  $form['debug'] = array(
    '#title' => t('HubSpot Debugging Settings'),
    '#type' => 'fieldset',
  );
  $form['debug']['hubspot_debug_on'] = array(
    '#title' => t('Debugging enabled'),
    '#type' => 'checkbox',
    '#default_value' => variable_get('hubspot_debug_on', 0),
    '#description' => t('If debugging is enabled, HubSpot errors will be emailed to the address below. Otherwise, they will be logged to the regular Drupal error log.'),
  );
  $form['debug']['hubspot_debug_email'] = array(
    '#title' => t('Debugging email'),
    '#type' => 'textfield',
    '#default_value' => variable_get('hubspot_debug_email', variable_get('site_mail', '')),
    '#description' => t('Email error reports to this address if debugging is enabled.'),
  );
  return system_settings_form($form);
}