I am trying create a site for where authenticated users can register their mobile numbers via a block and then be automatically sent an sms when a content of certain types are created. I have clickatell working ok to send confirmations and send to phone works - I have also created a rule that states that every time a content of type x is saved send an sms.

When I get to the rule to send to a destination number I cannot see an option to add all users with confirmed numbers.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alansaviolobo’s picture

Assigned: Unassigned » alansaviolobo
Issue summary: View changes
alansaviolobo’s picture

This can be achieved with the following lines of code added to the sms_blast.module.

/**
 * Implements hook_rules_action_info().
 */
function sms_blast_rules_action_info()
{
  return array(
    'sms_blast_rules_action_fetch_users' => array(
      'label' => t('Fetch Users to send sms'),
      'group' => t('SMS'),
      'arguments' => array(
      ),
      'provides' => array(
        'users_fetched' => array('type' => 'list<user>', 'label' => t('Fetched users')),
      ),
    ),
  );
}

function sms_blast_rules_action_fetch_users()
{
  return array('users_fetched' => user_load_multiple(
    db_select('sms_user')
    ->fields('sms_user', array('uid', 'uid'))
    ->condition('status', 2, '=')
    ->execute()
    ->fetchAllKeyed()
  ));
}
alansaviolobo’s picture

Status: Active » Needs review
FileSize
1.54 KB

rolled a patch for the same

almaudoh’s picture

Re-uploaded patch in #3 above with "smsframework-" prefix so the testbot can pick it up...

almaudoh’s picture

Status: Needs review » Needs work
almaudoh’s picture

Status: Needs work » Needs review
almaudoh’s picture

Component: Core Framework » SMS User
Status: Needs review » Needs work
+++ b/modules/sms_blast/sms_blast.module
@@ -22,9 +22,9 @@ function sms_blast_permission() {
 function sms_blast_menu() {
...
+    'title' => 'SMS Blast',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('sms_blast_form'),

@@ -65,4 +65,30 @@ function sms_blast_form_submit(&$form, $form_state) {
+function sms_blast_rules_action_info() {
+  return array(
+    'sms_blast_rules_action_fetch_users' => array(
+      'label' => t('Fetch Users to send sms'),
+      'group' => t('SMS'),
+      'arguments' => array(),
+      'provides' => array(
+        'users_fetched' => array('type' => 'list<user>', 'label' => t('Fetched users')),
+      ),
+    ),
+  );
+}
+
+function sms_blast_rules_action_fetch_users() {
+  return array('users_fetched' => user_load_multiple(
+    db_select('sms_user')
+      ->fields('sms_user', array('uid', 'uid'))
+      ->condition('status', 2, '=')
+      ->execute()
+      ->fetchAllKeyed()
+  ));
+}

This functionality should be incorporated into the sms_user module, not sms_blast

alansaviolobo’s picture

I believe since this functionality is helping you send sms to multiple users, it would make more sense to be in sms_blast rather than sms_user

almaudoh’s picture

I believe since this functionality is helping you send sms to multiple users, it would make more sense to be in sms_blast rather than sms_user

It is creating an unnecessary dependency on sms_blast module because all the functionality is from sms_user module. Some admins may want this functionality but not sms_blast module (sms_blast is just a convenient ui).

Status: Needs work » Needs review
almaudoh’s picture

Status: Needs review » Needs work

CNW for #7.

almaudoh’s picture

Issue tags: +7.x-1.1