approved) || !variable_get("user_relationship_privatemsg_send_{$op}", TRUE)) { return; } !$relationship->requester ? $relationship->requester = user_load(array('uid' => $relationship->requester_id)) : NULL; !$relationship->requestee ? $relationship->requestee = user_load(array('uid' => $relationship->requestee_id)) : NULL; $requester = $relationship->requester; $requestee = $relationship->requestee; $send_to = array(); switch ($op) { case 'request': case 'cancel': $message_to[] = $requestee; break; case 'approve': case 'disapprove': $message_to[] = $requester; break; case 'remove': $message_to[] = $requester; if (!$relationship->is_oneway) { $message_to[] = $requestee; } break; default: return; } $sender = user_load(array('uid' => variable_get('user_relationship_privatemsg_sender', 1))); foreach ($message_to as $target) { // This prevents possible "You cannot contact" messages from the Privatemsg module if ($sender->uid == $target->uid) { continue; } $replacements = user_relationship_privatemsg_replacements($relationship); if ($op == 'remove') { $replacements['@profile_uid'] = $target->uid; } $message_function = "user_relationship_privatemsg_{$op}_default"; $subject = t(variable_get("user_relationship_privatemsg_{$op}_subject", constant(strtoupper("user_relationship_privatemsg_{$op}_subject"))), $replacements); $message = t(variable_get("user_relationship_privatemsg_{$op}_message", $message_function()), $replacements); _privatemsg_send($sender, $target, $subject, $message, FILTER_FORMAT_DEFAULT, 0, 'user-relationship-notification'); } } /** * hook_form_alter() */ function user_relationship_privatemsg_form_alter($form_id, &$form) { global $user; switch ($form_id) { case 'privatemsg_new': $relationships = user_relationships_load(array('requester_id' => $user->uid), FALSE, 'requestee_id', NULL, NULL, TRUE); $contacts = array(); foreach ($relationships as $relationship_list) { foreach ($relationship_list as $relationship) { $contacts[$relationship->plural_name][$relationship->requestee_name] = $relationship->requestee_name; } } $form['quick']['#options'] = array_merge($form['quick']['#options'], $contacts); break; case 'privatemsg_contacts_form': $relationships = user_relationships_load(array('requester_id' => $user->uid), FALSE, 'rid', NULL, NULL, TRUE); foreach ($relationships as $relationship) { $form['contacts'][$relationship->requestee_id]['selected'] = array( '#type' => 'checkbox', ); $form['contacts'][$relationship->requestee_id]['name'] = array( '#type' => 'value', '#value' => $relationship->requestee_name, ); $form['contacts'][$relationship->requestee_id]['contact'] = array( '#type' => 'value', '#value' => theme('privatemsg_username', (object)array('uid' => $relationship->requestee_id, 'name' => $relationship->requestee_name)), ); $form['contacts'][$relationship->requestee_id]['operations'] = array( '#type' => 'value', '#value' => l(t('Write private message'), 'privatemsg/new/'. $relationship->requestee_id), ); } if ($relationships) { $form['selected'] = array( '#type' => 'fieldset', '#collapsible' => FALSE, '#collapsed' => FALSE, '#prefix' => '