function simplenews_node_tab_send_form in Simplenews 6.2
Same name and namespace in other branches
- 7.2 includes/simplenews.admin.inc \simplenews_node_tab_send_form()
- 7 includes/simplenews.admin.inc \simplenews_node_tab_send_form()
Simplenews tab form
1 string reference to 'simplenews_node_tab_send_form'
- simplenews_node_tab_page in ./
simplenews.module - Menu callback. Displays newsletter-related stuff of a node.
File
- ./
simplenews.module, line 324 - Simplenews node handling, sent email, newsletter block and general hooks
Code
function simplenews_node_tab_send_form($form_state, $node) {
// Prepare
$simplenews_values = _simplenews_get_node_defaults();
if (isset($node->simplenews) && !empty($node->simplenews)) {
$simplenews_values = $node->simplenews;
}
// Flatten the values for e.g. preview to make them accessible same as default and load.
$simplenews_values = _simplenews_flatten_array($simplenews_values);
$form = array();
// We will need the node
$form['nid'] = array(
'#type' => 'hidden',
'#value' => $node->nid,
);
$form['simplenews'] = array(
'#type' => 'fieldset',
'#title' => t('Send newsletter'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
// We need #tree to persist key 'simplenews' in submissions
'#tree' => TRUE,
);
// Add tid
$vid = variable_get('simplenews_vid', '');
foreach ($node->taxonomy as $tid => $term) {
if ($term->vid == $vid) {
$form['simplenews']['tid'] = array(
'#type' => 'hidden',
'#value' => $term->tid,
);
break;
}
}
// Show newsletter sending options if newsletter has not been send yet.
// If send a nodification is shown.
if (!isset($simplenews_values['s_status']) || isset($simplenews_values['s_status']) && $simplenews_values['s_status'] == SIMPLENEWS_STATUS_SEND_NOT) {
$options[SIMPLENEWS_COMMAND_SEND_TEST] = t('Send one test newsletter to the test address');
$options[SIMPLENEWS_COMMAND_SEND_NOW] = t('Send newsletter');
$form['simplenews']['send'] = array(
'#type' => 'radios',
'#title' => t('Send action'),
'#default_value' => variable_get('simplenews_send', SIMPLENEWS_COMMAND_SEND_TEST),
'#options' => $options,
'#attributes' => array(
'class' => 'simplenews-command-send',
),
);
$address_default = variable_get('site_mail', ini_get('sendmail_from'));
if (variable_get('simplenews_test_address_override', 0)) {
$form['simplenews']['test_address'] = array(
'#type' => 'textfield',
'#title' => t('Test email addresses'),
'#description' => t('Supply a comma-separated list of email addresses to be used as test addresses.'),
'#default_value' => isset($simplenews_values['test_address']) ? $simplenews_values['test_address'] : variable_get('simplenews_test_address', $address_default),
'#size' => 60,
'#maxlength' => 128,
);
}
else {
$form['simplenews']['test_address'] = array(
'#type' => 'hidden',
'#value' => variable_get('simplenews_test_address', $address_default),
);
}
$form['simplenews']['advanced'] = array(
'#type' => 'fieldset',
'#title' => t('Email options'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
// Hide format selection if there is nothing to choose.
// The default format is plain text.
$format_options = _simplenews_format_options();
if (count($format_options) > 1) {
$form['simplenews']['advanced']['s_format'] = array(
'#type' => 'select',
'#title' => t('Email format'),
'#default_value' => isset($simplenews_values['s_format']) ? $simplenews_values['s_format'] : variable_get('simplenews_format', 'plain'),
'#options' => _simplenews_format_options(),
);
}
else {
$form['simplenews']['advanced']['s_format'] = array(
'#type' => 'hidden',
'#value' => key($format_options),
);
}
// include function that provides the priority values
module_load_include('inc', 'simplenews', 'includes/simplenews.admin');
$form['simplenews']['advanced']['priority'] = array(
'#type' => 'select',
'#title' => t('Email priority'),
'#default_value' => isset($simplenews_values['priority']) ? $simplenews_values['priority'] : variable_get('simplenews_priority', SIMPLENEWS_PRIORITY_NONE),
'#options' => simplenews_get_priority(),
);
$form['simplenews']['advanced']['receipt'] = array(
'#type' => 'checkbox',
'#title' => t('Request receipt'),
'#return_value' => 1,
'#default_value' => isset($simplenews_values['receipt']) ? $simplenews_values['receipt'] : variable_get('simplenews_receipt', 0),
);
}
else {
$form['simplenews']['none'] = array(
'#type' => 'checkbox',
'#return_value' => 0,
'#attributes' => array(
'checked' => 'checked',
'disabled' => 'disabled',
),
);
$form['simplenews']['none']['#title'] = $simplenews_values['s_status'] == SIMPLENEWS_STATUS_SEND_READY ? t('This newsletter has been sent.') : t('This newsletter is pending.');
// We return now, because there's no point in having a submit button
return $form;
}
$form['simplenews']['s_status'] = array(
'#type' => 'hidden',
'#value' => isset($simplenews_values['s_status']) ? $simplenews_values['s_status'] : SIMPLENEWS_STATUS_SEND_NOT,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Submit'),
);
return $form;
}