Skip to main content
edited title
Link
pinueve
  • 1.6k
  • 1
  • 11
  • 17

trigger in rules a beep sound on user side (current user is working)

deleted 317 characters in body
Source Link
pinueve
  • 1.6k
  • 1
  • 11
  • 17

I have a D7 site running with Organic groups, rules, VBO, panels, badges, private-message modules ... and a bootstrap sub-theme (js, jQuery update, ...) working in all browsers, ios & android, i need to alert users with a beep sound when new OG content is created (or any rules reaction). I google arround and some answers are based on JS (only browsers), other by HTML5, and some by CSS using a wav file, all very confusing. I'll apreciate how to handle it by a custom module, some code included will be very helpfull named beepsound module.

• Rules action: Loop: all OG group members, loop action: EMPTYsee code below

For rules action I suppose that I have to trigger some JS code in “my-module”, or just “play” a HTML5 audio tag, with mp3 or wav file, "my-module""beepsound module" must have UID variable to target a specific OG member.

Big cuestion is, how to implement “my-module” code actions triggered by rules?

EDIT: iI have manage to have my beepsound as an action in rules, it targets UID, it display a personalised message corectly, also, message is displayed 5 times (when tiggered when mycontentype is being viewed), meaning rule is triggered 5 times, here isare my module INC file-module code files, dot module file exist but is empty (and not displayed here), If i run this rule with current-user, it works (makes a beep), but not in my OG loop, what it is wrong?

I have a D7 site running with Organic groups, rules, VBO, panels, badges, private-message modules ... and a bootstrap sub-theme (js, jQuery update, ...) working in all browsers, ios & android, i need to alert users with a beep sound when new OG content is created (or any rules reaction). I google arround and some answers are based on JS (only browsers), other by HTML5, and some by CSS using a wav file, all very confusing. I'll apreciate how to handle it by a custom module, some code included will be very helpfull.

• Rules action: Loop: all OG group members, loop action: EMPTY

For rules action I suppose that I have to trigger some JS code in “my-module”, or just “play” a HTML5 audio tag, with mp3 or wav file, "my-module" must have UID variable to target a specific OG member.

Big cuestion is, how to implement “my-module” code actions triggered by rules?

EDIT: i have manage to have my beepsound as an action in rules, it targets UID, it display a personalised message corectly, also, message is displayed 5 times, meaning rule is triggered 5 times, here is my module INC file, dot module file exist but is empty, If i run this rule with current-user, it works (makes a beep), but not in my OG loop, what it is wrong?

I have a D7 site running with Organic groups, rules, VBO, panels, badges, private-message modules ... and a bootstrap sub-theme (js, jQuery update, ...) working in all browsers, ios & android, i need to alert users with a beep sound when new OG content is created (or any rules reaction) by a custom module named beepsound module.

• Rules action: Loop: all OG group members, loop action: see code below

"beepsound module" must have UID variable to target a specific OG member.

I have manage to have my beepsound as an action in rules, it targets UID, it display a personalised message corectly, also, message is displayed 5 times (when tiggered when mycontentype is being viewed), meaning rule is triggered 5 times, here are my-module code files, dot module file exist but is empty (and not displayed here), If i run this rule with current-user, it works (makes a beep), but not in my OG loop, what it is wrong?

added 1617 characters in body
Source Link
pinueve
  • 1.6k
  • 1
  • 11
  • 17

EDIT: i have manage to have my beepsound as an action in rules, it targets UID, it display a personalised message corectly, but NO sound, if I run same code on XAMPP it "sounds" only once as spected, but not in drupal, also, message is displayed 5 times, meaning rule is triggered 5 times, here is my module INC file, dot module file exist but is empty, mp3 andIf i run this rule with current-user, it works .ogg files are uploaded and(makes a beep), but not in correct path and accessmy OG loop, what it is wrong?

/**
* Implement hook_rules_action_info()
* Declare any meta data about actions for Rules
*/

