Previous Thread
Next Thread
Print Thread
Rate Thread
Joined: Mar 2000
Posts: 528
Junior Member
Junior Member
Offline
Joined: Mar 2000
Posts: 528
Mod Name / Version: Private Message Enhancement 1.0

Description: This modification will allow all users to save selected private messages, and allow them to view statistics on their private messages (ie, #saved, #received, #sent, #total in box). It also shows the total allowed number of private messages set by the forum admistrators in the 6.5 control panel, and the user's percent usage of their PM Box.


Working Under: UBB.Threads 6.5

Mod Status: Beta

Any pre-requisites: none

Author(s): Medar

Date: 09/24/04

Credits:

Files Altered: delete.php, mess_handler.php, mess_reply.php, viewmessages.php, viewmessages.tmpl, viewmessage.tmpl, and the generic, viewmessage, and viewmessages language files.

New Files: none

Database Altered: No.

Info/Instructions: Yes, I know this could be considered a cheesy knock-off of other similar systems, but as a Threads admin, I have always wanted to be able to save a few Private Messages here and there.

Plus with the 6.5 Admin ability to set a PM limit, this allows users to view their status as well.

To play with this first (if you like), head to http://www.bladekeep.com/forums/

Login: threadsdev
pass: threadsdev

Send as many PMs to yourself as you like!

Disclaimer: Please backup every file that you intend to modify. If the modification modifies the database, it's a good idea to backup your database before doing so. I am not a php coder, I figure this stuff out by pure accident at times! Test and install at your own risk (but it seems to work for me).

Note: If you modify your UBB.Threads code, you may be giving up your right for "official" support from Infopop. If you need official support, you'll need to restore unmodified files.
Attachments
120365-pme.zip (0 Bytes, 274 downloads)

Last edited by Medar; 10/28/2004 12:06 PM.
Sponsored Links
Joined: Mar 2000
Posts: 528
Junior Member
Junior Member
Offline
Joined: Mar 2000
Posts: 528
FYI I hacked this out last night, and it was rather late. So if there are any small bugs, definitely let me know, as I will continue to use this, my forum members already love it.

Here is an example image:
Attachments
120366-pme_examp.png (0 Bytes, 222 downloads)

Joined: Mar 2001
Posts: 644
Member
Member
Offline
Joined: Mar 2001
Posts: 644
Nice, adding this to my list.

Joined: Sep 2003
Posts: 803
Coder
Coder
Offline
Joined: Sep 2003
Posts: 803
I added it. Took about 30 minutes to install. The directions were perfect. This is certainly one of the top mods Ive seen and used

Thanks for this mod Medar!

Joined: May 2001
Posts: 550
Code Monkey
Code Monkey
Offline
Joined: May 2001
Posts: 550
What is the purpose of Saved messages?

Sponsored Links
Joined: Mar 2000
Posts: 528
Junior Member
Junior Member
Offline
Joined: Mar 2000
Posts: 528
Anno - sometimes you have a message you want to hold onto for a few days, or separate from the mess of other messages, or various reasons.

I didn't say it would be useful for a lot of people, it was just something I wanted, so I figured I would share!

Joined: Feb 2002
Posts: 950
Hacker
Hacker
Offline
Joined: Feb 2002
Posts: 950
Giving it a try, I notice...

a) I see a limit on the PMs being displayed; but there isn't anything that actually limits the users number of PM's, right?
b) No instructions to add the $config['tital_pm'] variable to the config file.
c) There are three $i = 1;'s in viewmessages.php (only one would be needed, I would think)
d) The group of excessive SELECT fields seems unnecessary when all you are doing is a numrows.

Joined: Mar 2000
Posts: 528
Junior Member
Junior Member
Offline
Joined: Mar 2000
Posts: 528
Thanks for the heads up on some of this...but one or two questions.

a) No, there is nothing in here that limits the users number of Private Messages. This basically filters any PMs marked as "S" or "Y" (Saved or Saved/Replied) to a separate view.

b) $config['total_pm'] is part of 6.5 and is set in the control panel...I didn't add that, just used it.

c) Correct, the $i=1; were not needed, I removed them and updated. Thanks!

d) I have no idea how to query the filtered totals I am looking to grab by using just a Numrows, would I still not need to query each using a separate WHERE statement like I did? Would love to make this more efficient if possible, I just didn't know any other way.

Joined: Feb 2002
Posts: 950
Hacker
Hacker
Offline
Joined: Feb 2002
Posts: 950
Maybe 6.5 has a limit on the number of PMs; okay, I modded this down to my 6.4. The queries in (d) are okay by themselves although you don't need to select all those fields if you arent going to use them (might speed up the query?).

Joined: Mar 2000
Posts: 528
Junior Member
Junior Member
Offline
Joined: Mar 2000
Posts: 528
Good point on the fields - really I just need to select one or two for a proper count. Will fix that when I get home.

I meant to do that when I copied/pasted that original query, and then just forgot to be rid of the extraneous data.

Thanks!

Sponsored Links
Joined: Sep 2003
Posts: 803
Coder
Coder
Offline
Joined: Sep 2003
Posts: 803
In the box that has "Private message details", where would I go to add, "send a pm" so users dont have to go back to the main index to send a pm.

