You are here

function sms_blast_form_submit in SMS Framework 6

Same name and namespace in other branches
  1. 5 modules/sms_blast/sms_blast.module \sms_blast_form_submit()
  2. 6.2 modules/sms_blast/sms_blast.module \sms_blast_form_submit()
  3. 7 modules/sms_blast/sms_blast.module \sms_blast_form_submit()

Submit handler for the sms blast form

File

modules/sms_blast/sms_blast.module, line 51
Allows bulk text messages to be sent to registered users.

Code

function sms_blast_form_submit(&$form, $form_state) {
  $result = db_query("SELECT uid FROM {sms_user} WHERE status = 2");
  $confirmed_user_qty = db_affected_rows();
  if ($confirmed_user_qty) {
    while ($row = db_fetch_array($result)) {
      sms_user_send($row['uid'], $form_state['values']['message']);
    }
    drupal_set_message(t('The message was sent to %count users.', array(
      '%count' => $confirmed_user_qty,
    )));
  }
  else {
    drupal_set_message(t('There are 0 users with confirmed phone numbers. Message not sent.'));
  }
}