You are here

function push_notifications_mass_push_form in Push Notifications 7

Form callback for sending a mass-push notification.

1 string reference to 'push_notifications_mass_push_form'
push_notifications_menu in ./push_notifications.module
Implements of hook_menu().

File

includes/push_notifications.admin.inc, line 403
Admin files for Push Notifications module.

Code

function push_notifications_mass_push_form($form_state) {
  $form = array();
  $form['message'] = array(
    '#type' => 'fieldset',
    '#title' => t('Push Notification Message'),
    '#description' => t('Compose the elements of your push notification message.'),
    '#tree' => TRUE,
  );
  $form['message']['alert'] = array(
    '#type' => 'textfield',
    '#title' => t('Push Message'),
    '#description' => t('Compose the message to send out (!limit characters max.)', array(
      '!limit' => PUSH_NOTIFICATIONS_APNS_PAYLOAD_SIZE_LIMIT,
    )),
    '#default_value' => isset($form_state['values']['message']['alert']) ? $form_state['values']['message']['alert'] : '',
    '#required' => TRUE,
    '#size' => 128,
    '#maxlength' => PUSH_NOTIFICATIONS_APNS_PAYLOAD_SIZE_LIMIT,
    '#weight' => 10,
  );
  if (module_exists('locale')) {
    $form['language'] = array(
      '#type' => 'select',
      '#title' => t('Language'),
      '#options' => push_notifications_used_languages(),
      '#description' => t('Optionally, only select the push notifications to recipients with this language.'),
      '#default_value' => isset($form_state['values']['language']) ? $form_state['values']['language'] : '',
      '#weight' => 12,
    );
  }

  // Only show Android option if C2DM credentials are available.
  $recipients_options = array(
    'ios' => t('iOS (iPhone/iPad)'),
  );
  if (PUSH_NOTIFICATIONS_C2DM_USERNAME && PUSH_NOTIFICATIONS_C2DM_PASSWORD || PUSH_NOTIFICATIONS_GCM_API_KEY || PUSH_NOTIFICATIONS_FCM_SERVER_KEY) {
    $recipients_options['android'] = t('Android');
  }
  $form['recipients'] = array(
    '#type' => 'checkboxes',
    '#title' => t('Recipients'),
    '#description' => t('Select the recipients for this push message'),
    '#options' => $recipients_options,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => 'Send Push Notification',
    '#weight' => 50,
  );
  return $form;
}