You are here

function user_relationships_request in User Relationships 5

Same name and namespace in other branches
  1. 5.2 user_relationships_forms.inc \user_relationships_request()

Request a new relationship with another user

1 string reference to 'user_relationships_request'
user_relationships_menu in ./user_relationships_hooks.inc
Menu

File

./user_relationships_forms.inc, line 202

Code

function user_relationships_request($requestee_id) {
  global $user;
  $requester = user_load(array(
    'uid' => $user->uid,
  ));
  $requestee = user_load(array(
    'uid' => $requestee_id,
  ));
  if (empty($requestee->name)) {
    drupal_set_message(user_relationships_get_message('non_existant_user'));
  }
  else {
    if (!user_access('can have relationship', $requestee)) {
      drupal_set_message(user_relationships_get_message('not_accepting_requests'));
    }
    else {
      if ($user->uid == $requestee_id) {
        drupal_set_message(user_relationships_get_message('self_request'));
      }
      else {
        $form = user_relationships_request_form($requester, $requestee);
        if (!$form['rtid']['#options']) {
          drupal_set_message(user_relationships_get_message('too_many_relationships'));
        }
        else {
          $form = confirm_form($form, t('How do you relate to %name?', array(
            '%name' => $requestee->name,
          )), "user/{$requestee->uid}", '', t('Create'), t('Cancel'), 'user_relationships_request_confirm');
          return $form;
        }
      }
    }
  }
  drupal_goto();
}