? overlay_subtabs_invisible.png
Index: privatemsg.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/privatemsg/privatemsg.module,v
retrieving revision 1.70.2.30.2.91.2.64.2.64
diff -u -p -r1.70.2.30.2.91.2.64.2.64 privatemsg.module
--- privatemsg.module	19 Jun 2010 11:30:33 -0000	1.70.2.30.2.91.2.64.2.64
+++ privatemsg.module	20 Jun 2010 08:09:22 -0000
@@ -1137,7 +1137,7 @@ function _privatemsg_block_menu() {
   if (count($links)) {
     $block = array(
       'subject' => t('Private messages'),
-      'content' => theme('item_list', array('links' => $links)),
+      'content' => theme('item_list', array('items' => $links)),
     );
   }
   return $block;
@@ -1953,7 +1953,7 @@ function privatemsg_node_view($node, $vi
   if (in_array($node->type, $types) && !empty($url) && ($view_mode == 'full' || (variable_get('privatemsg_display_on_teaser', 1) && $view_mode == 'teaser'))) {
     $links['privatemsg_link'] = array(
       'title' => t('Send author a message'),
-      'href' => $url . '/' . t('Message regarding @node', array( '@node' => $node->title['und'][0]['value'])),
+      'href' => $url . '/' . t('Message regarding @node', array('@node' => $node->title)),
       'query' => drupal_get_destination(),
     );
     $node->content['links']['privatemsg'] = array(
Index: privatemsg.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/privatemsg/privatemsg.test,v
retrieving revision 1.2.2.1.2.23
diff -u -p -r1.2.2.1.2.23 privatemsg.test
--- privatemsg.test	19 Jun 2010 11:30:33 -0000	1.2.2.1.2.23
+++ privatemsg.test	20 Jun 2010 08:09:22 -0000
@@ -804,3 +804,146 @@ class PrivatemsgFieldsTestCase extends D
     $this->assertText($response['field_' . $name . '[und][0][value]'], t('Content of new field is displayed.'));
   }
 }
+
+/**
+ * Tests for fields integration.
+ */
+class PrivatemsgLinksTestCase extends DrupalWebTestCase {
+  /**
+   * Implements of getInfo().
+   */
+  public static function getInfo() {
+    return array
+    (
+      'name' => t('Privatemsg links'),
+      'description' => t('Tests links displayed in nodes, profiles and blocks.'),
+      'group' => t('Privatemsg'),
+    );
+  }
+
+  /**
+   * Implements setUp().
+   */
+  function setUp() {
+    parent::setUp('privatemsg');
+  }
+
+  /**
+   * Tests author links displayed on nodes and comments.
+   */
+  function testAuthorLinks() {
+    $admin = $this->drupalCreateUser(array('read privatemsg', 'write privatemsg', 'administer privatemsg settings', 'create article content', 'create page content'));
+    $user = $this->drupalCreateUser(array('read privatemsg', 'write privatemsg'));
+
+    $this->drupalLogin($admin);
+
+    $settings = array(
+      'privatemsg_display_link_self' => FALSE,
+      'privatemsg_link_node_types[article]' => TRUE,
+      'privatemsg_display_on_teaser' => FALSE,
+      'privatemsg_display_on_comments' => TRUE,
+    );
+    $this->drupalPost('admin/config/messaging/privatemsg', $settings, t('Save configuration'));
+
+    $node1 = array(
+      'title' => $this->randomName(10),
+      'body[und][0][value]' => $this->randomString(50),
+    );
+    $this->drupalPost('node/add/article', $node1, t('Save'));
+
+    $comment = array(
+      'comment_body[und][0][value]' => $this->randomName(20),
+    );
+    $this->drupalPost(NULL, $comment, t('Save'));
+
+    $node2 = array(
+      'title' => $this->randomName(),
+      'body[und][0][value]' => $this->randomString(50),
+    );
+    $this->drupalPost('node/add/page', $node2, t('Save'));
+
+    $this->drupalGet('node');
+    $this->assertNoText(t('Send author a message'), t('Send author a message link not displayed.'));
+    $this->clickLink($node1['title']);
+    $this->assertNoText(t('Send author a message'), t('Send author a message link not displayed.'));
+
+    $this->drupalLogin($user);
+    $this->drupalGet('node');
+    $this->assertNoText(t('Send author a message'), t('Send author a message link not displayed.'));
+    $this->clickLink($node1['title']);
+    $this->assertNoUniqueText(t('Send author a message'), t('Send author a message link displayed.'));
+
+    // @todo: Do not guess nid.
+    $this->drupalGet('node/2');
+    $this->assertNoText(t('Send author a message'), t('Send author a message link not displayed.'));
+  }
+
+  /**
+   * Tests menu block.
+   */
+  function testMenuBlock() {
+    $admin = $this->drupalCreateUser(array('read privatemsg', 'write privatemsg', 'administer privatemsg settings', 'administer blocks', 'administer menu'));
+    $user = $this->drupalCreateUser(array('read privatemsg'));
+
+    // Enable block.
+    $this->drupalLogin($admin);
+    $blocks = array(
+      'privatemsg_privatemsg-menu[region]' => 'sidebar_second',
+    );
+    $this->drupalPost('admin/structure/block', $blocks, t('Save blocks'));
+
+    // Disable secondary menu.
+    /* @todo: Not yet possible because simpletest needs a log out link to verify that the user is logged in.
+    $menu_settings = array(
+      'menu_secondary_links_source' => '',
+    );
+    $this->drupalPost('admin/structure/menu/settings', $menu_settings, t('Save configuration'));
+     *
+     */
+
+    $this->drupalGet('');
+    $this->assertRaw('<h2 class="title">Private messages</h2>', t('Privatemsg menu block title displayed.'));
+    $this->assertText('Write new message', t('Write new message link displayed.'));
+
+    $message = array(
+      'recipient' => $user->name,
+      'subject' => $this->randomName(),
+      'body[value]' => $this->randomName(50),
+    );
+    $this->drupalPost('messages/new', $message, t('Send message'));
+
+    $this->drupalLogin($user);
+    $this->assertNoText(t('Write new message'), t('Write new message link not displayed.'));
+    $this->assertNoUniqueText(t('Messages (1 new)'), t('Messages link including new message information displayed'));
+  }
+
+  /**
+   * Tests menu block.
+   */
+  function testNewBlock() {
+    $admin = $this->drupalCreateUser(array('read privatemsg', 'write privatemsg', 'administer privatemsg settings', 'administer blocks', 'administer menu'));
+    $user = $this->drupalCreateUser(array('read privatemsg'));
+
+    // Enable block.
+    $this->drupalLogin($admin);
+    $blocks = array(
+      'privatemsg_privatemsg-new[region]' => 'sidebar_second',
+    );
+    $this->drupalPost('admin/structure/block', $blocks, t('Save blocks'));
+
+    $this->drupalGet('');
+    $this->assertNoRaw('<h2 class="title">New messages</h2>', t('Privatemsg new block title not displayed.'));
+
+    $message = array(
+      'recipient' => $user->name,
+      'subject' => $this->randomName(),
+      'body[value]' => $this->randomName(50),
+    );
+    $this->drupalPost('messages/new', $message, t('Send message'));
+
+    $this->drupalLogin($user);
+    $this->assertRaw('<h2 class="title">New message</h2>', t('Privatemsg new block title displayed.'));
+
+    $this->assertText(t('You have a new message, click here to read it'), t('New message indication displayed.'));
+  }
+}
Index: privatemsg.theme.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/privatemsg/privatemsg.theme.inc,v
retrieving revision 1.1.2.7.2.5
diff -u -p -r1.1.2.7.2.5 privatemsg.theme.inc
--- privatemsg.theme.inc	26 Nov 2009 21:04:53 -0000	1.1.2.7.2.5
+++ privatemsg.theme.inc	20 Jun 2010 08:09:22 -0000
@@ -230,6 +230,7 @@ function phptemplate_privatemsg_list_hea
  * Theme a block which displays the number of new messages a user has.
  */
 function theme_privatemsg_new_block($count) {
+  $count = $count['count'];
   $text = format_plural($count, 'You have a new message, click here to read it',
                         'You have @count new messages, click here to read them',
                         array('@count' => $count));
