vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Activating a plugin via a query - or how to update the cache? (https://vborg.vbsupport.ru/showthread.php?t=253824)

AntonyF 11-17-2010 11:17 AM

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.

Lynne 11-17-2010 01:25 PM

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.

AntonyF 11-18-2010 10:02 AM

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.

Lynne 11-18-2010 01:45 PM

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.

AntonyF 11-19-2010 07:15 AM

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.

kh99 11-19-2010 08:23 AM

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); 


AntonyF 11-23-2010 07:56 AM

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

kh99 11-23-2010 10:03 AM

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.


All times are GMT. The time now is 07:13 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.01287 seconds
  • Memory Usage 1,729KB
  • 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
  • (2)bbcode_code_printable
  • (1)bbcode_html_printable
  • (2)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (8)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
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete