You are here

function carrier_save in SMS Framework 7

Same name and namespace in other branches
  1. 6.2 sms.module \carrier_save()

Saves a carrier to database.

Parameters

string $domain: The domain for which the carrier is to be saved.

array $edit: An array of new values to be saved for the carrier.

1 call to carrier_save()
sms_carriers_edit_form_submit in ./sms.admin.inc
Form submission handler for sms_carriers_edit_form().

File

./sms.module, line 576
The core of the SMS Framework. Provides gateway management and API for sending and receiving SMS messages.

Code

function carrier_save($domain, $edit) {
  if (!empty($domain)) {
    $carrier = carrier_load($domain);
    if ($carrier['type'] == SMS_CARRIER_DEFAULT) {
      $edit['status'] = 1;
      drupal_write_record('sms_carriers', $edit);
    }
    elseif (!empty($edit['domain'])) {

      //Case for when the domain name hasn't changed
      if ($edit['domain'] == $domain) {
        drupal_write_record('sms_carriers', $edit, 'domain');
      }
      else {
        carrier_delete($domain);
        drupal_write_record('sms_carriers', $edit);
      }

      // TODO: we need more logic to figure out when someone is changing the
      //   domain name.
    }
  }
  else {
    $edit['status'] = 1;
    drupal_write_record('sms_carriers', $edit);
  }
}