Quantcast
Channel: Arnelbornales's Blog » Drupal Planet
Viewing all articles
Browse latest Browse all 2

How to show unread messages using privatemsg module

$
0
0

Recently, Im working on privatemsg module. I already customized the form: removing the subject field(replacing it with the node title), removing the recipients field, for these are some of the clients specifications. Now, my next task is to show all unread messages. Unfortunately, there’s no unread messages tab nor page for it. So, I decided to ask help by filling issues in privatemsg module. Berdir quickly suggested me on how to achieve what I wanted and I thanked him for that suggestion because it worked for me smoothly.

so, here’s the custom module

first, create a .info file named it as privatemsg_unread.info

 

; $Id: privatemsg_unread.info $
name = Show Unread Private messages
description = Show Unread Private messages
package = CUSTOM MODULE
core = 6.x

 

Next, Create the module file,named it as privatemsg_unread.module

function privatemsg_unread_menu() {
$items['messages/unread'] = array(
‘title’ => ‘Unread’,
‘page callback’ => ‘unread_messages’,
‘access callback’ => ‘privatemsg_user_access’,
‘type’ => MENU_LOCAL_TASK,
‘weight’ => -20,
);
return $items;
}
function unread_messages(){
$unread_msgss = drupal_get_form(‘privatemsg_list’, ‘unread’);
return $unread_msgss;
}
function privatemsg_unread_privatemsg_sql_list_alter(&$fragments, $account, $argument) {
if ($argument == ‘unread’) {
$fragments['where'][2] = ‘pmi.is_new > 0′;
}
}

 

Put it inside a folder privatemsg_unread upload to your modules folder(usually sites/all/modules)
enable the module(admin/build/module) then voila!!!

To test(if only you have recent unread messages, otherwise no messages will be displayed) ,
try to access http://www.YOURSITE.com/messages/unread

Feel free to add some more..



Viewing all articles
Browse latest Browse all 2

Latest Images

Trending Articles





Latest Images