messaging_sms.module in Messaging 6.4
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(
'title' => 'SMS Framework',
'name' => t('SMS'),
'description' => t('Send SMS using SMS Framework.'),
'group' => 'sms',
// Class of send method
'type' => MESSAGING_TYPE_SEND,
'address_type' => 'mobile',
// Which kind of address this method uses
'glue' => ' ',
'render callback' => 'messaging_sms_render',
'send callback' => 'messaging_sms_send_msg',
'destination callback' => 'messaging_sms_user_destination',
'anonymous' => TRUE,
// Allow anonymous destinations
'filter' => 'messaging_plaintext',
);
return $info;
case 'address types':
$types['mobile'] = array(
'name' => t('Mobile phone number'),
'uid2address callback' => 'messaging_sms_user_destination',
);
}
}
/**
* Message Render callback
*/
function messaging_sms_render($message, $info) {
// We need to apply filtering first or run through the render function
$message = Messaging_Send_Method::default_render($message, $info);
// Now we do some clean up in the body that may contain new lines, replace them with spaces
if ($message->body) {
$message->body = messaging_text_clean($message->body, ' ');
}
return $message;
}
/**
* Map user account to SMS destination (phone number)
*/
function messaging_sms_user_destination($account) {
$account = messaging_user_object($account);
// Check for active mobile infomation. Simply return it so that the send
// callback has a destination array and access everything.
if (!empty($account->sms_user) && $account->sms_user[0]['status'] == 2 && !empty($account->sms_user[0]['number'])) {
return $account->sms_user[0]['number'];
}
}
/**
* Send SMS message using the default gateway
*
* This is just a wrapper for sms_send()
*
* @param $destination
* Mobile phone number
*/
function messaging_sms_send_msg($destination, $message, $params = array()) {
$text = messaging_text_build($message, ' ');
return sms_send($destination, $text, $params);
}
/**
* Implementation of hook_disable()
*/
function messaging_sms_disable() {
messaging_method_disable('sms');
}
Functions
Name | Description |
---|---|
messaging_sms_disable | Implementation of hook_disable() |
messaging_sms_messaging | Implementation of hook_messaging |
messaging_sms_render | Message Render callback |
messaging_sms_send_msg | Send SMS message using the default gateway |
messaging_sms_user_destination | Map user account to SMS destination (phone number) |