View Full Version : Activating a plugin via a query - or how to update the cache?
AntonyF
11-17-2010, 11:17 AM
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:
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:
$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.
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:
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
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:
$datastore_fetch[]="'closemessage'";
(all those quotes need to be there).
Then in your template use something like:
<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.
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.