Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
  #1  
Old 08-18-2005, 11:28 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Why doesn't this code work for 3.5?

I am converting my local time in postbit and profile hack to vB3.5. The following code (with vB3.5 changes) worked fine in the member.php on vB3.0, but now it doesn't seem to want to work in 3.5 with the member_complete hook. Can someone please tell me why and what I need to change to get it to work now?

PHP Code:
 // Local Date and Time in Post
 
global $vbulletin;
 
$this->post['tzoffset'] = $this->post['timezoneoffset'];
 if (
$vbulletin->userinfo['dstonoff'])
 {
  
// DST is on, add an hour
  
$this->post['tzoffset']++;
  if (
substr($this->post['tzoffset'], 01) != '-')
  {
   
// recorrect so that it has + sign, if necessary
   
$this->post['tzoffset'] = '+' $this->post['tzoffset'];
  }
 }
 
$this->post['localtime'] = date($this->registry->options['timeformat'], TIMENOW+($this->post['tzoffset']-$this->post['timeoffset'])*3600);
 
$this->post['localdate'] = date($this->registry->options['dateformat'], TIMENOW+($this->post['tzoffset']-$this->post['timeoffset'])*3600);
// Local Date and Time in Post 
Reply With Quote
  #2  
Old 08-18-2005, 11:48 PM
Zero Tolerance's Avatar
Zero Tolerance Zero Tolerance is offline
 
Join Date: Feb 2004
Location: England
Posts: 813
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

PHP Code:
$this->post 
Should be:
PHP Code:
$userinfo 
Right? Since you're sticking it in member.php, well thats for the user your viewing, your own user acc would be:
PHP Code:
$vbulletin->userinfo 
- Zero Tolerance
Reply With Quote
  #3  
Old 08-19-2005, 12:00 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How would I do it for my account and the user viewing at the same time then? Or did I misunderstand something?
Reply With Quote
  #4  
Old 08-19-2005, 12:08 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Still doesn't work. I used this code and it doesn't show the local time or date in the profile.

PHP Code:
 // Local Date and Time in Profile
 
global $vbulletin;
 
$userinfo['tzoffset'] = $userinfo['timezoneoffset'];
 if (
$vbulletin->userinfo['dstonoff'])
 {
  
// DST is on, add an hour
  
$userinfo['tzoffset']++;
  if (
substr($userinfo['tzoffset'], 01) != '-')
  {
   
// recorrect so that it has + sign, if necessary
   
$userinfo['tzoffset'] = '+' $userinfo['tzoffset'];
  }
 }
  
$userinfo['localtime'] = date($this->registry->options['timeformat'], TIMENOW+($userinfo['tzoffset']-$userinfo['timeoffset'])*3600);
  
$userinfo['localdate'] = date($this->registry->options['dateformat'], TIMENOW+($userinfo['tzoffset']-$userinfo['timeoffset'])*3600);
// Local Date and Time in Profile 
Reply With Quote
  #5  
Old 08-19-2005, 08:44 PM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Guess you would have to retrieve the timezones for the members posting in that thread first. Don't think it is stored with the post.
Reply With Quote
  #6  
Old 08-19-2005, 09:06 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try this.

Hook: member_complete
PHP Code:
// Local Date and Time in Profile
 
$userinfo['tzoffset'] = $userinfo['timezoneoffset'];
 if (
$vbulletin->userinfo['dstonoff'])
 {
  
// DST is on, add an hour
  
$userinfo['tzoffset']++;
  if (
substr($userinfo['tzoffset'], 01) != '-')
  {
   
// recorrect so that it has + sign, if necessary
   
$userinfo['tzoffset'] = '+' $userinfo['tzoffset'];
  }
 }
  
$userinfo['localtime'] = date($vbulletin->options['timeformat'], TIMENOW+($userinfo['tzoffset']-$userinfo['timeoffset'])*3600);
  
$userinfo['localdate'] = date($vbulletin->options['dateformat'], TIMENOW+($userinfo['tzoffset']-$userinfo['timeoffset'])*3600);
// Local Date and Time in Profile 
Reply With Quote
  #7  
Old 08-20-2005, 12:32 AM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

That worked, sir. Thank you.

Is this where I messed up then?

Should be:

Quote:
$vbulletin->options
where I had:

Quote:
$this->registry->options
Reply With Quote
  #8  
Old 08-20-2005, 09:25 PM
Boofo's Avatar
Boofo Boofo is offline
 
Join Date: Mar 2002
Location: Des Moines, IA (USA)
Posts: 15,776
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Kirby, this code seems to work in the postbit, but is it 3.5 ready and the way it should be for the postbit?

I'm using the postbit_display_complete hook for this one.

PHP Code:
  global $vbulletin;
 
$this->post['tzoffset'] = $this->post['timezoneoffset'];
 if (
$vbulletin->userinfo['dstonoff'])
 {
  
// DST is on, add an hour
  
$this->post['tzoffset']++;
  if (
substr($this->post['tzoffset'], 01) != '-')
  {
   
// recorrect so that it has + sign, if necessary
   
$this->post['tzoffset'] = '+' $this->post['tzoffset'];
  }
 }
 
$this->post['localtime'] = date($this->registry->options['timeformat'], TIMENOW+($this->post['tzoffset']-$this->post['timeoffset'])*3600);
 
$this->post['localdate'] = date($this->registry->options['dateformat'], TIMENOW+($this->post['tzoffset']-$this->post['timeoffset'])*3600); 
Reply With Quote
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 02:31 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.04115 seconds
  • Memory Usage 2,265KB
  • 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
  • (7)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)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_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
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete