You are here

function user_relationships_get_message in User Relationships 7

Same name and namespace in other branches
  1. 5 user_relationships_api.inc \user_relationships_get_message()
  2. 5.2 user_relationships_api.inc \user_relationships_get_message()

Public API for getting the set or default message

Use the relationship message system. This is set up to retrieve the admin's set messages or fall back on the default if those aren't set. It'll automatically replace specific tokens with information from $relationship. If you need to provide additional tokens, they can be sent through $replacements.

Parameters

$key: Message name, see _user_relationships_ui_default_messages() for the keys and default messages attached to those keys.

$replacements: Replaceable tokens to append or replace default tokens.

Return value

Formatted message.

9 calls to user_relationships_get_message()
user_relationships_admin_type_delete in ./user_relationships.admin.inc
Relationship type delete page.
user_relationships_ui_pending_requested_submit in user_relationships_ui/user_relationships_ui.actions.inc
Approve, Decline, or Cancel a relationship request
user_relationships_ui_remove_submit in user_relationships_ui/user_relationships_ui.actions.inc
Remove a relationship
user_relationships_ui_request in user_relationships_ui/user_relationships_ui.forms.inc
Request a new relationship with another user
user_relationships_ui_request_submit in user_relationships_ui/user_relationships_ui.actions.inc
Process relationship request.

... See full list

File

./user_relationships.module, line 959
User Relationships API. Module shell.

Code

function user_relationships_get_message($key, $relationship = NULL, $replacements = array()) {
  $msg = variable_get("user_relationships_msg_{$key}", NULL);
  if ($relationship) {
    if (!isset($relationship->requester)) {
      $relationship->requester = user_load($relationship->requester_id);
    }
    if (!isset($relationship->requestee)) {
      $relationship->requestee = user_load($relationship->requestee_id);
    }
    $replaceables = user_relationships_type_translations(user_relationships_type_load($relationship->rtid)) + array(
      '!requester' => theme('username', array(
        'account' => $relationship->requester,
      )),
      '!requestee' => theme('username', array(
        'account' => $relationship->requestee,
      )),
    );
    $replacements = array_merge($replaceables, $replacements);
  }
  if (is_null($msg)) {
    $messages = _user_relationships_default_messages($replacements);
    $msg = _user_relationships_get_from_array($key, $messages);
  }
  else {
    $msg = t($msg, $replacements);
  }
  return $msg;
}