MyBB Community Forums

Full Version: Warning of someone posted before you
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I just tried to realise the a plugin which warns you if someone posted before you in the same thread while you were writing your post
(Inspired by this idea: http://ideas.mybboard.net/idea/warning-i...the-same-t)

So I wrote the following code and hooked it into newreply_do_newreply_start:

  $posttime = $mybb->input['posttime'];
  $reply = $db->fetch_array($db->simple_select("posts", "dateline", "visible='1' AND tid='".$tid."' AND dateline > ".$posttime));
  
  if($reply)
  {
    $post_errors[] = "Something";
  }

(postdate is the time the "New Reply" button is clicked)

The problem is: I cant find a way to redirect the user back to the newreply.php and show an info box without any code change in the newreply.php file.
Can anyone image a way to realise this with only using the plugin file and making no code changes?
Ya I saw this feature in SMF.
Are you trying to do this from the quick reply, or the new reply page? If the latter, does "posttime" refer to the time they clicked on the "Post Reply" link, or the time they entered the thread?
I first wanted to do this from the new reply page and posttime id the time the user clicked the "new reply" button.
Alright, first things first
- intval the incomming 'posttime' to prevent an SQL injection
- $post_errors is overwritten after the hook
$post_errors = array();
There's a number of ways around this issue - you can issue a warning directly, or you can add a second hook (in your newreply_do_newreply_start hook) to the posthandler's validation function, (the datahandler_post_validate_post hook) and cause the check to be performed there.