Joined: Mar 2000
Posts: 528
Junior Member
Junior Member
Offline
Joined: Mar 2000
Posts: 528
You could add that in your viewmessages.tmpl file.

And that is a good idea, I will probably replace the "total PMs" piece of that with a Send PM link, at least on my local version.

Thanks!

Joined: Feb 2002
Posts: 950
Hacker
Hacker
Offline
Joined: Feb 2002
Posts: 950
Word of warning, on larger sites the queries that count the number of messages will dramatically slow down the page and since they don't use the do_query function, they weren't being timed or counted:

Generated in 8.893 seconds in which 8.884 seconds were spent on a total of 11 queries.

There are three numrow calls to count messages; the second of which appears to be a near duplicate of the $pmsaved query; not sure but maybe this can be done only once. All three are near duplicates in themselves, only checking for different status codes.

Joined: Mar 2000
Posts: 528
Junior Member
Junior Member
Offline
Joined: Mar 2000
Posts: 528
I have never had a php class and do not write code for a living, so any suggestions on making this "better" or "correct" are greatly appreciated...so thanks for the heads up PhotoPost.

I have changed the three queries you are talking about to read as follows - they 'work' on my forums and are now counted and timed. Is there any better optimization that can be done on the below queries?

[]// ------------------------------
// Private Message Enhancement Start

// ---------------------------
// Grab total private messages
$query = "
SELECT COUNT(*)
FROM {$config['tbprefix']}Messages AS t1,
{$config['tbprefix']}Users AS t2
WHERE t1.M_Uid = '{$user['U_Number']}'
AND t1.M_Sender = t2.U_Number
";
$sth = $dbh -> do_query($query,__LINE__,__FILE__);
list($pmtotal) = $dbh -> fetch_array($sth);

// ---------------------------------
// Grab total saved private messages
$query = "
SELECT COUNT(*)
FROM {$config['tbprefix']}Messages AS t1,
{$config['tbprefix']}Users AS t2
WHERE t1.M_Uid = '{$user['U_Number']}'
AND t1.M_Sender = t2.U_Number
AND t1.M_Status IN ('S', 'Y')
";
$sth = $dbh -> do_query($query,__LINE__,__FILE__);
list($pmsaved) = $dbh -> fetch_array($sth);

// ---------------------------------
// Grab total sent private messages
$query = "
SELECT COUNT(*)
FROM {$config['tbprefix']}Messages AS t1,
{$config['tbprefix']}Users AS t2
WHERE t1.M_Uid = '{$user['U_Number']}'
AND t1.M_Sender = t2.U_Number
AND t1.M_Status = 'X'
";
$sth = $dbh -> do_query($query,__LINE__,__FILE__);
list($pmsent) = $dbh -> fetch_array($sth);

$pmrec = $pmtotal - $pmsaved - $pmsent;
$max_pm = $config['total_pm'];
$p_pm = (($pmtotal/$config['total_pm']) * 100);

// ----------------------------
// Private Message Enhancement End[/]
Any way you could test this again to see if it fixes the query timing issue? My forums only have 700+ members and do not get regularly hammered...

Joined: Feb 2002
Posts: 950
Hacker
Hacker
Offline
Joined: Feb 2002
Posts: 950
It has as much to do with the number of PMs as it does users. I had 4,000+ messages between the Saved, Received and Sent folders and got those horrible delays. When I just deleted all but a couple hundred, the speed was back to normal.

I have one user with 9,000 messages between the folders - his page has to be really slow.

If I get some time, I'll play around with it; but even one query instead of the three is going to have the same delay because its the first query that took 96% of the time.

Joined: Mar 2000
Posts: 528
Junior Member
Junior Member
Offline
Joined: Mar 2000
Posts: 528
That makes sense now, I guess in my limited use on larger boards I never dreamt of anyone having 9000+ PMs, or even 3 or 4k!

What I changed will mesh better with the threads code (ie its more compliant), but you are right, it won't make it any faster per se. The way Threads typically gets around this issue would be to add a couple of fields to the Users table that track the PM numbers.

The downside is that these would need to be constantly updated due to deletions and additions, but storing a hard number is really the only way around huge PM users having a delay.

Joined: Sep 2002
Posts: 151
Member
Member
Offline
Joined: Sep 2002
Posts: 151
Would it be possible to use this mod only for selected user groups?

Joined: Aug 2000
Posts: 1,609
Addict
Addict
Offline
Joined: Aug 2000
Posts: 1,609
Very

Joined: Jun 2002
Posts: 160
Member
Member
Offline
Joined: Jun 2002
Posts: 160
I've tried installing this on my 6.5.1 test site, and am having one problem with it. When I'm viewing a message, I can save it, and it'll be marked as saved properly. However, viewing things from viewmessages.php, if I check messages and then use the "Save Checked" button, the page just refreshes and clears the check marks, but doesn't actually save the message(s).

Joined: Mar 2000
Posts: 528
Junior Member
Junior Member
Offline
Joined: Mar 2000
Posts: 528
I have not installed 6.5.1 yet, and am not near ready to do so. It is still too buggy for my taste, and my 6.5 is actually working somewhat properly.

Will work on this as soon as I get a fixed 6.5.1 uploaded.


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Gizmo
Gizmo
Portland, OR, USA
Posts: 5,833
Joined: January 2000
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20221218)