You are here

function user_relationships_api_socnet_is_pending in User Relationships 6

true if user1 has requested a relationship to uid2, optionally set which relation and style to query

File

user_relationships_api/user_relationships_api.socnet.inc, line 45
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_is_pending($uid1 = NULL, $uid2 = NULL, $relation_name = NULL, $relation_style = 'all') {
  $args = array(
    'requester_id' => $uid1,
    'requestee_id' => $uid2,
    '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;
  }
  $count = user_relationships_load($args, array(
    'count' => TRUE,
  ));
  if ($count > 0) {
    return TRUE;
  }

  //else return nothing
}