You are here

function notifications_scheduler_admin_form in Notifications 7

Event configuration administration

1 string reference to 'notifications_scheduler_admin_form'
notifications_scheduler_menu in notifications_scheduler/notifications_scheduler.module
Implements hook_menu().

File

notifications_scheduler/notifications_scheduler.admin.inc, line 9

Code

function notifications_scheduler_admin_form($form, &$form_state, $aid = NULL) {
  $action_list = notifications_scheduler_admin_action_list();
  if ($aid && isset($action_list[$aid])) {
    return notifications_scheduler_admin_send_form($form, $form_state, $action_list[$aid]);
  }

  // Compile template list by type
  $template_list = array();
  foreach (notifications_info('message templates') as $key => $template) {
    $template_list[$key] = $template['title'];
  }
  $header = array(
    'action' => t('Action'),
    'template' => t('Template'),
    'triggers' => t('Triggers'),
    'operations' => t('Operations'),
  );
  $form['actions'] = array(
    '#tree' => TRUE,
    '#type' => 'fieldset',
    '#theme' => 'notifications_admin_table_form',
    '#header' => $header,
    '#empty' => t('There are no scheduled notifications available.'),
  );
  foreach (notifications_scheduler_admin_action_list() as $key => $action) {
    $form['actions'][$key]['action']['#markup'] = $action['label'];
    $form['actions'][$key]['template']['#markup'] = isset($template_list[$action['template']]) ? $template_list[$action['template']] : t('None');
    $form['actions'][$key]['triggers']['#markup'] = implode(', ', $action['triggers']);
    $operations['send'] = array(
      '#type' => 'link',
      '#title' => t('Preview'),
      '#href' => 'admin/config/messaging/notifications/scheduler/' . $key,
    );
    $form['actions'][$key]['operations'] = $operations;
  }
  return $form;
}