function engagements_mass_sms_form

7.x engagements.module engagements_mass_sms_form()
6.x engagements.module engagements_mass_sms_form()

File

modules/engagements/engagements.module, line 503
This is the primary module file for the engagements module.

Code

function engagements_mass_sms_form() 
 {
  global $user;
  $form = array();

  fp_add_css(fp_get_module_path('engagements') . '/css/style.css');


  $form ['mark_top'] = array(
    'value' => "<p>" . t("Use this form to send the same SMS (txt) message to multiple recipients at a time.  <strong>Recipients must be either students
                          or faculty/staff at your institution, with their mobile numbers already in the database</strong>.  Your messages will
                  be queued, and sent out approximately one per second.") . "</p>",
  );



  if (isset($_SESSION ['mass_sms_batch_data'])) {
    $html = "";
    $html .= "<div class='mass-sms-batch-results'>";

    $message = $_SESSION ['mass_sms_batch_data']['message'];
    if (strlen($message) > 160) {
      $message = substr($message, 0, 160) . "...<em>" . t("trimmed") . "</em>";
    }
    $message = nl2br($message);

    $last_timestamp = $_SESSION ["mass_sms_batch_data"]["last_timestamp"];
    $last_batch_id = $_SESSION ["mass_sms_batch_data"]["batch_id"];
    $html .= t("The last mass batch of txt messages were sent on %time.", array('%time' => format_date(convert_time($last_timestamp)))) . "<br><br>
                " . t("The message sent was:") . "
                <div class='mass-msg-sent-trunc'>$message</div>";
    $html .= "<p>" . t("You may download a CSV of results relating to this session for the next hour by clicking the following link (valid for 1 hour):") . "</p>";
    $html .= "<p>" . l(t("Download CSV"), "stats/download-csv-from-batch/$last_batch_id", "filename=" . urlencode("mass_sms_results__" . $last_timestamp), array('class' => 'button')) . "
                " . t("Note: Row 2 of this CSV shows the actual message that was sent.  It is not repeated per-row, to save space.") . "</p>";


    $html .= "</div>";

    $form ['mark_last_batch'] = array(
      'type' => 'markup',
      'value' => $html,
    );
  }









  $form ['from_number'] = array(
    'label' => t("Select which mass-text phone number this will be coming from:"),
    'type' => 'select',
    'options' => engagements_get_from_phones_for_fapi(FALSE, $user, TRUE),
    'required' => TRUE,
    'hide_please_select' => TRUE,
  );

  $form ['message'] = array(
    'type' => 'textarea',
    'label' => t('Your message:'),
    'maxlength' => 1600,
    'required' => TRUE,
    'description' => t("To insert emoji in Windows, press <span style='padding-left: 10px; padding-right: 10px; font-size: 1.3em;'><i class='fa fa-windows'></i> + .</span>  <em>(Windows key + period)</em>
                        <br><br>
                        Keep in mind that pricing is based on 160-chars = 1 message segment.  
                        <br><b>Important:</b> Your message <u>will NOT</u> have any
                        header attached.  It would be a good idea to begin by stating what unit/department/school you are sending from.
                        <br>&nbsp; &nbsp; Ex: &nbsp; <em>From the UFP President's Office:  Welcome students to the new term...</em>
                        <br><b>Important:</b> Your message <u>WILL automatically</u> have a message appended letting the user know they can reply with STOP to opt-out of receiving text messages."),
  );


  $form ['recipients'] = array(
    'type' => 'textarea',
    'label' => t('Recipients:'),
    'rows' => 20,
    'required' => TRUE,
    'description' => t("List the recipients you wish to send your message, one per line.  You may enter a valid phone number, CWID, or email address.
                        The mobile phone number that is on record for the user with the entered CWID or email address is the one which will be used.  Invalid phone numbers
                        or users missing phone numbers will be skipped, with a report of skipped users displayed after this routine is run.
                        <br>Ex:
                        <br> &nbsp; &nbsp; 100556
                        <br> &nbsp; &nbsp; 100557
                        <br> &nbsp; &nbsp; 100558
                        <br> &nbsp; &nbsp; tom431@demo.edu
                        <br> &nbsp; &nbsp; 555-123-4567 "),
  );


  $form ['password'] = array(
    'label' => t("Enter the Mass SMS password:"),
    'type' => 'password',
    'description' => t("To prevent accidental submissions, please enter the Mass SMS password.  This is a word or phrase which is configured on the Engagements SMS settings
                        screen.  If you do not know this password, ask your system administrator."),
  );


  $form ['submit_btn'] = array(
    'type' => 'submit',
    'value' => t("Submit"),
    'spinner' => TRUE,
    'suffix' => "<a href='javascript:history.go(-1);'>" . t("Cancel") . "</a>",
  );

  return $form;
}