function postmark_settings_form in Postmark 6
Same name and namespace in other branches
- 7 postmark.admin.inc \postmark_settings_form()
Setting form for Postmark
1 call to postmark_settings_form()
- postmark_mailengine in ./
postmark.module - Implementation of hook_mailengine().
1 string reference to 'postmark_settings_form'
- postmark_menu in ./
postmark.module - Implementation of hook_menu().
File
- ./
postmark.admin.inc, line 12 - Administration include for Postmark.
Code
function postmark_settings_form() {
// Is Postmark enabled
$postmark_enabled = variable_get('postmark_enabled', 0);
// Enable the Postmark library for sending emails
$form['postmark_enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Enable Postmark to send Drupal emails'),
'#default_value' => $postmark_enabled,
'#description' => t('Use Postmark to act as your mail handler.'),
);
// The user's Postmark API key
$form['postmark_api_key'] = array(
'#type' => 'textfield',
'#title' => t('Postmark API key'),
'#default_value' => variable_get('postmark_api_key', ''),
'#description' => t('You Postmark API key similar to : ed742D75-5a45-49b6-a0a1-5b9ec3dc9e5d (taken from the API page)'),
'#required' => TRUE,
);
// Debug settings fieldset
$form['debug'] = array(
'#type' => 'fieldset',
'#title' => t('Debugging'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['debug']['postmark_debug_mode'] = array(
'#type' => 'checkbox',
'#title' => t('Enable Postmark debugging'),
'#default_value' => variable_get('postmark_debug_mode', 0),
'#description' => t('Use Postmark debugging, just to display what is contained in the Drupal $message variable (this will be extended to include more debugging options)'),
);
$form['debug']['postmark_debug_email'] = array(
'#type' => 'textfield',
'#title' => t('Enable Postmark debugging email'),
'#default_value' => variable_get('postmark_debug_email', variable_get('site_mail', '')),
'#description' => t('Use a debugging email, so all system emails will go to this address. Debugging mode must be on for this to work'),
);
$form['debug']['postmark_debug_no_send'] = array(
'#type' => 'checkbox',
'#title' => t('Enable Postmark debugging to not send an email and therefore not use a credit'),
'#default_value' => variable_get('postmark_debug_no_send', 0),
'#description' => t('Disable credit usage when debugging'),
);
$form['test'] = array(
'#type' => 'fieldset',
'#title' => t('Test configuration'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['test']['test_address'] = array(
'#type' => 'textfield',
'#title' => t('Recipient'),
'#default_value' => '',
'#description' => t('Enter a valid email address to send a test email.'),
);
// Add our own submit to the form
$form['#submit'][] = 'postmark_settings_form_submit';
// It makes sense to set the smtp_library value as
// per PHPMailer as both modules may be in place
// and so the settings could work together as opposed
// to overlapping, which would mean the heaviest
// (in weight) module wins
$smtp_library = variable_get('smtp_library', '');
if ($postmark_enabled) {
if (strpos($smtp_library, 'postmark') === FALSE) {
variable_set('smtp_library', drupal_get_filename('module', 'postmark'));
}
}
else {
if (strpos($smtp_library, 'postmark') !== FALSE || !$smtp_library) {
// We unset the smtp_library if postmark
variable_del('smtp_library');
// Inform user smtp_library isn't set but Postmark is installed and disabled
drupal_set_message('Postmark is installed but <em>disabled</em>, also the current SMTP library is not set: <em>sending via default PHP mail class</em>.', 'warning', FALSE);
}
}
return system_settings_form($form);
}