function beepsound_rules_action_info() {
$actions = array(
'beepsound_action_beepsound_user' => array(
    'label' => t('Make a beep sound'),
    'group' => t('sound'),
    'parameter' => array(
        'account' => array(
            'type' => 'user',
            'label' => t('User to beep'),
            ),
    ),
  ),

);

  return $actions;
}

/**
 * The action function for produce sound
 */

function beepsound_action_beepsound_user($account) {
    drupal_set_message(t('Hello @username',
 array('@username' => $account->name)));
    ?><audio autoplay="autoplay">
      <source src="Asrc="/sites/all/modules/beepsound/A-tone.ogg" type="audio/ogg">
      <source src="Asrc="/sites/all/modules/beepsound/A-Tone.mp3" type="audio/mp3">
    </audio><?php
} 

here is my rule

{ "og_og_new_content_notification_message" : {
"LABEL" : "OG new content notification message",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"TAGS" : [ "OG" ],
"REQUIRES" : [ "og", "rules", "privatemsg_rules", "beepsound" ],
"ON" : { "node_insert" : [] },
"IF" : [ { "og_entity_is_group_content" : { "entity" : [ "node" ] } } ],
"DO" : [
  { "og_get_members" : {
      "USING" : { "group_content" : [ "node" ] },
      "PROVIDE" : { "group_members" : { "group_members" : "List of group members" } }
    }
  },
  { "LOOP" : {
      "USING" : { "list" : [ "group-members" ] },
      "ITEM" : { "list_item" : "Current list item" },
      "DO" : [
        { "privatemsg_rules_new" : {
            "USING" : {
              "recipient" : [ "list-item" ],
              "author" : [ "node:author" ],
              "subject" : "\u0022[node:title]\u0022 a sido creado. ",
              "body" : "\u003Ca href=\u0022\/node\/[node:nid]\u0022\u003E Por favor haz clic aqu\u00ed para ver su contenido\u003C\/a\u003E"
            },
            "PROVIDE" : { "thread_id" : { "thread_id" : "ID of new thread" } }
          }
        },
        { "beepsound_action_beepsound_user" : { "account" : [ "list-item" ] } },
        { "drupal_message" : { "message" : "beep beep, usuario: \u0022[list-item:uid]\u0022" } }
      ]
    }
  },
  { "drupal_message" : { "message" : "Se ha enviado un mensaje a todos los miembros del departamento." } }
]

} }

EDIT: i have manage to have my beepsound as an action in rules, it targets UID, it display a personalised message corectly, but NO sound, if I run same code on XAMPP it "sounds" only once as spected, but not in drupal, also, message is displayed 5 times, meaning rule is triggered 5 times, here is my module INC file, dot module file exist but is empty, mp3 and .ogg files are uploaded and in correct path and access, what it is wrong?

/**
* Implement hook_rules_action_info()
* Declare any meta data about actions for Rules
*/

function beepsound_rules_action_info() {
$actions = array(
'beepsound_action_beepsound_user' => array(
    'label' => t('Make a beep sound'),
    'group' => t('sound'),
    'parameter' => array(
        'account' => array(
            'type' => 'user',
            'label' => t('User to beep'),
            ),
    ),
  ),

);

  return $actions;
}

/**
 * The action function for produce sound
 */

function beepsound_action_beepsound_user($account) {
    drupal_set_message(t('Hello @username',
 array('@username' => $account->name)));
    ?><audio autoplay="autoplay">
      <source src="A-tone.ogg" type="audio/ogg">
      <source src="A-Tone.mp3" type="audio/mp3">
    </audio><?php
} 

EDIT: i have manage to have my beepsound as an action in rules, it targets UID, it display a personalised message corectly, also, message is displayed 5 times, meaning rule is triggered 5 times, here is my module INC file, dot module file exist but is empty, If i run this rule with current-user, it works (makes a beep), but not in my OG loop, what it is wrong?

