vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Hook location for setting-changing plug-in (https://vborg.vbsupport.ru/showthread.php?t=106759)

reismarktq2 01-30-2006 10:22 PM

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?

Andreas 01-30-2006 10:31 PM

global_start

reismarktq2 02-02-2006 02:51 AM

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?

Andreas 02-02-2006 06:31 AM

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.

reismarktq2 02-09-2006 10:46 AM

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.

Andreas 02-09-2006 03:00 PM

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 ...

reismarktq2 02-09-2006 03:29 PM

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.

Andreas 02-09-2006 03:43 PM

The hook location is fine, you just need that file.

reismarktq2 02-09-2006 05:38 PM

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

Andreas 02-09-2006 05:39 PM

Because you don't use it :)

PHP Code:

require_once(DIR '/includes/adminfunctions.php'); 



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

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.02464 seconds
  • Memory Usage 1,739KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_code_printable
  • (1)bbcode_php_printable
  • (4)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • pagenav_page
  • pagenav_complete
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete