You are here

function nodejs_send_role_message in Node.js integration 8

Same name and namespace in other branches
  1. 6 nodejs.module \nodejs_send_role_message()
  2. 7 nodejs.module \nodejs_send_role_message()

Send a message to users in a role.

Parameters

string $role_name:

string $subject:

string $body:

1 string reference to 'nodejs_send_role_message'
nodejs_drush_command in ./nodejs.drush.inc
Implements hook_drush_command().

File

./nodejs.module, line 245

Code

function nodejs_send_role_message($role_name, $subject, $body) {
  $query = \Drupal::database()
    ->select('users', 'u');
  $query
    ->join('users_roles', 'ur', 'ur.uid = u.uid');
  $query
    ->join('role', 'r', 'ur.rid = r.rid');
  $uids = $query
    ->fields('u', array(
    'uid',
  ))
    ->condition('r.name', $role_name)
    ->execute()
    ->fetchCol();
  nodejs_send_user_message_multiple($uids, $subject, $body);
}