function simplenews_send_newsletter_action_form in Simplenews 6
Same name and namespace in other branches
- 6.2 simplenews_action/simplenews_action.module \simplenews_send_newsletter_action_form()
Implementation of a configurable Drupal action. Send newsletter
File
- simplenews_action/
simplenews_action.module, line 92 - simplenews_action.inc Provide actions for simplenews.
Code
function simplenews_send_newsletter_action_form($context) {
//TODO improve usability by adding a pre-selection of newsletters before the newsletter issue selection
// Requires AHAH function to select newsletters issues based on selected newsletter
//
// if (!isset($context['newsletter'])) {
// $context['newsletter'] = array();
// }
if (!isset($context['newsletter_issue'])) {
$context['newsletter_issue'] = array();
}
if (!isset($context['resend'])) {
$context['resend'] = FALSE;
}
$tree = taxonomy_get_tree(variable_get('simplenews_vid', ''));
$terms = array();
foreach ($tree as $newsletter) {
$terms[$newsletter->tid] = $newsletter->name;
}
// $form['newsletter'] = array(
// '#title' => t('Newsletter'),
// '#type' => 'select',
// '#options' => $terms,
// '#default_value' => $context['newsletter'],
// '#description' => t('The newsletter series'),
// );
$result = taxonomy_select_nodes(array_keys($terms));
$nids = array();
while ($node = db_fetch_object($result)) {
$nids[$node->nid] = $node->title;
}
$form['newsletter_issue'] = array(
'#title' => t('Newsletter issue'),
'#type' => 'select',
'#options' => $nids,
'#default_value' => $context['newsletter_issue'],
'#description' => t('The newsletter issue to send'),
);
$form['resend'] = array(
'#title' => t('Allow to resend newsletter'),
'#type' => 'checkbox',
'#default_value' => $context['resend'],
'#description' => t('When checked a newsletter will be send even when already sent before. The newsletter sent status is checked, not the status of individual email addresses. Use this for repeated (e.g. monthly) newsletters.'),
);
return $form;
}