PDA

View Full Version : Small hack: New, unread, and total messages in PM folders



fury
Sat 6th Oct '01, 6:39am
My first hack! Yay!

This should theoretically work for 2.0.0 and above, but I've only tested it to work in 2.0.3. Here goes.

In your main forum folder, download private.php, make a backup of it, then open it in a text editor such as Wordpad or Textpad.

Find this code: (approximately line 66 for version 2.0.3)
//check if the user will receive PMs
if (!$bbuserinfo[receivepm]) {
eval("standarderror(\"".gettemplate("error_pmturnedoff")."\");");
exit;
}

Below that code, enter this:
//BEGIN messages stored hack

$ignoreusers="";
if (trim($bbuserinfo['ignorelist'])!="") {
$ignoreusers='AND fromuserid<>'.implode(' AND fromuserid<>',explode(' ',$bbuserinfo[ignorelist]));
}

$allpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] $ignoreusers");
$newpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] AND dateline>$bbuserinfo[lastvisit] AND folderid=0 $ignoreusers");
$unreadpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] AND messageread=0 AND folderid=0 $ignoreusers");

//END messages stored hack

Save and upload private.php

In your privfolder template, you can now use the following variables:

$newpm[messages] new messages
$unreadpm[messages] unread messages
$allpm[messages] total messages

Enjoy! :)

edit: To uninstall the hack, follow these steps:

1) Remove the variables $newpm[messages], $unreadpm[messages] and $allpm[messages] from your privfolder template.
2) Either reupload the backup of private.php or if you lost it, download the file from the server again and simply delete the following code from the file and reupload:
//BEGIN messages stored hack

$ignoreusers="";
if (trim($bbuserinfo['ignorelist'])!="") {
$ignoreusers='AND fromuserid<>'.implode(' AND fromuserid<>',explode(' ',$bbuserinfo[ignorelist]));
}

$allpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] $ignoreusers");
$newpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] AND dateline>$bbuserinfo[lastvisit] AND folderid=0 $ignoreusers");
$unreadpm=$DB_site->query_first("SELECT COUNT(*) AS messages FROM privatemessage WHERE userid=$bbuserinfo[userid] AND messageread=0 AND folderid=0 $ignoreusers");

//END messages stored hack