News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Allowed no. of Free PM by no of posts.

Started by fiver, August 22, 2008, 09:19:08 AM

Previous topic - Next topic

fiver

Hi,

Can anyone help me with coding something for this? This is how I imagine it works:

1. When a member click on My Messages, it checks how many post made in the last 24 hour (number of hours can be adjusted in admin panel).

2. If there are 3 posts made, there'll be a message like "You are able to send 3 PM."

I'm hoping this function will keep forum discussions in the "front" (on discussion boards) and less at the "back" through PM, without having to disable PM totally.

Hope to hear from some experts here.

:)


kizer

You do realize making people post in a PM will make your forum appear less active.
Own a Jeep? Links4Jeeps.com

[SiNaN]

Hope I got it correctly.

../Sources/PersonalMessage.php

Find:

global $txt, $context, $scripturl, $sc, $modSettings, $settings, $user_info;

Replace:

global $txt, $context, $scripturl, $sc, $modSettings, $settings, $user_info, $ID_MEMBER, $db_prefix;

Find:

$context['template_layers'][] = 'pm';

Replace:

$context['template_layers'][] = 'pm';

list ($modSettings['max_pm_recipients'], $modSettings['pm_posts_verification'], $modSettings['pm_posts_per_hour']) = explode(',', $modSettings['pm_spam_settings']);

if (!empty($modSettings['pm_posts_per_hour']))
{
$request = db_query("
SELECT COUNT(pr.ID_PM) AS postCount
FROM ({$db_prefix}personal_messages AS pm, {$db_prefix}pm_recipients AS pr)
WHERE pm.ID_MEMBER_FROM = $ID_MEMBER
AND pm.msgtime > " . (time() - 3600) . "
AND pr.ID_PM = pm.ID_PM", __FILE__, __LINE__);
list ($postCount) = mysql_fetch_row($request);
mysql_free_result($request);

if (!empty($postCount))
{
$request = db_query("
SELECT ID_MEMBER
FROM {$db_prefix}moderators
WHERE ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
if (mysql_num_rows($request) == 0)
$context['allowed_pm_left'] = $modSettings['pm_posts_per_hour'] - $postCount;
mysql_free_result($request);
}
}


You can use $context['allowed_pm_left'] in PersonalMessage.template.php file.
Former SMF Core Developer | My Mods | SimplePortal

fiver

Quote from: kizer on August 22, 2008, 11:31:01 AM
You do realize making people post in a PM will make your forum appear less active.

Hi kizer,

I don't mean post in a PM. At the moment PM has been disabled for members for the last 3 years, and the reason is to prevent members from using PM privately and at the same time inactive in the boards. So I thought if I come up with a compromise (as in the 1st post) and also prevent more PM than post at the same time.

fiver

Quote from: [SiNaN] on August 23, 2008, 11:04:38 AM
Hope I got it correctly.

Many thanks SiNan. I'll package and install it, and give it a go.

kizer

Many apologies. Your giving them PM privledges from posting. Ah very intresting I must say. I at first thought you where discouraging people from posting and wanted them to PM.
Own a Jeep? Links4Jeeps.com

fiver

Quote from: kizer on August 25, 2008, 02:49:41 PM
Many apologies. Your giving them PM privledges from posting. Ah very intresting I must say. I at first thought you where discouraging people from posting and wanted them to PM.

No problem ;)

fiver

Hi [SiNaN]

Just to confirm with you. Where do I set the number of hours? Also, when someone click My Messages, how do I add a line under

Show unread posts since last visit.
                        Show new replies to your posts.
                        Total time logged in:
Number of free PM: 3

Does you code only affect post group? I hope it won't affect Global Moderators, Moderators and Admin.

Many thanks again for your help.

:D


[SiNaN]

You can change the hour, in the codes I gave above you should change 3600. It is seconds. So if you want two hours, it will be 7200; if 3 hours, 10800.

What's your theme?

Well, we can make it like that:

Find:

   if (!empty($modSettings['pm_posts_per_hour']))

Replace:

   if (!empty($modSettings['pm_posts_per_hour']) && !allowedTo(array('admin_forum', 'moderate_forum', 'send_mail')))

Admin and moderators will not be affected.
Former SMF Core Developer | My Mods | SimplePortal

fiver

Hi,

I installed and after which only admin is able to post. When Normal members and even Global Mod try to submit a post, they get this message:

An Error Has Occurred!
The last posting from your IP was less than 1 minute ago. Please try again later.

Any help to fix the bug pls? Thks.

[SiNaN]

I don't think this is related to those codes above. Just to make sure, remove them and try again.
Former SMF Core Developer | My Mods | SimplePortal

fiver

Hi the error seems to have gone.

I tested under normal member account. Posted 4 posts and still able to send 6 pm. No block after sending 4 pm. Also would be good if there are some indicator like, Free PM available: 0.

Thks for your time and afford. Really appreciate it.

[SiNaN]

Are you sure that you've set "Number of personal messages a user may send in an hour." setting correctly in Admin CP >> Features and Options?
Former SMF Core Developer | My Mods | SimplePortal

fiver


assam_siddibapa

Can some one make this a mod .. it will be great

bfeo

Wouldn't having pm limit and inbox size by membergroup be alot more useful?  I'd personally like to see that.  I'll start a thread if you'd like.


fiver

Hi [SiNaN],

I wonder should I set the Limit to 0 and let your codes do the control?

[SiNaN]

The codes a gave just shows the left count, it doesn't block. So your problem is they aren't blocked?
Former SMF Core Developer | My Mods | SimplePortal

fiver

Quote from: Blue Dream on September 08, 2008, 12:19:35 PM
Are you sure that you've set "Number of personal messages a user may send in an hour." setting correctly in Admin CP >> Features and Options?
Hi Blue Dream,
I'm still very keen to get this idea working. What should I set for "Number of personal messages a user may send in an hour."?
Thanks.

Advertisement: