messaging_sms.module in Messaging 5
Same filename and directory in other branches
SMS Messsaging using SMS Framework. Messaging method plug-in
File
messaging_sms/messaging_sms.moduleView source
<?php
/**
* @file
* SMS Messsaging using SMS Framework. Messaging method plug-in
*/
/**
* Implementation of hook_messaging
*/
function messaging_sms_messaging($op = 'info') {
switch ($op) {
case 'send methods':
$info['sms'] = array(
'name' => t('SMS'),
'group' => 'sms',
// Class of send method
'send' => 'messaging_sms_send_msg',
'send_user' => 'messaging_sms_send_user',
'type' => MESSAGING_TYPE_PUSH,
'render' => 'messaging_sms_render_message',
'glue' => '',
'description' => t('Send SMS using SMS Framework.'),
);
return $info;
}
}
/**
* Message Render callback
*/
function messaging_sms_render_message($message, $info) {
// We need to apply filtering first or run through the render function
$message = messaging_message_render($message, $info);
// Now we do some clean up in the body that may contain new lines
if ($message->body) {
$message->body = str_replace("\n", ' ', $message->body);
}
return $message;
}
/**
* Send mail message to user account
*/
function messaging_sms_send_user($account, $message) {
// Try to find an available gateway
if (!empty($account->sms_user[0]) && $account->sms_user[0]['status'] == 2) {
return messaging_message_send(array(
$account,
), $message, 'sms');
}
else {
return FALSE;
}
}
/**
* Send message to multiple destinations
*
* @param $destination
* User account or destination phone number
*/
function messaging_sms_send_msg($destination, $message, $params = array()) {
$text = $message['subject'] . ' ' . $message['body'];
if (is_object($destination)) {
return sms_user_send($destination->uid, $text);
}
else {
return sms_send($destination, $text, $params);
}
}
Functions
Name | Description |
---|---|
messaging_sms_messaging | Implementation of hook_messaging |
messaging_sms_render_message | Message Render callback |
messaging_sms_send_msg | Send message to multiple destinations |
messaging_sms_send_user | Send mail message to user account |