/**
* Implement hook_rules_action_info()
* Declare any meta data about actions for Rules
*/

function beepsound_rules_action_info() {
$actions = array(
'beepsound_action_beepsound_user' => array(
    'label' => t('Make a beep sound'),
    'group' => t('sound'),
    'parameter' => array(
        'account' => array(
            'type' => 'user',
            'label' => t('User to beep'),
            ),
    ),
  ),

);

  return $actions;
}

/**
 * The action function for produce sound
 */

function beepsound_action_beepsound_user($account) {
    drupal_set_message(t('Hello @username',
 array('@username' => $account->name)));
    ?><audio autoplay="autoplay">
      <source src="/sites/all/modules/beepsound/A-tone.ogg" type="audio/ogg">
      <source src="/sites/all/modules/beepsound/A-Tone.mp3" type="audio/mp3">
    </audio><?php
} 

here is my rule

{ "og_og_new_content_notification_message" : {
"LABEL" : "OG new content notification message",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"TAGS" : [ "OG" ],
"REQUIRES" : [ "og", "rules", "privatemsg_rules", "beepsound" ],
"ON" : { "node_insert" : [] },
"IF" : [ { "og_entity_is_group_content" : { "entity" : [ "node" ] } } ],
"DO" : [
  { "og_get_members" : {
      "USING" : { "group_content" : [ "node" ] },
      "PROVIDE" : { "group_members" : { "group_members" : "List of group members" } }
    }
  },
  { "LOOP" : {
      "USING" : { "list" : [ "group-members" ] },
      "ITEM" : { "list_item" : "Current list item" },
      "DO" : [
        { "privatemsg_rules_new" : {
            "USING" : {
              "recipient" : [ "list-item" ],
              "author" : [ "node:author" ],
              "subject" : "\u0022[node:title]\u0022 a sido creado. ",
              "body" : "\u003Ca href=\u0022\/node\/[node:nid]\u0022\u003E Por favor haz clic aqu\u00ed para ver su contenido\u003C\/a\u003E"
            },
            "PROVIDE" : { "thread_id" : { "thread_id" : "ID of new thread" } }
          }
        },
        { "beepsound_action_beepsound_user" : { "account" : [ "list-item" ] } },
        { "drupal_message" : { "message" : "beep beep, usuario: \u0022[list-item:uid]\u0022" } }
      ]
    }
  },
  { "drupal_message" : { "message" : "Se ha enviado un mensaje a todos los miembros del departamento." } }
]

} }

added 1628 characters in body
Source Link
pinueve
  • 1.6k
  • 1
  • 11
  • 17
Loading
Post Reopened by Pierre.Vriens, Clive
added 41 characters in body
Source Link
pinueve
  • 1.6k
  • 1
  • 11
  • 17
Loading
added 41 characters in body
Source Link
pinueve
  • 1.6k
  • 1
  • 11
  • 17
Loading
added 347 characters in body
Source Link
pinueve
  • 1.6k
  • 1
  • 11
  • 17
Loading
deleted 63 characters in body
Source Link
pinueve
  • 1.6k
  • 1
  • 11
  • 17
Loading
Post Closed as "Needs more focus" by Kevin, Adrian Cid Almaguer, Shawn Conn, Clive
deleted 24 characters in body; edited title
Source Link
pinueve
  • 1.6k
  • 1
  • 11
  • 17
Loading
added 20 characters in body; edited title
Source Link
pinueve
  • 1.6k
  • 1
  • 11
  • 17
Loading
deleted 11 characters in body; edited title
Source Link
pinueve
  • 1.6k
  • 1
  • 11
  • 17
Loading
added 128 characters in body
Source Link
pinueve
  • 1.6k
  • 1
  • 11
  • 17
Loading
Source Link
pinueve
  • 1.6k
  • 1
  • 11
  • 17
Loading