You are here

function user_relationship_invites_invite_form_validate in User Relationships 7

Same name and namespace in other branches
  1. 6 user_relationship_invites/user_relationship_invites.module \user_relationship_invites_invite_form_validate()

Custom form validation handler for the 'invite_form' form from Invite module This custom handler acts to store the User Relationships relationship type ID so that it can be used in the hook_invite implementation as it is not otherwise available. Also, adds a relationship action link if the user already exists.

1 string reference to 'user_relationship_invites_invite_form_validate'
user_relationship_invites_form_invite_form_alter in user_relationship_invites/user_relationship_invites.module
Implements hook_form_alter().

File

user_relationship_invites/user_relationship_invites.module, line 65
Drupal Module: User Relationship Invites

Code

function user_relationship_invites_invite_form_validate($form, &$form_state) {
  global $user;
  if (!empty($form_state['values']['rtid']) && $form_state['values']['ur_request']) {
    $user->rtid = $form_state['values']['rtid'];
    $emails = _invite_get_emails($form_state['values']['email']);
    if ($failed_emails = _invite_filter_registered_emails($emails)) {
      foreach ($failed_emails as $email) {
        $account = user_load_by_mail($email);
        if ($actions = user_relationships_ui_actions_between($user, $account, array(
          'add' => 1,
          'requested' => 1,
          'received' => 1,
        ))) {
          drupal_set_message(theme('item_list', array(
            'items' => $actions,
          )), 'error');
        }
      }
    }
  }
  else {
    unset($form_state['values']['rtid']);
    unset($form_state['values']['requestor']);
    unset($form_state['values']['requestee']);
  }
}