Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 01-30-2006, 10:22 PM
reismarktq2 reismarktq2 is offline
 
Join Date: Feb 2003
Posts: 109
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Hook location for setting-changing plug-in

Hi:

I'm in the midst of developing a custom hack for a website I run (to integrate a fantasy game they're running with various elements of vBulletin). I need to create a plug-in that will automatically change a "yesno" setting I've created in vBulletin Options after a certain time has passed.

I know how I'm going to write the plug-in; what I *don't* know is which hook location to place it in. Any suggestions?
Reply With Quote
  #2  
Old 01-30-2006, 10:31 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

global_start
Reply With Quote
  #3  
Old 02-02-2006, 02:51 AM
reismarktq2 reismarktq2 is offline
 
Join Date: Feb 2003
Posts: 109
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the help.

It turns out I was a little mistaken about how to write the plugin. It currently looks something like this:

Code:
// Get current time and deadline.
$now = time();
$then = explode(',',$vbulletin->options['fantasygame_closingtime']);
$deadline = mktime($then[3], $then[4], 0, $then[0], $then[1], $then[2]);

// If the deadline has passed, update the setting.
if ($now >= $deadline) {
     $db->query_write("UPDATE setting SET value = 0 WHERE varname = 'fantasygame_picksactive'");
}
Here's the issue: I ran the SQL statement in phpMyAdmin to test it, and while it updates the database correctly, and I see the setting change in the control panel, I don't get the desired effect on my forum home (which is to make a couple of links disappear based on a conditional). I still need to save the settings in the control panel (even without making any changes to them!) in order for it to show up how I want it to.

I'm guessing there's something else I have to do... any ideas what it is?
Reply With Quote
  #4  
Old 02-02-2006, 06:31 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You have to call build_options() to rebuild the cache when you've changed a setting.
I though you just wanted to change it at runtime.
Reply With Quote
  #5  
Old 02-09-2006, 10:46 AM
reismarktq2 reismarktq2 is offline
 
Join Date: Feb 2003
Posts: 109
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Andreas
You have to call build_options() to rebuild the cache when you've changed a setting.
I though you just wanted to change it at runtime.
I'd appreciate it if you could explain to me how to call this.

My attempts to do so resulted in my boards crashing with a function undefined error, and I had to go into phpMyAdmin and edit it out of the plugin table and the datastore manually.
Reply With Quote
  #6  
Old 02-09-2006, 03:00 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

build_options() is defined in includes/adminfunctions.php.

Though, you really should not change settings too often.
As far as I understand the above code, it updates the setting on every pageload when the time has passed ...
Reply With Quote
  #7  
Old 02-09-2006, 03:29 PM
reismarktq2 reismarktq2 is offline
 
Join Date: Feb 2003
Posts: 109
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
build_options() is defined in includes/adminfunctions.php.
So would I need to change the hook location to get it to run? How would I call it so that it will work from forum home?

Quote:
As far as I understand the above code, it updates the setting on every pageload when the time has passed ...
It does, but I plan on adding another conditional that only updates the setting if it's currently true (which is easy enough to do). I wanted to make sure it would work without such a limit before I added it.
Reply With Quote
  #8  
Old 02-09-2006, 03:43 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

The hook location is fine, you just need that file.
Reply With Quote
  #9  
Old 02-09-2006, 05:38 PM
reismarktq2 reismarktq2 is offline
 
Join Date: Feb 2003
Posts: 109
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I have that file, and it has the function in it. So why would I get this type of an error message, then?

Quote:
Fatal error: Call to undefined function: build_options() in /hsphere/local/home/gabby/boards.survivoraddicts.net/global.php(351) : eval()'d code on line 134
Reply With Quote
  #10  
Old 02-09-2006, 05:39 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Because you don't use it

PHP Code:
require_once(DIR '/includes/adminfunctions.php'); 
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 06:50 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.07363 seconds
  • Memory Usage 2,253KB
  • 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
  • (1)bbcode_code
  • (1)bbcode_php
  • (4)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (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_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
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete