View Full Version : Notify user that their post has been modified
dushan26
06-27-2013, 11:21 PM
I'm writing a plugin that modifies the user's post in the newpost_process hook. I want to display a notification to the user when they are sent back to their post telling them that it was modified (in the postbit_complete hook).
I got it to work but I'm use the "p" get variable because that's the only way I could detect if the user has just been sent back after submitting the post.
I say for each post in the postbit, if its id is equal to $_REQUEST['p'] then display the message at the top of that post. I have a feeling this isn't a good way to do it though.
Is there a better way to do this?
Scanu
06-28-2013, 09:12 AM
Can you post your code?
dushan26
06-28-2013, 09:43 PM
newpost_complete hook
$id = $post['id'];
$pagetext = modify(post['pagetext']);
$title = modify(post['title']);
$pagetext = $this->db->escape_string($pagetext);
$title = $this->db->escape_string($title);
$update_query =
"UPDATE " . TABLE_PREFIX . "post
SET
pagetext='{$pagetext}',
title='{$title}'
WHERE postid = '{$id}'";
$this->db->query_write($update_query);
postbit_complete hook
$id =$post['postid'];
//detect if we are returning after having just submitted a post <--(This is what I'm trying to do)
if(isset($_REQUEST['p']) && $_REQUEST['p']==$id){ //<--(This is how I'm doing it, but I feel this isn't the best way.)
//insert the notification
$template_hook['postbit_messagearea_start'] = //notification html
}
dushan26
07-03-2013, 07:41 PM
Bump.
Also another problem with the technique I am using.
The flow is like this:
Someone posts a message - > gets taken to the "your message has been sent" screen -> gets sent back to their new post -> a message appears above their new post notifying them that it has been modified
It works, however if they post a quick reply their post is modified but they receive no notification. I think this is because the quick reply isn't affected by the postbit hook.
tbworld
07-05-2013, 08:14 PM
You need to repost with your proper hooks. There is no 'postbit_complete' hook in vb4, that I know of. Anyway, tried to help, but could not follow.
I'm pretty sure it's using "postbit_display_complete". But the problem is that when you quick edit, javascript on the page makes a call to editpost.php and gets back just the edited message area. So postbit_display_complete is not called, and also the place where the notice is displayed is not getting updated. I think you'd either need to figure out how you can get some javascript to run when the post is updated, so you can set the message, or else you could disable ajax features so that the page reloads, but then of course you're losing that feature.
dushan26
07-05-2013, 09:13 PM
Thank you so much for your response.
Quick edit is fine, but quick reply is what I'm wondering about. It's probably the same concept though, it doesn't seem to change the url or call the postbit_display_complete hook. Is there a hook in the quick reply code?
tbworld
07-05-2013, 09:36 PM
This is not an area of the code that I am familiar with -- although I am beginning to look at it now. I would start with looking at "vbulletin_quick _reply.js". Sorry, I cannot comment on the hooks, but I am looking. Maybe brighter minds will chime in (@kh99) or the like! :)
Oh right, quick reply. Sorry. Yeah, it calls newreply instead of editpost, but it is the same idea. Unfortunately it's not really my area either.
Although I did create a "check for new replies" mod that has a similar issue. It displays a message if someone else replied to the thread while you were typing your reply. If I remember correctly, it works because the javascript that makes the "ajax" call gives up if it gets an error, and just goes ahead and reloads the page. So mayb yours could work the same way: use a hook in newreply.php, check for ajax=1 and for the post being modified, and if it is just exit the script (which will cause an error and make the page reload). I hope.
Actually I just looked at the code for the mod I mentioned (https://vborg.vbsupport.ru/showthread.php?t=264858) and I see that what I actually did was to disable ajax for quick reply if the mod is enabled, so I suppose I couldn't figure out any other way for it to work. But I also was trying to make a mod without code changes, so if you only want to get it to work on your site you always have the option of modifying the code.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2024, vBulletin Solutions Inc.