You are here

function simplenews_scheduler_form_alter in Simplenews Scheduler 5

Same name and namespace in other branches
  1. 6 simplenews_scheduler.module \simplenews_scheduler_form_alter()

Implementation of hook_form_alter().

File

./simplenews_scheduler.module, line 59

Code

function simplenews_scheduler_form_alter($form_id, &$form) {
  if ($form_id == 'simplenews_node_form') {

    // todo: on this radio click show/unshow the schedule form part
    $form['sending_options']['send']['#options'][] = 'Send newsletter according to schedule';
    $form['sending_options']['schedule'] = array(
      '#type' => 'fieldset',
      '#title' => t('Schedule details'),
      '#weight' => 5,
      '#collapsible' => FALSE,
    );
    if (!$form['#node']->simplenews_scheduler_edition) {
      if (is_array($form['#node']->simplenews_scheduler)) {
        $form['sending_options']['send']['#default_value'] = sizeof($form['sending_options']['send']['#options']) - 1;
      }
      $form['sending_options']['schedule']['send_interval'] = array(
        '#type' => 'select',
        '#title' => t('Send once per'),
        '#default_value' => is_array($form['#node']->simplenews_scheduler) ? $form['#node']->simplenews_scheduler['send_interval'] : 'week',
        '#options' => array(
          'day' => t('Day'),
          'week' => t('Week'),
          'month' => t('Month'),
        ),
        '#description' => t('Interval to send at'),
      );
      $form['sending_options']['schedule']['interval_start'] = array(
        '#type' => 'textfield',
        '#title' => t('Starting on'),
        '#default_value' => is_array($form['#node']->simplenews_scheduler) ? format_date($form['#node']->simplenews_scheduler['sched_start'], 'custom', 'F j, Y H:i') : format_date(time(), 'custom', 'F j, Y H:i'),
        '#description' => t('Note: this will be rounded UP to the nearest hour or when ever your cron runs.'),
      );
      $form['sending_options']['schedule']['about_intervals'] = array(
        '#value' => 'Intervals work by creating a new node at the desired time and marking this to be sent.',
      );
    }
    else {
      $content = t('This node has been sent as part of a scheduled edition') . "<BR>";
      $content .= l(t('View the original newsletter here'), 'node/' . $form['#node']->simplenews_scheduler_edition['snid']);
      $form['sending_options']['schedule']['edition'] = array(
        '#value' => $content,
      );
    }
  }
}