Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 06-27-2013, 11:21 PM
dushan26 dushan26 is offline
 
Join Date: Jun 2013
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Notify user that their post has been modified

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?
Reply With Quote
  #2  
Old 06-28-2013, 09:12 AM
Scanu's Avatar
Scanu Scanu is offline
 
Join Date: Nov 2010
Posts: 829
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Can you post your code?
Reply With Quote
  #3  
Old 06-28-2013, 09:43 PM
dushan26 dushan26 is offline
 
Join Date: Jun 2013
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

newpost_complete hook
PHP Code:
$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
PHP Code:
$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

Reply With Quote
  #4  
Old 07-03-2013, 07:41 PM
dushan26 dushan26 is offline
 
Join Date: Jun 2013
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #5  
Old 07-05-2013, 08:14 PM
tbworld tbworld is offline
 
Join Date: Oct 2008
Posts: 2,126
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #6  
Old 07-05-2013, 08:46 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Благодарность от:
tbworld
  #7  
Old 07-05-2013, 09:13 PM
dushan26 dushan26 is offline
 
Join Date: Jun 2013
Posts: 10
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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?
Reply With Quote
  #8  
Old 07-05-2013, 09:36 PM
tbworld tbworld is offline
 
Join Date: Oct 2008
Posts: 2,126
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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!
Reply With Quote
  #9  
Old 07-05-2013, 10:41 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #10  
Old 07-06-2013, 09:43 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:32 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04795 seconds
  • Memory Usage 2,262KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (1)post_thanks_box_bit
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (1)post_thanks_postbit
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete