Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
  #1  
Old 03-29-2015, 03:50 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Getting the date/time of last post in a thread

Hello everyone!

I am currently working on a plugin that will automatically generate a report if a new user, that is one with less than 10 posts, posts a reply to a thread whose last post was made a significant time ago.

What I have done so far is check the difference between the ids of the last post and the post that has just been submitted, using the expression:

Code:
$post['postid'] - $threadinfo['lastpostid']
This works, and I am able then to auto-create a thread in our "Reported Posts" forum.

However, this is not completely satisfactory as it is based on forum posting activity (which could change of course) and not on time (the passage of which is constant), but I have thus far not been able to get the date/time information of the last post. For example, the expression:

Code:
$threadinfo['lastposttime']
returns a blank. Does anyone know which subscript contains the information regarding the last post's dateline, or otherwise how to obtain this information?
Reply With Quote
  #2  
Old 03-30-2015, 11:00 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I think you might want $threadinfo['lastpost'].
Reply With Quote
Благодарность от:
MarkFL
  #3  
Old 03-30-2015, 12:24 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
I think you might want $threadinfo['lastpost'].
I just gave that a try, but it returns a blank as well.
Reply With Quote
  #4  
Old 03-30-2015, 12:31 PM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Where do you hook into to get the $threadinfo['lastpost'] variable? It should contain the timestamp of the last post.
Reply With Quote
Благодарность от:
MarkFL
  #5  
Old 03-30-2015, 12:39 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The hook location of the plugin is "newpost_complete." I am relatively new to writing plugins, so I'm not sure if this is what you mean.
Reply With Quote
  #6  
Old 03-30-2015, 12:59 PM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That's weird, $threadinfo['lastpost'] should have a value at that hook location.
Put the following in the hook and see what's displayed on the screen, maybe also post some more code of the plugin.

Code:
print_r($threadinfo);
exit;
Reply With Quote
  #7  
Old 03-30-2015, 01:18 PM
MarkFL's Avatar
MarkFL MarkFL is offline
 
Join Date: Feb 2014
Location: St. Augustine, FL
Posts: 3,853
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Dave View Post
That's weird, $threadinfo['lastpost'] should have a value at that hook location.
Put the following in the hook and see what's displayed on the screen, maybe also post some more code of the plugin.

Code:
print_r($threadinfo);
exit;
Thanks...okay here's what I got using your code:

Code:
Array ( [isdeleted] => 0 [issubscribed] => 0 [emailupdate] => [folderid] => [threadread] => 1427725346 [forumread] => 1427725347 [description] => Hey everyone! [threadid] => 124 [title] => Hello again!! [prefixid] => [firstpostid] => 410 [lastpostid] => 802 [lastpost] => 1427725346 [forumid] => 10 [pollid] => 0 [open] => 1 [replycount] => 3 [postercount] => 2 [hiddencount] => 0 [deletedcount] => 0 [postusername] => regular dumb dude [postuserid] => 4 [lastposter] => MarkFL [lastposterid] => 1 [dateline] => 1420537306 [views] => 72 [iconid] => 0 [notes] => [visible] => 1 [sticky] => 0 [votenum] => 0 [votetotal] => 0 [attach] => 0 [similar] => [taglist] => [keywords] => [dbtech_thanks_disabledbuttons] => 0 [dbtech_thanks_requiredbuttons_content] => 0 [dbtech_thanks_requiredbuttons_attach] => 0 )
I see that $threadinfo['lastpost'] does in fact have a value there...perhaps I am not using PHP correctly to display it.

Okay, I just discovered I had a typo in my plugin when I attempted to use $threadinfo['lastpost'] before and it works beautifully now. My apologies for the added confusion.

I am very grateful for the help, and once I have this plugin working correctly I will post the complete code. I have one other issue I want to iron out with this, and that is to set the reported post into the moderation queue, but I will create a separate thread for that once I have the timestamp worked out.
Reply With Quote
2 благодарности(ей) от:
EasyEazy, Stratis
Reply

Thread Tools
Display Modes

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 03:55 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04044 seconds
  • Memory Usage 2,233KB
  • 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
  • (5)bbcode_code
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (4)post_thanks_box_bit
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)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