New users only able to reply to posts within last x days...

Started by charlottezweb, October 04, 2005, 07:57:17 PM

Previous topic - Next topic

charlottezweb

If this exists or has been requested before, sorry -- I wasn't sure how to search for something like this :)

I had a request on a board to make it so that new members have to have "x" amount of posts before they can reply to threads older than "x" days.

For example, we get some new sign-ups there who reply to posts that are years old thus digging them up becomes a nuissance to regular members. They would like to set a requirement so that you have to have, say, 100 posts before you can reply to posts beyond x (90?) days. 

It would be nice to have this as a mod or built-in feature where you can specify the posts required by the user and the number of days old the posts have to be in order for them to reply.

Hope that makes sense!  ;D

Oldiesmann

Not too hard to do. However, do you mean the time since the last reply or the time since the topic was started?
Michael Eshom
Christian Metal Fans

Ivan Minic

Last reply..
I had few ideas but were unable to complete because of that..

charlottezweb

#3
Quote from: Ivan Minic on October 05, 2005, 01:23:14 PM
Last reply..

Exactly.  If a post hasn't been replied to in x amount of days, someone with less than y posts should not have the ability to post a reply.

(edit, fixed word)

Oldiesmann

Ok. Easy to do :)

Sources/Display.php

Find
// The start isn't a number; it's information about what to do, where to go.

Add before that
// Figure out when the topic was last replied to...
$request = db_query("
SELECT
m.posterTime, t.ID_LAST_MSG
FROM {$db_prefix}messages AS m, {$db_prefix}topics AS t
WHERE t.ID_TOPIC = $topic
AND m.ID_MSG = t.ID_LAST_MSG", __FILE__, __LINE__);
$topiclastreplied = mysql_result($request, 0);


Then find
$context['can_reply'] &= empty($topicinfo['locked']) || allowedTo('moderate_board');

And add after that
if(!$user_info['is_guest'])
$context['can_reply'] &= (floor((time() - $topiclastreplied) / 84600) < 90 || $user_info['posts'] > 99);


Or, if you want to do it differently for each group:
if(!$user_info['is_guests'])
{
if($user_info['posts'] < 100))
{
$days = 90;
}
elseif($user_info['posts'] < 200)
{
$days = 100;
}
...

$timediff = floor((time() - $topiclastreplied) / 84600);
$context['can_reply'] &= $timediff < $days;
}


Just continue the pattern above.
Michael Eshom
Christian Metal Fans

charlottezweb


Septimus

How do you do this in 2.0? Can you make it display a message telling them why they cannot reply?

Nathaniel

Edits to the 'Display.php' file, for SMF 2 Beta.

Find this code:
    // The start isn't a number; it's information about what to do, where to go.
Replace with this code:
        // Figure out when the topic was last replied to...
   $request = $smcFunc['db_query']('', '
        SELECT
            m.poster_time
        FROM {db_prefix}messages AS m, {db_prefix}topics AS t
        WHERE t.ID_TOPIC = {int:topic}
            AND m.id_msg = t.id_last_msg',
        array(
            'topic' => $topic,
        )
    );
    list($topiclastreplied) = $smcFunc['db_fetch_row']($request);
    $smcFunc['db_free_result']($request);
   
    // The start isn't a number; it's information about what to do, where to go.


Find this code:
    $context['can_reply'] &= empty($topicinfo['locked']) || allowedTo('moderate_board');
Replace with this code:
    $context['can_reply'] &= empty($topicinfo['locked']) || allowedTo('moderate_board');
    if(!$user_info['is_guest'])
        $context['can_reply'] &= (floor((time() - $topiclastreplied) / 84600) < 90 || $user_info['posts'] > 99);


You can change that last edit as required. :)
SMF Friend (Former Support Specialist) | SimplePortal Developer
My SMF Mods | SimplePortal

"Quis custodiet ipsos custodes?" - Who will Guard the Guards?

Please don't send me ANY support related PMs. I will just delete them.

Advertisement: