diff --git a/privatemsg.pages.inc b/privatemsg.pages.inc index aecd4a1..87939e9 100644 --- a/privatemsg.pages.inc +++ b/privatemsg.pages.inc @@ -291,7 +291,11 @@ function privatemsg_new($form, &$form_state, $recipients = '', $subject = '') { $to_plain = array(); $to_title = array(); foreach ($to as $recipient) { - $to_plain[] = privatemsg_recipient_format($recipient, array('plain' => TRUE, 'unique' => $unique)); + // Load user(s) with that name + $user = _privatemsg_parse_userstring($recipient->name); + // If the count of duplicated is more than 0 that means the recipient name is used by the other recipient type, + // so we should use unique. + $to_plain[] = privatemsg_recipient_format($recipient, array('plain' => TRUE, 'unique' => (count($user[2]) > 0))); $to_title[] = privatemsg_recipient_format($recipient, array('plain' => TRUE)); } $recipients_plain = implode(', ', $to_plain); diff --git a/privatemsg.test b/privatemsg.test index c564437..62e692c 100644 --- a/privatemsg.test +++ b/privatemsg.test @@ -1396,16 +1396,16 @@ class PrivatemsgAPITestCase extends PrivatemsgBaseTestCase { $this->drupalLogin($author); $this->drupalGet(privatemsg_get_link(array($recipient1))); - $this->assertFieldByName('recipient', $recipient1->name . ' [user]'); + $this->assertFieldByName('recipient', $recipient1->name); $this->drupalGet(privatemsg_get_link(array($recipient1, $recipient2))); - $this->assertFieldByName('recipient', $recipient1->name . ' [user], ' . $recipient2->name . ' [user]'); + $this->assertFieldByName('recipient', $recipient1->name . ', ' . $recipient2->name); $this->drupalGet(privatemsg_get_link(array($recipient1, $recipient2), $author)); - $this->assertFieldByName('recipient', $recipient1->name . ' [user], ' . $recipient2->name . ' [user]'); + $this->assertFieldByName('recipient', $recipient1->name . ', ' . $recipient2->name); $this->drupalGet(privatemsg_get_link(array($recipient1, $recipient2), $author, $subject = 'Str/"ang\\w3//')); - $this->assertFieldByName('recipient', $recipient1->name . ' [user], ' . $recipient2->name . ' [user]'); + $this->assertFieldByName('recipient', $recipient1->name . ', ' . $recipient2->name); $this->assertFieldByName('subject', $subject); // Disable privatemsg for recipient 3. @@ -1414,7 +1414,7 @@ class PrivatemsgAPITestCase extends PrivatemsgBaseTestCase { $this->assertFalse(privatemsg_get_link(array($recipient3), $author)); $this->drupalGet(privatemsg_get_link(array($recipient1, $recipient3), $author)); - $this->assertFieldByName('recipient', $recipient1->name . ' [user]'); + $this->assertFieldByName('recipient', $recipient1->name); // Disable links to self, verify that a link is only returned when the // author is not the only recipient. @@ -1423,14 +1423,14 @@ class PrivatemsgAPITestCase extends PrivatemsgBaseTestCase { $this->assertFalse(privatemsg_get_link(array($author), $author)); $this->drupalGet(privatemsg_get_link(array($recipient1, $author), $author)); - $this->assertFieldByName('recipient', $recipient1->name . ' [user]'); + $this->assertFieldByName('recipient', $recipient1->name); // Verify that link is not shown when recipient doesn't have read // permission. $this->assertFalse(privatemsg_get_link(array($recipient4), $author)); $this->drupalGet(privatemsg_get_link(array($recipient1, $recipient4), $author)); - $this->assertFieldByName('recipient', $recipient1->name . ' [user]'); + $this->assertFieldByName('recipient', $recipient1->name); // Verify that link is not shown when author does not have write permission. $this->drupalLogin($recipient1);