You are here

function workbench_email_get_user_roles in Workbench Email 7.3

Returns roles array if the user has any.

Parameters

int $uid: The user ID

Return value

roles Returns an array of roles associated to the user or an empty array

1 call to workbench_email_get_user_roles()
workbench_email_get_editors in ./workbench_email.module
Function to get all the editors of workbench access section.

File

./workbench_email.module, line 569
Code for the Workbench Email Module.

Code

function workbench_email_get_user_roles($uid) {
  $rids = array();
  $query = db_select('users_roles', 'ur');
  $query
    ->fields('ur', array(
    'rid',
  ));
  $query
    ->fields('r', array(
    'name',
    'weight',
  ));
  $query
    ->join('role', 'r', 'ur.rid = r.rid');
  $query
    ->condition('ur.uid', $uid);
  $query
    ->distinct();
  $result = $query
    ->execute();
  while ($row = $result
    ->fetchAssoc()) {
    $rids[$row['rid']] = $row;
  }
  return $rids;
}