You are here

function campaignmonitor_admin in Campaign Monitor 6.2

Same name and namespace in other branches
  1. 5.2 campaignmonitor.module \campaignmonitor_admin()
  2. 5 campaignmonitor.module \campaignmonitor_admin()
  3. 6 campaignmonitor.module \campaignmonitor_admin()
1 string reference to 'campaignmonitor_admin'
campaignmonitor_menu in ./campaignmonitor.module

File

./campaignmonitor.module, line 116

Code

function campaignmonitor_admin() {
  $api_key = variable_get('campaignmonitor_api_key', '');
  $client_id = variable_get('campaignmonitor_client_id', '');
  $list_id = variable_get('campaignmonitor_list_id', '');
  if ($api_key != '') {

    // check if valid details
    $valid = _campaignmonitor_check_details($api_key, $client_id, $list_id);
    if (!$valid) {
      drupal_set_message(t('Your Campaign Monitor details are not valid, please check them and try again.'), 'error');
    }
  }
  $form['campaignmonitor_api_key'] = array(
    '#type' => 'textfield',
    '#title' => t('API Key'),
    '#default_value' => $api_key,
    '#required' => TRUE,
    '#size' => 50,
    '#maxlength' => 200,
    '#description' => t('Your Campaign Monitor API Key. See <a href="http://www.campaignmonitor.com/api/required/">documentation</a>.'),
  );
  $form['campaignmonitor_client_id'] = array(
    '#type' => 'textfield',
    '#title' => t('Client ID'),
    '#default_value' => $client_id,
    '#required' => TRUE,
    '#size' => 50,
    '#maxlength' => 200,
    '#description' => t('Your Campaign Monitor Client ID. See <a href="http://www.campaignmonitor.com/api/required/">documentation</a>.'),
  );
  $form['campaignmonitor_list_id'] = array(
    '#type' => 'textfield',
    '#title' => t('List ID'),
    '#default_value' => $list_id,
    '#required' => TRUE,
    '#size' => 50,
    '#maxlength' => 200,
    '#description' => t('Your Campaign Monitor List ID. See <a href="http://www.campaignmonitor.com/api/required/">documentation</a>.'),
  );
  $keyoptions = campaignmonitor_get_field_keys();
  $form['campaignmonitor_namekey'] = array(
    '#type' => 'select',
    '#title' => t('Name'),
    '#options' => $keyoptions,
    '#default_value' => variable_get('campaignmonitor_namekey', ''),
    '#description' => t('Select what you wish to populate the name field with by default.'),
  );
  $form['campaignmonitor_block_options'] = array(
    '#type' => 'checkboxes',
    '#title' => 'Block Options',
    '#default_value' => variable_get('campaignmonitor_block_options', array()),
    '#options' => array(
      'unsubscribe' => t('Hide the unsubscribe option?'),
      'name_hide' => t('Hide the name field?'),
      'name_required' => t('Make the name field required? (Will be ignored if name field is hidden)'),
    ),
    '#description' => t("These options will affect how the Campaign Monitor block will display and function."),
  );
  $form['campaignmonitor_display_on'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Display on Options'),
    '#default_value' => variable_get('campaignmonitor_display_on', array()),
    '#options' => array(
      'contact' => t('Contact Page'),
      'registration' => t('Registration Page'),
    ),
    '#description' => t('Choose which forms you want to display the Join Newsletter checkbox.'),
  );
  $form['campaignmonitor_checkboxdisplaytext'] = array(
    '#type' => 'textfield',
    '#title' => t('Display Text for Checkbox'),
    '#default_value' => variable_get('campaignmonitor_checkboxdisplaytext', 'Join our Newsletter?'),
    '#description' => t("This text will display next to the checkbox on the selected forms."),
  );
  $form['campaignmonitor_userpagedisplaytext'] = array(
    '#type' => 'textfield',
    '#title' => t('Display Text for User Page'),
    '#default_value' => variable_get('campaignmonitor_userpagedisplaytext', 'Newsletter'),
    '#description' => t("This text will display next to the checkbox on the user profile page."),
  );
  $form['campaignmonitor_pastcampaignurl'] = array(
    '#type' => 'textfield',
    '#title' => t('Past Campaign URL'),
    '#default_value' => variable_get('campaignmonitor_pastcampaignurl', ''),
    '#size' => 100,
    '#maxlength' => 100,
    '#description' => t('This is required if you want to use the page that displays past campaigns. You can find this value if you go to Manage Clients, click on the client, go to the link that tells you how to display past campaigns, then copy the URL ONLY from the html given. The URL is in between the src="" value.'),
  );
  $form['campaignmonitor_connection_timeout'] = array(
    '#type' => 'textfield',
    '#title' => t('Connection timeout'),
    '#default_value' => variable_get('campaignmonitor_connection_timeout', 15),
    '#size' => 10,
    '#maxlength' => 10,
    '#description' => t("If your server can't get through to the API, or the API server is down, this is the amount of time until the connection times out in seconds. Default is 15 seconds."),
  );
  return system_settings_form($form);
}