sms_blast.module in SMS Framework 5
Same filename and directory in other branches
Allows bulk text messages to be sent to registered users.
File
modules/sms_blast/sms_blast.moduleView source
<?php
/**
* @file
* Allows bulk text messages to be sent to registered users.
*/
/**
* Implementation of hook_menu().
*/
function sms_blast_menu($may_cache) {
$items = array();
if ($may_cache) {
$items[] = array(
'path' => 'sms_blast',
'title' => t('SMS Blast'),
'callback' => 'drupal_get_form',
'callback arguments' => array(
'sms_blast_form',
),
'access' => user_access('send sms blasts'),
'type' => MENU_NORMAL_ITEM,
);
}
return $items;
}
/**
* Implementation of hook_perm().
*/
function sms_blast_perm() {
return array(
'send sms blasts',
);
}
function sms_blast_form() {
$form['message'] = array(
'#type' => 'textarea',
'#title' => t('Message'),
'#cols' => 60,
'#rows' => 5,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Send'),
);
return $form;
}
function sms_blast_form_submit($form_id, $form_values) {
$result = db_query("SELECT uid FROM {users} WHERE uid <> 0");
while ($row = db_fetch_array($result)) {
$users[] = $row;
}
foreach ($users as $user) {
$this_user = user_load(array(
'uid' => $user['uid'],
));
if ($this_user->sms_user[0]['status'] == 2) {
sms_send($this_user->sms_user[0]['number'], $form_values['message'], $this_user->sms_user[0]['gateway']);
}
}
}
Functions
Name | Description |
---|---|
sms_blast_form | |
sms_blast_form_submit | |
sms_blast_menu | Implementation of hook_menu(). |
sms_blast_perm | Implementation of hook_perm(). |