You are here

public static function drupalchatController::_drupalchat_buddylist in DrupalChat 8

2 calls to drupalchatController::_drupalchat_buddylist()
drupalchatController::drupalchat_poll in src/Controller/drupalchatController.php
Process and get messages
drupalchatController::_drupalchat_chat in src/Controller/drupalchatController.php

File

src/Controller/drupalchatController.php, line 314
Contains Drupal\drupalchat\Controller\drupalchatController

Class

drupalchatController

Namespace

Drupal\drupalchat\Controller

Code

public static function _drupalchat_buddylist($uid) {
  $users = array();
  $drupalchat_rel = \Drupal::config('drupalchat.settings')
    ->get('drupalchat_rel');
  if ($drupalchat_rel == DRUPALCHAT_REL_UR && function_exists('user_relationships_load')) {
    $relationships = user_relationships_load(array(
      'name' => Tags::explode(\Drupal::config('drupalchat.settings')
        ->get('drupalchat_ur_name')),
      'user' => $uid,
      'approved' => 1,
    ), array(), TRUE);
    foreach ($relationships as $rid => $relationship) {
      $uid == $relationship->requester_id ? $users[] = $relationship->requestee_id : ($users[] = $relationship->requester_id);
    }
  }
  elseif ($drupalchat_rel == DRUPALCHAT_REL_FF) {
    $result = db_query("SELECT * FROM {flag_friend} WHERE uid = :uid OR friend_uid = :uid", array(
      ':uid' => $uid,
      ':friend_uid' => $uid,
    ));
    foreach ($result as $friend) {
      $uid == $friend->uid ? $users[] = $friend->friend_uid : ($users[] = $friend->uid);
    }
  }
  return $users;
}