Advertisement:

Author Topic: New users only able to reply to posts within last x days...  (Read 21820 times)

Offline charlottezweb

  • Charter Member
  • SMF Hero
  • *
  • Posts: 2,472
  • Gender: Male
    • Charlottezweb.com
New users only able to reply to posts within last x days...
« on: October 04, 2005, 07:57:17 PM »
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

Offline Oldiesmann

  • Developer
  • SMF Super Hero
  • *
  • Posts: 24,814
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • Oldiesmann on GitHub
    • http://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: New users only able to reply to posts within last x days...
« Reply #1 on: October 05, 2005, 01:13:04 PM »
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
Webmaster / SMF Lead Developer
oldiesmann@simplemachines.org

Offline Ivan Minic

  • Full Member
  • ***
  • Posts: 513
  • Gender: Male
  • Owner: www.Burek.com
    • Burek Forum
Re: New users only able to reply to posts within last x days...
« Reply #2 on: October 05, 2005, 01:23:14 PM »
Last reply..
I had few ideas but were unable to complete because of that..

Offline charlottezweb

  • Charter Member
  • SMF Hero
  • *
  • Posts: 2,472
  • Gender: Male
    • Charlottezweb.com
Re: New users only able to reply to posts within last x days...
« Reply #3 on: October 05, 2005, 01:37:32 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)
« Last Edit: October 08, 2005, 11:58:01 AM by charlottezweb »

Offline Oldiesmann

  • Developer
  • SMF Super Hero
  • *
  • Posts: 24,814
  • Gender: Male
  • Ask me about the function DB :)
    • oldiesmann on Facebook
    • Oldiesmann on GitHub
    • http://www.linkedin.com/in/michaeleshom on LinkedIn
    • @oldiesmann on Twitter
    • Archie Comics Fan Forum
Re: New users only able to reply to posts within last x days...
« Reply #4 on: October 05, 2005, 02:24:08 PM »
Ok. Easy to do :)

Sources/Display.php

Find
Code: [Select]
// The start isn't a number; it's information about what to do, where to go.
Add before that
Code: [Select]
// 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
Code: [Select]
$context['can_reply'] &= empty($topicinfo['locked']) || allowedTo('moderate_board');
And add after that
Code: [Select]
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:
Code: [Select]
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
Webmaster / SMF Lead Developer
oldiesmann@simplemachines.org

Offline charlottezweb

  • Charter Member
  • SMF Hero
  • *
  • Posts: 2,472
  • Gender: Male
    • Charlottezweb.com
Re: New users only able to reply to posts within last x days...
« Reply #5 on: October 08, 2005, 11:58:17 AM »
Worked perfectly -- THANKS so much!!

-Jason

Offline Septimus

  • Semi-Newbie
  • *
  • Posts: 77
Re: New users only able to reply to posts within last x days...
« Reply #6 on: October 05, 2008, 01:15:26 AM »
How do you do this in 2.0? Can you make it display a message telling them why they cannot reply?

Offline Nathaniel

  • SMF Friend
  • SMF Hero
  • *
  • Posts: 3,117
  • Gender: Male
    • Verbtest.com
Re: New users only able to reply to posts within last x days...
« Reply #7 on: November 05, 2008, 05:44:54 AM »
Edits to the 'Display.php' file, for SMF 2 Beta.

Find this code:
Code: [Select]
    // The start isn't a number; it's information about what to do, where to go.Replace with this code:
Code: [Select]
        // 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:
Code: [Select]
    $context['can_reply'] &= empty($topicinfo['locked']) || allowedTo('moderate_board');Replace with this code:
Code: [Select]
    $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.