You are here

function nodejs_add_user_to_channel in Node.js integration 8

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

Add a user to a channel.

Parameters

mixed $uid:

mixed $channel:

Return value

boolean

1 call to nodejs_add_user_to_channel()
AddUserToChannelForm::submitForm in src/Form/AddUserToChannelForm.php
Form submission handler.

File

./nodejs.module, line 624

Code

function nodejs_add_user_to_channel($uid, $channel) {

  // Http request went ok. Process Node.js server response.
  if ($node_response = nodejs_get_nodejs()
    ->addUserToChannel($uid, $channel)) {
    if ($node_response->status == 'success') {
      return TRUE;
    }
    else {
      $params = array(
        '%uid' => $uid,
        '%channel' => $channel,
        '%error' => $node_response->error,
      );
      \Drupal::logger('nodejs')
        ->error(t('Error adding user with uid: %uid to channel %channel on the Node.js server. Server response: %error', $params));
      return FALSE;
    }
  }
  else {
    return FALSE;
  }
}