You are here

function user_relationships_pending_requested_submit in User Relationships 5

Same name and namespace in other branches
  1. 5.2 user_relationships_actions.inc \user_relationships_pending_requested_submit()

Approve, Disapprove, or Cancel a relationship request

File

./user_relationships_actions.inc, line 159

Code

function user_relationships_pending_requested_submit($form_id, &$form_values) {
  global $user;
  $relationship = $form_values['relationship'];
  $requester = $relationship->requester;
  $requestee = $relationship->requestee;
  $viewing_own_account = $user->uid == $requestee->uid;
  switch ($form_values['action']) {
    case 'approve':
      $updated = $relationship;
      $updated->approved = TRUE;
      user_relationships_update_relationship($relationship, $updated);
      drupal_set_message(user_relationships_get_message('accepted', array(
        '!requester' => theme('username', $requester),
        '!requestee' => theme('username', $requester),
        '%relationship_name' => $relationship->name,
        '%relationship_plural_name' => $relationship->plural_name,
      )));
      break;
    case 'cancel':
    case 'disapprove':
      user_relationships_delete_relationship($relationship, $user, $form_values['action']);
      drupal_set_message(user_relationships_get_message('denied', array(
        '!requester' => theme('username', $requester),
        '!requestee' => theme('username', $requestee),
        '%relationship_name' => $relationship->name,
        '%relationship_plural_name' => $relationship->plural_name,
      )));
      break;
    default:
      drupal_set_message(user_relationships_get_message('default'));
  }
  return 'relationships/' . $form_values['viewed_id'] . '/requests';
}