You are here

function user_relationships_api_socnet_all_pending_to in User Relationships 6

return a list of uid of users who want to relate to $uid, optionally filter by relationship name

File

user_relationships_api/user_relationships_api.socnet.inc, line 121
User Relationships implementation of http://drupal.org/project/drupal_universal_relation_api @author Alex Karshakevich http://drupal.org/user/183217

Code

function user_relationships_api_socnet_all_pending_to($uid = NULL, $relation_name = NULL, $relation_style = 'all') {
  $args = array(
    'requestee_id' => $uid,
    'approved' => 0,
  );

  //optinally filter on relationship name
  if ($relation_name) {
    $args['name'] = $relation_name;
  }

  //or, filter on relationship directionality
  if ($relation_style == 'one-way') {
    $args['is_oneway'] = TRUE;
  }
  elseif ($relation_style == 'two-way') {
    $args['is_oneway'] = FALSE;
  }
  $result = user_relationships_load($args, array(
    'sort' => 'requester_id',
  ));
  if ($result > 0) {
    return array_keys($result);
  }

  //else return nothing
}