You are here

function sms_clickatell_admin_form_validate in SMS Framework 6

Same name and namespace in other branches
  1. 5 modules/sms_clickatell/sms_clickatell.module \sms_clickatell_admin_form_validate()

File

modules/sms_clickatell/sms_clickatell.module, line 152
Clickatell gateway module for Drupal SMS Framework. Outbound+Inbound+Receipts

Code

function sms_clickatell_admin_form_validate($form, &$form_state) {

  // Check default sender
  if (!empty($form_state['values']['sms_clickatell_from'])) {
    if (!is_numeric($form_state['values']['sms_clickatell_from'])) {
      if (strlen($form_state['values']['sms_clickatell_from']) > 11) {
        form_set_error('sms_clickatell_from', t('An alphanumeric sender is limited to a maximum of 11 characters.'));
      }
    }
  }

  // Attempt a connection with the given credentials
  $result = sms_clickatell_command('auth', array(), $form_state['values']);
  if (!$result['status']) {
    form_set_error('', t('A Clickatell gateway error occured: @code: @text', array(
      '@code' => $result['gateway_status_code'],
      '@text' => $result['gateway_status_text'],
    )));
  }
  variable_set('sms_clickatell_session_id_timestamp', 0);
}