-
Notifications
You must be signed in to change notification settings - Fork 0
/
sms.rules.inc
67 lines (59 loc) · 1.42 KB
/
sms.rules.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
/**
* @file
* Rules module support of the smsframework.
*/
/**
* Implements hook_rules_event_info().
*/
function sms_rules_event_info() {
return array(
'sms_incoming' => array(
'label' => t('When a SMS message is received.'),
'module' => 'SMS Framework',
'arguments' => array(
'number' => array(
'label' => t('Number'),
'type' => 'sms_number',
),
'message' => array(
'label' => t('Message'),
'type' => 'sms_message',
),
),
),
);
}
/**
* Implements hook_token_values().
*/
function sms_token_values($type, $object = NULL, $options = array()) {
$values = array();
if ($type == 'sms_message') {
$values['message'] = $object;
$words = explode(' ', $object);
foreach ($words as $key => $word) {
$values['word-' . $key] = $word;
}
}
elseif ($type == 'sms_number') {
$values['number'] = $object;
}
return $values;
}
/**
* Implements hook_token_list().
*/
function sms_token_list($type = 'all') {
$tokens = array();
switch ($type) {
case 'sms_message':
$tokens['sms_message']['message'] = t('SMS message text');
$tokens['sms_message']['word-??'] = t('Individual word of the message text as specified by the ??.');
break;
case 'sms_number':
$tokens['sms_number']['number'] = t('The origin mobile number');
break;
}
return $tokens;
}