The problem originates in the following function found in the nodeownership.inc file:

function nodeownership_mail_tokens($language) {
  global $base_url;
  global $user;

  $tokens = array(
    '!username' => $user->name,
    '!site' => variable_get('site_name', 'Drupal'),
    '!uri' => $base_url,
    '!uri_brief' => preg_replace('!^https?://!', '', $base_url),
    '!mailto' => $user->mail,
    '!date' => format_date(REQUEST_TIME, 'medium', '', NULL, $language->language),
  );
  return $tokens;
}

For the mails automatically sent to the user when he submits a claim this code is fine, because $user will contain the account of the user making the claim.

However, when the administrator logs in and accepts or denies a claim, $user will contain the account details of the administrator, and any !username token placed in the acceptance or denial emails will be substituted with the administrators username, and not the username of the user making the claim.

To fix this requires adding a parameter (perhaps claim_id) to the nodeownership_mail_tokens function.

The relevant call stack for this is:
node_ownership_send_mail (in nodeownership.inc)
drupal_mail
nodeownership_mail
nodeownership_mail_tokens

To get a variable such as claim_id or the claimer's uid into nodeownership_mail_tokens, it looks like the node_ownership_send_mail function would have to use drupal_mail's $params parameter. This parameter is optional for drupal_mail, and is currently not being populated when called by node_ownership_send_mail.

Having a claim id available in nodeownership_mail_tokens would have the additional benefit of making it possible to create some additional and very useful tokens, such as !claimed_node_url

Comments

bhavikshah9’s picture

Assigned: Unassigned » bhavikshah9