0

I am using the Privatemsg module, version 6.x-1.x.

If my username is "TEST" and I am sending the email to myself, the sent messages doesn't show "TEST." The "From" field is empty.

If I send the email to other users their names is displaying fine.

What is the reason of this, and what should I do to display my name there?

2 Answers 2

1

This is currently working as designed. The message listings do not show your own username as you obviously are a recipient as it is displayed for you. It is however a limitation of the current system that when you send a message to yourself, no recipient is shown.

You can alter the sql query and remove the exclusion of the current user for the sent list, but then it will always show the current user there.

There are some ideas on how to make the whole listings more flexible but that's quite a bit of work and needs time that I currently don't have.

0
0

Here's the answer:

/**
 * Theme the participants field.
 *
 * @see theme_privatemsg_list_field_participants()
 */
function YOUR_THEME_NAME_privatemsg_list_field__participants($thread) {
  global $user;
  if ((arg(1) == 'inbox' && arg(0) == 'messages') || (!arg(1) && arg(0) == 'messages') || ($_SESSION['parti'] == 'From') || (arg(1) == 'list' && arg(0) == 'messages')) {
    $msg = privatemsg_message_load($thread['thread_id'], $account = NULL);
    $participants[$msg[$msg['author']->uid]] = $msg['author'];
  }
  elseif ((arg(1) == 'sent' && arg(0) == 'messages') || ($_SESSION['parti'] == 'To')) {
    global $user;
    $participants = _privatemsg_generate_user_array($thread['participants'], -4);
    unset($participants[$user->uid]);
  }

  $field = $to = array();
  $limited = FALSE;

  if ($participants) {
    foreach ($participants as $account) {

      if (count($to) >= 1) {
        $limited = TRUE;
      }
      $to = get_profile_name(array('uid' => $account->uid));
      if($to->field_profile_first_name_value && $to->field_profile_last_name_value) {
        $dis_name = drupal_ucfirst($to->field_profile_first_name_value) .' '. drupal_ucfirst($to->field_profile_last_name_value);
      }
      else {
        $dis_name = drupal_ucfirst($account->name);
      }
      $pname[] = $dis_name;
      $plink[] = 'user/'. $account->uid;
    }
  }
  // This else do the magic of the displaying the user name.
  else {
    $to = get_profile_name(array('uid' => $user->uid));
    if($to->field_profile_first_name_value && $to->field_profile_last_name_value) {
      $dis_name = drupal_ucfirst($to->field_profile_first_name_value) .' '. drupal_ucfirst($to->field_profile_last_name_value);
    }
    else {
      $dis_name = drupal_ucfirst($account->name);
    }
    $pname[] = $dis_name;
    $plink[] = 'user/'. $account->uid;
  }

  $limit_string = '';
  if ($limited) {
    $limit_string = t(' and others');
  }
  if(count($pname)>0){
  $implodeVal = implode(', ', $pname);

    if(strlen($dis_name) > 10 && $_SESSION['parti']) {
      $textName = truncate_utf8($implodeVal, 10, FALSE, TRUE);
    } else {
      $textName = truncate_utf8($implodeVal, 35, FALSE, TRUE);
    }
    $explodeNameArray = explode(',',$textName);
    foreach($explodeNameArray as $key => $value){
      $splitedText[] = l($value,$plink[$key], 'title' => $value)));
    }

    $finalParticipants = implode(', ',$splitedText);
    $field['data'] = $finalParticipants;
  }
  $field['class'] = 'privatemsg-list-participants';
  return $field;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.