1

I used this tip to put private the Drupal 7 private messages into blocks, in order to put those blocks on a quicktabs block:

<?php
/**
 * Implements hook_block_info().
 */
function MYMODULE_block_info() {
  $blocks = array();
  $blocks['messages_list'] = array(
    'info' => t('Messages List'),
    'cache' => DRUPAL_NO_CACHE,
  );
  $blocks['messages_sent'] = array(
    'info' => t('Sent Messages'),
    'cache' => DRUPAL_NO_CACHE,
  );
  $blocks['new_message'] = array(
    'info' => t('New Private Message'),
    'cache' => DRUPAL_NO_CACHE,
  );
  return $blocks;
}

/**
 * Implements hook_block_view().
 */
require_once('sites/all/modules/privatemsg/privatemsg.pages.inc');
function MYMODULE_block_view($delta = '') {
  $block = array();
  switch ($delta) {
    case 'messages_list':
      global $user;
      $block['subject'] = t('Private Messages List');
      $block['content'] = 
        drupal_get_form('privatemsg_list', 'list', $user);
      break;

    case 'messages_list':
      global $user;
      $block['subject'] = t('Private Sent Messages');
      $block['content'] = 
        drupal_get_form('privatemsg_list', 'sent', $user);
      break;
    case 'new_message':
      $block['subject'] = t('New Private Message');
      $block['content'] = drupal_get_form('privatemsg_new');
      break;
  }
  return $block;
} ?>

It works quite well, but I have the following issues:

  1. Tab 1 (Inbox): Why I can't delete messages on the message list, or change their status.
  2. Tab 2 (Sent messages): How do I see the sent messages list? Is there a separate form?
  3. Tab 3 (New message): After sending a new message, how to I redirect the user back to the messages list?
  4. How to avoid needing to include sites/all/modules/privatemsg/privatemsg.pages.inc (If I want to put this block on a non-standard URL, not starting with '/messages', I get an error that a function in that file is not found.

Notes (EDITED):

Drupal 7 Privatemsg views integration module is stuck (you can see the latest patch here). Forms integration works, somewhat.

Alternate approachers:

  • Edit it with the data module (which allows to make a view on any table) + VBO. IF they work together.
  • Recreate the whole solution with Views + VBO.

Please advise

Thanks

Amnon

  • Just my curiosity, but can't you do that with Views? And VBO? – Mołot Nov 7 '13 at 15:27
  • 1
    Drupal 7 Privatemsg views support is stuck. Maybe it can be done with the data module (which allows to make a view on any table) + VBO. IF they work together. – Druvision Nov 7 '13 at 15:34
1

No need to use quicktabs. The tabs functionality is inherent if you use the privatemsg_filter addon module - inbox, sent messages and all mail are exposed as three tabs.

It was only needed to add a 4th tab with the option to send a new private message.

The tab already existed as a page, so adding it was simple using hook_menu_alter().

So the final code is:

<?php 
function MYMODULE_menu_alter(&$items) {
  // Make the privatemsg new link a tab
  $items['messages/new']['type'] = MENU_LOCAL_TASK;
}
?>
0

You could use that sandbox project enter link description here to create the block you want

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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