Announcement

Collapse
No announcement yet.

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

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Small hack: New, unread, and total messages in PM folders

    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)
    PHP Code:
    //check if the user will receive PMs
    if (!$bbuserinfo[receivepm]) {
      eval(
    "standarderror(\"".gettemplate("error_pmturnedoff")."\");");
      exit;

    Below that code, enter this:
    PHP Code:
    //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:
    PHP Code:
    //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 
    Last edited by fury; Sat 6th Oct '01, 1:47am.
widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
Working...
X