function sms_handle_result in SMS Framework 6
Same name and namespace in other branches
- 5 sms.module \sms_handle_result()
- 6.2 sms.module \sms_handle_result()
- 7 sms.module \sms_handle_result()
Handle the gateway response so that it can be passed back for processing by the sender function
Parameters
array $response: Gateway response array, containing: status - Mandatory: TRUE or FALSE. (must maintain this for backward-compatibility). status_code - Optional: The SMS Framework gateway status code, as per the constants in this module. gateway_status_code - Optional: The gateway-specific status code, will be a different set of codes for each gateway. gateway_status_text - Optional: The gateway-specific status message text, will be different for each gateway and code. message - Optional: Same as gateway_status_text (must maintain this for backward-compatibility).
$number: The number used by sms_send().
$message: The message used by sms_send().
$gateway: The gateway array used by sms_send().
$options: The options array used by sms_send(). May also include key: 'return_full_gateway_response'.
Return value
Depending on value of $options['return_full_gateway_reponse'] (an optional key), this may be one of: TRUE or FALSE Array of status, gateway and message information.
1 call to sms_handle_result()
- sms_send in ./
sms.module - Sends a message using the active gateway.
File
- ./
sms.module, line 302 - The core of the SMS Framework. Provides gateway managment and API for sending and receiving SMS messages.
Code
function sms_handle_result($response, $number, $message, $gateway = array(), $options = array()) {
$status = $response['status'];
$status_code = array_key_exists('status_code', $response) ? $response['status_code'] : SMS_GW_UNKNOWN_STATUS;
$gateway_status_code = array_key_exists('gateway_status_code', $response) ? $response['gateway_status_code'] : '';
// Get the gateway_status_text
if (array_key_exists('gateway_status_text', $response)) {
$gateway_status_text = $response['gateway_status_text'];
}
elseif (array_key_exists('message', $response)) {
// This is here for backward-compatbility
$gateway_status_text = $response['message'];
}
else {
$gateway_status_text = '';
}
// Log failed messages (enabled by default as per previous behavior)
if (!$status && variable_get('sms_log_failed_messages', TRUE)) {
$error_message = 'Sending SMS to %number failed.';
$variables['%number'] = $number;
if ($gateway_status_text) {
$error_message .= ' The gateway said: ' . $gateway_status_text;
// Keeping this variable capture for backward-compatibility
if (!empty($result['variables'])) {
$variables = array_merge($variables, $result['variables']);
}
}
watchdog('sms', $error_message, $variables, WATCHDOG_ERROR);
}
// Whether to return the full response (disabled by default for backward-compatibility)
if (array_key_exists('return_full_gateway_response', $options) && $options['return_full_gateway_response'] == TRUE) {
// Return full gateway response array
$full_response = array(
'status' => $status,
'status_code' => $status_code,
'number' => $number,
'message' => $message,
'gateway' => $gateway,
'options' => $options,
);
$full_response['gateway']['status_code'] = $gateway_status_code;
$full_response['gateway']['status_text'] = $gateway_status_text;
return $full_response;
}
else {
// Return simple gateway response (TRUE or FALSE)
return $status;
}
}