function sms_carriers in SMS Framework 7
Same name and namespace in other branches
- 6.2 sms.module \sms_carriers()
Gets a list of all carriers
Parameters
string $domain: (optional) The domain for which the carriers are to be listed.
Return value
array An array of carriers keyed by the domain name and having arrays as values with the following keys:
- name: The human readable name of the carrier.
- type: The carrier type.
3 calls to sms_carriers()
- carrier_load in ./
sms.module - Loads a single carrier.
- sms_carriers_admin_form in ./
sms.admin.inc - Form builder for the list of sms carriers.
- sms_carriers_edit_form_validate in ./
sms.admin.inc - Form submission handler for sms_carriers_edit_form().
1 string reference to 'sms_carriers'
- carrier_save in ./
sms.module - Saves a carrier to database.
File
- ./
sms.module, line 512 - The core of the SMS Framework. Provides gateway management and API for sending and receiving SMS messages.
Code
function sms_carriers($domain = NULL) {
$default_carriers = module_invoke_all('sms_carriers');
$enabled_carriers = variable_get('sms_enabled_carriers', array());
$carriers = array();
// Load default carriers from code.
foreach ($default_carriers as $id => $carrier) {
$carriers[$id] = array(
'name' => $carrier,
'type' => SMS_CARRIER_DEFAULT,
);
}
// Load overriden carriers from database.
$result = db_query("SELECT name, domain FROM {sms_carriers}");
foreach ($result as $carrier) {
if (in_array($carrier->domain, array_keys($carriers))) {
$type = SMS_CARRIER_OVERRIDDEN;
}
else {
$type = SMS_CARRIER_NORMAL;
}
$carriers[$carrier->domain] = array(
'name' => $carrier->name,
'type' => $type,
);
}
foreach ($enabled_carriers as $carrier) {
if (is_array($carriers[$carrier])) {
$carriers[$carrier]['status'] = 1;
}
}
if ($domain) {
$carriers[$domain]['domain'] = $domain;
return $carriers[$domain];
}
return $carriers;
}