Current time: 01-09-2009, 07:40 AM Hello There, Guest! (LoginRegister)


Post Reply 
Warning of someone posted before you
10-09-2008, 10:12 AM
Post: #1
Warning of someone posted before you
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...he-same-t)

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

PHP Code:
$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?
Find all posts by this user
Quote this message in a reply
10-09-2008, 10:17 AM
Post: #2
RE: Warning of someone posted before you
Ya I saw this feature in SMF.

[Image: certcollection_org_banner.gif]
Forum | Sitemap
Find all posts by this user
Quote this message in a reply
10-11-2008, 01:16 AM
Post: #3
RE: Warning of someone posted before you
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?

Who is Yumi?


It's still the KFC crazed person who can't spell names properly with annoying AlTeRnAtInG CaPiTaLs in the NaMe
Visit this user's website Find all posts by this user
Quote this message in a reply
10-11-2008, 06:27 AM
Post: #4
RE: Warning of someone posted before you
I first wanted to do this from the new reply page and posttime id the time the user clicked the "new reply" button.
Find all posts by this user
Quote this message in a reply
10-11-2008, 07:40 AM
Post: #5
RE: Warning of someone posted before you
Alright, first things first
- intval the incomming 'posttime' to prevent an SQL injection
- $post_errors is overwritten after the hook
PHP Code:
$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.

Who is Yumi?


It's still the KFC crazed person who can't spell names properly with annoying AlTeRnAtInG CaPiTaLs in the NaMe
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Forum Jump: