Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
  #1  
Old 11-17-2010, 11:17 AM
AntonyF AntonyF is offline
 
Join Date: Jul 2006
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Activating a plugin via a query - or how to update the cache?

Hello all,

I want to activate a plugin via a mySQL query, just to put up a message at a certain time, then turn it off again. I worked out how to activate/deactivate it via a query...

However, the page does't update - some sort of cache I suspect.

Anyone know how to trigger an update of the cache, or a way to achieve what I want?

Thanks.
Reply With Quote
  #2  
Old 11-17-2010, 01:25 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

All you are doing is single a single plugin one time via a query? Perhaps post your code and state the goal and we can see what is going on.
Reply With Quote
  #3  
Old 11-18-2010, 10:02 AM
AntonyF AntonyF is offline
 
Join Date: Jul 2006
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I just want to put up a message saying that we're closing for maintenance, then turn it off after maintenance.

The plugin is simply:

HTML Code:
ob_start();
echo "<center><font color=\"yellow\"><font size=\"+1\"><b>This is a test of the maintenance system message.</b></font></center>";
  $closemessage = ob_get_contents();
  ob_end_clean();
The $closemessage is placed in the template... then ideally I just want to turn that plugin on and off at the designated times.
Reply With Quote
  #4  
Old 11-18-2010, 01:45 PM
Lynne's Avatar
Lynne Lynne is offline
 
Join Date: Sep 2004
Location: California/Idaho
Posts: 41,180
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Why are you not using the actual option to do this? vboptions > turn vb board on / off > reason for turning forum off

And why not just say:
PHP Code:
$closemessage="<center><font color=\"yellow\"><font size=\"+1\"><b>This is a test of the maintenance system message.</b></font></center>"
No echo, no get_contents, just set the variable.
Reply With Quote
  #5  
Old 11-19-2010, 07:15 AM
AntonyF AntonyF is offline
 
Join Date: Jul 2006
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Because this isn't to turn the forum off, it's to give a warning that it will be turned off. So ten minutes before maintenance it lets people know and they can avoid starting to make long posts.
Reply With Quote
  #6  
Old 11-19-2010, 08:23 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

When the acp updates the active status of a plugin (in admincp/plugin/php) it calls vBulletinHook::build_datastore() which is in includes/class_hook.php. So you'd probably want something like:

PHP Code:
require_once(DIR '/includes/class_hook.php');
...
vBulletinHook::build_datastore($db); 
Reply With Quote
  #7  
Old 11-23-2010, 07:56 AM
AntonyF AntonyF is offline
 
Join Date: Jul 2006
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the response kh99.

Well, that half works! It works to turn the plugin off via command line... but doesn't work to turn it on. Any ideas?

Thanks
Reply With Quote
  #8  
Old 11-23-2010, 10:03 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I don't know why that doesn't work. But I have an alternative suggestion: create a plugin (always active) using hook init_startup with code:

Code:
$datastore_fetch[]="'closemessage'";
(all those quotes need to be there).

Then in your template use something like:

Code:
<if condition="$vbulletin->closemessage">
<center><font color=\"yellow\"><font size=\"+1\"><b>$vbulletin->closemessage</b></font></center>";  
</if>
Then have your command line program write to the datastore table with title = "closemessage" and data = your message (I'm not sure if the message string needs to be serialized or not, so you'd either need to call serialize on it and write the resulting string to the db and set the unserialize field to 1, or not. I don't think it hurts to just do that even if it's not necessary).

To turn off the message you could either delete the record or set the message to a null string.

I haven't tried this myself but it seems like it should work, and I think it's less complicated than rebuilding the plugin datastore.

ETA: another idea would be to add a setting under vBulletin options (which you can do when the site is in debug mode), then figure out where to change the value in the database. That would have the advantage of letting you also set it from the acp if you wanted.
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:15 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.03738 seconds
  • Memory Usage 2,222KB
  • 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_code
  • (1)bbcode_html
  • (2)bbcode_php
  • (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_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
  • 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