Thread: Private Messages Enhancements - View Unread PMs
View Single Post
  #8  
Old 05-28-2007, 06:11 AM
Ian Montgomerie Ian Montgomerie is offline
 
Join Date: Dec 2003
Posts: 11
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I tried this and there's a fundamental problem with the coding - it sets up the "unread PMs" folder to be treated the same way as the "sent items" folder. It should be treated like the inbox folder, because the unread PMs are from the inbox. For example, this problem causes all messages in the unread PM list to display as if they were sent by you.

The fix is easy because the "inbox" way of doing things is the default. You just have to remove all of the modifications which look for a "-1" case in the code and change it to "-1 or -2". "-1" is the special case for the sent items folder.

I'm using a shorter, simpler mod file that looks like this. Working with 3.7 PL1.

Code:
//################################################################################//
//         MOD NAME: Unread PMs                                                  #//
//################################################################################//
//      DESCRIPTION: Let's users view only unread PMs                            #//
//                   Sorry, folks; this couldn't be done via a plug-in because   #//
//                   it requires changing lines of code which explicitly use     #//
//                   a folder id to identify "system" folders.                   #//
//################################################################################//
//               BY: MPDev                                                       #//
//             DATE: 4.07.07                                                     #//
//          VERSION: 1.0                                                         #//
//################################################################################//
//      FILES UPDATED:                                                           #//
//                   private.php                                                 #//
//                   includes/functions_misc.php                                 #//
//################################################################################//

Please make backups of these two files before editting them so you can back
it out if you want.

//################################################################################//
//                                 private.php                                   #//
//################################################################################//

Find:

	$pmfolders = array('0' => $vbphrase['inbox'], '-1' => $vbphrase['sent_items']);

change to:

	$pmfolders = array('0' => $vbphrase['inbox'], '-1' => $vbphrase['sent_items'], '-2' => 'Unread PMs');

//################################################################################//

Find:

			switch ($vbulletin->GPC['folderid'])
			{
				case -1:

change to:

			switch ($vbulletin->GPC['folderid'])
			{
    			// MDP
				case -2:
					$fromfolder = 'Unread PMs';
					break;
			    // MDP
				case -1:

//################################################################################//


Find:

	($hook = vBulletinHook::fetch_hook('private_messagelist_start')) ? eval($hook) : false;

Add after:

    $foldernames["-2"] = "Unread PMs";
	$show['showunread'] = iif($vbulletin->userinfo['pmunread'], true, false);

//################################################################################//

Find:

		    $pms = $db->query_read_slave("
    			SELECT pm.*, pmtext.*
				    " . iif($vbulletin->options['privallowicons'], ", icon.title AS icontitle, icon.iconpath") . "
			    FROM " . TABLE_PREFIX . "pm AS pm
			    LEFT JOIN " . TABLE_PREFIX . "pmtext AS pmtext ON(pmtext.pmtextid = pm.pmtextid)
			    " . iif($vbulletin->options['privallowicons'], "LEFT JOIN " . TABLE_PREFIX . "icon AS icon ON(icon.iconid = pmtext.iconid)") . "
			    WHERE pm.userid=" . $vbulletin->userinfo['userid'] . " AND pm.folderid=" . $vbulletin->GPC['folderid'] . "
			    ORDER BY pmtext.dateline DESC
			    LIMIT $startat, " . $vbulletin->GPC['perpage'] . "
		    ");


Replace with:

		if ( $vbulletin->GPC['folderid'] == -2 )
		{
		    $pms = $db->query_read_slave("
    			SELECT pm.*, pmtext.*
				    " . iif($vbulletin->options['privallowicons'], ", icon.title AS icontitle, icon.iconpath") . "
			    FROM " . TABLE_PREFIX . "pm AS pm
			    LEFT JOIN " . TABLE_PREFIX . "pmtext AS pmtext ON(pmtext.pmtextid = pm.pmtextid)
			    " . iif($vbulletin->options['privallowicons'], "LEFT JOIN " . TABLE_PREFIX . "icon AS icon ON(icon.iconid = pmtext.iconid)") . "
			    WHERE pm.userid=" . $vbulletin->userinfo['userid'] . " AND pm.folderid=0 AND pm.messageread=0
			    ORDER BY pmtext.dateline DESC
			    LIMIT $startat, " . $vbulletin->GPC['perpage'] . "
		    ");
		}
		else
		{
		    $pms = $db->query_read_slave("
    			SELECT pm.*, pmtext.*
				    " . iif($vbulletin->options['privallowicons'], ", icon.title AS icontitle, icon.iconpath") . "
			    FROM " . TABLE_PREFIX . "pm AS pm
			    LEFT JOIN " . TABLE_PREFIX . "pmtext AS pmtext ON(pmtext.pmtextid = pm.pmtextid)
			    " . iif($vbulletin->options['privallowicons'], "LEFT JOIN " . TABLE_PREFIX . "icon AS icon ON(icon.iconid = pmtext.iconid)") . "
			    WHERE pm.userid=" . $vbulletin->userinfo['userid'] . " AND pm.folderid=" . $vbulletin->GPC['folderid'] . "
			    ORDER BY pmtext.dateline DESC
			    LIMIT $startat, " . $vbulletin->GPC['perpage'] . "
		    ");
		}

//################################################################################//
//                          includes/functions_misc.php                          #//
//################################################################################//

Find:

			$folders = array('0' => $vbphrase['inbox'], '-1' => $vbphrase['sent_items']);

replace with:

            $messagecounters["-2"] = $vbulletin->userinfo['pmunread'];
			$folders = array('0' => $vbphrase['inbox'], '-1' => $vbphrase['sent_items'], '-2' => 'Unread');
Reply With Quote
 
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01082 seconds
  • Memory Usage 1,799KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD_SHOWPOST
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_box
  • (1)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit_info
  • (1)postbit
  • (1)postbit_onlinestatus
  • (1)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • reputationlevel
  • showthread
Included Files:
  • ./showpost.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showpost_start
  • bbcode_fetch_tags
  • bbcode_create
  • postbit_factory
  • showpost_post
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • showpost_complete