You are here

function _user_relationships_actions_between in User Relationships 5

Same name and namespace in other branches
  1. 5.2 user_relationships.module \_user_relationships_actions_between()

List of pending relationships with between two users

1 call to _user_relationships_actions_between()
user_relationships_user in ./user_relationships_hooks.inc
User

File

./user_relationships.module, line 99

Code

function _user_relationships_actions_between(&$viewer, &$viewed) {
  if ($viewer->uid == $viewed->uid) {
    return;
  }
  $list = array();
  $viewer_relationships = user_relationships_load_all_for_user($viewer->uid);
  foreach ($viewer_relationships as $relationship) {
    if (!$relationship->approved) {

      // Viewer is the requester
      if ($relationship->requestee_id == $viewed->uid) {
        $list[] = t('You have requested to be a %relationship_name of this user. (!pending_requests)', array(
          '%relationship_name' => $relationship->name,
          '!pending_requests' => l(t('pending requests'), "relationships/{$viewer->uid}/requests"),
        ));
      }
      else {
        if ($relationship->requester_id == $viewed->uid) {
          $list[] = t('This user believes that they are a %relationship_name of yours. (!pending_requests)', array(
            '%relationship_name' => $relationship->name,
            '!pending_requests' => l(t('pending requests'), "relationships/{$viewer->uid}/requests"),
          ));
        }
      }
    }
  }
  $count = 0;
  foreach ($viewer_relationships as $relationship) {
    if ($relationship->requester_id == $viewed->uid || $relationship->requestee_id == $viewed->uid) {
      $count++;
    }
  }
  $size = db_result(db_query("SELECT COUNT(*) FROM {user_relationship_types}"));
  if (variable_get('user_relationships_allow_multiple', TRUE) && $count < $size) {
    $list[] = theme('user_relationships_request_relationship_link', $viewed);
  }
  return $list;
}